EnergyKatanaSystem.cs 1019 B

12345678910111213141516171819202122232425262728293031323334
  1. using Content.Shared.Inventory.Events;
  2. using Content.Shared.Ninja.Components;
  3. namespace Content.Shared.Ninja.Systems;
  4. /// <summary>
  5. /// System for katana binding and dash events. Recalling is handled by the suit.
  6. /// </summary>
  7. public sealed class EnergyKatanaSystem : EntitySystem
  8. {
  9. [Dependency] private readonly SharedSpaceNinjaSystem _ninja = default!;
  10. public override void Initialize()
  11. {
  12. base.Initialize();
  13. SubscribeLocalEvent<EnergyKatanaComponent, GotEquippedEvent>(OnEquipped);
  14. SubscribeLocalEvent<EnergyKatanaComponent, CheckDashEvent>(OnCheckDash);
  15. }
  16. /// <summary>
  17. /// When equipped by a ninja, try to bind it.
  18. /// </summary>
  19. private void OnEquipped(Entity<EnergyKatanaComponent> ent, ref GotEquippedEvent args)
  20. {
  21. _ninja.BindKatana(args.Equipee, ent);
  22. }
  23. private void OnCheckDash(Entity<EnergyKatanaComponent> ent, ref CheckDashEvent args)
  24. {
  25. if (!_ninja.IsNinja(args.User))
  26. args.Cancelled = true;
  27. }
  28. }