diff --git a/.gitmodules b/.gitmodules
index cd4c53c00f..03081a0dd7 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,4 +1,4 @@
[submodule "engine"]
path = engine
url = https://github.com/space-wizards/space-station-14.git
- branch = 0a231f0217a7b9f9ce7093bdd091ce3e3de1b69d
\ No newline at end of file
+ branch = 56508df91937fd456bc5411008575169d93b262b
\ No newline at end of file
diff --git a/Content.Server/Content.Server.csproj b/Content.Server/Content.Server.csproj
index 7ca6c53904..175c3cc462 100644
--- a/Content.Server/Content.Server.csproj
+++ b/Content.Server/Content.Server.csproj
@@ -57,7 +57,6 @@
-
@@ -65,8 +64,8 @@
+
-
@@ -109,4 +108,7 @@
+
+
+
\ No newline at end of file
diff --git a/Content.Server/EntryPoint.cs b/Content.Server/EntryPoint.cs
index a9d5ca592d..dc5ca3636e 100644
--- a/Content.Server/EntryPoint.cs
+++ b/Content.Server/EntryPoint.cs
@@ -52,10 +52,7 @@ namespace Content.Server
factory.Register();
factory.RegisterReference();
-
- factory.Register();
- factory.RegisterReference();
-
+
factory.Register();
factory.Register();
factory.Register();
diff --git a/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs b/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs
index 50d279c681..8b9b9d10ac 100644
--- a/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs
+++ b/Content.Server/GameObjects/Components/Doors/ServerDoorComponent.cs
@@ -1,41 +1,40 @@
-using Content.Server.Interfaces.GameObjects;
+using System;
+using Content.Server.Interfaces.GameObjects;
using Content.Shared.GameObjects;
using SS14.Server.GameObjects;
using SS14.Shared.GameObjects;
+using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.Interfaces.GameObjects.Components;
using SS14.Shared.Log;
using SS14.Shared.Maths;
+using SS14.Shared.IoC;
+using Content.Server.GameObjects.EntitySystems;
namespace Content.Server.GameObjects
{
- public class ServerDoorComponent : SharedDoorComponent
+ public class ServerDoorComponent : SharedDoorComponent, IAttackHand
{
public bool Opened { get; private set; }
private float OpenTimeCounter;
-
- private IInteractableComponent interactableComponent;
+
private CollidableComponent collidableComponent;
public override void Initialize()
{
base.Initialize();
- interactableComponent = Owner.GetComponent();
- interactableComponent.OnAttackHand += OnAttackHand;
collidableComponent = Owner.GetComponent();
collidableComponent.OnBump += OnBump;
}
public override void OnRemove()
{
- interactableComponent.OnAttackHand -= OnAttackHand;
- interactableComponent = null;
collidableComponent.OnBump -= OnBump;
collidableComponent = null;
}
- private void OnAttackHand(object sender, AttackHandEventArgs args)
+ public bool Attackhand(IEntity user)
{
if (Opened)
{
@@ -45,6 +44,7 @@ namespace Content.Server.GameObjects
{
Open();
}
+ return true;
}
private void OnBump(object sender, BumpEventArgs args)
diff --git a/Content.Server/GameObjects/Components/Interactable/InteractableComponent.cs b/Content.Server/GameObjects/Components/Interactable/InteractableComponent.cs
deleted file mode 100644
index 8a4c50cc19..0000000000
--- a/Content.Server/GameObjects/Components/Interactable/InteractableComponent.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-using Content.Server.Interfaces.GameObjects;
-using SS14.Server.Interfaces.GameObjects;
-using SS14.Shared.GameObjects;
-using SS14.Shared.Interfaces.GameObjects.Components;
-using SS14.Shared.Log;
-using System;
-
-namespace Content.Server.GameObjects
-{
- public class InteractableComponent : Component, IInteractableComponent
- {
- public override string Name => "Interactable";
-
- ///
- public event EventHandler OnAttackHand;
-
- ///
- public event EventHandler OnAttackBy;
-
- private IClickableComponent clickableComponent;
- private IServerTransformComponent transform;
- private const float INTERACTION_RANGE = 2;
- private const float INTERACTION_RANGE_SQUARED = INTERACTION_RANGE * INTERACTION_RANGE;
-
- public override void Initialize()
- {
- transform = Owner.GetComponent();
- if (Owner.TryGetComponent(out var component))
- {
- clickableComponent = component;
- clickableComponent.OnClick += ClickableComponent_OnClick;
- }
- else
- {
- Logger.Error($"Interactable component must also have a clickable component to function! Prototype: {Owner.Prototype.ID}");
- }
- base.Initialize();
- }
-
- public override void Shutdown()
- {
- if (clickableComponent != null)
- {
- clickableComponent.OnClick -= ClickableComponent_OnClick;
- clickableComponent = null;
- }
- transform = null;
- base.Shutdown();
- }
-
- private void ClickableComponent_OnClick(object sender, ClickEventArgs e)
- {
- if (!e.User.TryGetComponent(out var userTransform))
- {
- return;
- }
-
- var distance = (userTransform.WorldPosition - transform.WorldPosition).LengthSquared;
- if (distance > INTERACTION_RANGE_SQUARED)
- {
- return;
- }
-
- if (!e.User.TryGetComponent(out var hands))
- {
- return;
- }
-
- var item = hands.GetHand(hands.ActiveIndex);
- if (item != null)
- {
- OnAttackBy?.Invoke(this, new AttackByEventArgs(Owner, e.User, item, hands.ActiveIndex));
- }
- else
- {
- OnAttackHand?.Invoke(this, new AttackHandEventArgs(Owner, e.User, hands.ActiveIndex));
- }
- }
- }
-}
diff --git a/Content.Server/GameObjects/Components/Items/ItemComponent.cs b/Content.Server/GameObjects/Components/Items/ItemComponent.cs
index af9980906d..1ca94df250 100644
--- a/Content.Server/GameObjects/Components/Items/ItemComponent.cs
+++ b/Content.Server/GameObjects/Components/Items/ItemComponent.cs
@@ -1,19 +1,17 @@
using Content.Server.Interfaces.GameObjects;
using SS14.Server.Interfaces.GameObjects;
using SS14.Shared.GameObjects;
-using SS14.Shared.Interfaces.GameObjects.Components;
-using SS14.Shared.Log;
using System;
+using SS14.Shared.Interfaces.GameObjects;
namespace Content.Server.GameObjects
{
- public class ItemComponent : Component, IItemComponent
+ public class ItemComponent : Component, IItemComponent, EntitySystems.IAttackHand
{
public override string Name => "Item";
///
public IInventorySlot ContainingSlot { get; private set; }
- private IInteractableComponent interactableComponent;
public void RemovedFromSlot()
{
@@ -45,38 +43,15 @@ namespace Content.Server.GameObjects
}
}
- public override void Initialize()
- {
- if (Owner.TryGetComponent(out var interactable))
- {
- interactableComponent = interactable;
- interactableComponent.OnAttackHand += InteractableComponent_OnAttackHand;
- }
- else
- {
- Logger.Error($"Item component must have an interactable component to function! Prototype: {Owner.Prototype.ID}");
- }
- base.Initialize();
- }
-
- private void InteractableComponent_OnAttackHand(object sender, AttackHandEventArgs e)
+ public bool Attackhand(IEntity user)
{
if (ContainingSlot != null)
{
- return;
+ return false;
}
- var hands = e.User.GetComponent();
- hands.PutInHand(this, e.HandIndex, fallback: false);
- }
-
- public override void Shutdown()
- {
- if (interactableComponent != null)
- {
- interactableComponent.OnAttackHand -= InteractableComponent_OnAttackHand;
- interactableComponent = null;
- }
- base.Shutdown();
+ var hands = user.GetComponent();
+ hands.PutInHand(this, hands.ActiveIndex, fallback: false);
+ return true;
}
}
}
diff --git a/Content.Server/GameObjects/Components/Items/ServerHandsComponent.cs b/Content.Server/GameObjects/Components/Items/ServerHandsComponent.cs
index 2e2595b48b..29c8cd07e6 100644
--- a/Content.Server/GameObjects/Components/Items/ServerHandsComponent.cs
+++ b/Content.Server/GameObjects/Components/Items/ServerHandsComponent.cs
@@ -2,13 +2,11 @@
using Content.Shared.GameObjects;
using SS14.Server.GameObjects.Events;
using SS14.Server.Interfaces.GameObjects;
-using SS14.Shared;
using SS14.Shared.GameObjects;
using SS14.Shared.Utility;
using System;
using System.Collections.Generic;
using YamlDotNet.RepresentationModel;
-using Lidgren.Network;
using SS14.Shared.Enums;
namespace Content.Server.GameObjects
diff --git a/Content.Server/GameObjects/EntitySystems/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/InteractionSystem.cs
new file mode 100644
index 0000000000..bf78a116ee
--- /dev/null
+++ b/Content.Server/GameObjects/EntitySystems/InteractionSystem.cs
@@ -0,0 +1,149 @@
+using Content.Server.Interfaces.GameObjects;
+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;
+
+namespace Content.Server.GameObjects.EntitySystems
+{
+ ///
+ /// This interface gives components behavior when being clicked on or "attacked" by a user with an object in their hand
+ ///
+ public interface IAttackby
+ {
+ bool Attackby(IEntity user, IEntity attackwith);
+ }
+
+ ///
+ /// This interface gives components behavior when being clicked on or "attacked" by a user with an empty hand
+ ///
+ public interface IAttackHand
+ {
+ bool Attackhand(IEntity user);
+ }
+
+ public interface IUse
+ {
+ bool UseEntity(IEntity user);
+ }
+
+ ///
+ /// Governs interactions during clicking on entities
+ ///
+ public class InteractionSystem : EntitySystem
+ {
+ private const float INTERACTION_RANGE = 2;
+ private const float INTERACTION_RANGE_SQUARED = INTERACTION_RANGE * INTERACTION_RANGE;
+
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ SubscribeEvent(UserInteraction, this);
+ }
+
+ public void UserInteraction(object sender, EntityEventArgs arg)
+ {
+ ClickedOnEntityEventArgs e = (ClickedOnEntityEventArgs)arg;
+ if (e.MouseButton != Clicktype.Left)
+ return;
+
+ IEntity user = EntityManager.GetEntity(e.Clicker);
+ IEntity attacked = EntityManager.GetEntity(e.Clicked);
+
+ if (!user.TryGetComponent(out var userTransform))
+ {
+ return;
+ }
+
+ var distance = (userTransform.WorldPosition - attacked.GetComponent().WorldPosition).LengthSquared;
+ if (distance > INTERACTION_RANGE_SQUARED)
+ {
+ return;
+ }
+
+ if (!user.TryGetComponent(out var hands))
+ {
+ return;
+ }
+
+ var item = hands.GetHand(hands.ActiveIndex)?.Owner;
+
+ if (item != null && attacked != item)
+ {
+ Interaction(user, item, attacked);
+ }
+ else if(attacked == item)
+ {
+ UseInteraction(user, item);
+ }
+ else
+ {
+ Interaction(user, attacked);
+ }
+ }
+
+ ///
+ /// Uses a weapon/object on an entity
+ ///
+ ///
+ ///
+ ///
+ public static void Interaction(IEntity user, IEntity weapon, IEntity attacked)
+ {
+ List interactables = attacked.GetComponents().ToList();
+
+ for(var i = 0; i < interactables.Count; i++)
+ {
+ if (interactables[i].Attackby(user, weapon)) //If an attackby returns a status completion we finish our attack
+ {
+ return;
+ }
+ }
+
+ //Else check damage component to see if we damage if not attackby, and if so can we attack object
+ }
+
+ ///
+ /// Uses an empty hand on an entity
+ ///
+ ///
+ ///
+ public static void Interaction(IEntity user, IEntity attacked)
+ {
+ List interactables = attacked.GetComponents().ToList();
+
+ for (var i = 0; i < interactables.Count; i++)
+ {
+ if (interactables[i].Attackhand(user)) //If an attackby returns a status completion we finish our attack
+ {
+ return;
+ }
+ }
+
+ //Else check damage component to see if we damage if not attackby, and if so can we attack object
+ }
+
+ ///
+ /// Activates/Uses an object in control/possession of a user
+ ///
+ ///
+ ///
+ public static void UseInteraction(IEntity user, IEntity used)
+ {
+ List usables = used.GetComponents().ToList();
+
+ for (var i = 0; i < usables.Count; i++)
+ {
+ if (usables[i].UseEntity(user)) //If an attackby returns a status completion we finish our attack
+ {
+ return;
+ }
+ }
+ }
+ }
+}
diff --git a/Content.Server/Interfaces/GameObjects/Components/Interactable/IInteractableComponent.cs b/Content.Server/Interfaces/GameObjects/Components/Interactable/IInteractableComponent.cs
deleted file mode 100644
index 9c63dc4a0c..0000000000
--- a/Content.Server/Interfaces/GameObjects/Components/Interactable/IInteractableComponent.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using SS14.Shared.Interfaces.GameObjects;
-using System;
-
-namespace Content.Server.Interfaces.GameObjects
-{
- public interface IInteractableComponent : IComponent
- {
- ///
- /// Invoked when an entity is clicked with an empty hand.
- ///
- event EventHandler OnAttackHand;
-
- ///
- /// Invoked when an entity is clicked with an item.
- ///
- event EventHandler OnAttackBy;
- }
-
- public class AttackByEventArgs : EventArgs
- {
- public readonly IEntity Target;
- public readonly IEntity User;
- public readonly IItemComponent Item;
- public readonly string HandIndex;
-
- public AttackByEventArgs(IEntity target, IEntity user, IItemComponent item, string handIndex)
- {
- Target = target;
- User = user;
- Item = item;
- HandIndex = handIndex;
- }
- }
-
- public class AttackHandEventArgs : EventArgs
- {
- public readonly IEntity Target;
- public readonly IEntity User;
- public readonly string HandIndex;
-
- public AttackHandEventArgs(IEntity target, IEntity user, string handIndex)
- {
- Target = target;
- User = user;
- HandIndex = handIndex;
- }
- }
-}
diff --git a/Resources/Prototypes/Entities/Door.yml b/Resources/Prototypes/Entities/Door.yml
index fea4e841d6..15bc04eed8 100644
--- a/Resources/Prototypes/Entities/Door.yml
+++ b/Resources/Prototypes/Entities/Door.yml
@@ -4,7 +4,6 @@
components:
- type: Transform
- type: Clickable
- - type: Interactable
- type: Sprite
drawdepth: FloorPlaceable
sprites:
diff --git a/Resources/Prototypes/Entities/Items.yml b/Resources/Prototypes/Entities/Items.yml
index b6f8e72d5c..0472b55c71 100644
--- a/Resources/Prototypes/Entities/Items.yml
+++ b/Resources/Prototypes/Entities/Items.yml
@@ -3,7 +3,6 @@
id: BaseItem
components:
- type: Transform
- - type: Interactable
- type: Item
- type: Clickable
- type: BoundingBox
diff --git a/engine b/engine
index 0a231f0217..56508df919 160000
--- a/engine
+++ b/engine
@@ -1 +1 @@
-Subproject commit 0a231f0217a7b9f9ce7093bdd091ce3e3de1b69d
+Subproject commit 56508df91937fd456bc5411008575169d93b262b