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.
This commit is contained in:
committed by
Pieter-Jan Briers
parent
6497cdf8ff
commit
12cf5559c2
@@ -1,8 +1,13 @@
|
||||
using Content.Shared.GameObjects;
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.GameObjects.Components.Mobs;
|
||||
using Content.Shared.GameObjects.Components.Mobs;
|
||||
using JetBrains.Annotations;
|
||||
using ScreenEffects = Content.Shared.GameObjects.Components.Mobs.ScreenEffects;
|
||||
|
||||
namespace Content.Server.GameObjects
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class Human : DamageTemplates
|
||||
{
|
||||
int critvalue = 200;
|
||||
@@ -30,9 +35,11 @@ namespace Content.Server.GameObjects
|
||||
}
|
||||
}
|
||||
|
||||
public override HudStateChange ChangeHudState(DamageableComponent damage)
|
||||
public override void ChangeHudState(DamageableComponent damage)
|
||||
{
|
||||
ThresholdType healthstate = CalculateDamageState(damage);
|
||||
damage.Owner.TryGetComponent(out ServerStatusEffectsComponent statusEffectsComponent);
|
||||
damage.Owner.TryGetComponent(out ServerOverlayEffectsComponent overlayComponent);
|
||||
switch (healthstate)
|
||||
{
|
||||
case ThresholdType.None:
|
||||
@@ -42,23 +49,26 @@ namespace Content.Server.GameObjects
|
||||
throw new System.InvalidOperationException(); //these should all be below the crit value, possibly going over multiple thresholds at once?
|
||||
}
|
||||
var modifier = totaldamage / (critvalue / normalstates); //integer division floors towards zero
|
||||
return new HudStateChange()
|
||||
{
|
||||
StateSprite = "Mob/UI/Human/human" + modifier.ToString() + ".png",
|
||||
effect = ScreenEffects.None
|
||||
};
|
||||
statusEffectsComponent?.ChangeStatus(StatusEffect.Health,
|
||||
"/Textures/Mob/UI/Human/human" + modifier + ".png");
|
||||
|
||||
overlayComponent?.ChangeOverlay(ScreenEffects.None);
|
||||
|
||||
return;
|
||||
case ThresholdType.Critical:
|
||||
return new HudStateChange()
|
||||
{
|
||||
StateSprite = "Mob/UI/Human/humancrit-0.png", //TODO: display as gif or alternate with -0 and -1 as frames
|
||||
effect = ScreenEffects.GradientCircleMask
|
||||
};
|
||||
statusEffectsComponent?.ChangeStatus(
|
||||
StatusEffect.Health,
|
||||
"/Textures/Mob/UI/Human/humancrit-0.png");
|
||||
overlayComponent?.ChangeOverlay(ScreenEffects.GradientCircleMask);
|
||||
|
||||
return;
|
||||
case ThresholdType.Death:
|
||||
return new HudStateChange()
|
||||
{
|
||||
StateSprite = "Mob/UI/Human/humandead.png",
|
||||
effect = ScreenEffects.CircleMask
|
||||
};
|
||||
statusEffectsComponent?.ChangeStatus(
|
||||
StatusEffect.Health,
|
||||
"/Textures/Mob/UI/Human/humandead.png");
|
||||
overlayComponent?.ChangeOverlay(ScreenEffects.CircleMask);
|
||||
|
||||
return;
|
||||
default:
|
||||
throw new System.InvalidOperationException();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user