* Fix Finish and update submodule Comments code, changes network messages FIXES THE USE INTERACTION SO YOU CAN ACTUALLY ACTIVATE THINGS NOW Need engine commits We'll figure out what to do about this shit later eh mates? Maybe have a script in the build process that automatically moves them over to godot/scenes Changes some prototypes and fixes stuff Fixes some more bugs, makes storage values show up properly Part 3 Part 2 Storage Take 1 * Doneso
57 lines
1.5 KiB
C#
57 lines
1.5 KiB
C#
using Content.Server.Interfaces.GameObjects;
|
|
using SS14.Server.Interfaces.GameObjects;
|
|
using System;
|
|
using SS14.Shared.Interfaces.GameObjects;
|
|
|
|
namespace Content.Server.GameObjects
|
|
{
|
|
public class ItemComponent : StoreableComponent, IItemComponent, EntitySystems.IAttackHand
|
|
{
|
|
public override string Name => "Item";
|
|
|
|
/// <inheritdoc />
|
|
public IInventorySlot ContainingSlot { get; private set; }
|
|
|
|
public void RemovedFromSlot()
|
|
{
|
|
if (ContainingSlot == null)
|
|
{
|
|
throw new InvalidOperationException("Item is not in a slot.");
|
|
}
|
|
|
|
ContainingSlot = null;
|
|
|
|
foreach (var component in Owner.GetComponents<ISpriteRenderableComponent>())
|
|
{
|
|
component.Visible = true;
|
|
}
|
|
}
|
|
|
|
public void EquippedToSlot(IInventorySlot slot)
|
|
{
|
|
if (ContainingSlot != null)
|
|
{
|
|
throw new InvalidOperationException("Item is already in a slot.");
|
|
}
|
|
|
|
ContainingSlot = slot;
|
|
|
|
foreach (var component in Owner.GetComponents<ISpriteRenderableComponent>())
|
|
{
|
|
component.Visible = false;
|
|
}
|
|
}
|
|
|
|
public bool Attackhand(IEntity user)
|
|
{
|
|
if (ContainingSlot != null)
|
|
{
|
|
return false;
|
|
}
|
|
var hands = user.GetComponent<IHandsComponent>();
|
|
hands.PutInHand(this, hands.ActiveIndex, fallback: false);
|
|
return true;
|
|
}
|
|
}
|
|
}
|