From 50bbb1c1016c900d2e0637177519732cc2e13f4d Mon Sep 17 00:00:00 2001 From: slarticodefast <161409025+slarticodefast@users.noreply.github.com> Date: Mon, 7 Apr 2025 02:54:47 +0200 Subject: [PATCH] predict IgnitionSourceComponent (#36310) * PREDICTION * comment * don't overwrite event args * totally not a web edit * intn't --- .../IgnitionSource/IgnitionSourceSystem.cs | 5 ++ .../Atmos/EntitySystems/FlammableSystem.cs | 4 +- .../IgniteOnTriggerComponent.cs | 2 +- .../IgnitionSource/IgniteOnTriggerSystem.cs | 3 +- .../IgnitionSource/IgnitionSourceComponent.cs | 14 ------ .../IgnitionSource/IgnitionSourceSystem.cs | 48 ++----------------- .../IgnitionSource/IgnitionEvent.cs | 2 +- .../IgnitionSource/IgnitionSourceComponent.cs | 22 +++++++++ .../SharedIgnitionSourceSystem.cs | 47 ++++++++++++++++++ 9 files changed, 83 insertions(+), 64 deletions(-) create mode 100644 Content.Client/IgnitionSource/IgnitionSourceSystem.cs delete mode 100644 Content.Server/IgnitionSource/IgnitionSourceComponent.cs create mode 100644 Content.Shared/IgnitionSource/IgnitionSourceComponent.cs create mode 100644 Content.Shared/IgnitionSource/SharedIgnitionSourceSystem.cs diff --git a/Content.Client/IgnitionSource/IgnitionSourceSystem.cs b/Content.Client/IgnitionSource/IgnitionSourceSystem.cs new file mode 100644 index 0000000000..4f1449b219 --- /dev/null +++ b/Content.Client/IgnitionSource/IgnitionSourceSystem.cs @@ -0,0 +1,5 @@ +using Content.Shared.IgnitionSource; + +namespace Content.Client.IgnitionSource; + +public sealed partial class IgnitionSourceSystem : SharedIgnitionSourceSystem; diff --git a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs index bc96807af2..412f0d476d 100644 --- a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs +++ b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs @@ -1,6 +1,5 @@ using Content.Server.Administration.Logs; using Content.Server.Atmos.Components; -using Content.Server.IgnitionSource; using Content.Server.Stunnable; using Content.Server.Temperature.Components; using Content.Server.Temperature.Systems; @@ -11,6 +10,7 @@ using Content.Shared.Atmos; using Content.Shared.Atmos.Components; using Content.Shared.Damage; using Content.Shared.Database; +using Content.Shared.IgnitionSource; using Content.Shared.Interaction; using Content.Shared.Inventory; using Content.Shared.Physics; @@ -37,7 +37,7 @@ namespace Content.Server.Atmos.EntitySystems [Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!; [Dependency] private readonly StunSystem _stunSystem = 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 AlertsSystem _alertsSystem = default!; [Dependency] private readonly FixtureSystem _fixture = default!; diff --git a/Content.Server/IgnitionSource/IgniteOnTriggerComponent.cs b/Content.Server/IgnitionSource/IgniteOnTriggerComponent.cs index 2037b2ea49..939198c45e 100644 --- a/Content.Server/IgnitionSource/IgniteOnTriggerComponent.cs +++ b/Content.Server/IgnitionSource/IgniteOnTriggerComponent.cs @@ -5,7 +5,7 @@ namespace Content.Server.IgnitionSource; /// /// Ignites for a certain length of time when triggered. -/// Requires along with triggering components. +/// Requires along with triggering components. /// [RegisterComponent, Access(typeof(IgniteOnTriggerSystem))] public sealed partial class IgniteOnTriggerComponent : Component diff --git a/Content.Server/IgnitionSource/IgniteOnTriggerSystem.cs b/Content.Server/IgnitionSource/IgniteOnTriggerSystem.cs index a1c288e225..0e9dd56622 100644 --- a/Content.Server/IgnitionSource/IgniteOnTriggerSystem.cs +++ b/Content.Server/IgnitionSource/IgniteOnTriggerSystem.cs @@ -1,4 +1,5 @@ using Content.Server.Explosion.EntitySystems; +using Content.Shared.IgnitionSource; using Content.Shared.Timing; using Robust.Shared.Audio.Systems; using Robust.Shared.Timing; @@ -11,7 +12,7 @@ namespace Content.Server.IgnitionSource; public sealed class IgniteOnTriggerSystem : EntitySystem { [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 UseDelaySystem _useDelay = default!; diff --git a/Content.Server/IgnitionSource/IgnitionSourceComponent.cs b/Content.Server/IgnitionSource/IgnitionSourceComponent.cs deleted file mode 100644 index d6e0ab9407..0000000000 --- a/Content.Server/IgnitionSource/IgnitionSourceComponent.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace Content.Server.IgnitionSource; - -/// -/// This is used for creating atmosphere hotspots while ignited to start reactions such as fire. -/// -[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; -} diff --git a/Content.Server/IgnitionSource/IgnitionSourceSystem.cs b/Content.Server/IgnitionSource/IgnitionSourceSystem.cs index 9adbf1f6de..2e3defadf4 100644 --- a/Content.Server/IgnitionSource/IgnitionSourceSystem.cs +++ b/Content.Server/IgnitionSource/IgnitionSourceSystem.cs @@ -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; - -/// -/// This handles ignition, Jez basically coded this. -/// -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(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; - } + [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); } } diff --git a/Content.Shared/IgnitionSource/IgnitionEvent.cs b/Content.Shared/IgnitionSource/IgnitionEvent.cs index be168fd46f..2886e0132c 100644 --- a/Content.Shared/IgnitionSource/IgnitionEvent.cs +++ b/Content.Shared/IgnitionSource/IgnitionEvent.cs @@ -1,7 +1,7 @@ namespace Content.Shared.IgnitionSource; /// -/// Raised in order to toggle the ignitionSourceComponent on an entity on or off +/// Raised in order to toggle the on an entity on or off /// [ByRefEvent] public readonly record struct IgnitionEvent(bool Ignite = false); diff --git a/Content.Shared/IgnitionSource/IgnitionSourceComponent.cs b/Content.Shared/IgnitionSource/IgnitionSourceComponent.cs new file mode 100644 index 0000000000..636bfbb22a --- /dev/null +++ b/Content.Shared/IgnitionSource/IgnitionSourceComponent.cs @@ -0,0 +1,22 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared.IgnitionSource; + +/// +/// This is used for creating atmosphere hotspots while ignited to start reactions such as fire. +/// +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(SharedIgnitionSourceSystem))] +public sealed partial class IgnitionSourceComponent : Component +{ + /// + /// Is this source currently ignited? + /// + [DataField, AutoNetworkedField] + public bool Ignited; + + /// + /// The temperature used when creating atmos hotspots. + /// + [DataField, AutoNetworkedField] + public float Temperature = 700f; +} diff --git a/Content.Shared/IgnitionSource/SharedIgnitionSourceSystem.cs b/Content.Shared/IgnitionSource/SharedIgnitionSourceSystem.cs new file mode 100644 index 0000000000..46ee449746 --- /dev/null +++ b/Content.Shared/IgnitionSource/SharedIgnitionSourceSystem.cs @@ -0,0 +1,47 @@ +using Content.Shared.Item.ItemToggle.Components; +using Content.Shared.Temperature; + +namespace Content.Shared.IgnitionSource; + +/// +/// 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. +/// +public abstract partial class SharedIgnitionSourceSystem : EntitySystem +{ + 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) + { + SetIgnited(ent.Owner, 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; + Dirty(ent, ent.Comp); + } +} -- 2.51.2