using Content.Server.Atmos.EntitySystems;
using Content.Shared.Temperature;
using Robust.Server.GameObjects;
namespace Content.Server.IgnitionSource;
///
/// This handles ignition, Jez basically coded this.
///
public sealed class IgnitionSourceSystem : EntitySystem
{
[Dependency] private readonly AtmosphereSystem _atmosphere = default!;
[Dependency] private readonly TransformSystem _transform = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent(OnIsHot);
}
private void OnIsHot(Entity ent, ref IsHotEvent args)
{
SetIgnited((ent.Owner, ent.Comp), args.IsHot);
}
///
/// Simply sets the ignited field to the ignited param.
///
public void SetIgnited(Entity ent, bool ignited = true)
{
if (!Resolve(ent, ref ent.Comp))
return;
ent.Comp.Ignited = ignited;
}
public override void Update(float frameTime)
{
base.Update(frameTime);
var query = EntityQueryEnumerator();
while (query.MoveNext(out var uid, out var comp, out var xform))
{
if (!comp.Ignited)
continue;
if (xform.GridUid is { } gridUid)
{
var position = _transform.GetGridOrMapTilePosition(uid, xform);
_atmosphere.HotspotExpose(gridUid, position, comp.Temperature, 50, uid, true);
}
}
}
}