From 3f89f3f0f798795e2a7fb660469800b414457b86 Mon Sep 17 00:00:00 2001 From: Acruid Date: Sat, 3 Mar 2018 18:07:09 -0800 Subject: [PATCH] InputSystem Messages (#37) * Misc Cleanup. * Removed BoundKeyChangeEventArgs. * Nothing uses EntityEventArgs now. * Rebase fixes. * Updated Engine. Fixed .gitmodules file. --- .gitmodules | 2 +- .../Components/Items/ServerHandsComponent.cs | 51 ++++++++----------- .../EntitySystems/InteractionSystem.cs | 14 +++-- engine | 2 +- 4 files changed, 29 insertions(+), 40 deletions(-) diff --git a/.gitmodules b/.gitmodules index 5e7fdd5053..dedcf933ac 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ [submodule "engine"] path = engine url = https://github.com/space-wizards/space-station-14.git - branch = 98b7e4ee9ede281f5159539fbb9dba3d08a015cf \ No newline at end of file + branch = master \ No newline at end of file diff --git a/Content.Server/GameObjects/Components/Items/ServerHandsComponent.cs b/Content.Server/GameObjects/Components/Items/ServerHandsComponent.cs index c6968dcabe..59d3ed7715 100644 --- a/Content.Server/GameObjects/Components/Items/ServerHandsComponent.cs +++ b/Content.Server/GameObjects/Components/Items/ServerHandsComponent.cs @@ -1,19 +1,19 @@ -using Content.Server.Interfaces.GameObjects; +using System; +using System.Collections.Generic; +using Content.Server.Interfaces.GameObjects; using Content.Shared.GameObjects; -using SS14.Server.GameObjects.Events; using SS14.Server.Interfaces.GameObjects; using SS14.Shared.GameObjects; +using SS14.Shared.Input; using SS14.Shared.Utility; -using System; -using System.Collections.Generic; using YamlDotNet.RepresentationModel; -using SS14.Shared.Enums; namespace Content.Server.GameObjects { public class HandsComponent : SharedHandsComponent, IHandsComponent { private string activeIndex; + public string ActiveIndex { get => activeIndex; @@ -48,16 +48,13 @@ namespace Content.Server.GameObjects AddHand(node.AsString()); } } - - Owner.SubscribeEvent(OnKeyChange, this); + base.Initialize(); } public override void OnRemove() { inventory = null; - Owner.UnsubscribeEvent(this); - Owner.UnsubscribeEvent(this); base.OnRemove(); } @@ -223,27 +220,7 @@ namespace Content.Server.GameObjects } return new HandsComponentState(dict, ActiveIndex); } - - // Game logic goes here. - public void OnKeyChange(object sender, EntityEventArgs uncast) - { - var cast = (BoundKeyChangeEventArgs)uncast; - if (cast.Actor != Owner || cast.KeyState != BoundKeyState.Down) - { - return; - } - - switch (cast.KeyFunction) - { - case BoundKeyFunctions.SwitchHands: - SwapHands(); - break; - case BoundKeyFunctions.Drop: - Drop(ActiveIndex); - break; - } - } - + private void SwapHands() { var index = orderedHands.FindIndex(x => x == ActiveIndex); @@ -266,6 +243,20 @@ namespace Content.Server.GameObjects if (HasHand(msg.Index)) ActiveIndex = msg.Index; break; + + case BoundKeyChangedMsg msg: + if(msg.State != BoundKeyState.Down) + return; + switch (msg.Function) + { + case BoundKeyFunctions.SwitchHands: + SwapHands(); + break; + case BoundKeyFunctions.Drop: + Drop(ActiveIndex); + break; + } + break; } } } diff --git a/Content.Server/GameObjects/EntitySystems/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/InteractionSystem.cs index 3661962d2b..2d54e7e8c0 100644 --- a/Content.Server/GameObjects/EntitySystems/InteractionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/InteractionSystem.cs @@ -3,11 +3,9 @@ using SS14.Server.Interfaces.GameObjects; using SS14.Shared.GameObjects; using SS14.Shared.GameObjects.System; using SS14.Shared.Interfaces.GameObjects; -using SS14.Shared.Interfaces.GameObjects.Components; -using SS14.Shared.IoC; using System.Collections.Generic; using System.Linq; -using SS14.Shared.Enums; +using SS14.Shared.Input; namespace Content.Server.GameObjects.EntitySystems { @@ -44,17 +42,17 @@ namespace Content.Server.GameObjects.EntitySystems { base.Initialize(); - SubscribeEvent(UserInteraction, this); + SubscribeEvent(UserInteraction); } - public void UserInteraction(object sender, EntityEventArgs arg) + private void UserInteraction(object sender, EntityEventArgs arg) { - ClickedOnEntityEventArgs e = (ClickedOnEntityEventArgs)arg; + var e = (ClickedOnEntityMessage)arg; if (e.MouseButton != ClickType.Left) return; - IEntity user = EntityManager.GetEntity(e.Clicker); - IEntity attacked = EntityManager.GetEntity(e.Clicked); + var user = EntityManager.GetEntity(e.Owner); + var attacked = EntityManager.GetEntity(e.Clicked); if (!user.TryGetComponent(out var userTransform)) { diff --git a/engine b/engine index 98b7e4ee9e..659b57940c 160000 --- a/engine +++ b/engine @@ -1 +1 @@ -Subproject commit 98b7e4ee9ede281f5159539fbb9dba3d08a015cf +Subproject commit 659b57940c2d2e5c27731c9aeab640fb5a35a484