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

@@ -0,0 +1,5 @@
using Content.Shared.IgnitionSource;
namespace Content.Client.IgnitionSource;
public sealed partial class IgnitionSourceSystem : SharedIgnitionSourceSystem;

View File

@@ -1,6 +1,5 @@
using Content.Server.Administration.Logs; using Content.Server.Administration.Logs;
using Content.Server.Atmos.Components; using Content.Server.Atmos.Components;
using Content.Server.IgnitionSource;
using Content.Server.Stunnable; using Content.Server.Stunnable;
using Content.Server.Temperature.Components; using Content.Server.Temperature.Components;
using Content.Server.Temperature.Systems; using Content.Server.Temperature.Systems;
@@ -11,6 +10,7 @@ using Content.Shared.Atmos;
using Content.Shared.Atmos.Components; using Content.Shared.Atmos.Components;
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.IgnitionSource;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Inventory; using Content.Shared.Inventory;
using Content.Shared.Physics; using Content.Shared.Physics;
@@ -37,7 +37,7 @@ namespace Content.Server.Atmos.EntitySystems
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!; [Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly StunSystem _stunSystem = default!; [Dependency] private readonly StunSystem _stunSystem = default!;
[Dependency] private readonly TemperatureSystem _temperatureSystem = default!; [Dependency] private readonly TemperatureSystem _temperatureSystem = default!;
[Dependency] private readonly IgnitionSourceSystem _ignitionSourceSystem = default!; [Dependency] private readonly SharedIgnitionSourceSystem _ignitionSourceSystem = default!;
[Dependency] private readonly DamageableSystem _damageableSystem = default!; [Dependency] private readonly DamageableSystem _damageableSystem = default!;
[Dependency] private readonly AlertsSystem _alertsSystem = default!; [Dependency] private readonly AlertsSystem _alertsSystem = default!;
[Dependency] private readonly FixtureSystem _fixture = default!; [Dependency] private readonly FixtureSystem _fixture = default!;

View File

@@ -5,7 +5,7 @@ namespace Content.Server.IgnitionSource;
/// <summary> /// <summary>
/// Ignites for a certain length of time when triggered. /// Ignites for a certain length of time when triggered.
/// Requires <see cref="IgnitionSourceComponent"/> along with triggering components. /// Requires <see cref="Shared.IgnitionSourceComponent"/> along with triggering components.
/// </summary> /// </summary>
[RegisterComponent, Access(typeof(IgniteOnTriggerSystem))] [RegisterComponent, Access(typeof(IgniteOnTriggerSystem))]
public sealed partial class IgniteOnTriggerComponent : Component public sealed partial class IgniteOnTriggerComponent : Component

View File

@@ -1,4 +1,5 @@
using Content.Server.Explosion.EntitySystems; using Content.Server.Explosion.EntitySystems;
using Content.Shared.IgnitionSource;
using Content.Shared.Timing; using Content.Shared.Timing;
using Robust.Shared.Audio.Systems; using Robust.Shared.Audio.Systems;
using Robust.Shared.Timing; using Robust.Shared.Timing;
@@ -11,7 +12,7 @@ namespace Content.Server.IgnitionSource;
public sealed class IgniteOnTriggerSystem : EntitySystem public sealed class IgniteOnTriggerSystem : EntitySystem
{ {
[Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IgnitionSourceSystem _source = default!; [Dependency] private readonly SharedIgnitionSourceSystem _source = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly UseDelaySystem _useDelay = default!; [Dependency] private readonly UseDelaySystem _useDelay = default!;

View File

@@ -1,14 +0,0 @@
namespace Content.Server.IgnitionSource;
/// <summary>
/// This is used for creating atmosphere hotspots while ignited to start reactions such as fire.
/// </summary>
[RegisterComponent, Access(typeof(IgnitionSourceSystem))]
public sealed partial class IgnitionSourceComponent : Component
{
[DataField, ViewVariables(VVAccess.ReadWrite)]
public bool Ignited;
[DataField, ViewVariables(VVAccess.ReadWrite)]
public int Temperature = 700;
}

View File

@@ -1,54 +1,11 @@
using Content.Server.Atmos.EntitySystems; using Content.Server.Atmos.EntitySystems;
using Content.Shared.IgnitionSource; using Content.Shared.IgnitionSource;
using Content.Shared.Item.ItemToggle.Components;
using Content.Shared.Temperature;
using Robust.Server.GameObjects;
namespace Content.Server.IgnitionSource; namespace Content.Server.IgnitionSource;
public sealed partial class IgnitionSourceSystem : SharedIgnitionSourceSystem
/// <summary>
/// This handles ignition, Jez basically coded this.
/// </summary>
public sealed class IgnitionSourceSystem : EntitySystem
{ {
[Dependency] private readonly AtmosphereSystem _atmosphere = default!; [Dependency] private readonly AtmosphereSystem _atmosphere = default!;
[Dependency] private readonly TransformSystem _transform = default!; [Dependency] private readonly SharedTransformSystem _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;
}
public override void Update(float frameTime) public override void Update(float frameTime)
{ {
@@ -63,6 +20,7 @@ public sealed class IgnitionSourceSystem : EntitySystem
if (xform.GridUid is { } gridUid) if (xform.GridUid is { } gridUid)
{ {
var position = _transform.GetGridOrMapTilePosition(uid, xform); var position = _transform.GetGridOrMapTilePosition(uid, xform);
// TODO: Should this be happening every single tick?
_atmosphere.HotspotExpose(gridUid, position, comp.Temperature, 50, uid, true); _atmosphere.HotspotExpose(gridUid, position, comp.Temperature, 50, uid, true);
} }
} }

View File

@@ -1,7 +1,7 @@
namespace Content.Shared.IgnitionSource; namespace Content.Shared.IgnitionSource;
/// <summary> /// <summary>
/// Raised in order to toggle the ignitionSourceComponent on an entity on or off /// Raised in order to toggle the <see cref="IgnitionSourceComponent"/> on an entity on or off
/// </summary> /// </summary>
[ByRefEvent] [ByRefEvent]
public readonly record struct IgnitionEvent(bool Ignite = false); public readonly record struct IgnitionEvent(bool Ignite = false);

View File

@@ -0,0 +1,22 @@
using Robust.Shared.GameStates;
namespace Content.Shared.IgnitionSource;
/// <summary>
/// This is used for creating atmosphere hotspots while ignited to start reactions such as fire.
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(SharedIgnitionSourceSystem))]
public sealed partial class IgnitionSourceComponent : Component
{
/// <summary>
/// Is this source currently ignited?
/// </summary>
[DataField, AutoNetworkedField]
public bool Ignited;
/// <summary>
/// The temperature used when creating atmos hotspots.
/// </summary>
[DataField, AutoNetworkedField]
public float Temperature = 700f;
}

View File

@@ -0,0 +1,47 @@
using Content.Shared.Item.ItemToggle.Components;
using Content.Shared.Temperature;
namespace Content.Shared.IgnitionSource;
/// <summary>
/// Ignites flammable gases when the ignition source is toggled on.
/// Also makes the entity hot so that it can be used to ignite matchsticks, cigarettes ect.
/// </summary>
public abstract partial class SharedIgnitionSourceSystem : EntitySystem
{
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)
{
SetIgnited(ent.Owner, 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;
Dirty(ent, ent.Comp);
}
}