Fix xenos not changing sprites when going into crit or dying (#1854)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Content.Shared.GameObjects;
|
using Content.Shared.GameObjects;
|
||||||
|
using Content.Shared.GameObjects.Components.Damage;
|
||||||
using Content.Shared.GameObjects.Components.Mobs;
|
using Content.Shared.GameObjects.Components.Mobs;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
@@ -12,26 +13,26 @@ namespace Content.Client.GameObjects.Components.Mobs
|
|||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public sealed class DamageStateVisualizer : AppearanceVisualizer
|
public sealed class DamageStateVisualizer : AppearanceVisualizer
|
||||||
{
|
{
|
||||||
private DamageStateVisualData _data = DamageStateVisualData.Normal;
|
private DamageState _data = DamageState.Alive;
|
||||||
private Dictionary<DamageStateVisualData, string> _stateMap = new Dictionary<DamageStateVisualData,string>();
|
private readonly Dictionary<DamageState, string> _stateMap = new Dictionary<DamageState, string>();
|
||||||
private int? _originalDrawDepth = null;
|
private int? _originalDrawDepth;
|
||||||
|
|
||||||
public override void LoadData(YamlMappingNode node)
|
public override void LoadData(YamlMappingNode node)
|
||||||
{
|
{
|
||||||
base.LoadData(node);
|
base.LoadData(node);
|
||||||
if (node.TryGetNode("normal", out var normal))
|
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))
|
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))
|
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);
|
base.OnChangeData(component);
|
||||||
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
||||||
if (!component.TryGetData(DamageStateVisuals.State, out DamageStateVisualData data))
|
if (!component.TryGetData(DamageStateVisuals.State, out DamageState data))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -57,7 +58,7 @@ namespace Content.Client.GameObjects.Components.Mobs
|
|||||||
}
|
}
|
||||||
|
|
||||||
// So they don't draw over mobs anymore
|
// So they don't draw over mobs anymore
|
||||||
if (_data == DamageStateVisualData.Dead)
|
if (_data == DamageState.Dead)
|
||||||
{
|
{
|
||||||
_originalDrawDepth = sprite.DrawDepth;
|
_originalDrawDepth = sprite.DrawDepth;
|
||||||
sprite.DrawDepth = (int) DrawDepth.FloorObjects;
|
sprite.DrawDepth = (int) DrawDepth.FloorObjects;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using Content.Server.Mobs;
|
|||||||
using Content.Shared.GameObjects.Components.Damage;
|
using Content.Shared.GameObjects.Components.Damage;
|
||||||
using Content.Shared.GameObjects.Components.Mobs;
|
using Content.Shared.GameObjects.Components.Mobs;
|
||||||
using Content.Shared.GameObjects.EntitySystems;
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.GameObjects.Components;
|
using Robust.Shared.GameObjects.Components;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
@@ -163,6 +164,11 @@ namespace Content.Server.GameObjects.Components.Mobs
|
|||||||
{
|
{
|
||||||
public void EnterState(IEntity entity)
|
public void EnterState(IEntity entity)
|
||||||
{
|
{
|
||||||
|
if (entity.TryGetComponent(out AppearanceComponent appearance))
|
||||||
|
{
|
||||||
|
appearance.SetData(DamageStateVisuals.State, DamageState.Alive);
|
||||||
|
}
|
||||||
|
|
||||||
UpdateState(entity);
|
UpdateState(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,6 +296,11 @@ namespace Content.Server.GameObjects.Components.Mobs
|
|||||||
{
|
{
|
||||||
public void EnterState(IEntity entity)
|
public void EnterState(IEntity entity)
|
||||||
{
|
{
|
||||||
|
if (entity.TryGetComponent(out AppearanceComponent appearance))
|
||||||
|
{
|
||||||
|
appearance.SetData(DamageStateVisuals.State, DamageState.Critical);
|
||||||
|
}
|
||||||
|
|
||||||
if (entity.TryGetComponent(out ServerStatusEffectsComponent status))
|
if (entity.TryGetComponent(out ServerStatusEffectsComponent status))
|
||||||
{
|
{
|
||||||
status.ChangeStatusEffectIcon(StatusEffect.Health,
|
status.ChangeStatusEffectIcon(StatusEffect.Health,
|
||||||
@@ -391,6 +402,11 @@ namespace Content.Server.GameObjects.Components.Mobs
|
|||||||
{
|
{
|
||||||
public void EnterState(IEntity entity)
|
public void EnterState(IEntity entity)
|
||||||
{
|
{
|
||||||
|
if (entity.TryGetComponent(out AppearanceComponent appearance))
|
||||||
|
{
|
||||||
|
appearance.SetData(DamageStateVisuals.State, DamageState.Dead);
|
||||||
|
}
|
||||||
|
|
||||||
if (entity.TryGetComponent(out ServerStatusEffectsComponent status))
|
if (entity.TryGetComponent(out ServerStatusEffectsComponent status))
|
||||||
{
|
{
|
||||||
status.ChangeStatusEffectIcon(StatusEffect.Health,
|
status.ChangeStatusEffectIcon(StatusEffect.Health,
|
||||||
|
|||||||
@@ -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
|
namespace Content.Shared.GameObjects.Components.Damage
|
||||||
{
|
{
|
||||||
@@ -11,6 +13,7 @@ namespace Content.Shared.GameObjects.Components.Damage
|
|||||||
/// <see cref="DamageState.Alive"/> and <see cref="DamageState.Dead"/>,
|
/// <see cref="DamageState.Alive"/> and <see cref="DamageState.Dead"/>,
|
||||||
/// as inanimate objects don't go into crit.
|
/// as inanimate objects don't go into crit.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Serializable, NetSerializable]
|
||||||
public enum DamageState
|
public enum DamageState
|
||||||
{
|
{
|
||||||
Alive,
|
Alive,
|
||||||
|
|||||||
@@ -8,12 +8,4 @@ namespace Content.Shared.GameObjects.Components.Mobs
|
|||||||
{
|
{
|
||||||
State
|
State
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
|
||||||
public enum DamageStateVisualData
|
|
||||||
{
|
|
||||||
Normal,
|
|
||||||
Crit,
|
|
||||||
Dead
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -42,6 +42,7 @@
|
|||||||
- type: Damageable
|
- type: Damageable
|
||||||
criticalThreshold: 50
|
criticalThreshold: 50
|
||||||
deadThreshold: 100
|
deadThreshold: 100
|
||||||
|
- type: MobStateManager
|
||||||
- type: HeatResistance
|
- type: HeatResistance
|
||||||
- type: CombatMode
|
- type: CombatMode
|
||||||
- type: Teleportable
|
- type: Teleportable
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
- type: Damageable
|
- type: Damageable
|
||||||
criticalThreshold: 50
|
criticalThreshold: 50
|
||||||
deadThreshold: 100
|
deadThreshold: 100
|
||||||
|
- type: MobStateManager
|
||||||
- type: HeatResistance
|
- type: HeatResistance
|
||||||
- type: CombatMode
|
- type: CombatMode
|
||||||
- type: Teleportable
|
- type: Teleportable
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
- type: Damageable
|
- type: Damageable
|
||||||
criticalThreshold: 50
|
criticalThreshold: 50
|
||||||
deadThreshold: 100
|
deadThreshold: 100
|
||||||
|
- type: MobStateManager
|
||||||
- type: HeatResistance
|
- type: HeatResistance
|
||||||
- type: CombatMode
|
- type: CombatMode
|
||||||
- type: Teleportable
|
- type: Teleportable
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
- type: Damageable
|
- type: Damageable
|
||||||
criticalThreshold: 150
|
criticalThreshold: 150
|
||||||
deadThreshold: 200
|
deadThreshold: 200
|
||||||
|
- type: MobStateManager
|
||||||
- type: Metabolism
|
- type: Metabolism
|
||||||
- type: MobStateManager
|
- type: MobStateManager
|
||||||
- type: HeatResistance
|
- type: HeatResistance
|
||||||
|
|||||||
Reference in New Issue
Block a user