Files
OldThink/Content.Server/Light/EntitySystems/MatchboxSystem.cs

30 lines
1.0 KiB
C#
Raw Normal View History

using Content.Server.Light.Components;
2022-06-09 14:39:29 +12:00
using Content.Server.Storage.EntitySystems;
using Content.Shared.Interaction;
using Content.Shared.Smoking;
namespace Content.Server.Light.EntitySystems
{
public sealed class MatchboxSystem : EntitySystem
{
2022-06-09 14:39:29 +12:00
[Dependency] private readonly MatchstickSystem _stickSystem = default!;
public override void Initialize()
{
base.Initialize();
2022-06-09 14:39:29 +12:00
SubscribeLocalEvent<MatchboxComponent, InteractUsingEvent>(OnInteractUsing, before: new[] { typeof(StorageSystem) });
}
private void OnInteractUsing(EntityUid uid, MatchboxComponent component, InteractUsingEvent args)
{
if (!args.Handled
&& EntityManager.TryGetComponent(args.Used, out MatchstickComponent? matchstick)
&& matchstick.CurrentState == SmokableState.Unlit)
{
_stickSystem.Ignite((args.Used, matchstick), args.User);
args.Handled = true;
}
}
}
}