using Content.Server.Atmos.EntitySystems; using Content.Shared.IgnitionSource; using Content.Shared.Item.ItemToggle.Components; 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); SubscribeLocalEvent(OnItemToggle); SubscribeLocalEvent(OnIgnitionEvent); } private void OnIsHot(Entity ent, ref IsHotEvent args) { args.IsHot = ent.Comp.Ignited; } private void OnItemToggle(Entity ent, ref ItemToggledEvent args) { if (TryComp(ent, out var comp)) SetIgnited((ent.Owner, comp), args.Activated); } private void OnIgnitionEvent(Entity ent, ref IgnitionEvent args) { SetIgnited((ent.Owner, ent.Comp), args.Ignite); } /// /// Simply sets the ignited field to the ignited param. /// public void SetIgnited(Entity ent, bool ignited = true) { if (!Resolve(ent, ref ent.Comp, false)) 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); } } } }