1
0

MatchboxSystem.cs 1.0 KB

1234567891011121314151617181920212223242526272829
  1. using Content.Server.Light.Components;
  2. using Content.Server.Storage.EntitySystems;
  3. using Content.Shared.Interaction;
  4. using Content.Shared.Smoking;
  5. namespace Content.Server.Light.EntitySystems
  6. {
  7. public sealed class MatchboxSystem : EntitySystem
  8. {
  9. [Dependency] private readonly MatchstickSystem _stickSystem = default!;
  10. public override void Initialize()
  11. {
  12. base.Initialize();
  13. SubscribeLocalEvent<MatchboxComponent, InteractUsingEvent>(OnInteractUsing, before: new[] { typeof(StorageSystem) });
  14. }
  15. private void OnInteractUsing(EntityUid uid, MatchboxComponent component, InteractUsingEvent args)
  16. {
  17. if (!args.Handled
  18. && EntityManager.TryGetComponent(args.Used, out MatchstickComponent? matchstick)
  19. && matchstick.CurrentState == SmokableState.Unlit)
  20. {
  21. _stickSystem.Ignite((args.Used, matchstick), args.User);
  22. args.Handled = true;
  23. }
  24. }
  25. }
  26. }