2022-09-29 18:23:12 -05:00
|
|
|
|
using Content.Shared.Examine;
|
2024-01-03 04:07:02 -05:00
|
|
|
|
using Content.Shared.Eye.Blinding.Components;
|
2023-04-29 17:32:14 +12:00
|
|
|
|
using Content.Shared.Eye.Blinding.Systems;
|
2022-09-29 18:23:12 -05:00
|
|
|
|
using Content.Shared.IdentityManagement;
|
|
|
|
|
|
using Robust.Shared.Network;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Content.Shared.Traits.Assorted;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// This handles permanent blindness, both the examine and the actual effect.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public sealed class PermanentBlindnessSystem : EntitySystem
|
|
|
|
|
|
{
|
|
|
|
|
|
[Dependency] private readonly INetManager _net = default!;
|
2024-01-03 04:07:02 -05:00
|
|
|
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
2023-04-29 17:32:14 +12:00
|
|
|
|
[Dependency] private readonly BlindableSystem _blinding = default!;
|
2022-09-29 18:23:12 -05:00
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public override void Initialize()
|
|
|
|
|
|
{
|
2024-05-09 18:40:49 -07:00
|
|
|
|
SubscribeLocalEvent<PermanentBlindnessComponent, MapInitEvent>(OnMapInit);
|
2022-09-29 18:23:12 -05:00
|
|
|
|
SubscribeLocalEvent<PermanentBlindnessComponent, ComponentShutdown>(OnShutdown);
|
|
|
|
|
|
SubscribeLocalEvent<PermanentBlindnessComponent, ExaminedEvent>(OnExamined);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-03 04:07:02 -05:00
|
|
|
|
private void OnExamined(Entity<PermanentBlindnessComponent> blindness, ref ExaminedEvent args)
|
2022-09-29 18:23:12 -05:00
|
|
|
|
{
|
2024-05-09 18:40:49 -07:00
|
|
|
|
if (args.IsInDetailsRange && !_net.IsClient && blindness.Comp.Blindness == 0)
|
2022-09-29 18:23:12 -05:00
|
|
|
|
{
|
2024-01-03 04:07:02 -05:00
|
|
|
|
args.PushMarkup(Loc.GetString("permanent-blindness-trait-examined", ("target", Identity.Entity(blindness, EntityManager))));
|
2022-09-29 18:23:12 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-03 04:07:02 -05:00
|
|
|
|
private void OnShutdown(Entity<PermanentBlindnessComponent> blindness, ref ComponentShutdown args)
|
2022-09-29 18:23:12 -05:00
|
|
|
|
{
|
2024-01-03 04:07:02 -05:00
|
|
|
|
_blinding.UpdateIsBlind(blindness.Owner);
|
2022-09-29 18:23:12 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-09 18:40:49 -07:00
|
|
|
|
private void OnMapInit(Entity<PermanentBlindnessComponent> blindness, ref MapInitEvent args)
|
2022-09-29 18:23:12 -05:00
|
|
|
|
{
|
2024-01-03 04:07:02 -05:00
|
|
|
|
if (!_entityManager.TryGetComponent<BlindableComponent>(blindness, out var blindable))
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
2024-05-09 18:40:49 -07:00
|
|
|
|
if (blindness.Comp.Blindness != 0)
|
|
|
|
|
|
_blinding.SetMinDamage(new Entity<BlindableComponent?>(blindness.Owner, blindable), blindness.Comp.Blindness);
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
var maxMagnitudeInt = (int) BlurryVisionComponent.MaxMagnitude;
|
|
|
|
|
|
_blinding.SetMinDamage(new Entity<BlindableComponent?>(blindness.Owner, blindable), maxMagnitudeInt);
|
|
|
|
|
|
}
|
2022-09-29 18:23:12 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|