diff --git a/Content.Client/Content.Client.csproj b/Content.Client/Content.Client.csproj
index 6fad7de4a6..4927d2da9e 100644
--- a/Content.Client/Content.Client.csproj
+++ b/Content.Client/Content.Client.csproj
@@ -62,6 +62,8 @@
+
+
diff --git a/Content.Client/EntryPoint.cs b/Content.Client/EntryPoint.cs
index d2ff4e773f..cd7fc67701 100644
--- a/Content.Client/EntryPoint.cs
+++ b/Content.Client/EntryPoint.cs
@@ -1,4 +1,6 @@
-using SS14.Shared.ContentPack;
+using Content.Client.GameObjects;
+using Content.Client.Interfaces.GameObjects;
+using SS14.Shared.ContentPack;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.IoC;
@@ -12,6 +14,9 @@ namespace Content.Client
factory.RegisterIgnore("Inventory");
factory.RegisterIgnore("Item");
+
+ factory.Register();
+ factory.RegisterReference();
}
}
}
diff --git a/Content.Client/GameObjects/Components/Items/HandsComponent.cs b/Content.Client/GameObjects/Components/Items/HandsComponent.cs
new file mode 100644
index 0000000000..315b9aa7d2
--- /dev/null
+++ b/Content.Client/GameObjects/Components/Items/HandsComponent.cs
@@ -0,0 +1,34 @@
+using Content.Client.Interfaces.GameObjects;
+using Content.Shared.GameObjects;
+using SS14.Shared.GameObjects;
+using SS14.Shared.Interfaces.GameObjects;
+using SS14.Shared.IoC;
+using System.Collections.Generic;
+
+namespace Content.Client.GameObjects
+{
+ public class HandsComponent : SharedHandsComponent, IHandsComponent
+ {
+ private readonly Dictionary hands = new Dictionary();
+
+ public IEntity GetEntity(string index)
+ {
+ if (hands.TryGetValue(index, out var entity))
+ {
+ return entity;
+ }
+
+ return null;
+ }
+
+ public override void HandleComponentState(ComponentState state)
+ {
+ var cast = (HandsComponentState)state;
+ hands.Clear();
+ foreach (var hand in cast.Hands)
+ {
+ hands[hand.Key] = Owner.EntityManager.GetEntity(hand.Value);
+ }
+ }
+ }
+}
diff --git a/Content.Client/Interfaces/GameObjects/Components/Items/IHandsComponent.cs b/Content.Client/Interfaces/GameObjects/Components/Items/IHandsComponent.cs
new file mode 100644
index 0000000000..06a9f6c1c7
--- /dev/null
+++ b/Content.Client/Interfaces/GameObjects/Components/Items/IHandsComponent.cs
@@ -0,0 +1,16 @@
+using Content.Client.Interfaces.GameObjects;
+using Content.Shared.GameObjects;
+using SS14.Shared.GameObjects;
+using SS14.Shared.Interfaces.GameObjects;
+using SS14.Shared.IoC;
+using System.Collections.Generic;
+
+namespace Content.Client.Interfaces.GameObjects
+{
+ // HYPER SIMPLE HANDS API CLIENT SIDE.
+ // To allow for showing the HUD, mostly.
+ public interface IHandsComponent
+ {
+ IEntity GetEntity(string index);
+ }
+}
diff --git a/Content.Server/GameObjects/Components/Items/HandsComponent.cs b/Content.Server/GameObjects/Components/Items/HandsComponent.cs
index 997e57bcba..28e5063ba6 100644
--- a/Content.Server/GameObjects/Components/Items/HandsComponent.cs
+++ b/Content.Server/GameObjects/Components/Items/HandsComponent.cs
@@ -1,4 +1,5 @@
using Content.Server.Interfaces.GameObjects;
+using Content.Shared.GameObjects;
using SS14.Shared.GameObjects;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.Utility;
@@ -9,10 +10,8 @@ using YamlDotNet.RepresentationModel;
namespace Content.Server.GameObjects
{
- public class HandsComponent : Component, IHandsComponent
+ public class HandsComponent : SharedHandsComponent, IHandsComponent
{
- public override string Name => "Hands";
-
private string activeIndex;
public string ActiveIndex
{
@@ -54,8 +53,6 @@ namespace Content.Server.GameObjects
public IEnumerable GetAllHeldItems()
{
- throw new NotImplementedException();
- /*
foreach (var slot in hands.Values)
{
if (slot.Item != null)
@@ -63,7 +60,6 @@ namespace Content.Server.GameObjects
yield return slot.Item;
}
}
- */
}
public IItemComponent GetHand(string index)
@@ -77,8 +73,6 @@ namespace Content.Server.GameObjects
///
private IEnumerable ActivePriorityEnumerable()
{
- throw new NotImplementedException();
- /*
yield return ActiveIndex;
foreach (var hand in hands.Keys)
{
@@ -89,7 +83,6 @@ namespace Content.Server.GameObjects
yield return hand;
}
- */
}
public bool PutInHand(IItemComponent item)
@@ -183,5 +176,18 @@ namespace Content.Server.GameObjects
/// Get the name of the slot passed to the inventory component.
///
private string HandSlotName(string index) => $"_hand_{index}";
+
+ public override ComponentState GetComponentState()
+ {
+ var dict = new Dictionary(hands.Count);
+ foreach (var hand in hands)
+ {
+ if (hand.Value.Item != null)
+ {
+ dict[hand.Key] = hand.Value.Item.Owner.Uid;
+ }
+ }
+ return new HandsComponentState(dict);
+ }
}
}
diff --git a/Content.Shared/Content.Shared.csproj b/Content.Shared/Content.Shared.csproj
index af0cea6ca3..7618413325 100644
--- a/Content.Shared/Content.Shared.csproj
+++ b/Content.Shared/Content.Shared.csproj
@@ -56,6 +56,8 @@
+
+
diff --git a/Content.Shared/GameObjects/Components/Items/HandsComponent.cs b/Content.Shared/GameObjects/Components/Items/HandsComponent.cs
new file mode 100644
index 0000000000..bac1c58156
--- /dev/null
+++ b/Content.Shared/GameObjects/Components/Items/HandsComponent.cs
@@ -0,0 +1,25 @@
+using SS14.Shared.GameObjects;
+using System;
+using System.Collections.Generic;
+
+namespace Content.Shared.GameObjects
+{
+ public abstract class SharedHandsComponent : Component
+ {
+ public sealed override string Name => "Hands";
+ public sealed override uint? NetID => ContentNetIDs.HANDS;
+ public sealed override Type StateType => typeof(HandsComponentState);
+ }
+
+ // The IDs of the items get synced over the network.
+ [Serializable]
+ public class HandsComponentState : ComponentState
+ {
+ public readonly Dictionary Hands;
+
+ public HandsComponentState(Dictionary hands)
+ {
+ Hands = hands;
+ }
+ }
+}
diff --git a/Content.Shared/GameObjects/Components/NetIDs.cs b/Content.Shared/GameObjects/Components/NetIDs.cs
new file mode 100644
index 0000000000..da323846c2
--- /dev/null
+++ b/Content.Shared/GameObjects/Components/NetIDs.cs
@@ -0,0 +1,7 @@
+namespace Content.Shared.GameObjects
+{
+ public static class ContentNetIDs
+ {
+ public const uint HANDS = 0;
+ }
+}