Skip to content

Commit

Permalink
fix PermanentBlindnessComponent to be not so permanent (space-wizards…
Browse files Browse the repository at this point in the history
…#33292)

* adjust min blindness back to 0 when PermanentBlindnessComponent is removed

* mapinit changes

* remove OnRemove, move changes to OnShutdown

* goodbye event

* dependency removal

* final adjustment

---------

Co-authored-by: lunarcomets <luanrcomets2@gmail,com>
  • Loading branch information
lunarcomets and lunarcomets authored Nov 30, 2024
1 parent e9ef00f commit b45c9d5
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Content.Shared/Traits/Assorted/PermanentBlindnessSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ namespace Content.Shared.Traits.Assorted;
public sealed class PermanentBlindnessSystem : EntitySystem
{
[Dependency] private readonly INetManager _net = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly BlindableSystem _blinding = default!;

/// <inheritdoc/>
Expand All @@ -33,20 +32,26 @@ private void OnExamined(Entity<PermanentBlindnessComponent> blindness, ref Exami

private void OnShutdown(Entity<PermanentBlindnessComponent> blindness, ref ComponentShutdown args)
{
_blinding.UpdateIsBlind(blindness.Owner);
if (!TryComp<BlindableComponent>(blindness.Owner, out var blindable))
return;

if (blindable.MinDamage != 0)
{
_blinding.SetMinDamage((blindness.Owner, blindable), 0);
}
}

private void OnMapInit(Entity<PermanentBlindnessComponent> blindness, ref MapInitEvent args)
{
if (!_entityManager.TryGetComponent<BlindableComponent>(blindness, out var blindable))
if(!TryComp<BlindableComponent>(blindness.Owner, out var blindable))
return;

if (blindness.Comp.Blindness != 0)
_blinding.SetMinDamage(new Entity<BlindableComponent?>(blindness.Owner, blindable), blindness.Comp.Blindness);
_blinding.SetMinDamage((blindness.Owner, blindable), blindness.Comp.Blindness);
else
{
var maxMagnitudeInt = (int) BlurryVisionComponent.MaxMagnitude;
_blinding.SetMinDamage(new Entity<BlindableComponent?>(blindness.Owner, blindable), maxMagnitudeInt);
_blinding.SetMinDamage((blindness.Owner, blindable), maxMagnitudeInt);
}
}
}

0 comments on commit b45c9d5

Please sign in to comment.