Add IEquipped and IUnequipped interfaces (#837)

This commit is contained in:
Víctor Aguilera Puerto
2020-04-21 14:38:35 +02:00
committed by GitHub
parent d77dea6498
commit 3fc4725df7
3 changed files with 168 additions and 4 deletions

View File

@@ -110,7 +110,7 @@ namespace Content.Server.GameObjects
return false;
}
item.EquippedToSlot();
_entitySystemManager.GetEntitySystem<InteractionSystem>().EquippedInteraction(Owner, item.Owner, slot);
Dirty();
return true;
@@ -166,11 +166,12 @@ namespace Content.Server.GameObjects
return false;
}
item.RemovedFromSlot();
// TODO: The item should be dropped to the container our owner is in, if any.
var itemTransform = item.Owner.GetComponent<ITransformComponent>();
itemTransform.GridPosition = Owner.GetComponent<ITransformComponent>().GridPosition;
_entitySystemManager.GetEntitySystem<InteractionSystem>().UnequippedInteraction(Owner, item.Owner, slot);
Dirty();
return true;
}

View File

@@ -27,7 +27,7 @@ namespace Content.Server.GameObjects
{
[RegisterComponent]
[ComponentReference(typeof(StoreableComponent))]
public class ItemComponent : StoreableComponent, IAttackHand, IExAct
public class ItemComponent : StoreableComponent, IAttackHand, IExAct, IEquipped, IUnequipped
{
public override string Name => "Item";
public override uint? NetID => ContentNetIDs.ITEM;
@@ -69,6 +69,16 @@ namespace Content.Server.GameObjects
}
}
public void Equipped(EquippedEventArgs eventArgs)
{
EquippedToSlot();
}
public void Unequipped(UnequippedEventArgs eventArgs)
{
RemovedFromSlot();
}
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);