Files
tbd-station-14/Content.Server/Light/EntitySystems/MatchboxSystem.cs
2021-12-03 14:17:01 +01:00

29 lines
941 B
C#

using Content.Server.Light.Components;
using Content.Shared.Interaction;
using Content.Shared.Smoking;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Light.EntitySystems
{
public class MatchboxSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MatchboxComponent, InteractUsingEvent>(OnInteractUsing);
}
private void OnInteractUsing(EntityUid uid, MatchboxComponent component, InteractUsingEvent args)
{
if (!args.Handled
&& IoCManager.Resolve<IEntityManager>().TryGetComponent<MatchstickComponent?>(args.Used.Uid, out var matchstick)
&& matchstick.CurrentState == SmokableState.Unlit)
{
Get<MatchstickSystem>().Ignite(matchstick, args.User);
args.Handled = true;
}
}
}
}