Files
RobustToolbox/SS14.Server/GameObjects/Component/Equippable/EquippableComponent.cs
Pieter-Jan Briers 13ae3647be Entity prototype & YAML cleanup, prototypes unified. (#268)
* gotta go

* Work cleaning up entity prototypes.

Added handling for the data field in entity prototypes. Closes #131.
Cleaned up a bunch of the YAML handling.
Made missing components throw errors and added a (to be done) error ignore
list.

This'll allow me to unify the prototypes of client and server later.

* Unify client and server prototypes.
2017-07-11 00:44:28 +02:00

57 lines
1.6 KiB
C#

using SS14.Shared;
using SS14.Shared.GameObjects;
using SS14.Shared.GameObjects.Components.Equippable;
using SS14.Shared.Interfaces.GameObjects;
using SS14.Shared.IoC;
using SS14.Shared.Utility;
using System;
using System.Collections.Generic;
using YamlDotNet.RepresentationModel;
namespace SS14.Server.GameObjects
{
public class EquippableComponent : Component
{
public override string Name => "Equippable";
public EquipmentSlot wearloc;
public IEntity currentWearer { get; set; }
public EquippableComponent()
{
Family = ComponentFamily.Equippable;
}
public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type,
params object[] list)
{
ComponentReplyMessage reply = base.RecieveMessage(sender, type, list);
if (sender == this)
return ComponentReplyMessage.Empty;
switch (type)
{
case ComponentMessageType.GetWearLoc:
reply = new ComponentReplyMessage(ComponentMessageType.ReturnWearLoc, wearloc);
break;
}
return reply;
}
public override void LoadParameters(YamlMappingNode mapping)
{
if (mapping.TryGetNode("wearloc", out YamlNode node))
{
wearloc = node.AsEnum<EquipmentSlot>();
}
}
public override ComponentState GetComponentState()
{
return new EquippableComponentState(wearloc, currentWearer?.Uid);
}
}
}