IgnitionSourceComponent added (#13555)

Co-authored-by: Jezithyr <6192499+Jezithyr@users.noreply.github.com>
Co-authored-by: Kara <lunarautomaton6@gmail.com>
This commit is contained in:
gus
2023-01-18 00:45:54 -08:00
committed by GitHub
parent df81da7041
commit 76498fcc54
7 changed files with 86 additions and 7 deletions

View File

@@ -0,0 +1,53 @@
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Temperature;
using Robust.Server.GameObjects;
namespace Content.Server.IgnitionSource;
/// <summary>
/// This handles ignition, Jez basically coded this.
/// </summary>
///
public sealed class IgnitionSourceSystem : EntitySystem
{
/// <inheritdoc/>
///
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly TransformSystem _transformSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<IgnitionSourceComponent,IsHotEvent>(OnIsHot);
}
private void OnIsHot(EntityUid uid, IgnitionSourceComponent component, IsHotEvent args)
{
Logger.Debug(args.IsHot.ToString());
SetIgnited(uid,component,args.IsHot);
}
private void SetIgnited(EntityUid uid, IgnitionSourceComponent component, bool newState)
{
component.Ignited = newState;
}
public override void Update(float frameTime)
{
base.Update(frameTime);
foreach (var (component,transform) in EntityQuery<IgnitionSourceComponent,TransformComponent>())
{
var source = component.Owner;
if (!component.Ignited)
continue;
if (transform.GridUid is { } gridUid)
{
var position = _transformSystem.GetGridOrMapTilePosition(source, transform);
_atmosphereSystem.HotspotExpose(gridUid, position, component.Temperature, 50, true);
}
}
}
}