predict IgnitionSourceComponent (#36310)

* PREDICTION

* comment

* don't overwrite event args

* totally not a web edit

* intn't
This commit is contained in:
slarticodefast
2025-04-07 02:54:47 +02:00
committed by GitHub
parent 8d8c1e4dae
commit 50bbb1c101
9 changed files with 83 additions and 64 deletions

View File

@@ -1,54 +1,11 @@
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;
/// <summary>
/// This handles ignition, Jez basically coded this.
/// </summary>
public sealed class IgnitionSourceSystem : EntitySystem
public sealed partial class IgnitionSourceSystem : SharedIgnitionSourceSystem
{
[Dependency] private readonly AtmosphereSystem _atmosphere = default!;
[Dependency] private readonly TransformSystem _transform = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<IgnitionSourceComponent, IsHotEvent>(OnIsHot);
SubscribeLocalEvent<ItemToggleHotComponent, ItemToggledEvent>(OnItemToggle);
SubscribeLocalEvent<IgnitionSourceComponent, IgnitionEvent>(OnIgnitionEvent);
}
private void OnIsHot(Entity<IgnitionSourceComponent> ent, ref IsHotEvent args)
{
args.IsHot = ent.Comp.Ignited;
}
private void OnItemToggle(Entity<ItemToggleHotComponent> ent, ref ItemToggledEvent args)
{
if (TryComp<IgnitionSourceComponent>(ent, out var comp))
SetIgnited((ent.Owner, comp), args.Activated);
}
private void OnIgnitionEvent(Entity<IgnitionSourceComponent> ent, ref IgnitionEvent args)
{
SetIgnited((ent.Owner, ent.Comp), args.Ignite);
}
/// <summary>
/// Simply sets the ignited field to the ignited param.
/// </summary>
public void SetIgnited(Entity<IgnitionSourceComponent?> ent, bool ignited = true)
{
if (!Resolve(ent, ref ent.Comp, false))
return;
ent.Comp.Ignited = ignited;
}
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Update(float frameTime)
{
@@ -63,6 +20,7 @@ public sealed class IgnitionSourceSystem : EntitySystem
if (xform.GridUid is { } gridUid)
{
var position = _transform.GetGridOrMapTilePosition(uid, xform);
// TODO: Should this be happening every single tick?
_atmosphere.HotspotExpose(gridUid, position, comp.Temperature, 50, uid, true);
}
}