As discussed on the Discord, xenos are not humans (#1840)
* As discussed on the Discord, xenos are not humans * Add living component for living beings without a defined body * Merge LivingDamageable and Damageable components * Fix ruinable and state manager inconsistencies * Fix ruinable exposedata * Fix new destructibles yamls * Fix healing not healing * Fix alive not being a valid state * Fix valid state checking
This commit is contained in:
@@ -5,7 +5,6 @@ using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Systems;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.GameObjects.Components.Damage
|
||||
{
|
||||
@@ -18,13 +17,6 @@ namespace Content.Server.GameObjects.Components.Damage
|
||||
{
|
||||
private DamageState _currentDamageState;
|
||||
|
||||
/// <summary>
|
||||
/// How much HP this component can sustain before triggering
|
||||
/// <see cref="PerformDestruction"/>.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public int MaxHp { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Sound played upon destruction.
|
||||
/// </summary>
|
||||
@@ -35,29 +27,24 @@ namespace Content.Server.GameObjects.Components.Damage
|
||||
|
||||
public override DamageState CurrentDamageState => _currentDamageState;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
HealthChangedEvent += OnHealthChanged;
|
||||
}
|
||||
|
||||
public override void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
base.ExposeData(serializer);
|
||||
|
||||
serializer.DataField(this, ruinable => ruinable.MaxHp, "maxHP", 100);
|
||||
serializer.DataReadWriteFunction(
|
||||
"deadThreshold",
|
||||
100,
|
||||
t => DeadThreshold = t ,
|
||||
() => DeadThreshold ?? -1);
|
||||
|
||||
serializer.DataField(this, ruinable => ruinable.DestroySound, "destroySound", string.Empty);
|
||||
}
|
||||
|
||||
public override void OnRemove()
|
||||
protected override void EnterState(DamageState state)
|
||||
{
|
||||
base.OnRemove();
|
||||
HealthChangedEvent -= OnHealthChanged;
|
||||
}
|
||||
base.EnterState(state);
|
||||
|
||||
private void OnHealthChanged(HealthChangedEventArgs e)
|
||||
{
|
||||
if (CurrentDamageState != DamageState.Dead && TotalDamage >= MaxHp)
|
||||
if (state == DamageState.Dead)
|
||||
{
|
||||
PerformDestruction();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user