diff --git a/Content.Client/GameObjects/Components/Mobs/DamageStateVisualizer.cs b/Content.Client/GameObjects/Components/Mobs/DamageStateVisualizer.cs index 83a3e4f70c..725ba807bc 100644 --- a/Content.Client/GameObjects/Components/Mobs/DamageStateVisualizer.cs +++ b/Content.Client/GameObjects/Components/Mobs/DamageStateVisualizer.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using Content.Shared.GameObjects; +using Content.Shared.GameObjects.Components.Damage; using Content.Shared.GameObjects.Components.Mobs; using JetBrains.Annotations; using Robust.Client.GameObjects; @@ -12,26 +13,26 @@ namespace Content.Client.GameObjects.Components.Mobs [UsedImplicitly] public sealed class DamageStateVisualizer : AppearanceVisualizer { - private DamageStateVisualData _data = DamageStateVisualData.Normal; - private Dictionary _stateMap = new Dictionary(); - private int? _originalDrawDepth = null; + private DamageState _data = DamageState.Alive; + private readonly Dictionary _stateMap = new Dictionary(); + private int? _originalDrawDepth; public override void LoadData(YamlMappingNode node) { base.LoadData(node); if (node.TryGetNode("normal", out var normal)) { - _stateMap.Add(DamageStateVisualData.Normal, normal.AsString()); + _stateMap.Add(DamageState.Alive, normal.AsString()); } if (node.TryGetNode("crit", out var crit)) { - _stateMap.Add(DamageStateVisualData.Crit, crit.AsString()); + _stateMap.Add(DamageState.Critical, crit.AsString()); } if (node.TryGetNode("dead", out var dead)) { - _stateMap.Add(DamageStateVisualData.Dead, dead.AsString()); + _stateMap.Add(DamageState.Dead, dead.AsString()); } } @@ -39,7 +40,7 @@ namespace Content.Client.GameObjects.Components.Mobs { base.OnChangeData(component); var sprite = component.Owner.GetComponent(); - if (!component.TryGetData(DamageStateVisuals.State, out DamageStateVisualData data)) + if (!component.TryGetData(DamageStateVisuals.State, out DamageState data)) { return; } @@ -57,7 +58,7 @@ namespace Content.Client.GameObjects.Components.Mobs } // So they don't draw over mobs anymore - if (_data == DamageStateVisualData.Dead) + if (_data == DamageState.Dead) { _originalDrawDepth = sprite.DrawDepth; sprite.DrawDepth = (int) DrawDepth.FloorObjects; diff --git a/Content.Server/GameObjects/Components/Mobs/MobStateManager.cs b/Content.Server/GameObjects/Components/Mobs/MobStateManager.cs index d1e01e208c..beb3bfa2d3 100644 --- a/Content.Server/GameObjects/Components/Mobs/MobStateManager.cs +++ b/Content.Server/GameObjects/Components/Mobs/MobStateManager.cs @@ -5,6 +5,7 @@ using Content.Server.Mobs; using Content.Shared.GameObjects.Components.Damage; using Content.Shared.GameObjects.Components.Mobs; using Content.Shared.GameObjects.EntitySystems; +using Robust.Server.GameObjects; using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Components; using Robust.Shared.Interfaces.GameObjects; @@ -163,6 +164,11 @@ namespace Content.Server.GameObjects.Components.Mobs { public void EnterState(IEntity entity) { + if (entity.TryGetComponent(out AppearanceComponent appearance)) + { + appearance.SetData(DamageStateVisuals.State, DamageState.Alive); + } + UpdateState(entity); } @@ -290,6 +296,11 @@ namespace Content.Server.GameObjects.Components.Mobs { public void EnterState(IEntity entity) { + if (entity.TryGetComponent(out AppearanceComponent appearance)) + { + appearance.SetData(DamageStateVisuals.State, DamageState.Critical); + } + if (entity.TryGetComponent(out ServerStatusEffectsComponent status)) { status.ChangeStatusEffectIcon(StatusEffect.Health, @@ -391,6 +402,11 @@ namespace Content.Server.GameObjects.Components.Mobs { public void EnterState(IEntity entity) { + if (entity.TryGetComponent(out AppearanceComponent appearance)) + { + appearance.SetData(DamageStateVisuals.State, DamageState.Dead); + } + if (entity.TryGetComponent(out ServerStatusEffectsComponent status)) { status.ChangeStatusEffectIcon(StatusEffect.Health, diff --git a/Content.Shared/GameObjects/Components/Damage/DamageState.cs b/Content.Shared/GameObjects/Components/Damage/DamageState.cs index 843c97be57..7ec6a260b7 100644 --- a/Content.Shared/GameObjects/Components/Damage/DamageState.cs +++ b/Content.Shared/GameObjects/Components/Damage/DamageState.cs @@ -1,4 +1,6 @@ -using Robust.Shared.Interfaces.GameObjects; +using System; +using Robust.Shared.Interfaces.GameObjects; +using Robust.Shared.Serialization; namespace Content.Shared.GameObjects.Components.Damage { @@ -11,6 +13,7 @@ namespace Content.Shared.GameObjects.Components.Damage /// and , /// as inanimate objects don't go into crit. /// + [Serializable, NetSerializable] public enum DamageState { Alive, diff --git a/Content.Shared/GameObjects/Components/Mobs/SharedDamageState.cs b/Content.Shared/GameObjects/Components/Mobs/SharedDamageState.cs index b6cc81cef2..87f6d6469c 100644 --- a/Content.Shared/GameObjects/Components/Mobs/SharedDamageState.cs +++ b/Content.Shared/GameObjects/Components/Mobs/SharedDamageState.cs @@ -8,12 +8,4 @@ namespace Content.Shared.GameObjects.Components.Mobs { State } - - [Serializable, NetSerializable] - public enum DamageStateVisualData - { - Normal, - Crit, - Dead - } -} \ No newline at end of file +} diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml index 2e60662acc..59c5531583 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/animals.yml @@ -42,6 +42,7 @@ - type: Damageable criticalThreshold: 50 deadThreshold: 100 + - type: MobStateManager - type: HeatResistance - type: CombatMode - type: Teleportable diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/carp.yml b/Resources/Prototypes/Entities/Mobs/NPCs/carp.yml index 3ba27aad56..bf711b3462 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/carp.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/carp.yml @@ -37,6 +37,7 @@ - type: Damageable criticalThreshold: 50 deadThreshold: 100 + - type: MobStateManager - type: HeatResistance - type: CombatMode - type: Teleportable diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/pets.yml b/Resources/Prototypes/Entities/Mobs/NPCs/pets.yml index 06943ffcf5..d7520299b8 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/pets.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/pets.yml @@ -34,6 +34,7 @@ - type: Damageable criticalThreshold: 50 deadThreshold: 100 + - type: MobStateManager - type: HeatResistance - type: CombatMode - type: Teleportable diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml b/Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml index a6214337cd..e0abe4df3c 100644 --- a/Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml +++ b/Resources/Prototypes/Entities/Mobs/NPCs/xeno.yml @@ -39,6 +39,7 @@ - type: Damageable criticalThreshold: 150 deadThreshold: 200 + - type: MobStateManager - type: Metabolism - type: MobStateManager - type: HeatResistance