Fix xenos not changing sprites when going into crit or dying (#1854)

This commit is contained in:
DrSmugleaf
2020-08-22 15:51:35 +02:00
committed by GitHub
parent c87a8d5b51
commit 092dd7c946
8 changed files with 34 additions and 18 deletions

View File

@@ -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<DamageStateVisualData, string> _stateMap = new Dictionary<DamageStateVisualData,string>();
private int? _originalDrawDepth = null;
private DamageState _data = DamageState.Alive;
private readonly Dictionary<DamageState, string> _stateMap = new Dictionary<DamageState, string>();
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<ISpriteComponent>();
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;

View File

@@ -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,

View File

@@ -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
/// <see cref="DamageState.Alive"/> and <see cref="DamageState.Dead"/>,
/// as inanimate objects don't go into crit.
/// </summary>
[Serializable, NetSerializable]
public enum DamageState
{
Alive,

View File

@@ -8,12 +8,4 @@ namespace Content.Shared.GameObjects.Components.Mobs
{
State
}
[Serializable, NetSerializable]
public enum DamageStateVisualData
{
Normal,
Crit,
Dead
}
}
}

View File

@@ -42,6 +42,7 @@
- type: Damageable
criticalThreshold: 50
deadThreshold: 100
- type: MobStateManager
- type: HeatResistance
- type: CombatMode
- type: Teleportable

View File

@@ -37,6 +37,7 @@
- type: Damageable
criticalThreshold: 50
deadThreshold: 100
- type: MobStateManager
- type: HeatResistance
- type: CombatMode
- type: Teleportable

View File

@@ -34,6 +34,7 @@
- type: Damageable
criticalThreshold: 50
deadThreshold: 100
- type: MobStateManager
- type: HeatResistance
- type: CombatMode
- type: Teleportable

View File

@@ -39,6 +39,7 @@
- type: Damageable
criticalThreshold: 150
deadThreshold: 200
- type: MobStateManager
- type: Metabolism
- type: MobStateManager
- type: HeatResistance