Files
tbd-station-14/Content.Server/GameObjects/Components/Mobs/DamageThresholdTemplates/DamageThresholdTemplates.cs
clusterfack 37df61113e Species Component (#130)
* Fix this
fug
oksure
Creates the initial species component, damage states, and threshold templates and hooks them into the damageable component

* More rebase fixes

* test

* Pre future rebase

* Please

* Lol

* Lol2

* SHADERS

* Update Engine

* yml file

* Fix an initialization issue, injects dependencies

* Fix error in loading shaders

* Makes a master character ui controller component added upon client attachment to entity and remove upon client detachment from entity

* Fixes just about everytrhing

* Address PJB's comments

* geeze

* Make overlays work in worldspace instead of screen space and not cover user interfaces

* update submodule
2018-12-13 14:47:18 +01:00

66 lines
2.3 KiB
C#

using System.Collections.Generic;
using Content.Shared.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="state"></param>
/// <param name="damage"></param>
/// <returns></returns>
public abstract HudStateChange 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;
}
}
}