2021-08-18 23:17:47 +02:00
|
|
|
using Content.Server.Light.Components;
|
2022-06-09 14:39:29 +12:00
|
|
|
using Content.Server.Storage.EntitySystems;
|
2021-08-18 23:17:47 +02:00
|
|
|
using Content.Shared.Interaction;
|
|
|
|
|
using Content.Shared.Smoking;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Light.EntitySystems
|
|
|
|
|
{
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class MatchboxSystem : EntitySystem
|
2021-08-18 23:17:47 +02:00
|
|
|
{
|
2022-06-09 14:39:29 +12:00
|
|
|
[Dependency] private readonly MatchstickSystem _stickSystem = default!;
|
|
|
|
|
|
2021-08-18 23:17:47 +02:00
|
|
|
public override void Initialize()
|
|
|
|
|
{
|
|
|
|
|
base.Initialize();
|
2022-06-09 14:39:29 +12:00
|
|
|
SubscribeLocalEvent<MatchboxComponent, InteractUsingEvent>(OnInteractUsing, before: new[] { typeof(StorageSystem) });
|
2021-08-18 23:17:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnInteractUsing(EntityUid uid, MatchboxComponent component, InteractUsingEvent args)
|
|
|
|
|
{
|
|
|
|
|
if (!args.Handled
|
2023-08-24 03:10:55 -07:00
|
|
|
&& EntityManager.TryGetComponent(args.Used, out MatchstickComponent? matchstick)
|
2021-09-26 15:19:00 +02:00
|
|
|
&& matchstick.CurrentState == SmokableState.Unlit)
|
2021-08-18 23:17:47 +02:00
|
|
|
{
|
2023-10-19 12:34:31 -07:00
|
|
|
_stickSystem.Ignite((args.Used, matchstick), args.User);
|
2021-08-18 23:17:47 +02:00
|
|
|
args.Handled = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|