diff --git a/Content.Client/_Amour/InteractionPanel/UI/InteractionPanelWindow.xaml.cs b/Content.Client/_Amour/InteractionPanel/UI/InteractionPanelWindow.xaml.cs index 4e66dc441c..d137c2764c 100644 --- a/Content.Client/_Amour/InteractionPanel/UI/InteractionPanelWindow.xaml.cs +++ b/Content.Client/_Amour/InteractionPanel/UI/InteractionPanelWindow.xaml.cs @@ -30,14 +30,14 @@ public sealed partial class InteractionPanelWindow : DefaultWindow public void AddButton(InteractionEntry entry) { - if(!_prototypeManager.TryIndex(entry.Prototype, out var prototype) + if (!_prototypeManager.TryIndex(entry.Prototype, out var prototype) || !_prototypeManager.TryIndex(prototype.Group, out var groupPrototype)) return; if (!Groups.TryGetValue(prototype.Group, out var box)) return; - if(DisCheckbox.Pressed && !entry.Enabled) + if (DisCheckbox.Pressed && !entry.Enabled) return; var btn = new InteractionPanelButton(); @@ -59,7 +59,7 @@ public sealed partial class InteractionPanelWindow : DefaultWindow var box = new BoxContainer(); Interactions.AddChild(box); box.Orientation = BoxContainer.LayoutOrientation.Vertical; - Groups.Add(prototype.ID,Interactions.ChildCount - 1); + Groups.Add(prototype.ID, Interactions.ChildCount - 1); } var messageUser = new FormattedMessage(); diff --git a/Content.Server/_Amour/InteractionPanel/InteractionPanelSystem.cs b/Content.Server/_Amour/InteractionPanel/InteractionPanelSystem.cs index 01758b5ad6..a964e0b704 100644 --- a/Content.Server/_Amour/InteractionPanel/InteractionPanelSystem.cs +++ b/Content.Server/_Amour/InteractionPanel/InteractionPanelSystem.cs @@ -40,11 +40,11 @@ public sealed class InteractionPanelSystem : EntitySystem public override void Initialize() { - SubscribeLocalEvent>(OnVerb); - SubscribeLocalEvent(OnInit); - SubscribeLocalEvent(OnPanel); - SubscribeLocalEvent(OnCancelable); - SubscribeLocalEvent(OnCancelable); + SubscribeLocalEvent>(OnVerb); + SubscribeLocalEvent(OnInit); + SubscribeLocalEvent(OnPanel); + SubscribeLocalEvent(OnCancelable); + SubscribeLocalEvent(OnCancelable); } private void OnCancelable(EntityUid uid, InteractionPanelComponent component, CancellableEntityEventArgs args) @@ -58,12 +58,12 @@ public sealed class InteractionPanelSystem : EntitySystem private void OnPanel(EntityUid uid, InteractionPanelComponent component, PanelDoAfterEvent args) { component.IsBlocked = false; - if(args.Cancelled + if (args.Cancelled || !_prototypeManager.TryIndex(args.Prototype, out var prototype) || !TryComp(args.Target, out var targetInteractionPanelComponent)) return; - Interact(new Entity(uid,component),new Entity(args.Target.Value,targetInteractionPanelComponent),prototype,false); + Interact(new Entity(uid, component), new Entity(args.Target.Value, targetInteractionPanelComponent), prototype, false); } private void OnInit(EntityUid uid, InteractionPanelComponent component, ComponentInit args) @@ -84,14 +84,14 @@ public sealed class InteractionPanelSystem : EntitySystem args.Verbs.Add(new Verb() { Text = Loc.GetString("interaction-open"), - Act = () => OpenPanel(args.User,args.User,uid) + Act = () => OpenPanel(args.User, args.User, uid) }); } public void OpenPanel(EntityUid panelOpener, Entity user, Entity target) { - if(!Resolve(user,ref user.Comp) || !Resolve(target,ref target.Comp) + if (!Resolve(user, ref user.Comp) || !Resolve(target, ref target.Comp) || !_playerManager.TryGetSessionByEntity(panelOpener, out var session)) return; @@ -99,8 +99,8 @@ public sealed class InteractionPanelSystem : EntitySystem return; _eui.OpenEui(new InteractionPanelEui( - new Entity(user,user.Comp), - new Entity(target,target.Comp)), + new Entity(user, user.Comp), + new Entity(target, target.Comp)), session); } @@ -108,8 +108,8 @@ public sealed class InteractionPanelSystem : EntitySystem Entity target, ProtoId protoId) { //TODO: Пиздец... пиздец.... пиздец.... - if( !Resolve(user,ref user.Comp) - || !Resolve(target,ref target.Comp) + if (!Resolve(user, ref user.Comp) + || !Resolve(target, ref target.Comp) || user.Comp.IsActive || user.Comp.IsBlocked || target.Comp.IsActive || target.Comp.IsBlocked || user.Comp.Timeout > _gameTiming.CurTime @@ -120,28 +120,28 @@ public sealed class InteractionPanelSystem : EntitySystem if (!_mobStateSystem.IsAlive(user) || !_mobStateSystem.IsAlive(target)) return; - if(!Check(user!,target!,prototype, out var check)) + if (!Check(user!, target!, prototype, out var check)) { - if(_playerManager.TryGetSessionByEntity(user,out var session) || session is null) + if (_playerManager.TryGetSessionByEntity(user, out var session) || session is null) return; var message = ParseMessage(target, $"interaction-fail-{check.GetType().Name.ToLower()}"); - _chatManager.ChatMessageToOne(ChatChannel.Emotes,message,message,EntityUid.Invalid,false,session.Channel); + _chatManager.ChatMessageToOne(ChatChannel.Emotes, message, message, EntityUid.Invalid, false, session.Channel); return; } if (prototype.BeginningTimeout == TimeSpan.Zero) { - Interact(user!,target!,prototype); + Interact(user!, target!, prototype); return; } user.Comp.IsBlocked = true; - if(prototype.PreBeginMessages.Count > 0) + if (prototype.PreBeginMessages.Count > 0) { _chatSystem.TrySendInGameICMessage(user, - ParseMessage(target,_robustRandom.Pick(prototype.PreBeginMessages)), + ParseMessage(target, _robustRandom.Pick(prototype.PreBeginMessages)), InGameICChatType.Emote, false); } @@ -150,7 +150,7 @@ public sealed class InteractionPanelSystem : EntitySystem EntityManager, user, prototype.BeginningTimeout, - new PanelDoAfterEvent(prototype.ID),user,target + new PanelDoAfterEvent(prototype.ID), user, target ) { BreakOnDamage = true, @@ -162,13 +162,13 @@ public sealed class InteractionPanelSystem : EntitySystem private void Interact(Entity user, Entity target, InteractionPrototype prototype, bool hasChecked = true) { - if(!hasChecked && !Check(user,target,prototype, out var check)) + if (!hasChecked && !Check(user, target, prototype, out var check)) { - if(_playerManager.TryGetSessionByEntity(user,out var session) || session is null) + if (_playerManager.TryGetSessionByEntity(user, out var session) || session is null) return; var message = ParseMessage(target, $"interaction-fail-{check.GetType().Name.ToLower()}"); - _chatManager.ChatMessageToOne(ChatChannel.Emotes,message,message,EntityUid.Invalid,false,session.Channel); + _chatManager.ChatMessageToOne(ChatChannel.Emotes, message, message, EntityUid.Invalid, false, session.Channel); return; } @@ -177,12 +177,12 @@ public sealed class InteractionPanelSystem : EntitySystem user.Comp.EndTime = _gameTiming.CurTime + prototype.EndTime; user.Comp.IsActive = true; user.Comp.CurrentAction = prototype.ID; - user.Comp.CurrentPartner = new Entity(target,target.Comp); + user.Comp.CurrentPartner = new Entity(target, target.Comp); - if(prototype.BeginningMessages.Count > 0) + if (prototype.BeginningMessages.Count > 0) { _chatSystem.TrySendInGameICMessage(user, - ParseMessage(target,_robustRandom.Pick(prototype.BeginningMessages)), + ParseMessage(target, _robustRandom.Pick(prototype.BeginningMessages)), InGameICChatType.Emote, false); } @@ -192,18 +192,18 @@ public sealed class InteractionPanelSystem : EntitySystem foreach (var action in prototype.BeginningActions) { - action.Run(user!,target!,EntityManager); + action.Run(user!, target!, EntityManager); } _actionBlockerSystem.UpdateCanMove(user); _actionBlockerSystem.UpdateCanMove(target); - RaiseLocalEvent(user,new InteractionBeginningEvent(prototype.ID,user,target)); + RaiseLocalEvent(user, new InteractionBeginningEvent(prototype.ID, user, target)); } private string GetName(EntityUid target) { - if(!TryComp(target,out var mind) || mind.CharacterName is null) + if (!TryComp(target, out var mind) || mind.CharacterName is null) return MetaData(target).EntityName; return mind.CharacterName; @@ -224,7 +224,7 @@ public sealed class InteractionPanelSystem : EntitySystem } public bool Check(Entity user, - Entity target, InteractionPrototype prototype,[NotNullWhen(false)] out IInteractionCheck? check) + Entity target, InteractionPrototype prototype, [NotNullWhen(false)] out IInteractionCheck? check) { check = null; foreach (var checkout in prototype.Checks.Where(check => !check.IsAvailable(user!, target!, EntityManager))) @@ -243,7 +243,7 @@ public sealed class InteractionPanelSystem : EntitySystem while (query.MoveNext(out var uid, out var component)) { - if(component.EndTime > _gameTiming.CurTime || !component.IsActive) + if (component.EndTime > _gameTiming.CurTime || !component.IsActive) continue; if (component.CurrentPartner is null) @@ -270,7 +270,7 @@ public sealed class InteractionPanelSystem : EntitySystem foreach (var action in prototype.EndingActions) { - action.Run(user,component.CurrentPartner.Value,EntityManager); + action.Run(user, component.CurrentPartner.Value, EntityManager); } } diff --git a/Content.Shared/_Amour/InteractionPanel/Checks/Distance.cs b/Content.Shared/_Amour/InteractionPanel/Checks/Distance.cs index 11e707e246..a23af01bf8 100644 --- a/Content.Shared/_Amour/InteractionPanel/Checks/Distance.cs +++ b/Content.Shared/_Amour/InteractionPanel/Checks/Distance.cs @@ -9,6 +9,10 @@ public sealed class HasSmallDistance : IInteractionCheck { var transformSystem = entityManager.System(); + if (!entityManager.HasComponent(user) || + !entityManager.HasComponent(target)) + return false; + if (_range <= 0) return true; diff --git a/Content.Shared/_Amour/InteractionPanel/Checks/IInteractionCheck.cs b/Content.Shared/_Amour/InteractionPanel/Checks/IInteractionCheck.cs index cfe3d280b3..7d9740028e 100644 --- a/Content.Shared/_Amour/InteractionPanel/Checks/IInteractionCheck.cs +++ b/Content.Shared/_Amour/InteractionPanel/Checks/IInteractionCheck.cs @@ -3,5 +3,5 @@ namespace Content.Shared._Amour.InteractionPanel.Checks; public interface IInteractionCheck { public bool IsAvailable(Entity user, - Entity target,IEntityManager entityManager); + Entity target, IEntityManager entityManager); }