* Flash component, overlay and shader Add BeginDraw method to Overlay.cs * Add flash icons, sounds * Progress * Multiple overlays without enums * This is probably the worst way to do this IDK * Remove nullable reference type * Add AttackEventArgs as parameter to OnHitEntities MeleeWeaponComponent.Attack now continues when OnHitEntities returns true (it hit something) Add OverlayType enum so client and server can agree on overlay ids Move IConfigurable to its own file Add AoE flash with shorter duration Flashing someone slows them down * Add arc to flash Set item size to something reasonable Remove chat log message when flash burns out * Remove unused interface
98 lines
4.2 KiB
C#
98 lines
4.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Content.Server.GameObjects.Components.Mobs;
|
|
using Content.Shared.GameObjects;
|
|
using Content.Shared.GameObjects.Components.Mobs;
|
|
using JetBrains.Annotations;
|
|
|
|
namespace Content.Server.GameObjects
|
|
{
|
|
[UsedImplicitly]
|
|
public class Human : DamageTemplates
|
|
{
|
|
int critvalue = 200;
|
|
int normalstates = 6;
|
|
//string startsprite = "human0";
|
|
|
|
public override List<(DamageType, int, ThresholdType)> AllowedStates => new List<(DamageType, int, ThresholdType)>()
|
|
{
|
|
(DamageType.Total, critvalue-1, ThresholdType.None),
|
|
(DamageType.Total, critvalue, ThresholdType.Critical),
|
|
(DamageType.Total, 300, ThresholdType.Death),
|
|
};
|
|
|
|
public override List<DamageThreshold> HealthHudThresholds
|
|
{
|
|
get
|
|
{
|
|
List<DamageThreshold> thresholds = new List<DamageThreshold>();
|
|
thresholds.Add(new DamageThreshold(DamageType.Total, 1, ThresholdType.HUDUpdate));
|
|
for (var i = 1; i <= normalstates; i++)
|
|
{
|
|
thresholds.Add(new DamageThreshold(DamageType.Total, i * critvalue / normalstates, ThresholdType.HUDUpdate));
|
|
}
|
|
return thresholds; //we don't need to respecify the state damage thresholds since we'll update hud on damage state changes as well
|
|
}
|
|
}
|
|
|
|
// for shared string dict, since we don't define these anywhere in content
|
|
[UsedImplicitly]
|
|
public static readonly string[] _humanStatusImages =
|
|
{
|
|
"/Textures/Mob/UI/Human/human0.png",
|
|
"/Textures/Mob/UI/Human/human1.png",
|
|
"/Textures/Mob/UI/Human/human2.png",
|
|
"/Textures/Mob/UI/Human/human3.png",
|
|
"/Textures/Mob/UI/Human/human4.png",
|
|
"/Textures/Mob/UI/Human/human5.png",
|
|
"/Textures/Mob/UI/Human/human6-0.png",
|
|
"/Textures/Mob/UI/Human/human6-1.png",
|
|
"/Textures/Mob/UI/Human/humancrit-0.png",
|
|
"/Textures/Mob/UI/Human/humancrit-1.png",
|
|
"/Textures/Mob/UI/Human/humandead.png",
|
|
};
|
|
|
|
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:
|
|
var totaldamage = damage.CurrentDamage[DamageType.Total];
|
|
if (totaldamage > critvalue)
|
|
{
|
|
throw new 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
|
|
statusEffectsComponent?.ChangeStatusEffectIcon(StatusEffect.Health,
|
|
"/Textures/Mob/UI/Human/human" + modifier + ".png");
|
|
|
|
overlayComponent?.RemoveOverlay(OverlayType.GradientCircleMaskOverlay);
|
|
overlayComponent?.RemoveOverlay(OverlayType.CircleMaskOverlay);
|
|
|
|
return;
|
|
case ThresholdType.Critical:
|
|
statusEffectsComponent?.ChangeStatusEffectIcon(
|
|
StatusEffect.Health,
|
|
"/Textures/Mob/UI/Human/humancrit-0.png");
|
|
overlayComponent?.ClearOverlays();
|
|
overlayComponent?.AddOverlay(OverlayType.GradientCircleMaskOverlay);
|
|
|
|
return;
|
|
case ThresholdType.Death:
|
|
statusEffectsComponent?.ChangeStatusEffectIcon(
|
|
StatusEffect.Health,
|
|
"/Textures/Mob/UI/Human/humandead.png");
|
|
overlayComponent?.ClearOverlays();
|
|
overlayComponent?.AddOverlay(OverlayType.CircleMaskOverlay);
|
|
|
|
return;
|
|
default:
|
|
throw new InvalidOperationException();
|
|
}
|
|
}
|
|
}
|
|
}
|