Interaction Entity System (#26)

* Interaction Entity System

* ye

* Update submodule

* Requires engine update to function, but doesn't use shitcode

* Fix conflicts

* Fix conflicts but for real

* Update submodule
This commit is contained in:
clusterfack
2018-02-05 13:57:26 -06:00
committed by Silver
parent 1f22f8ab6a
commit 1452502fbf
12 changed files with 172 additions and 181 deletions

View File

@@ -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";
/// <inheritdoc />
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<IInteractableComponent>(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<IHandsComponent>();
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<IHandsComponent>();
hands.PutInHand(this, hands.ActiveIndex, fallback: false);
return true;
}
}
}

View File

@@ -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