diff --git a/Content.Client/Content.Client.csproj b/Content.Client/Content.Client.csproj
index e84816fe8c..84595de385 100644
--- a/Content.Client/Content.Client.csproj
+++ b/Content.Client/Content.Client.csproj
@@ -71,6 +71,7 @@
+
diff --git a/Content.Client/EntryPoint.cs b/Content.Client/EntryPoint.cs
index a84ccbb567..d53b802528 100644
--- a/Content.Client/EntryPoint.cs
+++ b/Content.Client/EntryPoint.cs
@@ -3,7 +3,9 @@ using Content.Client.GameObjects.Components.Construction;
using Content.Client.GameObjects.Components.Power;
using Content.Client.GameObjects.Components.SmoothWalling;
using Content.Client.GameObjects.Components.Storage;
+using Content.Client.Input;
using Content.Client.Interfaces.GameObjects;
+using SS14.Client.Interfaces.Input;
using SS14.Shared.ContentPack;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.IoC;
@@ -63,6 +65,16 @@ namespace Content.Client
factory.RegisterIgnore("Smes");
prototypes.RegisterIgnore("material");
+
+ }
+
+ public override void PostInit()
+ {
+ base.PostInit();
+
+ // Setup key contexts
+ var inputMan = IoCManager.Resolve();
+ ContentContexts.SetupContexts(inputMan.Contexts);
}
}
}
diff --git a/Content.Client/Input/ContentContexts.cs b/Content.Client/Input/ContentContexts.cs
new file mode 100644
index 0000000000..654f3912dd
--- /dev/null
+++ b/Content.Client/Input/ContentContexts.cs
@@ -0,0 +1,23 @@
+using Content.Shared.Input;
+using SS14.Shared.Input;
+
+namespace Content.Client.Input
+{
+ ///
+ /// Contains a helper function for setting up all content
+ /// contexts, and modifying existing engine ones.
+ ///
+ public static class ContentContexts
+ {
+ public static void SetupContexts(IInputContextContainer contexts)
+ {
+ var human = contexts.GetContext("human");
+ human.AddFunction(ContentKeyFunctions.SwapHands);
+ human.AddFunction(ContentKeyFunctions.Drop);
+ human.AddFunction(ContentKeyFunctions.ActivateItemInHand);
+ human.AddFunction(ContentKeyFunctions.OpenCharacterMenu);
+ human.AddFunction(ContentKeyFunctions.ExamineEntity);
+ human.AddFunction(ContentKeyFunctions.UseItemInHand);
+ }
+ }
+}
diff --git a/Content.Server/Content.Server.csproj b/Content.Server/Content.Server.csproj
index d684ad38eb..2596d60733 100644
--- a/Content.Server/Content.Server.csproj
+++ b/Content.Server/Content.Server.csproj
@@ -91,7 +91,6 @@
-
diff --git a/Content.Server/GameObjects/EntitySystems/Click/ClickParser.cs b/Content.Server/GameObjects/EntitySystems/Click/ClickParser.cs
deleted file mode 100644
index fc0f9b5bae..0000000000
--- a/Content.Server/GameObjects/EntitySystems/Click/ClickParser.cs
+++ /dev/null
@@ -1,67 +0,0 @@
-using System;
-using SS14.Server.Interfaces.Player;
-using SS14.Shared.GameObjects;
-using SS14.Shared.GameObjects.Systems;
-using SS14.Shared.Input;
-using SS14.Shared.Interfaces.GameObjects;
-using SS14.Shared.Interfaces.Network;
-using SS14.Shared.IoC;
-
-namespace Content.Server.GameObjects.EntitySystems
-{
- ///
- /// Catches clicks from the client and parses them to relevant entity systems
- ///
- public class ClickParserSystem : EntitySystem
- {
- ///
- public override void RegisterMessageTypes()
- {
- base.RegisterMessageTypes();
-
- RegisterMessageType();
- }
-
- ///
- /// Grab click events sent from the client input system
- ///
- ///
- ///
- public override void HandleNetMessage(INetChannel channel, EntitySystemMessage message)
- {
- base.HandleNetMessage(channel, message);
-
- var playerMan = IoCManager.Resolve();
- var session = playerMan.GetSessionByChannel(channel);
- var playerentity = session.AttachedEntity;
-
- if (playerentity == null)
- return;
-
- switch (message)
- {
- case ClickEventMessage msg:
- ParseClickMessage(msg, playerentity);
- break;
- }
- }
-
- ///
- /// Parse click to the relevant entity system
- ///
- ///
- ///
- private void ParseClickMessage(ClickEventMessage message, IEntity player)
- {
- switch (message.Click)
- {
- case ClickType.Left:
- EntitySystemManager.GetEntitySystem().UserInteraction(message, player);
- break;
- case ClickType.Right:
- //Verb System
- break;
- }
- }
- }
-}
diff --git a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs
index 0db93c1764..4980c49df2 100644
--- a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs
+++ b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs
@@ -1,16 +1,21 @@
-using Content.Server.Interfaces.GameObjects;
+using System;
+using Content.Server.Interfaces.GameObjects;
using SS14.Server.Interfaces.GameObjects;
using SS14.Shared.GameObjects;
using SS14.Shared.GameObjects.Systems;
using SS14.Shared.Interfaces.GameObjects;
using System.Collections.Generic;
using System.Linq;
+using Content.Shared.Input;
using SS14.Shared.Input;
using SS14.Shared.Log;
using SS14.Shared.Map;
using SS14.Server.GameObjects;
+using SS14.Server.GameObjects.EntitySystems;
+using SS14.Server.Interfaces.Player;
using SS14.Shared.Interfaces.GameObjects.Components;
using SS14.Shared.GameObjects.Components.BoundingBox;
+using SS14.Shared.Players;
namespace Content.Server.GameObjects.EntitySystems
{
@@ -92,12 +97,22 @@ namespace Content.Server.GameObjects.EntitySystems
public const float INTERACTION_RANGE = 2;
public const float INTERACTION_RANGE_SQUARED = INTERACTION_RANGE * INTERACTION_RANGE;
- public void UserInteraction(ClickEventMessage msg, IEntity player)
+ public override void Initialize()
+ {
+ var inputSys = EntitySystemManager.GetEntitySystem();
+ inputSys.BindMap.BindFunction(ContentKeyFunctions.UseItemInHand, new PointerInputCmdHandler(HandleUseItemInHand));
+ }
+
+ private void HandleUseItemInHand(ICommonSession session, GridLocalCoordinates coords, EntityUid uid)
+ {
+ UserInteraction(((IPlayerSession)session).AttachedEntity, coords, uid);
+ }
+
+ private void UserInteraction(IEntity player, GridLocalCoordinates coordinates, EntityUid clickedUid)
{
//Get entity clicked upon from UID if valid UID, if not assume no entity clicked upon and null
- IEntity attacked = null;
- if (msg.Uid.IsValid())
- attacked = EntityManager.GetEntity(msg.Uid);
+ if (!EntityManager.TryGetEntity(clickedUid, out var attacked))
+ return;
//Verify player has a transform component
if (!player.TryGetComponent(out var playerTransform))
@@ -105,7 +120,7 @@ namespace Content.Server.GameObjects.EntitySystems
return;
}
//Verify player is on the same map as the entity he clicked on
- else if (msg.Coordinates.MapID != playerTransform.MapID)
+ else if (coordinates.MapID != playerTransform.MapID)
{
Logger.Warning(string.Format("Player named {0} clicked on a map he isn't located on", player.Name));
return;
@@ -129,7 +144,7 @@ namespace Content.Server.GameObjects.EntitySystems
if (attacked == null && item != null)
{
//AFTERATTACK: Check if we clicked on an empty location, if so the only interaction we can do is afterattack
- InteractAfterattack(player, item, msg.Coordinates);
+ InteractAfterattack(player, item, coordinates);
return;
}
else if (attacked == null)
@@ -147,7 +162,7 @@ namespace Content.Server.GameObjects.EntitySystems
//Check if ClickLocation is in object bounds here, if not lets log as warning and see why
if (attacked.TryGetComponent(out BoundingBoxComponent boundingbox))
{
- if (!boundingbox.WorldAABB.Contains(msg.Coordinates.Position))
+ if (!boundingbox.WorldAABB.Contains(coordinates.Position))
{
Logger.Warning(string.Format("Player {0} clicked {1} outside of its bounding box component somehow", player.Name, attacked.Name));
return;
@@ -161,7 +176,7 @@ namespace Content.Server.GameObjects.EntitySystems
{
if (item != null)
{
- RangedInteraction(player, item, attacked, msg.Coordinates);
+ RangedInteraction(player, item, attacked, coordinates);
return;
}
return; //Add some form of ranged attackhand here if you need it someday, or perhaps just ways to modify the range of attackhand
@@ -171,7 +186,7 @@ namespace Content.Server.GameObjects.EntitySystems
//ATTACKBY/AFTERATTACK: We will either use the item on the nearby object
if (item != null)
{
- Interaction(player, item, attacked, msg.Coordinates);
+ Interaction(player, item, attacked, coordinates);
}
//ATTACKHAND: Since our hand is empty we will use attackhand
else
diff --git a/Content.Shared/Content.Shared.csproj b/Content.Shared/Content.Shared.csproj
index 247ab590ba..233cfeb270 100644
--- a/Content.Shared/Content.Shared.csproj
+++ b/Content.Shared/Content.Shared.csproj
@@ -108,4 +108,4 @@
-
+
\ No newline at end of file
diff --git a/Content.Shared/Input/ContentKeyFunctions.cs b/Content.Shared/Input/ContentKeyFunctions.cs
index dc523fcce2..73140d87a5 100644
--- a/Content.Shared/Input/ContentKeyFunctions.cs
+++ b/Content.Shared/Input/ContentKeyFunctions.cs
@@ -10,5 +10,6 @@ namespace Content.Shared.Input
public static readonly BoundKeyFunction ActivateItemInHand = "ActivateItemInHand";
public static readonly BoundKeyFunction OpenCharacterMenu = "OpenCharacterMenu";
public static readonly BoundKeyFunction ExamineEntity = "ExamineEntity";
+ public static readonly BoundKeyFunction UseItemInHand = "UseItemInHand";
}
}
diff --git a/Resources/keybinds_content.yml b/Resources/keybinds_content.yml
index 7564c66ab9..273803e48e 100644
--- a/Resources/keybinds_content.yml
+++ b/Resources/keybinds_content.yml
@@ -16,3 +16,6 @@ binds:
key: MouseLeft
mod1: Shift
type: State
+- function: UseItemInHand
+ key: MouseLeft
+ type: state
diff --git a/SpaceStation14Content.sln b/SpaceStation14Content.sln
index ce4927a3f6..0545f388ac 100644
--- a/SpaceStation14Content.sln
+++ b/SpaceStation14Content.sln
@@ -184,7 +184,6 @@ Global
{C899FCA4-7037-4E49-ABC2-44DE72487110}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C899FCA4-7037-4E49-ABC2-44DE72487110}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C899FCA4-7037-4E49-ABC2-44DE72487110}.Debug|x64.ActiveCfg = Debug|Any CPU
- {C899FCA4-7037-4E49-ABC2-44DE72487110}.Debug|x64.Build.0 = Debug|Any CPU
{C899FCA4-7037-4E49-ABC2-44DE72487110}.Debug|x86.ActiveCfg = Debug|Any CPU
{C899FCA4-7037-4E49-ABC2-44DE72487110}.Debug|x86.Build.0 = Debug|Any CPU
{C899FCA4-7037-4E49-ABC2-44DE72487110}.Release|Any CPU.ActiveCfg = Debug|Any CPU
diff --git a/engine b/engine
index 900e2c94e8..bddd355f17 160000
--- a/engine
+++ b/engine
@@ -1 +1 @@
-Subproject commit 900e2c94e87e6a5f52550ea62f432fc9fd5ffe2b
+Subproject commit bddd355f178c986f7ba691297c776d569a4909b3