mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
using SS14.Shared.GameObjects;
|
|
using SS14.Shared.GameObjects.Components.Damageable;
|
|
using SS14.Shared.IoC;
|
|
using System;
|
|
|
|
namespace SS14.Client.GameObjects
|
|
{
|
|
/// <summary>
|
|
/// Basic damageable component only tracks whether its dead or not
|
|
/// </summary>
|
|
public class DamageableComponent : ClientComponent
|
|
{
|
|
public override string Name => "Damageable";
|
|
//Used for things that are binary. Either broken or not broken. (windows?)
|
|
protected bool IsDead;
|
|
|
|
public DamageableComponent()
|
|
{
|
|
Family = ComponentFamily.Damageable;
|
|
}
|
|
|
|
public override Type StateType
|
|
{
|
|
get { return typeof(DamageableComponentState); }
|
|
}
|
|
|
|
protected virtual void Die()
|
|
{
|
|
if (IsDead) return;
|
|
|
|
IsDead = true;
|
|
Owner.SendMessage(this, ComponentMessageType.Die);
|
|
}
|
|
|
|
public override void HandleComponentState(dynamic state)
|
|
{
|
|
dynamic newIsDeadState = state.IsDead;
|
|
|
|
if (newIsDeadState && !IsDead)
|
|
{
|
|
Die();
|
|
}
|
|
}
|
|
}
|
|
}
|