using Content.Shared.Examine; using Content.Shared.Eye.Blinding.Components; using Content.Shared.Eye.Blinding.Systems; using Content.Shared.IdentityManagement; using Robust.Shared.Network; namespace Content.Shared.Traits.Assorted; /// /// This handles permanent blindness, both the examine and the actual effect. /// public sealed class PermanentBlindnessSystem : EntitySystem { [Dependency] private readonly INetManager _net = default!; [Dependency] private readonly BlindableSystem _blinding = default!; /// public override void Initialize() { SubscribeLocalEvent(OnMapInit); SubscribeLocalEvent(OnShutdown); SubscribeLocalEvent(OnExamined); } private void OnExamined(Entity blindness, ref ExaminedEvent args) { if (args.IsInDetailsRange && !_net.IsClient && blindness.Comp.Blindness == 0) { args.PushMarkup(Loc.GetString("permanent-blindness-trait-examined", ("target", Identity.Entity(blindness, EntityManager)))); } } private void OnShutdown(Entity blindness, ref ComponentShutdown args) { if (!TryComp(blindness.Owner, out var blindable)) return; if (blindable.MinDamage != 0) { _blinding.SetMinDamage((blindness.Owner, blindable), 0); } } private void OnMapInit(Entity blindness, ref MapInitEvent args) { if(!TryComp(blindness.Owner, out var blindable)) return; if (blindness.Comp.Blindness != 0) _blinding.SetMinDamage((blindness.Owner, blindable), blindness.Comp.Blindness); else { var maxMagnitudeInt = (int) BlurryVisionComponent.MaxMagnitude; _blinding.SetMinDamage((blindness.Owner, blindable), maxMagnitudeInt); } } }