]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
ignition source refactor (#21044)
authordeltanedas <39013340+deltanedas@users.noreply.github.com>
Sun, 22 Oct 2023 06:05:48 +0000 (07:05 +0100)
committerGitHub <noreply@github.com>
Sun, 22 Oct 2023 06:05:48 +0000 (17:05 +1100)
Co-authored-by: deltanedas <@deltanedas:kde.org>
Content.Server/IgnitionSource/IgniteOnTriggerSystem.cs
Content.Server/IgnitionSource/IgnitionSourceComponent.cs
Content.Server/IgnitionSource/IgnitionSourceSystem.cs

index 1e4258869963b06434b7afff75fb07f2b19fef0a..256a8578642ad4f7f554549714a7254e32a5e6f1 100644 (file)
@@ -35,21 +35,21 @@ public sealed class IgniteOnTriggerSystem : EntitySystem
             if (_timing.CurTime < comp.IgnitedUntil)
                 continue;
 
-            _source.SetIgnited(uid, false, source);
+            _source.SetIgnited((uid, source), false);
         }
     }
 
-    private void OnTrigger(EntityUid uid, IgniteOnTriggerComponent comp, TriggerEvent args)
+    private void OnTrigger(Entity<IgniteOnTriggerComponent> ent, ref TriggerEvent args)
     {
         // prevent spamming sound and ignition
-        TryComp<UseDelayComponent>(uid, out var delay);
-        if (_useDelay.ActiveDelay(uid, delay))
+        TryComp<UseDelayComponent>(ent, out var delay);
+        if (_useDelay.ActiveDelay(ent, delay))
             return;
 
-        _source.SetIgnited(uid);
-        _audio.PlayPvs(comp.IgniteSound, uid);
+        _source.SetIgnited(ent.Owner);
+        _audio.PlayPvs(ent.Comp.IgniteSound, ent);
 
-        _useDelay.BeginDelay(uid, delay);
-        comp.IgnitedUntil = _timing.CurTime + comp.IgnitedTime;
+        _useDelay.BeginDelay(ent, delay);
+        ent.Comp.IgnitedUntil = _timing.CurTime + ent.Comp.IgnitedTime;
     }
 }
index d5a53c6ddb1cd4b657f04e92eeacf8249f3afedc..6b6a16000f949d05c130922e7c2d7af80091b2da 100644 (file)
@@ -1,15 +1,14 @@
 namespace Content.Server.IgnitionSource;
 
 /// <summary>
-/// This is used for...
+/// This is used for creating atmosphere hotspots while ignited to start reactions such as fire.
 /// </summary>
-[RegisterComponent]
-[Access(typeof(IgnitionSourceSystem))]
+[RegisterComponent, Access(typeof(IgnitionSourceSystem))]
 public sealed partial class IgnitionSourceComponent : Component
 {
-    [DataField("ignited")]
-    public bool Ignited = false;
+    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    public bool Ignited;
 
-    [DataField("temperature", required: true)]
+    [DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
     public int Temperature;
 }
index b70cf7a9a7c8d0d834f79b94486c632e178a3070..0a714063f413764a61802d85c6d7161345873e65 100644 (file)
@@ -7,34 +7,32 @@ 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!;
+    [Dependency] private readonly AtmosphereSystem _atmosphere = default!;
+    [Dependency] private readonly TransformSystem _transform = default!;
 
     public override void Initialize()
     {
         base.Initialize();
-        SubscribeLocalEvent<IgnitionSourceComponent,IsHotEvent>(OnIsHot);
+
+        SubscribeLocalEvent<IgnitionSourceComponent, IsHotEvent>(OnIsHot);
     }
 
-    private void OnIsHot(EntityUid uid, IgnitionSourceComponent component, IsHotEvent args)
+    private void OnIsHot(Entity<IgnitionSourceComponent> ent, ref IsHotEvent args)
     {
-        SetIgnited(uid, args.IsHot, component);
+        SetIgnited((ent.Owner, ent.Comp), args.IsHot);
     }
 
     /// <summary>
     /// Simply sets the ignited field to the ignited param.
     /// </summary>
-    public void SetIgnited(EntityUid uid, bool ignited = true, IgnitionSourceComponent? comp = null)
+    public void SetIgnited(Entity<IgnitionSourceComponent?> ent, bool ignited = true)
     {
-        if (!Resolve(uid, ref comp))
+        if (!Resolve(ent, ref ent.Comp))
             return;
 
-        comp.Ignited = ignited;
+        ent.Comp.Ignited = ignited;
     }
 
     public override void Update(float frameTime)
@@ -42,17 +40,16 @@ public sealed class IgnitionSourceSystem : EntitySystem
         base.Update(frameTime);
 
         var query = EntityQueryEnumerator<IgnitionSourceComponent, TransformComponent>();
-        while (query.MoveNext(out var source, out var component, out var transform))
+        while (query.MoveNext(out var uid, out var comp, out var xform))
         {
-            if (!component.Ignited)
+            if (!comp.Ignited)
                 continue;
 
-            if (transform.GridUid is { } gridUid)
+            if (xform.GridUid is { } gridUid)
             {
-                var position = _transformSystem.GetGridOrMapTilePosition(source, transform);
-                _atmosphereSystem.HotspotExpose(gridUid, position, component.Temperature, 50, source, true);
+                var position = _transform.GetGridOrMapTilePosition(uid, xform);
+                _atmosphere.HotspotExpose(gridUid, position, comp.Temperature, 50, uid, true);
             }
         }
-
     }
 }