Adds new "Short-Sighted" trait! (#26037)

* initial commit

* blindness trait now uses minDamage as suggested by deathride

* made fixes for review for shortsightedness

* review appeasal

* removed PermanentPoorVision & merged its functionality into PermanentBlindness
This commit is contained in:
Moomoobeef
2024-05-09 18:40:49 -07:00
committed by GitHub
parent 581e105aa2
commit 1699ddecf8
6 changed files with 52 additions and 25 deletions

View File

@@ -62,13 +62,31 @@ public sealed class BlindableSystem : EntitySystem
return;
blindable.Comp.EyeDamage += amount;
blindable.Comp.EyeDamage = Math.Clamp(blindable.Comp.EyeDamage, 0, BlindableComponent.MaxDamage);
Dirty(blindable);
UpdateIsBlind(blindable);
UpdateEyeDamage(blindable, true);
}
private void UpdateEyeDamage(Entity<BlindableComponent?> blindable, bool isDamageChanged)
{
if (!Resolve(blindable, ref blindable.Comp, false))
return;
var previousDamage = blindable.Comp.EyeDamage;
blindable.Comp.EyeDamage = Math.Clamp(blindable.Comp.EyeDamage, blindable.Comp.MinDamage, BlindableComponent.MaxDamage);
Dirty(blindable);
if (!isDamageChanged && previousDamage == blindable.Comp.EyeDamage)
return;
UpdateIsBlind(blindable);
var ev = new EyeDamageChangedEvent(blindable.Comp.EyeDamage);
RaiseLocalEvent(blindable.Owner, ref ev);
}
public void SetMinDamage(Entity<BlindableComponent?> blindable, int amount)
{
if (!Resolve(blindable, ref blindable.Comp, false))
return;
blindable.Comp.MinDamage = amount;
UpdateEyeDamage(blindable, false);
}
}
/// <summary>