]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
predict IgnitionSourceComponent (#36310)
authorslarticodefast <161409025+slarticodefast@users.noreply.github.com>
Mon, 7 Apr 2025 00:54:47 +0000 (02:54 +0200)
committerGitHub <noreply@github.com>
Mon, 7 Apr 2025 00:54:47 +0000 (17:54 -0700)
* PREDICTION

* comment

* don't overwrite event args

* totally not a web edit

* intn't

Content.Client/IgnitionSource/IgnitionSourceSystem.cs [new file with mode: 0644]
Content.Server/Atmos/EntitySystems/FlammableSystem.cs
Content.Server/IgnitionSource/IgniteOnTriggerComponent.cs
Content.Server/IgnitionSource/IgniteOnTriggerSystem.cs
Content.Server/IgnitionSource/IgnitionSourceComponent.cs [deleted file]
Content.Server/IgnitionSource/IgnitionSourceSystem.cs
Content.Shared/IgnitionSource/IgnitionEvent.cs
Content.Shared/IgnitionSource/IgnitionSourceComponent.cs [new file with mode: 0644]
Content.Shared/IgnitionSource/SharedIgnitionSourceSystem.cs [new file with mode: 0644]

diff --git a/Content.Client/IgnitionSource/IgnitionSourceSystem.cs b/Content.Client/IgnitionSource/IgnitionSourceSystem.cs
new file mode 100644 (file)
index 0000000..4f1449b
--- /dev/null
@@ -0,0 +1,5 @@
+using Content.Shared.IgnitionSource;
+
+namespace Content.Client.IgnitionSource;
+
+public sealed partial class IgnitionSourceSystem : SharedIgnitionSourceSystem;
index bc96807af2db827c074c52981b2c4f7ffaf33025..412f0d476df0f9b1fc7e5431baa681e5f0b25db7 100644 (file)
@@ -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!;
index 2037b2ea492c32f5764f01b20f593e275b193694..939198c45e09b4044668d4a208766cbef4da9e53 100644 (file)
@@ -5,7 +5,7 @@ namespace Content.Server.IgnitionSource;
 
 /// <summary>
 /// 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>
 [RegisterComponent, Access(typeof(IgniteOnTriggerSystem))]
 public sealed partial class IgniteOnTriggerComponent : Component
index a1c288e2259e08c8e8ee04f42f5f90571791b10b..0e9dd56622263f6e7e4eed5bb189b8593424ea95 100644 (file)
@@ -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 (file)
index d6e0ab9..0000000
+++ /dev/null
@@ -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;
-}
index 9adbf1f6de542965e8c2615a6d6ec705c9987f51..2e3defadf4c738e7ac5ffda08c72a8e88ab80fb9 100644 (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);
             }
         }
index be168fd46fe0c212cc95d52e8d480dcbfb0f2ff4..2886e0132c15ea92b3de2fc1056a69de9736b952 100644 (file)
@@ -1,7 +1,7 @@
 namespace Content.Shared.IgnitionSource;
 
 /// <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>
 [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 (file)
index 0000000..636bfbb
--- /dev/null
@@ -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;
+}
diff --git a/Content.Shared/IgnitionSource/SharedIgnitionSourceSystem.cs b/Content.Shared/IgnitionSource/SharedIgnitionSourceSystem.cs
new file mode 100644 (file)
index 0000000..46ee449
--- /dev/null
@@ -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);
+    }
+}