Files
tbd-station-14/Content.Server/GameObjects/Components/Mobs/DamageThresholdTemplates/DamageThresholdTemplates.cs
metalgearsloth 12cf5559c2 Refactor SpeciesUI into overlay and status effects (#381)
* Refactor SpeciesUI into overlay and status effects

All components that update the UI will need to use PlayerAttached for cases where the Mind transfers I think.

* Change overlay / status effects to use states

* Change TryRemoveStatus to RemoveStatus

Doesn't return a bool so not trying.
Addressing PJB's feedback.
2019-10-30 16:37:22 +01:00

67 lines
2.4 KiB
C#

using System.Collections.Generic;
using Content.Shared.GameObjects;
using Content.Shared.GameObjects.Components.Mobs;
using Robust.Shared.Interfaces.GameObjects;
namespace Content.Server.GameObjects
{
/// <summary>
/// Defines the threshold values for each damage state for any kind of species
/// </summary>
public abstract class DamageTemplates
{
public abstract List<DamageThreshold> HealthHudThresholds { get; }
/// <summary>
/// Changes the hud state when a threshold is reached
/// </summary>
/// <param name="damage"></param>
/// <returns></returns>
public abstract void ChangeHudState(DamageableComponent damage);
//public abstract ResistanceSet resistanceset { get; }
/// <summary>
/// Shows allowed states, ordered by priority, closest to last value to have threshold reached is preferred
/// </summary>
public abstract List<(DamageType, int, ThresholdType)> AllowedStates { get; }
/// <summary>
/// Map of ALL POSSIBLE damage states to the threshold enum value that will trigger them, normal state wont be triggered by this value but is a default that is fell back onto
/// </summary>
public static Dictionary<ThresholdType, DamageState> StateThresholdMap = new Dictionary<ThresholdType, DamageState>()
{
{ ThresholdType.None, new NormalState() },
{ ThresholdType.Critical, new CriticalState() },
{ ThresholdType.Death, new DeadState() }
};
public List<DamageThreshold> DamageThresholds
{
get
{
List<DamageThreshold> thresholds = new List<DamageThreshold>();
foreach (var element in AllowedStates)
{
thresholds.Add(new DamageThreshold(element.Item1, element.Item2, element.Item3));
}
return thresholds;
}
}
public ThresholdType CalculateDamageState(DamageableComponent damage)
{
ThresholdType healthstate = ThresholdType.None;
foreach(var element in AllowedStates)
{
if(damage.CurrentDamage[element.Item1] >= element.Item2)
{
healthstate = element.Item3;
}
}
return healthstate;
}
}
}