diff --git a/Content.Server/Content.Server.csproj b/Content.Server/Content.Server.csproj
index 2596d60733..cb693e87c7 100644
--- a/Content.Server/Content.Server.csproj
+++ b/Content.Server/Content.Server.csproj
@@ -94,11 +94,12 @@
+
-
+
diff --git a/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs b/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs
index 0ab2211b60..a848b7f170 100644
--- a/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs
+++ b/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs
@@ -13,7 +13,6 @@ using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.Interfaces.GameObjects.Components;
using SS14.Shared.Interfaces.Network;
using SS14.Shared.IoC;
-using SS14.Shared.Players;
using SS14.Shared.Serialization;
namespace Content.Server.GameObjects
@@ -43,10 +42,6 @@ namespace Content.Server.GameObjects
// Mostly arbitrary.
public const float PICKUP_RANGE = 2;
- private InputCmdHandler _swapHandsCmdHandler;
- private InputCmdHandler _dropCmdHandler;
- private InputCmdHandler _activateItemInHandCmdHandler;
-
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
@@ -251,7 +246,7 @@ namespace Content.Server.GameObjects
return new HandsComponentState(dict, ActiveIndex);
}
- private void SwapHands(ICommonSession channel)
+ public void SwapHands()
{
var index = orderedHands.FindIndex(x => x == ActiveIndex);
index++;
@@ -263,6 +258,15 @@ namespace Content.Server.GameObjects
ActiveIndex = orderedHands[index];
}
+ public void ActivateItem()
+ {
+ var used = GetActiveHand?.Owner;
+ if (used != null)
+ {
+ InteractionSystem.TryUseInteraction(Owner, used);
+ }
+ }
+
public override void HandleMessage(ComponentMessage message, INetChannel netChannel = null, IComponent component = null)
{
base.HandleMessage(message, netChannel, component);
@@ -294,42 +298,7 @@ namespace Content.Server.GameObjects
}
break;
}
-
- //Boundkeychangedmsg only works for the player entity and doesn't need any extra verification
- case PlayerAttachedMsg msg:
- InitInputCommands();
- input = msg.NewPlayer.Input;
- input.SetCommand(ContentKeyFunctions.SwapHands, _swapHandsCmdHandler);
- input.SetCommand(ContentKeyFunctions.Drop, _dropCmdHandler);
- input.SetCommand(ContentKeyFunctions.ActivateItemInHand, _activateItemInHandCmdHandler);
- break;
-
- case PlayerDetachedMsg msg:
- input = msg.OldPlayer.Input;
- input.SetCommand(ContentKeyFunctions.SwapHands, null);
- input.SetCommand(ContentKeyFunctions.Drop, null);
- input.SetCommand(ContentKeyFunctions.ActivateItemInHand, null);
- break;
}
}
-
- private void InitInputCommands()
- {
- if (_swapHandsCmdHandler != null)
- {
- return;
- }
-
- _swapHandsCmdHandler = InputCmdHandler.FromDelegate(SwapHands);
- _dropCmdHandler = InputCmdHandler.FromDelegate(session => Drop(ActiveIndex));
- _activateItemInHandCmdHandler = InputCmdHandler.FromDelegate(session =>
- {
- var used = GetActiveHand?.Owner;
- if (used != null)
- {
- InteractionSystem.TryUseInteraction(Owner, used);
- }
- });
- }
}
}
diff --git a/Content.Server/GameObjects/EntitySystems/HandsSystem.cs b/Content.Server/GameObjects/EntitySystems/HandsSystem.cs
new file mode 100644
index 0000000000..cf8f94a723
--- /dev/null
+++ b/Content.Server/GameObjects/EntitySystems/HandsSystem.cs
@@ -0,0 +1,78 @@
+using Content.Shared.Input;
+using SS14.Server.GameObjects.EntitySystems;
+using SS14.Server.Interfaces.Player;
+using SS14.Shared.GameObjects;
+using SS14.Shared.GameObjects.Systems;
+using SS14.Shared.Input;
+using SS14.Shared.Players;
+
+namespace Content.Server.GameObjects.EntitySystems
+{
+ internal class HandsSystem : EntitySystem
+ {
+ ///
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ var input = EntitySystemManager.GetEntitySystem();
+ input.BindMap.BindFunction(ContentKeyFunctions.SwapHands, InputCmdHandler.FromDelegate(HandleSwapHands));
+ input.BindMap.BindFunction(ContentKeyFunctions.Drop, InputCmdHandler.FromDelegate(HandleDrop));
+ input.BindMap.BindFunction(ContentKeyFunctions.ActivateItemInHand, InputCmdHandler.FromDelegate(HandleActivateItem));
+ }
+
+ ///
+ public override void Shutdown()
+ {
+ if (EntitySystemManager.TryGetEntitySystem(out InputSystem input))
+ {
+ input.BindMap.UnbindFunction(ContentKeyFunctions.SwapHands);
+ input.BindMap.UnbindFunction(ContentKeyFunctions.Drop);
+ input.BindMap.UnbindFunction(ContentKeyFunctions.ActivateItemInHand);
+ }
+
+ base.Shutdown();
+ }
+
+ private static bool TryGetAttachedComponent(IPlayerSession session, out T component)
+ where T : Component
+ {
+ component = default(T);
+
+ var ent = session.AttachedEntity;
+
+ if (ent == null || !ent.IsValid())
+ return false;
+
+ if (!ent.TryGetComponent(out T comp))
+ return false;
+
+ component = comp;
+ return true;
+ }
+
+ private static void HandleSwapHands(ICommonSession session)
+ {
+ if (!TryGetAttachedComponent(session as IPlayerSession, out HandsComponent handsComp))
+ return;
+
+ handsComp.SwapHands();
+ }
+
+ private static void HandleDrop(ICommonSession session)
+ {
+ if (!TryGetAttachedComponent(session as IPlayerSession, out HandsComponent handsComp))
+ return;
+
+ handsComp.Drop(handsComp.ActiveIndex);
+ }
+
+ private static void HandleActivateItem(ICommonSession session)
+ {
+ if (!TryGetAttachedComponent(session as IPlayerSession, out HandsComponent handsComp))
+ return;
+
+ handsComp.ActivateItem();
+ }
+ }
+}
diff --git a/Content.Server/GameObjects/TemperatureSystem.cs b/Content.Server/GameObjects/EntitySystems/TemperatureSystem.cs
similarity index 91%
rename from Content.Server/GameObjects/TemperatureSystem.cs
rename to Content.Server/GameObjects/EntitySystems/TemperatureSystem.cs
index ac399172dc..8aa2fb185d 100644
--- a/Content.Server/GameObjects/TemperatureSystem.cs
+++ b/Content.Server/GameObjects/EntitySystems/TemperatureSystem.cs
@@ -1,7 +1,7 @@
using SS14.Shared.GameObjects;
using SS14.Shared.GameObjects.Systems;
-namespace Content.Server.GameObjects
+namespace Content.Server.GameObjects.EntitySystems
{
class TemperatureSystem : EntitySystem
{