- fix: more fixes for interactions
This commit is contained in:
@@ -8,24 +8,6 @@ namespace Content.Server._Amour.Animation;
|
|||||||
public sealed class SharebleAnimationSystem : SharedAnimationSystem
|
public sealed class SharebleAnimationSystem : SharedAnimationSystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
SubscribeLocalEvent<HoleContainerComponent,GetVerbsEvent<Verb>>(OnVerb);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnVerb(EntityUid uid, HoleContainerComponent component, GetVerbsEvent<Verb> args)
|
|
||||||
{
|
|
||||||
if(!_prototypeManager.TryIndex<AnimationPrototype>("meow",out var prototype))
|
|
||||||
return;
|
|
||||||
|
|
||||||
args.Verbs.Add(new Verb()
|
|
||||||
{
|
|
||||||
Text = "MEOW ABOUT IT",
|
|
||||||
Act = () => Play(uid, prototype)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Play(EntityUid uid, ProtoId<AnimationPrototype> protoId)
|
public override void Play(EntityUid uid, ProtoId<AnimationPrototype> protoId)
|
||||||
{
|
{
|
||||||
RaiseNetworkEvent(new AnimationProtoStartMessage(GetNetEntity(uid),protoId));
|
RaiseNetworkEvent(new AnimationProtoStartMessage(GetNetEntity(uid),protoId));
|
||||||
|
|||||||
@@ -1,14 +1,18 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Content.Server.Access.Systems;
|
||||||
using Content.Server.Chat.Systems;
|
using Content.Server.Chat.Systems;
|
||||||
using Content.Server.EUI;
|
using Content.Server.EUI;
|
||||||
using Content.Shared._Amour.Hole;
|
using Content.Shared._Amour.Hole;
|
||||||
using Content.Shared._Amour.InteractionPanel;
|
using Content.Shared._Amour.InteractionPanel;
|
||||||
using Content.Shared.Emoting;
|
using Content.Shared.Emoting;
|
||||||
|
using Content.Shared.Humanoid;
|
||||||
|
using Content.Shared.Mind;
|
||||||
using Content.Shared.Random.Helpers;
|
using Content.Shared.Random.Helpers;
|
||||||
using Content.Shared.Verbs;
|
using Content.Shared.Verbs;
|
||||||
using Robust.Server.Audio;
|
using Robust.Server.Audio;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
|
using Robust.Shared.Enums;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
@@ -24,6 +28,7 @@ public sealed class InteractionPanelSystem : EntitySystem
|
|||||||
[Dependency] private readonly ChatSystem _chatSystem = default!;
|
[Dependency] private readonly ChatSystem _chatSystem = default!;
|
||||||
[Dependency] private readonly AudioSystem _audioSystem = default!;
|
[Dependency] private readonly AudioSystem _audioSystem = default!;
|
||||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||||
|
[Dependency] private readonly IdCardSystem _cardSystem = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -34,6 +39,7 @@ public sealed class InteractionPanelSystem : EntitySystem
|
|||||||
private void OnInit(EntityUid uid, InteractionPanelComponent component, ComponentInit args)
|
private void OnInit(EntityUid uid, InteractionPanelComponent component, ComponentInit args)
|
||||||
{
|
{
|
||||||
component.Timeout = _gameTiming.CurTime;
|
component.Timeout = _gameTiming.CurTime;
|
||||||
|
component.EndTime = _gameTiming.CurTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnVerb(EntityUid uid, InteractionPanelComponent component, GetVerbsEvent<Verb> args)
|
private void OnVerb(EntityUid uid, InteractionPanelComponent component, GetVerbsEvent<Verb> args)
|
||||||
@@ -66,32 +72,61 @@ public sealed class InteractionPanelSystem : EntitySystem
|
|||||||
|| !Resolve(target,ref target.Comp)
|
|| !Resolve(target,ref target.Comp)
|
||||||
|| user.Comp.IsActive || user.Comp.IsBlocked
|
|| user.Comp.IsActive || user.Comp.IsBlocked
|
||||||
|| target.Comp.IsActive || target.Comp.IsBlocked
|
|| target.Comp.IsActive || target.Comp.IsBlocked
|
||||||
|
|| user.Comp.Timeout > _gameTiming.CurTime
|
||||||
|
|| target.Comp.Timeout > _gameTiming.CurTime
|
||||||
|| !_prototypeManager.TryIndex(protoId, out var prototype)
|
|| !_prototypeManager.TryIndex(protoId, out var prototype)
|
||||||
|| !prototype.Checks.All(check => check.IsAvailable(user!,target!,EntityManager)))
|
|| !prototype.Checks.All(check => check.IsAvailable(user!,target!,EntityManager)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
user.Comp.Timeout = _gameTiming.CurTime + prototype.Timeout;
|
user.Comp.Timeout = _gameTiming.CurTime + prototype.Timeout;
|
||||||
|
user.Comp.EndTime = _gameTiming.CurTime + prototype.EndTime;
|
||||||
user.Comp.IsActive = true;
|
user.Comp.IsActive = true;
|
||||||
user.Comp.CurrentAction = protoId;
|
user.Comp.CurrentAction = protoId;
|
||||||
user.Comp.CurrentPartner = new Entity<InteractionPanelComponent>(target,target.Comp);
|
user.Comp.CurrentPartner = new Entity<InteractionPanelComponent>(target,target.Comp);
|
||||||
|
|
||||||
if(prototype.BeginningMessages.Count > 0)
|
if(prototype.BeginningMessages.Count > 0)
|
||||||
_chatSystem.TrySendInGameICMessage(user,_robustRandom.Pick(prototype.BeginningMessages),InGameICChatType.Emote,false);
|
{
|
||||||
|
_chatSystem.TrySendInGameICMessage(user,
|
||||||
|
ParseMessage(target,_robustRandom.Pick(prototype.BeginningMessages)),
|
||||||
|
InGameICChatType.Emote,
|
||||||
|
false);
|
||||||
|
}
|
||||||
|
|
||||||
if (prototype.BeginningSound is not null)
|
if (prototype.BeginningSound is not null)
|
||||||
_audioSystem.PlayPvs(prototype.BeginningSound, user);
|
_audioSystem.PlayPvs(prototype.BeginningSound, user);
|
||||||
|
|
||||||
|
|
||||||
RaiseLocalEvent(user,new InteractionBeginningEvent(protoId,user!,target!));
|
RaiseLocalEvent(user,new InteractionBeginningEvent(protoId,user!,target!));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string GetName(EntityUid target)
|
||||||
|
{
|
||||||
|
if(!TryComp<MindComponent>(target,out var mind) || mind.CharacterName is null)
|
||||||
|
return MetaData(target).EntityName;
|
||||||
|
|
||||||
|
return mind.CharacterName;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Gender GetGender(EntityUid target)
|
||||||
|
{
|
||||||
|
if (!TryComp<HumanoidAppearanceComponent>(target, out var humanoidAppearanceComponent))
|
||||||
|
return Gender.Male;
|
||||||
|
|
||||||
|
return humanoidAppearanceComponent.Gender;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ParseMessage(EntityUid target, string message)
|
||||||
|
{
|
||||||
|
return Loc.GetString(message,
|
||||||
|
("target", GetName(target)), ("gender", GetGender(target)));
|
||||||
|
}
|
||||||
|
|
||||||
public override void Update(float frameTime)
|
public override void Update(float frameTime)
|
||||||
{
|
{
|
||||||
base.Update(frameTime);
|
base.Update(frameTime);
|
||||||
var query = EntityQueryEnumerator<InteractionPanelComponent>();
|
var query = EntityQueryEnumerator<InteractionPanelComponent>();
|
||||||
while (query.MoveNext(out var uid, out var component))
|
while (query.MoveNext(out var uid, out var component))
|
||||||
{
|
{
|
||||||
if(component.Timeout > _gameTiming.CurTime || !component.IsActive)
|
if(component.EndTime > _gameTiming.CurTime || !component.IsActive)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (component.CurrentPartner is null)
|
if (component.CurrentPartner is null)
|
||||||
@@ -101,8 +136,14 @@ public sealed class InteractionPanelSystem : EntitySystem
|
|||||||
|
|
||||||
if (_prototypeManager.TryIndex(component.CurrentAction, out var prototype))
|
if (_prototypeManager.TryIndex(component.CurrentAction, out var prototype))
|
||||||
{
|
{
|
||||||
if(prototype.EndingMessages.Count > 0)
|
if (prototype.EndingMessages.Count > 0)
|
||||||
_chatSystem.TrySendInGameICMessage(uid,_robustRandom.Pick(prototype.EndingMessages),InGameICChatType.Emote,false);
|
{
|
||||||
|
_chatSystem.TrySendInGameICMessage(uid,
|
||||||
|
ParseMessage(component.CurrentPartner.Value,
|
||||||
|
_robustRandom.Pick(prototype.EndingMessages)),
|
||||||
|
InGameICChatType.Emote,
|
||||||
|
false);
|
||||||
|
}
|
||||||
|
|
||||||
if (prototype.EndingSound is not null)
|
if (prototype.EndingSound is not null)
|
||||||
_audioSystem.PlayPvs(prototype.EndingSound, uid);
|
_audioSystem.PlayPvs(prototype.EndingSound, uid);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ using System.Numerics;
|
|||||||
using Content.Server._Amour.Animation;
|
using Content.Server._Amour.Animation;
|
||||||
using Content.Shared._Amour.Animation;
|
using Content.Shared._Amour.Animation;
|
||||||
using Content.Shared._Amour.InteractionPanel;
|
using Content.Shared._Amour.InteractionPanel;
|
||||||
using Content.Shared.Movement.Components;
|
|
||||||
using Robust.Shared.Animations;
|
using Robust.Shared.Animations;
|
||||||
|
|
||||||
namespace Content.Server._Amour.InteractionPanel;
|
namespace Content.Server._Amour.InteractionPanel;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ public sealed partial class InteractionPanelComponent : Component
|
|||||||
[ViewVariables] public bool IsBlocked = false;
|
[ViewVariables] public bool IsBlocked = false;
|
||||||
[ViewVariables] public ProtoId<InteractionPrototype> CurrentAction;
|
[ViewVariables] public ProtoId<InteractionPrototype> CurrentAction;
|
||||||
[ViewVariables] public TimeSpan Timeout;
|
[ViewVariables] public TimeSpan Timeout;
|
||||||
|
[ViewVariables] public TimeSpan EndTime;
|
||||||
[ViewVariables] public Entity<InteractionPanelComponent>? CurrentPartner;
|
[ViewVariables] public Entity<InteractionPanelComponent>? CurrentPartner;
|
||||||
|
|
||||||
[DataField] public List<ProtoId<InteractionPrototype>> ActionPrototypes = new();
|
[DataField] public List<ProtoId<InteractionPrototype>> ActionPrototypes = new();
|
||||||
|
|||||||
@@ -10,14 +10,15 @@ public sealed partial class InteractionPrototype : IPrototype
|
|||||||
[IdDataField] public string ID { get; private set; } = default!;
|
[IdDataField] public string ID { get; private set; } = default!;
|
||||||
[ViewVariables] public PrototypeLayerData? Icon;
|
[ViewVariables] public PrototypeLayerData? Icon;
|
||||||
|
|
||||||
[ViewVariables] public SoundSpecifier? BeginningSound;
|
[DataField] public SoundSpecifier? BeginningSound;
|
||||||
[ViewVariables] public SoundSpecifier? EndingSound;
|
[DataField] public SoundSpecifier? EndingSound;
|
||||||
|
|
||||||
[DataField] public List<string> BeginningMessages = new();
|
[DataField] public List<string> BeginningMessages = new();
|
||||||
[DataField] public List<string> EndingMessages = new();
|
[DataField] public List<string> EndingMessages = new();
|
||||||
|
|
||||||
[DataField] public List<IInteractionCheck> Checks = new();
|
[DataField] public List<IInteractionCheck> Checks = new();
|
||||||
|
|
||||||
[DataField] public TimeSpan Timeout = TimeSpan.Zero;
|
[DataField] public TimeSpan EndTime = TimeSpan.Zero;
|
||||||
|
[DataField] public TimeSpan Timeout = TimeSpan.FromSeconds(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
6
Resources/Locale/ru-RU/_amour/interaction.ftl
Normal file
6
Resources/Locale/ru-RU/_amour/interaction.ftl
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
interaction-name-slapbutt = шлёпнуть по попке
|
||||||
|
interaction-butt-slap1 = шлёпает попку { $target }
|
||||||
|
interaction-butt-slap2 = со всей силы бьёт по жопе { $target }
|
||||||
|
interaction-butt-slap3 = шлёпает попку { $target }
|
||||||
|
|
||||||
|
interaction-panel-title = Панель взаимодействий
|
||||||
@@ -1,7 +1,11 @@
|
|||||||
- type: interaction
|
- type: interaction
|
||||||
id: SlapButt
|
id: SlapButt
|
||||||
|
beginningSound:
|
||||||
|
path: /Audio/White/Interactions/clap.ogg
|
||||||
checks:
|
checks:
|
||||||
- !type:HasSmallDistance
|
- !type:HasSmallDistance
|
||||||
- !type:CantInteractSelf
|
- !type:CantInteractSelf
|
||||||
beginningMessages:
|
beginningMessages:
|
||||||
- interaction-butt-slap
|
- interaction-butt-slap1
|
||||||
|
- interaction-butt-slap2
|
||||||
|
- interaction-butt-slap3
|
||||||
|
|||||||
Reference in New Issue
Block a user