]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
add igniter (#20962)
authordeltanedas <39013340+deltanedas@users.noreply.github.com>
Sat, 14 Oct 2023 07:11:50 +0000 (08:11 +0100)
committerGitHub <noreply@github.com>
Sat, 14 Oct 2023 07:11:50 +0000 (00:11 -0700)
Co-authored-by: deltanedas <@deltanedas:kde.org>
12 files changed:
Content.Server/IgnitionSource/IgniteOnTriggerComponent.cs [new file with mode: 0644]
Content.Server/IgnitionSource/IgniteOnTriggerSystem.cs [new file with mode: 0644]
Content.Server/IgnitionSource/IgnitionSourceSystem.cs
Resources/Prototypes/Catalog/VendingMachines/Inventories/robotics.yml
Resources/Prototypes/Catalog/VendingMachines/Inventories/vendomat.yml
Resources/Prototypes/Entities/Objects/Devices/Electronics/igniter.yml [new file with mode: 0644]
Resources/Prototypes/Entities/Structures/Machines/lathe.yml
Resources/Prototypes/Recipes/Lathes/devices.yml
Resources/Prototypes/Research/arsenal.yml
Resources/Prototypes/tags.yml
Resources/Textures/Objects/Devices/igniter.rsi/icon.png [new file with mode: 0644]
Resources/Textures/Objects/Devices/igniter.rsi/meta.json [new file with mode: 0644]

diff --git a/Content.Server/IgnitionSource/IgniteOnTriggerComponent.cs b/Content.Server/IgnitionSource/IgniteOnTriggerComponent.cs
new file mode 100644 (file)
index 0000000..2037b2e
--- /dev/null
@@ -0,0 +1,30 @@
+using Robust.Shared.Audio;
+using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
+
+namespace Content.Server.IgnitionSource;
+
+/// <summary>
+/// Ignites for a certain length of time when triggered.
+/// Requires <see cref="IgnitionSourceComponent"/> along with triggering components.
+/// </summary>
+[RegisterComponent, Access(typeof(IgniteOnTriggerSystem))]
+public sealed partial class IgniteOnTriggerComponent : Component
+{
+    /// <summary>
+    /// Once ignited, the time it will unignite at.
+    /// </summary>
+    [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), ViewVariables(VVAccess.ReadWrite)]
+    public TimeSpan IgnitedUntil = TimeSpan.Zero;
+
+    /// <summary>
+    /// How long the ignition source is active for after triggering.
+    /// </summary>
+    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    public TimeSpan IgnitedTime = TimeSpan.FromSeconds(0.5);
+
+    /// <summary>
+    /// Sound to play when igniting.
+    /// </summary>
+    [DataField]
+    public SoundSpecifier IgniteSound = new SoundCollectionSpecifier("WelderOn");
+}
diff --git a/Content.Server/IgnitionSource/IgniteOnTriggerSystem.cs b/Content.Server/IgnitionSource/IgniteOnTriggerSystem.cs
new file mode 100644 (file)
index 0000000..1e42588
--- /dev/null
@@ -0,0 +1,55 @@
+using Content.Server.Explosion.EntitySystems;
+using Content.Shared.Timing;
+using Robust.Shared.Audio;
+using Robust.Shared.Timing;
+
+namespace Content.Server.IgnitionSource;
+
+/// <summary>
+/// Handles igniting when triggered and stopping ignition after the delay.
+/// </summary>
+public sealed class IgniteOnTriggerSystem : EntitySystem
+{
+    [Dependency] private readonly IGameTiming _timing = default!;
+    [Dependency] private readonly IgnitionSourceSystem _source = default!;
+    [Dependency] private readonly SharedAudioSystem _audio = default!;
+    [Dependency] private readonly UseDelaySystem _useDelay = default!;
+
+    public override void Initialize()
+    {
+        base.Initialize();
+
+        SubscribeLocalEvent<IgniteOnTriggerComponent, TriggerEvent>(OnTrigger);
+    }
+
+    public override void Update(float deltaTime)
+    {
+        base.Update(deltaTime);
+
+        var query = EntityQueryEnumerator<IgniteOnTriggerComponent, IgnitionSourceComponent>();
+        while (query.MoveNext(out var uid, out var comp, out var source))
+        {
+            if (!source.Ignited)
+                continue;
+
+            if (_timing.CurTime < comp.IgnitedUntil)
+                continue;
+
+            _source.SetIgnited(uid, false, source);
+        }
+    }
+
+    private void OnTrigger(EntityUid uid, IgniteOnTriggerComponent comp, TriggerEvent args)
+    {
+        // prevent spamming sound and ignition
+        TryComp<UseDelayComponent>(uid, out var delay);
+        if (_useDelay.ActiveDelay(uid, delay))
+            return;
+
+        _source.SetIgnited(uid);
+        _audio.PlayPvs(comp.IgniteSound, uid);
+
+        _useDelay.BeginDelay(uid, delay);
+        comp.IgnitedUntil = _timing.CurTime + comp.IgnitedTime;
+    }
+}
index 25a625180d0ff6de5b027b3a59c2f55ec518c489..6984dbf56bcd46f41f2731a364999457b71c820f 100644 (file)
@@ -23,12 +23,18 @@ public sealed class IgnitionSourceSystem : EntitySystem
 
     private void OnIsHot(EntityUid uid, IgnitionSourceComponent component, IsHotEvent args)
     {
-        SetIgnited(uid,component,args.IsHot);
+        SetIgnited(uid, args.IsHot, component);
     }
 
-    private void SetIgnited(EntityUid uid, IgnitionSourceComponent component, bool newState)
+    /// <summary>
+    /// Simply sets the ignited field to the ignited param.
+    /// </summary>
+    public void SetIgnited(EntityUid uid, bool ignited = true, IgnitionSourceComponent? comp = null)
     {
-        component.Ignited = newState;
+        if (!Resolve(uid, ref comp))
+            return;
+
+        comp.Ignited = ignited;
     }
 
     public override void Update(float frameTime)
index 94e46d371a43c5229e523a9cc608d115378e77f6..06a7398a23c6b51e8e20d6a6c56181393a690381 100644 (file)
@@ -5,6 +5,7 @@
     Flash: 4
     ProximitySensor: 3
     RemoteSignaller: 3
+    Igniter: 3 # its more ordnance but yeah
     HandheldHealthAnalyzer: 3
     Scalpel: 2
     SawElectric: 2
index 2ef1ad62fe65fcc0c76002c708bc7544c6f31692..da7e30fd763aafcc6ba576e16d81c87f0b67185a 100644 (file)
@@ -2,10 +2,11 @@
   id: VendomatInventory
   startingInventory:
     RemoteSignaller: 1
+    Igniter: 2
     Wirecutter: 1
     CableApcStack: 2
     FlashlightLantern: 2
     PowerCellSmallPrinted: 3
     MatterBinStockPart: 4
     CapacitorStockPart: 4
-    MicroManipulatorStockPart: 4
\ No newline at end of file
+    MicroManipulatorStockPart: 4
diff --git a/Resources/Prototypes/Entities/Objects/Devices/Electronics/igniter.yml b/Resources/Prototypes/Entities/Objects/Devices/Electronics/igniter.yml
new file mode 100644 (file)
index 0000000..24843f6
--- /dev/null
@@ -0,0 +1,25 @@
+- type: entity
+  parent: BaseItem
+  id: Igniter
+  name: igniter
+  description: Creates a spark when activated by a signal.
+  components:
+  - type: Sprite
+    sprite: Objects/Devices/igniter.rsi
+    state: icon
+  - type: IgnitionSource
+    temperature: 800
+  - type: IgniteOnTrigger
+  - type: TriggerOnSignal
+  - type: DeviceNetwork
+    deviceNetId: Wireless
+    receiveFrequencyId: BasicDevice
+  - type: WirelessNetworkConnection
+    range: 200
+  - type: DeviceLinkSink
+    ports:
+    - Trigger
+  - type: UseDelay # prevent sound spam
+  - type: Tag
+    tags:
+    - Igniter
index b1ea5f9e3d1da409827f234d32a0ccea984202f8..045ee40556fe12e315bf3f9d25cd3ce62243dee9 100644 (file)
       - Signaller
       - SignalTrigger
       - VoiceTrigger
+      - Igniter
       - PowerCellMedium
       - PowerCellHigh
       - WeaponPistolCHIMP
index ed73dc1b644c7ce52ebc3f5c7c95bcc35536a5ec..01178b386c39faabf38a61594f5fcef811982bd1 100644 (file)
     Steel: 300
     Plastic: 200
 
+- type: latheRecipe
+  id: Igniter
+  result: Igniter
+  completetime: 2
+  materials:
+    Steel: 300
+    Plastic: 100
+    Glass: 100
+
 - type: latheRecipe
   id: ChemicalPayload
   result: ChemicalPayload
index cfd0faecd3c774e05adaf31a1e18ee70c46bfdad..75107a1b5e9c7ca359a27d87b13992a8e8dd2073 100644 (file)
@@ -51,6 +51,7 @@
   - TimerTrigger
   - FlashPayload
   - ExplosivePayload
+  - Igniter
 
 - type: technology
   id: WeaponizedLaserManipulation
index ccd042dd002bf660f0287313f8a1b25be1ab7183..d7397d483c0899efb5b64f0ce40d1af5497092b6 100644 (file)
 - type: Tag
   id: Hotsauce
 
+- type: Tag
+  id: Igniter
+
 - type: Tag #Drop this innate tool instead of deleting it.
   id: InnateDontDelete
 
diff --git a/Resources/Textures/Objects/Devices/igniter.rsi/icon.png b/Resources/Textures/Objects/Devices/igniter.rsi/icon.png
new file mode 100644 (file)
index 0000000..4074df0
Binary files /dev/null and b/Resources/Textures/Objects/Devices/igniter.rsi/icon.png differ
diff --git a/Resources/Textures/Objects/Devices/igniter.rsi/meta.json b/Resources/Textures/Objects/Devices/igniter.rsi/meta.json
new file mode 100644 (file)
index 0000000..81a3a32
--- /dev/null
@@ -0,0 +1,14 @@
+{
+  "version": 1,
+  "license": "CC-BY-SA-3.0",
+  "copyright": "Taken from tgstation at https://github.com/tgstation/tgstation/blob/9a401d19045574f3ea7f2cf3feebf65989903ccc/icons/obj/assemblies/new_assemblies.dmi",
+  "size": {
+    "x": 32,
+    "y": 32
+  },
+  "states": [
+    {
+      "name": "icon"
+    }
+  ]
+}