BlindfoldSystem.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. using Content.Shared.Eye.Blinding.Components;
  2. using Content.Shared.Inventory.Events;
  3. using Content.Shared.Inventory;
  4. namespace Content.Shared.Eye.Blinding.Systems;
  5. public sealed class BlindfoldSystem : EntitySystem
  6. {
  7. [Dependency] private readonly BlindableSystem _blindableSystem = default!;
  8. public override void Initialize()
  9. {
  10. base.Initialize();
  11. SubscribeLocalEvent<BlindfoldComponent, GotEquippedEvent>(OnEquipped);
  12. SubscribeLocalEvent<BlindfoldComponent, GotUnequippedEvent>(OnUnequipped);
  13. SubscribeLocalEvent<BlindfoldComponent, InventoryRelayedEvent<CanSeeAttemptEvent>>(OnBlindfoldTrySee);
  14. }
  15. private void OnBlindfoldTrySee(Entity<BlindfoldComponent> blindfold, ref InventoryRelayedEvent<CanSeeAttemptEvent> args)
  16. {
  17. args.Args.Cancel();
  18. }
  19. private void OnEquipped(Entity<BlindfoldComponent> blindfold, ref GotEquippedEvent args)
  20. {
  21. _blindableSystem.UpdateIsBlind(args.Equipee);
  22. }
  23. private void OnUnequipped(Entity<BlindfoldComponent> blindfold, ref GotUnequippedEvent args)
  24. {
  25. _blindableSystem.UpdateIsBlind(args.Equipee);
  26. }
  27. }