diff --git a/Content.Client/Entry/IgnoredComponents.cs b/Content.Client/Entry/IgnoredComponents.cs
index e067f012bd..fae7093a13 100644
--- a/Content.Client/Entry/IgnoredComponents.cs
+++ b/Content.Client/Entry/IgnoredComponents.cs
@@ -21,8 +21,9 @@ namespace Content.Client.Entry
"WarpPoint",
"EmitSoundOnUse",
"EmitSoundOnLand",
- "NameIdentifier",
+ "EmitSoundOnTrigger",
"EmitSoundOnActivate",
+ "NameIdentifier",
"HeatResistance",
"EntityStorage",
"MeleeWeapon",
@@ -101,7 +102,6 @@ namespace Content.Client.Entry
"SolarControlConsole",
"Thruster",
"FlashOnTrigger",
- "SoundOnTrigger",
"TriggerOnCollide",
"DeleteOnTrigger",
"EmptyOnMachineDeconstruct",
diff --git a/Content.Server/Chemistry/EntitySystems/SolutionContainerSystem.cs b/Content.Server/Chemistry/EntitySystems/SolutionContainerSystem.cs
index 5d90eb098d..788f7895dc 100644
--- a/Content.Server/Chemistry/EntitySystems/SolutionContainerSystem.cs
+++ b/Content.Server/Chemistry/EntitySystems/SolutionContainerSystem.cs
@@ -90,7 +90,7 @@ public sealed partial class SolutionContainerSystem : EntitySystem
("desc", Loc.GetString(proto.PhysicalDescription))));
}
- private void UpdateAppearance(EntityUid uid, Solution solution,
+ public void UpdateAppearance(EntityUid uid, Solution solution,
AppearanceComponent? appearanceComponent = null)
{
if (!EntityManager.EntityExists(uid)
@@ -116,7 +116,7 @@ public sealed partial class SolutionContainerSystem : EntitySystem
return splitSol;
}
- private void UpdateChemicals(EntityUid uid, Solution solutionHolder, bool needsReactionsProcessing = false)
+ public void UpdateChemicals(EntityUid uid, Solution solutionHolder, bool needsReactionsProcessing = false)
{
// Process reactions
if (needsReactionsProcessing && solutionHolder.CanReact)
diff --git a/Content.Server/Construction/Completions/AdminLog.cs b/Content.Server/Construction/Completions/AdminLog.cs
new file mode 100644
index 0000000000..62ec29986d
--- /dev/null
+++ b/Content.Server/Construction/Completions/AdminLog.cs
@@ -0,0 +1,32 @@
+using Content.Server.Administration.Logs;
+using Content.Shared.Construction;
+using Content.Shared.Database;
+using JetBrains.Annotations;
+
+namespace Content.Server.Construction.Completions;
+
+///
+/// Generate an admin log upon reaching this node. Useful for dangerous construction (e.g., modular grenades)
+///
+[UsedImplicitly]
+public sealed class AdminLog : IGraphAction
+{
+ [DataField("logType", required: true)]
+ public LogType LogType = LogType.Construction;
+
+ [DataField("impact")]
+ public LogImpact Impact = LogImpact.Medium;
+
+ [DataField("message", required: true)]
+ public string Message = string.Empty;
+
+ public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
+ {
+ var logSys = entityManager.EntitySysManager.GetEntitySystem();
+
+ if (userUid.HasValue)
+ logSys.Add(LogType, Impact, $"{Message} - Entity: {entityManager.ToPrettyString(uid):entity}, User: {entityManager.ToPrettyString(userUid.Value):user}");
+ else
+ logSys.Add(LogType, Impact, $"{Message} - Entity: {entityManager.ToPrettyString(uid):entity}");
+ }
+}
diff --git a/Content.Server/Construction/Completions/PlaySound.cs b/Content.Server/Construction/Completions/PlaySound.cs
index 955da59ee9..5cadaf0d88 100644
--- a/Content.Server/Construction/Completions/PlaySound.cs
+++ b/Content.Server/Construction/Completions/PlaySound.cs
@@ -1,12 +1,9 @@
-using System.Threading.Tasks;
-using Content.Shared.Audio;
using Content.Shared.Construction;
using Content.Shared.Sound;
using JetBrains.Annotations;
using Robust.Shared.Audio;
-using Robust.Shared.GameObjects;
using Robust.Shared.Player;
-using Robust.Shared.Serialization.Manager.Attributes;
+using Robust.Shared.Random;
namespace Content.Server.Construction.Completions
{
@@ -16,9 +13,17 @@ namespace Content.Server.Construction.Completions
{
[DataField("sound", required: true)] public SoundSpecifier Sound { get; private set; } = default!;
+ [DataField("AudioParams")]
+ public AudioParams AudioParams = AudioParams.Default;
+
+ [ViewVariables(VVAccess.ReadWrite)]
+ [DataField("variation")]
+ public float Variation = 0.125f;
+
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
{
- SoundSystem.Play(Filter.Pvs(uid), Sound.GetSound(), uid, AudioHelpers.WithVariation(0.125f));
+ var scale = (float) IoCManager.Resolve().NextGaussian(1, Variation);
+ SoundSystem.Play(Filter.Pvs(uid, entityManager: entityManager), Sound.GetSound(), uid, AudioParams.WithPitchScale(scale));
}
}
}
diff --git a/Content.Server/Explosion/Components/ActiveTimerTriggerComponent.cs b/Content.Server/Explosion/Components/ActiveTimerTriggerComponent.cs
new file mode 100644
index 0000000000..118a579b6d
--- /dev/null
+++ b/Content.Server/Explosion/Components/ActiveTimerTriggerComponent.cs
@@ -0,0 +1,29 @@
+using Content.Shared.Sound;
+using Robust.Shared.Audio;
+
+namespace Content.Server.Explosion.Components;
+
+///
+/// Component for tracking active trigger timers. A timers can activated by some other component, e.g. .
+///
+[RegisterComponent]
+public sealed class ActiveTimerTriggerComponent : Component
+{
+ [DataField("timeRemaining")]
+ public float TimeRemaining;
+
+ [DataField("user")]
+ public EntityUid? User;
+
+ [DataField("beepInterval")]
+ public float BeepInterval;
+
+ [DataField("timeUntilBeep")]
+ public float TimeUntilBeep;
+
+ [DataField("beepSound")]
+ public SoundSpecifier? BeepSound;
+
+ [DataField("beepParams")]
+ public AudioParams BeepParams = AudioParams.Default;
+}
diff --git a/Content.Server/Explosion/Components/OnUseTimerTriggerComponent.cs b/Content.Server/Explosion/Components/OnUseTimerTriggerComponent.cs
index fdc928e91d..a76c876421 100644
--- a/Content.Server/Explosion/Components/OnUseTimerTriggerComponent.cs
+++ b/Content.Server/Explosion/Components/OnUseTimerTriggerComponent.cs
@@ -1,11 +1,36 @@
-using Robust.Shared.GameObjects;
-using Robust.Shared.Serialization.Manager.Attributes;
+using Content.Shared.Sound;
+using Robust.Shared.Audio;
namespace Content.Server.Explosion.Components
{
[RegisterComponent]
public sealed class OnUseTimerTriggerComponent : Component
{
- [DataField("delay")] public float Delay = 0f;
+ [DataField("delay")]
+ public float Delay = 1f;
+
+ ///
+ /// If not null, a user can use verbs to configure the delay to one of these options.
+ ///
+ [DataField("delayOptions")]
+ public List? DelayOptions = null;
+
+ ///
+ /// If not null, this timer will periodically play this sound wile active.
+ ///
+ [DataField("beepSound")]
+ public SoundSpecifier? BeepSound;
+
+ ///
+ /// Time before beeping starts. Defaults to a single beep interval. If set to zero, will emit a beep immediately after use.
+ ///
+ [DataField("initialBeepDelay")]
+ public float? InitialBeepDelay;
+
+ [DataField("beepInterval")]
+ public float BeepInterval = 1;
+
+ [DataField("beepParams")]
+ public AudioParams BeepParams = AudioParams.Default.WithVolume(-2f);
}
}
diff --git a/Content.Server/Explosion/Components/SoundOnTriggerComponent.cs b/Content.Server/Explosion/Components/SoundOnTriggerComponent.cs
deleted file mode 100644
index 6d898239e1..0000000000
--- a/Content.Server/Explosion/Components/SoundOnTriggerComponent.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using Content.Server.Explosion.EntitySystems;
-using Content.Shared.Sound;
-using Robust.Shared.GameObjects;
-using Robust.Shared.Serialization.Manager.Attributes;
-using Robust.Shared.ViewVariables;
-
-namespace Content.Server.Explosion.Components
-{
- ///
- /// Whenever a is run play a sound in PVS range.
- ///
- [RegisterComponent]
- public sealed class SoundOnTriggerComponent : Component
- {
- [ViewVariables(VVAccess.ReadWrite)]
- [DataField("sound")]
- public SoundSpecifier? Sound { get; set; }
- }
-}
diff --git a/Content.Server/Explosion/EntitySystems/TriggerSystem.OnUse.cs b/Content.Server/Explosion/EntitySystems/TriggerSystem.OnUse.cs
index 3ea15d04a6..38389f856c 100644
--- a/Content.Server/Explosion/EntitySystems/TriggerSystem.OnUse.cs
+++ b/Content.Server/Explosion/EntitySystems/TriggerSystem.OnUse.cs
@@ -1,32 +1,119 @@
-using System;
using Content.Server.Explosion.Components;
+using Content.Shared.Examine;
+using Content.Shared.Popups;
using Content.Shared.Interaction.Events;
-using Content.Shared.Trigger;
-using Robust.Shared.GameObjects;
+using Content.Shared.Verbs;
+using Robust.Shared.Player;
namespace Content.Server.Explosion.EntitySystems;
public sealed partial class TriggerSystem
{
+ [Dependency] private readonly SharedPopupSystem _popupSystem = default!;
+
private void InitializeOnUse()
{
SubscribeLocalEvent(OnTimerUse);
+ SubscribeLocalEvent(OnExamined);
+ SubscribeLocalEvent>(OnGetAltVerbs);
+ }
+
+ private void OnExamined(EntityUid uid, OnUseTimerTriggerComponent component, ExaminedEvent args)
+ {
+ if (args.IsInDetailsRange)
+ args.PushText(Loc.GetString("examine-trigger-timer", ("time", component.Delay)));
+ }
+
+ ///
+ /// Add an alt-click interaction that cycles through delays.
+ ///
+ private void OnGetAltVerbs(EntityUid uid, OnUseTimerTriggerComponent component, GetVerbsEvent args)
+ {
+ if (!args.CanInteract || !args.CanAccess)
+ return;
+
+ if (component.DelayOptions == null || component.DelayOptions.Count == 1)
+ return;
+
+ args.Verbs.Add(new AlternativeVerb()
+ {
+ Category = TimerOptions,
+ Text = Loc.GetString("verb-trigger-timer-cycle"),
+ Act = () => CycleDelay(component, args.User),
+ Priority = 1
+ });
+
+ foreach (var option in component.DelayOptions)
+ {
+ if (MathHelper.CloseTo(option, component.Delay))
+ {
+ args.Verbs.Add(new AlternativeVerb()
+ {
+ Category = TimerOptions,
+ Text = Loc.GetString("verb-trigger-timer-set-current", ("time", option)),
+ Disabled = true,
+ Priority = (int) (-100 * option)
+ });
+ continue;
+ }
+
+ args.Verbs.Add(new AlternativeVerb()
+ {
+ Category = TimerOptions,
+ Text = Loc.GetString("verb-trigger-timer-set", ("time", option)),
+ Priority = (int) (-100 * option),
+
+ Act = () =>
+ {
+ component.Delay = option;
+ _popupSystem.PopupEntity(Loc.GetString("popup-trigger-timer-set", ("time", option)), args.User, Filter.Entities(args.User));
+ },
+ });
+ }
+ }
+
+ private void CycleDelay(OnUseTimerTriggerComponent component, EntityUid user)
+ {
+ if (component.DelayOptions == null || component.DelayOptions.Count == 1)
+ return;
+
+ // This is somewhat inefficient, but its good enough. This is run rarely, and the lists should be short.
+
+ component.DelayOptions.Sort();
+
+ if (component.DelayOptions[^1] <= component.Delay)
+ {
+ component.Delay = component.DelayOptions[0];
+ _popupSystem.PopupEntity(Loc.GetString("popup-trigger-timer-set", ("time", component.Delay)), user, Filter.Entities(user));
+ return;
+ }
+
+ foreach (var option in component.DelayOptions)
+ {
+ if (option > component.Delay)
+ {
+ component.Delay = option;
+ _popupSystem.PopupEntity(Loc.GetString("popup-trigger-timer-set", ("time", option)), user, Filter.Entities(user));
+ return;
+ }
+ }
}
private void OnTimerUse(EntityUid uid, OnUseTimerTriggerComponent component, UseInHandEvent args)
{
if (args.Handled) return;
- Trigger(uid, args.User, component);
+ HandleTimerTrigger(
+ uid,
+ args.User,
+ component.Delay,
+ component.BeepInterval,
+ component.InitialBeepDelay,
+ component.BeepSound,
+ component.BeepParams);
+
args.Handled = true;
}
- // TODO: Need to split this out so it's a generic "OnUseTimerTrigger" component.
- private void Trigger(EntityUid uid, EntityUid user, OnUseTimerTriggerComponent component)
- {
- if (TryComp(uid, out var appearance))
- appearance.SetData(TriggerVisuals.VisualState, TriggerVisualState.Primed);
-
- HandleTimerTrigger(TimeSpan.FromSeconds(component.Delay), uid, user);
- }
+ public static VerbCategory TimerOptions = new("verb-categories-timer", "/Textures/Interface/VerbIcons/clock.svg.192dpi.png");
}
diff --git a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs
index b6ead70656..ffa72a0039 100644
--- a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs
+++ b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs
@@ -1,27 +1,17 @@
-using System;
using Content.Server.Administration.Logs;
-using Content.Server.Doors;
using Content.Server.Doors.Components;
using Content.Server.Doors.Systems;
using Content.Server.Explosion.Components;
using Content.Server.Flash;
using Content.Server.Flash.Components;
-using Content.Shared.Audio;
-using Content.Shared.Doors;
using JetBrains.Annotations;
using Robust.Shared.Audio;
-using Robust.Shared.GameObjects;
-using Robust.Shared.IoC;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Player;
-using Robust.Shared.Timing;
-using System.Threading;
-using Content.Server.Construction.Components;
+using Content.Shared.Sound;
using Content.Shared.Trigger;
-using Timer = Robust.Shared.Timing.Timer;
-using Content.Shared.Physics;
-using System.Collections.Generic;
+using Content.Shared.Database;
namespace Content.Server.Explosion.EntitySystems
{
@@ -48,6 +38,7 @@ namespace Content.Server.Explosion.EntitySystems
[Dependency] private readonly FlashSystem _flashSystem = default!;
[Dependency] private readonly DoorSystem _sharedDoorSystem = default!;
[Dependency] private readonly SharedBroadphaseSystem _broadphase = default!;
+ [Dependency] private readonly AdminLogSystem _logSystem = default!;
public override void Initialize()
{
@@ -59,7 +50,6 @@ namespace Content.Server.Explosion.EntitySystems
SubscribeLocalEvent(OnTriggerCollide);
SubscribeLocalEvent(HandleDeleteTrigger);
- SubscribeLocalEvent(HandleSoundTrigger);
SubscribeLocalEvent(HandleExplodeTrigger);
SubscribeLocalEvent(HandleFlashTrigger);
SubscribeLocalEvent(HandleDoorTrigger);
@@ -100,12 +90,6 @@ namespace Content.Server.Explosion.EntitySystems
}
#endregion
- private void HandleSoundTrigger(EntityUid uid, SoundOnTriggerComponent component, TriggerEvent args)
- {
- if (component.Sound == null) return;
- SoundSystem.Play(Filter.Pvs(component.Owner), component.Sound.GetSound(), uid);
- }
-
private void HandleDeleteTrigger(EntityUid uid, DeleteOnTriggerComponent component, TriggerEvent args)
{
EntityManager.QueueDeleteEntity(uid);
@@ -128,19 +112,39 @@ namespace Content.Server.Explosion.EntitySystems
EntityManager.EventBus.RaiseLocalEvent(trigger, triggerEvent);
}
- public void HandleTimerTrigger(TimeSpan delay, EntityUid triggered, EntityUid? user = null)
+ public void HandleTimerTrigger(EntityUid uid, EntityUid? user, float delay , float beepInterval, float? initialBeepDelay, SoundSpecifier? beepSound, AudioParams beepParams)
{
- if (delay.TotalSeconds <= 0)
+ if (delay <= 0)
{
- Trigger(triggered, user);
+ RemComp(uid);
+ Trigger(uid, user);
return;
}
- Timer.Spawn(delay, () =>
+ if (HasComp(uid))
+ return;
+
+ if (user != null)
{
- if (Deleted(triggered)) return;
- Trigger(triggered, user);
- });
+ _logSystem.Add(LogType.Trigger,
+ $"{ToPrettyString(user.Value):user} started a {delay} second timer trigger on entity {ToPrettyString(uid):timer}");
+ }
+ else
+ {
+ _logSystem.Add(LogType.Trigger,
+ $"{delay} second timer trigger started on entity {ToPrettyString(uid):timer}");
+ }
+
+ var active = AddComp(uid);
+ active.TimeRemaining = delay;
+ active.User = user;
+ active.BeepParams = beepParams;
+ active.BeepSound = beepSound;
+ active.BeepInterval = beepInterval;
+ active.TimeUntilBeep = initialBeepDelay == null ? active.BeepInterval : initialBeepDelay.Value;
+
+ if (TryComp(uid, out var appearance))
+ appearance.SetData(TriggerVisuals.VisualState, TriggerVisualState.Primed);
}
public override void Update(float frameTime)
@@ -148,6 +152,40 @@ namespace Content.Server.Explosion.EntitySystems
base.Update(frameTime);
UpdateProximity(frameTime);
+ UpdateTimer(frameTime);
+ }
+
+ private void UpdateTimer(float frameTime)
+ {
+ HashSet toRemove = new();
+ foreach (var timer in EntityQuery())
+ {
+ timer.TimeRemaining -= frameTime;
+ timer.TimeUntilBeep -= frameTime;
+
+ if (timer.TimeRemaining <= 0)
+ {
+ Trigger(timer.Owner, timer.User);
+ toRemove.Add(timer.Owner);
+ continue;
+ }
+
+ if (timer.BeepSound == null || timer.TimeUntilBeep > 0)
+ continue;
+
+ timer.TimeUntilBeep += timer.BeepInterval;
+ var filter = Filter.Pvs(timer.Owner, entityManager: EntityManager);
+ SoundSystem.Play(filter, timer.BeepSound.GetSound(), timer.Owner, timer.BeepParams);
+ }
+
+ foreach (var uid in toRemove)
+ {
+ RemComp(uid);
+
+ // In case this is a re-usable grenade, un-prime it.
+ if (TryComp(uid, out var appearance))
+ appearance.SetData(TriggerVisuals.VisualState, TriggerVisualState.Unprimed);
+ }
}
}
}
diff --git a/Content.Server/Payload/EntitySystems/PayloadSystem.cs b/Content.Server/Payload/EntitySystems/PayloadSystem.cs
new file mode 100644
index 0000000000..ea45580868
--- /dev/null
+++ b/Content.Server/Payload/EntitySystems/PayloadSystem.cs
@@ -0,0 +1,141 @@
+using Content.Server.Administration.Logs;
+using Content.Server.Chemistry.EntitySystems;
+using Content.Server.Explosion.EntitySystems;
+using Content.Shared.Chemistry.Components;
+using Content.Shared.Chemistry.Reaction;
+using Content.Shared.Database;
+using Content.Shared.Payload.Components;
+using Content.Shared.Tag;
+using Robust.Shared.Containers;
+using Robust.Shared.Serialization.Manager;
+using Robust.Shared.Utility;
+
+namespace Content.Server.Payload.EntitySystems;
+
+public sealed class PayloadSystem : EntitySystem
+{
+ [Dependency] private readonly TagSystem _tagSystem = default!;
+ [Dependency] private readonly SolutionContainerSystem _solutionSystem = default!;
+ [Dependency] private readonly SharedChemicalReactionSystem _chemistrySystem = default!;
+ [Dependency] private readonly AdminLogSystem _logSystem = default!;
+ [Dependency] private readonly IComponentFactory _componentFactory = default!;
+ [Dependency] private readonly ISerializationManager _serializationManager = default!;
+
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ SubscribeLocalEvent(OnCaseTriggered);
+ SubscribeLocalEvent(OnTriggerTriggered);
+ SubscribeLocalEvent(OnEntityInserted);
+ SubscribeLocalEvent(OnEntityRemoved);
+ SubscribeLocalEvent(HandleChemicalPayloadTrigger);
+ }
+
+ private void OnCaseTriggered(EntityUid uid, PayloadCaseComponent component, TriggerEvent args)
+ {
+ if (!TryComp(uid, out ContainerManagerComponent? contMan))
+ return;
+
+ // Pass trigger event onto all contained payloads. Payload capacity configurable by construction graphs.
+ foreach (var container in contMan.Containers.Values)
+ {
+ foreach (var entity in container.ContainedEntities)
+ {
+ if (_tagSystem.HasTag(entity, "Payload"))
+ RaiseLocalEvent(entity, args, false);
+ }
+ }
+ }
+
+ private void OnTriggerTriggered(EntityUid uid, PayloadTriggerComponent component, TriggerEvent args)
+ {
+ if (!component.Active)
+ return;
+
+ if (Transform(uid).ParentUid is not { Valid: true } parent)
+ return;
+
+ // Ensure we don't enter a trigger-loop
+ DebugTools.Assert(!_tagSystem.HasTag(uid, "Payload"));
+
+ RaiseLocalEvent(parent, args, false);
+ }
+
+ private void OnEntityInserted(EntityUid uid, PayloadCaseComponent _, EntInsertedIntoContainerMessage args)
+ {
+ if (!TryComp(args.Entity, out PayloadTriggerComponent? trigger))
+ return;
+
+ trigger.Active = true;
+
+ if (trigger.Components == null)
+ return;
+
+ // ANY payload trigger that gets inserted can grant components. It is up to the construction graphs to determine trigger capacity.
+ foreach (var (name, data) in trigger.Components)
+ {
+ if (!_componentFactory.TryGetRegistration(name, out var registration))
+ continue;
+
+ if (HasComp(uid, registration.Type))
+ continue;
+
+ if (_componentFactory.GetComponent(registration.Type) is not Component component)
+ continue;
+
+ component.Owner = uid;
+
+ if (_serializationManager.Copy(data, component, null) is Component copied)
+ EntityManager.AddComponent(uid, copied);
+
+ trigger.GrantedComponents.Add(registration.Type);
+ }
+ }
+
+ private void OnEntityRemoved(EntityUid uid, PayloadCaseComponent component, EntRemovedFromContainerMessage args)
+ {
+ if (!TryComp(args.Entity, out PayloadTriggerComponent? trigger))
+ return;
+
+ trigger.Active = false;
+
+ foreach (var type in trigger.GrantedComponents)
+ {
+ EntityManager.RemoveComponent(uid, type);
+ }
+
+ trigger.GrantedComponents.Clear();
+ }
+
+ private void HandleChemicalPayloadTrigger(EntityUid uid, ChemicalPayloadComponent component, TriggerEvent args)
+ {
+ if (component.BeakerSlotA.Item is not EntityUid beakerA
+ || component.BeakerSlotB.Item is not EntityUid beakerB
+ || !TryComp(beakerA, out FitsInDispenserComponent? compA)
+ || !TryComp(beakerB, out FitsInDispenserComponent? compB)
+ || !_solutionSystem.TryGetSolution(beakerA, compA.Solution, out var solutionA)
+ || !_solutionSystem.TryGetSolution(beakerB, compB.Solution, out var solutionB)
+ || solutionA.TotalVolume == 0
+ || solutionB.TotalVolume == 0)
+ {
+ return;
+ }
+
+ var solStringA = SolutionContainerSystem.ToPrettyString(solutionA);
+ var solStringB = SolutionContainerSystem.ToPrettyString(solutionB);
+
+ _logSystem.Add(LogType.ChemicalReaction,
+ $"Chemical bomb payload {ToPrettyString(uid):payload} at {Transform(uid).MapPosition:location} is combining two solutions: {solStringA:solutionA} and {solStringB:solutionB}");
+
+ solutionA.MaxVolume += solutionB.MaxVolume;
+ _solutionSystem.TryAddSolution(beakerA, solutionA, solutionB);
+ solutionB.RemoveAllSolution();
+
+ // The grenade might be a dud. Redistribute solution:
+ var tmpSol = _solutionSystem.SplitSolution(beakerA, solutionA, solutionA.CurrentVolume * solutionB.MaxVolume / solutionA.MaxVolume);
+ _solutionSystem.TryAddSolution(beakerB, solutionB, tmpSol);
+ solutionA.MaxVolume -= solutionB.MaxVolume;
+ _solutionSystem.UpdateChemicals(beakerA, solutionA, false);
+ }
+}
diff --git a/Content.Server/Sound/Components/BaseEmitSoundComponent.cs b/Content.Server/Sound/Components/BaseEmitSoundComponent.cs
index ec2e85800c..bbbc6196bd 100644
--- a/Content.Server/Sound/Components/BaseEmitSoundComponent.cs
+++ b/Content.Server/Sound/Components/BaseEmitSoundComponent.cs
@@ -1,7 +1,5 @@
using Content.Shared.Sound;
-using Robust.Shared.GameObjects;
-using Robust.Shared.Serialization.Manager.Attributes;
-using Robust.Shared.ViewVariables;
+using Robust.Shared.Audio;
namespace Content.Server.Sound.Components
{
@@ -15,6 +13,9 @@ namespace Content.Server.Sound.Components
[DataField("sound", required: true)]
public SoundSpecifier Sound { get; set; } = default!;
+ [DataField("audioParams")]
+ public AudioParams AudioParams = AudioParams.Default.WithVolume(-2f);
+
[ViewVariables(VVAccess.ReadWrite)]
[DataField("variation")]
public float PitchVariation { get; set; } = 0.0f;
diff --git a/Content.Server/Sound/Components/EmitSoundOnTriggerComponent.cs b/Content.Server/Sound/Components/EmitSoundOnTriggerComponent.cs
new file mode 100644
index 0000000000..7824e51915
--- /dev/null
+++ b/Content.Server/Sound/Components/EmitSoundOnTriggerComponent.cs
@@ -0,0 +1,12 @@
+using Content.Server.Explosion.EntitySystems;
+
+namespace Content.Server.Sound.Components
+{
+ ///
+ /// Whenever a is run play a sound in PVS range.
+ ///
+ [RegisterComponent]
+ public sealed class EmitSoundOnTriggerComponent : BaseEmitSoundComponent
+ {
+ }
+}
diff --git a/Content.Server/Sound/EmitSoundSystem.cs b/Content.Server/Sound/EmitSoundSystem.cs
index 11d6f37af7..24cf39cfa8 100644
--- a/Content.Server/Sound/EmitSoundSystem.cs
+++ b/Content.Server/Sound/EmitSoundSystem.cs
@@ -1,14 +1,14 @@
+using Content.Server.Explosion.EntitySystems;
using Content.Server.Interaction.Components;
using Content.Server.Sound.Components;
using Content.Server.Throwing;
-using Content.Shared.Audio;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Throwing;
using JetBrains.Annotations;
using Robust.Shared.Audio;
-using Robust.Shared.GameObjects;
using Robust.Shared.Player;
+using Robust.Shared.Random;
namespace Content.Server.Sound
{
@@ -18,6 +18,8 @@ namespace Content.Server.Sound
[UsedImplicitly]
public sealed class EmitSoundSystem : EntitySystem
{
+ [Dependency] private readonly IRobustRandom _random = default!;
+
///
public override void Initialize()
{
@@ -26,6 +28,12 @@ namespace Content.Server.Sound
SubscribeLocalEvent(HandleEmitSoundOnUseInHand);
SubscribeLocalEvent(HandleEmitSoundOnThrown);
SubscribeLocalEvent(HandleEmitSoundOnActivateInWorld);
+ SubscribeLocalEvent(HandleEmitSoundOnTrigger);
+ }
+
+ private void HandleEmitSoundOnTrigger(EntityUid uid, EmitSoundOnTriggerComponent component, TriggerEvent args)
+ {
+ TryEmitSound(component);
}
private void HandleEmitSoundOnLand(EntityUid eUI, BaseEmitSoundComponent component, LandEvent arg)
@@ -35,9 +43,7 @@ namespace Content.Server.Sound
private void HandleEmitSoundOnUseInHand(EntityUid eUI, BaseEmitSoundComponent component, UseInHandEvent arg)
{
- if (arg.Handled) return;
-
- arg.Handled = true;
+ // Intentionally not handling interaction. This component is an easy way to add sounds in addition to other behavior.
TryEmitSound(component);
}
@@ -48,15 +54,14 @@ namespace Content.Server.Sound
private void HandleEmitSoundOnActivateInWorld(EntityUid eUI, BaseEmitSoundComponent component, ActivateInWorldEvent arg)
{
- if (arg.Handled) return;
-
- arg.Handled = true;
+ // Intentionally not handling interaction. This component is an easy way to add sounds in addition to other behavior.
TryEmitSound(component);
}
- private static void TryEmitSound(BaseEmitSoundComponent component)
+ private void TryEmitSound(BaseEmitSoundComponent component)
{
- SoundSystem.Play(Filter.Pvs(component.Owner), component.Sound.GetSound(), component.Owner, AudioHelpers.WithVariation(component.PitchVariation).WithVolume(-2f));
+ var audioParams = component.AudioParams.WithPitchScale((float) _random.NextGaussian(1, component.PitchVariation));
+ SoundSystem.Play(Filter.Pvs(component.Owner, entityManager: EntityManager), component.Sound.GetSound(), component.Owner, audioParams);
}
}
}
diff --git a/Content.Shared.Database/LogType.cs b/Content.Shared.Database/LogType.cs
index 5419d28e2a..eb8b55600a 100644
--- a/Content.Shared.Database/LogType.cs
+++ b/Content.Shared.Database/LogType.cs
@@ -65,6 +65,8 @@ public enum LogType
Chat = 61,
Action = 62,
RCD = 63,
+ Construction = 64,
+ Trigger = 65,
// haha so funny
Emag = 69,
}
diff --git a/Content.Shared/Payload/Components/ChemicalPayloadComponent.cs b/Content.Shared/Payload/Components/ChemicalPayloadComponent.cs
new file mode 100644
index 0000000000..99d0356aaa
--- /dev/null
+++ b/Content.Shared/Payload/Components/ChemicalPayloadComponent.cs
@@ -0,0 +1,33 @@
+using Content.Shared.Containers.ItemSlots;
+using Robust.Shared.Serialization;
+
+namespace Content.Shared.Payload.Components;
+
+///
+/// Chemical payload that mixes the solutions of two drain-able solution containers when triggered.
+///
+[RegisterComponent]
+public sealed class ChemicalPayloadComponent : Component
+{
+ [DataField("beakerSlotA", required: true)]
+ public ItemSlot BeakerSlotA = new();
+
+ [DataField("beakerSlotB", required: true)]
+ public ItemSlot BeakerSlotB = new();
+}
+
+[Serializable, NetSerializable]
+public enum ChemicalPayloadVisuals : byte
+{
+ Slots
+}
+
+[Flags]
+[Serializable, NetSerializable]
+public enum ChemicalPayloadFilledSlots : byte
+{
+ None = 0,
+ Left = 1 << 0,
+ Right = 1 << 1,
+ Both = Left | Right,
+}
diff --git a/Content.Shared/Payload/Components/PayloadCaseComponent.cs b/Content.Shared/Payload/Components/PayloadCaseComponent.cs
new file mode 100644
index 0000000000..a942dbb01b
--- /dev/null
+++ b/Content.Shared/Payload/Components/PayloadCaseComponent.cs
@@ -0,0 +1,12 @@
+namespace Content.Shared.Payload.Components;
+
+///
+/// Component that enables payloads and payload triggers to function.
+///
+///
+/// If an entity with a is installed into a an entity with a , the trigger will grant components to the case-entity. If the case entity is
+/// triggered, it will forward the trigger onto any contained payload entity.
+///
+[RegisterComponent]
+public sealed class PayloadCaseComponent : Component { }
diff --git a/Content.Shared/Payload/Components/PayloadTriggerComponent.cs b/Content.Shared/Payload/Components/PayloadTriggerComponent.cs
new file mode 100644
index 0000000000..c0dfb4db2a
--- /dev/null
+++ b/Content.Shared/Payload/Components/PayloadTriggerComponent.cs
@@ -0,0 +1,45 @@
+using Robust.Shared.GameStates;
+using Robust.Shared.Prototypes;
+
+namespace Content.Shared.Payload.Components;
+
+///
+/// Component for providing the means of triggering an explosive payload. Used in grenade construction.
+///
+///
+/// This component performs two functions. Firstly, it will add or remove other components to some entity when this
+/// item is installed inside of it. This is intended for use with constructible grenades. For example, this allows
+/// you to add things like , or .
+/// This is required because otherwise you would have to forward arbitrary interaction directed at the casing
+/// through to the trigger, which would be quite complicated. Also proximity triggers don't really work inside of
+/// containers.
+///
+/// Secondly, if the entity that this component is attached to is ever triggered directly (e.g., via a device
+/// network message), the trigger will be forwarded to the device that this entity is installed in (if any).
+///
+[RegisterComponent, NetworkedComponent]
+public sealed class PayloadTriggerComponent : Component
+{
+ ///
+ /// If true, triggering this entity will also cause the parent of this entity to be triggered.
+ ///
+ public bool Active = false;
+
+ ///
+ /// List of components to add or remove from an entity when this trigger is (un)installed.
+ ///
+ [DataField("components", serverOnly:true, readOnly: true)]
+ public readonly EntityPrototype.ComponentRegistry? Components = null;
+
+ ///
+ /// Keeps track of what components this trigger has granted to the payload case.
+ ///
+ ///
+ /// This is required in case someone creates a construction graph that accepts more than one trigger, and those
+ /// trigger grant the same type of component (or the case just innately has that component). This list is used
+ /// when removing the component, to ensure that removal of this trigger only removes the components that it was
+ /// responsible for adding.
+ ///
+ [DataField("grantedComponents", serverOnly: true)]
+ public readonly HashSet GrantedComponents = new();
+}
diff --git a/Content.Shared/Payload/EntitySystems/ChemicalPayloadSystem.cs b/Content.Shared/Payload/EntitySystems/ChemicalPayloadSystem.cs
new file mode 100644
index 0000000000..71670b2d04
--- /dev/null
+++ b/Content.Shared/Payload/EntitySystems/ChemicalPayloadSystem.cs
@@ -0,0 +1,53 @@
+using Content.Shared.Containers.ItemSlots;
+using Content.Shared.Payload.Components;
+using Robust.Shared.Containers;
+
+namespace Content.Shared.Payload.EntitySystems;
+
+public sealed class ChemicalPayloadSystem : EntitySystem
+{
+ [Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!;
+
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ SubscribeLocalEvent(OnComponentInit);
+ SubscribeLocalEvent(OnComponentRemove);
+ SubscribeLocalEvent(OnContainerModified);
+ SubscribeLocalEvent(OnContainerModified);
+ }
+
+ private void OnContainerModified(EntityUid uid, ChemicalPayloadComponent component, ContainerModifiedMessage args)
+ {
+ UpdateAppearance(uid, component);
+ }
+
+ private void UpdateAppearance(EntityUid uid, ChemicalPayloadComponent? component = null, AppearanceComponent? appearance = null)
+ {
+ if (!Resolve(uid, ref component, ref appearance, false))
+ return;
+
+ var filled = ChemicalPayloadFilledSlots.None;
+
+ if (component.BeakerSlotA.HasItem)
+ filled |= ChemicalPayloadFilledSlots.Left;
+
+ if (component.BeakerSlotB.HasItem)
+ filled |= ChemicalPayloadFilledSlots.Right;
+
+ appearance.SetData(ChemicalPayloadVisuals.Slots, filled);
+ }
+
+ private void OnComponentInit(EntityUid uid, ChemicalPayloadComponent payload, ComponentInit args)
+ {
+ _itemSlotsSystem.AddItemSlot(uid, "BeakerSlotA", payload.BeakerSlotA);
+ _itemSlotsSystem.AddItemSlot(uid, "BeakerSlotB", payload.BeakerSlotB);
+ }
+
+ private void OnComponentRemove(EntityUid uid, ChemicalPayloadComponent payload, ComponentRemove args)
+ {
+ _itemSlotsSystem.RemoveItemSlot(uid, payload.BeakerSlotA);
+ _itemSlotsSystem.RemoveItemSlot(uid, payload.BeakerSlotB);
+ }
+}
diff --git a/Content.Shared/Verbs/Verb.cs b/Content.Shared/Verbs/Verb.cs
index 4ad9f3e867..0c585cb079 100644
--- a/Content.Shared/Verbs/Verb.cs
+++ b/Content.Shared/Verbs/Verb.cs
@@ -190,6 +190,17 @@ namespace Content.Shared.Verbs
return string.Compare(Text, otherVerb.Text, StringComparison.CurrentCulture);
}
+ if (IconEntity != otherVerb.IconEntity)
+ {
+ if (IconEntity == null)
+ return -1;
+
+ if (otherVerb.IconEntity == null)
+ return 1;
+
+ return IconEntity.Value.CompareTo(otherVerb.IconEntity.Value);
+ }
+
// Finally, compare icon texture paths. Note that this matters for verbs that don't have any text (e.g., the rotate-verbs)
return string.Compare(IconTexture, otherVerb.IconTexture, StringComparison.CurrentCulture);
}
diff --git a/Resources/Locale/en-US/verbs/verb-system.ftl b/Resources/Locale/en-US/verbs/verb-system.ftl
index 622813050d..f988b8561b 100644
--- a/Resources/Locale/en-US/verbs/verb-system.ftl
+++ b/Resources/Locale/en-US/verbs/verb-system.ftl
@@ -20,6 +20,7 @@ verb-categories-rotate = Rotate
verb-categories-transfer = Set Transfer Amount
verb-categories-split = Split
verb-categories-set-sensor = Sensor
+verb-categories-timer = Set Delay
verb-common-toggle-light = Toggle light
verb-common-close = Close
diff --git a/Resources/Locale/en-US/weapons/grenades/timer-trigger.ftl b/Resources/Locale/en-US/weapons/grenades/timer-trigger.ftl
new file mode 100644
index 0000000000..70167b39d7
--- /dev/null
+++ b/Resources/Locale/en-US/weapons/grenades/timer-trigger.ftl
@@ -0,0 +1,8 @@
+
+verb-trigger-timer-set = {$time} Seconds
+verb-trigger-timer-set-current = {$time} Seconds (current)
+verb-trigger-timer-cycle = Cycle Time Delay
+
+examine-trigger-timer = The timer is set to {$time} seconds.
+
+popup-trigger-timer-set = Timer set to {$time} seconds.
\ No newline at end of file
diff --git a/Resources/Prototypes/Catalog/Research/technologies.yml b/Resources/Prototypes/Catalog/Research/technologies.yml
index 61813e15ac..15657e8758 100644
--- a/Resources/Prototypes/Catalog/Research/technologies.yml
+++ b/Resources/Prototypes/Catalog/Research/technologies.yml
@@ -98,6 +98,8 @@
- Syringe
- ReagentGrinderMachineCircuitboard
- PillCanister
+ - TimerTrigger
+ - ChemicalPayload
- type: technology
name: "medical machinery"
diff --git a/Resources/Prototypes/Entities/Objects/Devices/Electronics/triggers.yml b/Resources/Prototypes/Entities/Objects/Devices/Electronics/triggers.yml
new file mode 100644
index 0000000000..8189e1c1c0
--- /dev/null
+++ b/Resources/Prototypes/Entities/Objects/Devices/Electronics/triggers.yml
@@ -0,0 +1,27 @@
+# Misc electronic trigger devices.
+# TODO:
+# - proximity
+# - voice
+# - machine linking
+# - device network
+# - biometric/health (maybe just via device nets?)
+# - booby-trap / on-storage-open
+
+- type: entity
+ parent: BaseItem
+ id: TimerTrigger
+ name: timer trigger
+ description: A configurable timer.
+ components:
+ - type: Sprite
+ sprite: Objects/Devices/timer.rsi
+ state: timer
+ - type: Item
+ size: 5
+ - type: PayloadTrigger
+ components:
+ - type: OnUseTimerTrigger
+ delay: 5
+ delayOptions: [3, 5, 10, 15, 30]
+ initialBeepDelay: 0
+ beepSound: /Audio/Machines/Nuke/general_beep.ogg
diff --git a/Resources/Prototypes/Entities/Objects/Devices/payload.yml b/Resources/Prototypes/Entities/Objects/Devices/payload.yml
new file mode 100644
index 0000000000..0ab0a37a64
--- /dev/null
+++ b/Resources/Prototypes/Entities/Objects/Devices/payload.yml
@@ -0,0 +1,76 @@
+- type: entity
+ parent: BaseItem
+ abstract: true
+ id: BasePayload
+ components:
+ - type: Appearance
+ - type: Sprite
+ netsync: false
+ - type: Tag
+ tags:
+ - Payload
+ - type: Damageable
+ damageContainer: Inorganic
+ - type: Destructible
+ thresholds:
+ - trigger:
+ !type:DamageTrigger
+ damage: 50
+ behaviors:
+ - !type:DoActsBehavior
+ acts: [ "Destruction" ]
+
+- type: entity
+ name: explosive payload
+ parent: BasePayload
+ id: ExplosivePayload
+ components:
+ - type: Sprite
+ sprite: Objects/Devices/payload.rsi
+ state: payload-explosive-armed
+ - type: Explosive
+ devastationRange: 0
+ heavyImpactRange: 2
+ lightImpactRange: 4
+ flashRange: 7
+ - type: ExplodeOnTrigger
+ - type: Destructible
+ thresholds:
+ - trigger:
+ !type:DamageTypeTrigger
+ damageType: Heat
+ damage: 25
+ behaviors:
+ - !type:ExplodeBehavior
+ - trigger:
+ !type:DamageTrigger
+ damage: 50
+ behaviors:
+ - !type:DoActsBehavior
+ acts: [ "Destruction" ]
+
+- type: entity
+ name: chemical payload
+ parent: BasePayload
+ id: ChemicalPayload
+ description: A chemical payload. Has space to store two beakers. In combination with a trigger and a case, this can be used to initiate chemical reactions.
+ components:
+ - type: Sprite
+ sprite: Objects/Devices/payload.rsi
+ state: payload-empty
+ - type: ChemicalPayload
+ beakerSlotA: &slotDef
+ whitelist:
+ components:
+ - FitsInDispenser
+ swap: false
+ beakerSlotB: *slotDef
+ - type: Appearance
+ visuals:
+ - type: GenericEnumVisualizer
+ key: enum.ChemicalPayloadVisuals.Slots
+ states:
+ enum.ChemicalPayloadFilledSlots.None: payload-empty
+ enum.ChemicalPayloadFilledSlots.Left: payload-chemical-left
+ enum.ChemicalPayloadFilledSlots.Right: payload-chemical-right
+ enum.ChemicalPayloadFilledSlots.Both: payload-chemical-armed
diff --git a/Resources/Prototypes/Entities/Objects/Fun/bike_horn.yml b/Resources/Prototypes/Entities/Objects/Fun/bike_horn.yml
index 18ba3aedd8..bbbb3f775e 100644
--- a/Resources/Prototypes/Entities/Objects/Fun/bike_horn.yml
+++ b/Resources/Prototypes/Entities/Objects/Fun/bike_horn.yml
@@ -19,3 +19,9 @@
variation: 0.125
- type: UseDelay
delay: 0.5
+ - type: EmitSoundOnTrigger
+ sound:
+ collection: BikeHorn
+ - type: Tag
+ tags:
+ - Payload # yes, you can make re-usable prank grenades
diff --git a/Resources/Prototypes/Entities/Objects/Specific/chemistry.yml b/Resources/Prototypes/Entities/Objects/Specific/chemistry.yml
index 71ef40058e..25bc998c3d 100644
--- a/Resources/Prototypes/Entities/Objects/Specific/chemistry.yml
+++ b/Resources/Prototypes/Entities/Objects/Specific/chemistry.yml
@@ -1,8 +1,6 @@
- type: entity
- name: beaker
parent: BaseItem
- description: Used to contain a moderate amount of chemicals and solutions.
- id: Beaker
+ id: BaseBeaker
components:
- type: Tag
tags:
@@ -39,8 +37,6 @@
interfaces:
- key: enum.TransferAmountUiKey.Key
type: TransferAmountBoundUserInterface
- - type: Spillable
- solution: beaker
- type: Drink
isOpen: true
- type: Appearance
@@ -60,7 +56,8 @@
- !type:PlaySoundBehavior
sound:
collection: GlassBreak
- - !type:SpillBehavior { }
+ - !type:SpillBehavior
+ solution: beaker
- !type:SpawnEntitiesBehavior
spawn:
ShardGlass:
@@ -82,12 +79,23 @@
types:
Blunt: 5
+- type: entity
+ name: beaker
+ parent: BaseBeaker
+ description: Used to contain a moderate amount of chemicals and solutions.
+ id: Beaker
+ components:
+ - type: Spillable
+ solution: beaker
+
- type: entity
name: large beaker
- parent: Beaker
+ parent: BaseBeaker
description: Used to contain a large amount of chemicals or solutions.
id: LargeBeaker
components:
+ - type: Spillable
+ solution: beaker
- type: Sprite
sprite: Objects/Specific/Chemistry/beaker_large.rsi
layers:
@@ -109,7 +117,7 @@
- type: entity
name: cryostasis beaker
- parent: Beaker
+ parent: BaseBeaker
description: Used to contain chemicals or solutions without reactions.
id: CryostasisBeaker
components:
@@ -122,13 +130,28 @@
beaker:
maxVol: 40
canReact: false
-
+ - type: Damageable
+ damageContainer: Inorganic
+ damageModifierSet: FlimsyMetallic
+ - type: Destructible
+ thresholds:
+ - trigger:
+ !type:DamageTrigger
+ damage: 100
+ behaviors:
+ - !type:SpillBehavior
+ solution: beaker
+ - !type:DoActsBehavior
+ acts: [ "Destruction" ]
+
- type: entity
name: bluespace beaker
- parent: Beaker
+ parent: BaseBeaker
description: Powered by experimental bluespace technology.
id: BluespaceBeaker
components:
+ - type: Spillable
+ solution: beaker
- type: Sprite
sprite: Objects/Specific/Chemistry/beaker_bluespace.rsi
layers:
diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml
index 72258eefcf..23a624c138 100644
--- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml
+++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/projectiles.yml
@@ -64,7 +64,7 @@
path: /Audio/Weapons/Guns/Hits/snap.ogg
- type: FlashOnTrigger
range: 1
- - type: SoundOnTrigger
+ - type: EmitSoundOnTrigger
sound:
path: "/Audio/Effects/flash_bang.ogg"
diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Throwable/grenades.yml b/Resources/Prototypes/Entities/Objects/Weapons/Throwable/grenades.yml
index 6446769fd4..e51ace2f79 100644
--- a/Resources/Prototypes/Entities/Objects/Weapons/Throwable/grenades.yml
+++ b/Resources/Prototypes/Entities/Objects/Weapons/Throwable/grenades.yml
@@ -58,7 +58,7 @@
delay: 3.5
- type: FlashOnTrigger
range: 7
- - type: SoundOnTrigger
+ - type: EmitSoundOnTrigger
sound:
path: "/Audio/Effects/flash_bang.ogg"
- type: DeleteOnTrigger
@@ -148,3 +148,36 @@
- type: TimerTriggerVisualizer
countdown_sound:
path: /Audio/Effects/countdown.ogg
+
+- type: entity
+ name: modular grenade
+ description: A grenade casing. Requires a trigger and a payload.
+ parent: BaseItem
+ id: ModularGrenade
+ components:
+ - type: Sprite
+ sprite: Objects/Weapons/Grenades/modular.rsi
+ state: empty
+ - type: Item
+ size: 8
+ - type: PayloadCase
+ - type: Construction
+ graph: ModularGrenadeGraph
+ node: emptyCase
+ - type: Damageable
+ damageContainer: Inorganic
+ - type: Destructible
+ thresholds:
+ - trigger:
+ !type:DamageTrigger
+ damage: 50
+ behaviors:
+ - !type:DoActsBehavior
+ acts: [ "Destruction" ]
+ - type: Appearance
+ visuals:
+ - type: GenericEnumVisualizer
+ key: enum.Trigger.TriggerVisuals.VisualState
+ states:
+ enum.Trigger.TriggerVisualState.Primed: primed
+ enum.Trigger.TriggerVisualState.Unprimed: complete
diff --git a/Resources/Prototypes/Entities/Objects/Weapons/security.yml b/Resources/Prototypes/Entities/Objects/Weapons/security.yml
index 40c45b4e1c..5505142ece 100644
--- a/Resources/Prototypes/Entities/Objects/Weapons/security.yml
+++ b/Resources/Prototypes/Entities/Objects/Weapons/security.yml
@@ -56,7 +56,7 @@
id: PortableFlasher
description: An ultrabright flashbulb with a proximity trigger, useful for making an area security-only.
components:
- - type: SoundOnTrigger
+ - type: EmitSoundOnTrigger
sound:
path: /Audio/Weapons/flash.ogg
- type: FlashOnTrigger
diff --git a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml
index c73a898994..3791b36ae2 100644
--- a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml
+++ b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml
@@ -185,6 +185,8 @@
- KitchenKnife
- ButchCleaver
- FlashlightLantern
+ - TimerTrigger
+ - ChemicalPayload
- type: ActivatableUI
key: enum.LatheUiKey.Key #Yes only having 1 of them here doesn't break anything
- type: ActivatableUIRequiresPower
@@ -294,6 +296,7 @@
- CableStack
- CableMVStack
- CableHVStack
+ - TimerTrigger
- type: entity
parent: Autolathe
diff --git a/Resources/Prototypes/Recipes/Construction/Graphs/weapons/modular_grenade.yml b/Resources/Prototypes/Recipes/Construction/Graphs/weapons/modular_grenade.yml
new file mode 100644
index 0000000000..f2240fe18e
--- /dev/null
+++ b/Resources/Prototypes/Recipes/Construction/Graphs/weapons/modular_grenade.yml
@@ -0,0 +1,83 @@
+- type: constructionGraph
+ id: ModularGrenadeGraph
+ start: start
+ graph:
+
+ - node: start
+ edges:
+ - to: emptyCase
+ steps:
+ - material: Steel
+ amount: 5
+ doAfter: 1
+
+ - node: emptyCase
+ entity: ModularGrenade
+ actions:
+ - !type:SpriteStateChange
+ state: empty
+ edges:
+ - to: wiredCase
+ steps:
+ - material: Cable
+ doAfter: 0.5
+
+ - node: wiredCase
+ entity: ModularGrenade
+ actions:
+ - !type:SpriteStateChange
+ state: wired
+ - !type:PlaySound
+ sound: /Audio/Machines/button.ogg
+ edges:
+ - to: emptyCase
+ steps:
+ - tool: Cutting
+ doAfter: 0.5
+ completed:
+ - !type:SpawnPrototype
+ prototype: CableApcStack1
+ - to: caseWithTrigger
+ steps:
+ - component: PayloadTrigger
+ store: payloadTrigger
+ name: Trigger
+ doAfter: 0.5
+
+ - node: caseWithTrigger
+ actions:
+ - !type:SpriteStateChange
+ state: no-payload
+ - !type:PlaySound
+ sound: /Audio/Machines/button.ogg
+ edges:
+ - to: wiredCase
+ steps:
+ - tool: Prying
+ doAfter: 0.5
+ completed:
+ - !type:EmptyContainer
+ container: payloadTrigger
+ - to: grenade
+ steps:
+ - tag: Payload
+ store: payload
+ name: Payload
+ doAfter: 0.5
+
+ - node: grenade
+ actions:
+ - !type:SpriteStateChange
+ state: complete
+ - !type:PlaySound
+ sound: /Audio/Machines/button.ogg
+ - !type:AdminLog
+ message: "A grenade was crafted"
+ edges:
+ - to: caseWithTrigger
+ steps:
+ - tool: Prying
+ doAfter: 0.5
+ completed:
+ - !type:EmptyContainer
+ container: payload
\ No newline at end of file
diff --git a/Resources/Prototypes/Recipes/Construction/modular_grenades.yml b/Resources/Prototypes/Recipes/Construction/modular_grenades.yml
new file mode 100644
index 0000000000..280c8a0ad7
--- /dev/null
+++ b/Resources/Prototypes/Recipes/Construction/modular_grenades.yml
@@ -0,0 +1,12 @@
+- type: construction
+ name: Modular Grenade
+ id: ModularGrenadeRecipe
+ graph: ModularGrenadeGraph
+ startNode: start
+ targetNode: grenade
+ category: Weapons
+ description: Construct a grenade using a trigger and a payload.
+ icon:
+ sprite: Objects/Weapons/Grenades/modular.rsi
+ state: complete
+ objectType: Item
\ No newline at end of file
diff --git a/Resources/Prototypes/Recipes/Construction/weapons.yml b/Resources/Prototypes/Recipes/Construction/weapons.yml
index b8517ca579..c97b97e7e7 100644
--- a/Resources/Prototypes/Recipes/Construction/weapons.yml
+++ b/Resources/Prototypes/Recipes/Construction/weapons.yml
@@ -18,4 +18,4 @@
category: Weapons
description: A simple weapon for tripping someone at a distance.
icon: Objects/Weapons/Throwable/bola.rsi/icon.png
- objectType: Item
+ objectType: Item
\ No newline at end of file
diff --git a/Resources/Prototypes/Recipes/Lathes/devices.yml b/Resources/Prototypes/Recipes/Lathes/devices.yml
new file mode 100644
index 0000000000..c522ef648e
--- /dev/null
+++ b/Resources/Prototypes/Recipes/Lathes/devices.yml
@@ -0,0 +1,21 @@
+- type: latheRecipe
+ id: TimerTrigger
+ icon:
+ sprite: Objects/Devices/timer.rsi
+ state: timer
+ result: TimerTrigger
+ completetime: 500
+ materials:
+ Steel: 300
+ Plastic: 200
+
+- type: latheRecipe
+ id: ChemicalPayload
+ icon:
+ sprite: Objects/Devices/payload.rsi
+ state: payload-empty
+ result: ChemicalPayload
+ completetime: 500
+ materials:
+ Steel: 200
+ Plastic: 300
diff --git a/Resources/Prototypes/tags.yml b/Resources/Prototypes/tags.yml
index e38ea86249..6eadfbebba 100644
--- a/Resources/Prototypes/tags.yml
+++ b/Resources/Prototypes/tags.yml
@@ -216,6 +216,9 @@
- type: Tag
id: Ore
+- type: Tag
+ id: Payload # for grenade/bomb crafting
+
- type: Tag
id: PercussionInstrument
diff --git a/Resources/Textures/Interface/VerbIcons/clock.svg.192dpi.png b/Resources/Textures/Interface/VerbIcons/clock.svg.192dpi.png
new file mode 100644
index 0000000000..be3f2d4942
Binary files /dev/null and b/Resources/Textures/Interface/VerbIcons/clock.svg.192dpi.png differ
diff --git a/Resources/Textures/Interface/VerbIcons/clock.svg.192dpi.png.yml b/Resources/Textures/Interface/VerbIcons/clock.svg.192dpi.png.yml
new file mode 100644
index 0000000000..5c43e23305
--- /dev/null
+++ b/Resources/Textures/Interface/VerbIcons/clock.svg.192dpi.png.yml
@@ -0,0 +1,2 @@
+sample:
+ filter: true
diff --git a/Resources/Textures/Objects/Devices/payload.rsi/meta.json b/Resources/Textures/Objects/Devices/payload.rsi/meta.json
new file mode 100644
index 0000000000..7f1958955b
--- /dev/null
+++ b/Resources/Textures/Objects/Devices/payload.rsi/meta.json
@@ -0,0 +1,35 @@
+{
+ "version": 1,
+
+ "license": "CC0-1.0",
+ "copyright": "Taken from https://github.com/tgstation/tgstation/blob/master/icons/obj/assemblies/new_assemblies.dmi",
+
+ "size": {
+ "x": 32,
+ "y": 32
+ },
+ "states": [
+ {
+ "name": "payload-empty",
+ "directions": 1
+ },
+ {
+ "name": "payload-chemical-left",
+ "directions": 1
+ },
+ {
+ "name": "payload-chemical-right",
+ "directions": 1
+ },
+ {
+ "name": "payload-chemical-armed",
+ "directions": 1,
+ "delays": [ [ 0.2, 0.2, 0.2 ] ]
+ },
+ {
+ "name": "payload-explosive-armed",
+ "directions": 1,
+ "delays": [ [ 0.2, 0.2, 0.2 ] ]
+ }
+ ]
+}
diff --git a/Resources/Textures/Objects/Devices/payload.rsi/payload-chemical-armed.png b/Resources/Textures/Objects/Devices/payload.rsi/payload-chemical-armed.png
new file mode 100644
index 0000000000..a7a2896a89
Binary files /dev/null and b/Resources/Textures/Objects/Devices/payload.rsi/payload-chemical-armed.png differ
diff --git a/Resources/Textures/Objects/Devices/payload.rsi/payload-chemical-left.png b/Resources/Textures/Objects/Devices/payload.rsi/payload-chemical-left.png
new file mode 100644
index 0000000000..ac900aaac2
Binary files /dev/null and b/Resources/Textures/Objects/Devices/payload.rsi/payload-chemical-left.png differ
diff --git a/Resources/Textures/Objects/Devices/payload.rsi/payload-chemical-right.png b/Resources/Textures/Objects/Devices/payload.rsi/payload-chemical-right.png
new file mode 100644
index 0000000000..d3f375e716
Binary files /dev/null and b/Resources/Textures/Objects/Devices/payload.rsi/payload-chemical-right.png differ
diff --git a/Resources/Textures/Objects/Devices/payload.rsi/payload-empty.png b/Resources/Textures/Objects/Devices/payload.rsi/payload-empty.png
new file mode 100644
index 0000000000..e84716db10
Binary files /dev/null and b/Resources/Textures/Objects/Devices/payload.rsi/payload-empty.png differ
diff --git a/Resources/Textures/Objects/Devices/payload.rsi/payload-explosive-armed.png b/Resources/Textures/Objects/Devices/payload.rsi/payload-explosive-armed.png
new file mode 100644
index 0000000000..4d60ce17d8
Binary files /dev/null and b/Resources/Textures/Objects/Devices/payload.rsi/payload-explosive-armed.png differ
diff --git a/Resources/Textures/Objects/Devices/timer.rsi/meta.json b/Resources/Textures/Objects/Devices/timer.rsi/meta.json
new file mode 100644
index 0000000000..acad76a3ed
--- /dev/null
+++ b/Resources/Textures/Objects/Devices/timer.rsi/meta.json
@@ -0,0 +1,17 @@
+{
+ "version": 1,
+
+ "license": "CC0-1.0",
+ "copyright": "Taken from https://github.com/tgstation/tgstation/blob/master/icons/obj/assemblies/new_assemblies.dmi",
+
+ "size": {
+ "x": 32,
+ "y": 32
+ },
+ "states": [
+ {
+ "name": "timer",
+ "directions": 1
+ }
+ ]
+}
\ No newline at end of file
diff --git a/Resources/Textures/Objects/Devices/timer.rsi/timer.png b/Resources/Textures/Objects/Devices/timer.rsi/timer.png
new file mode 100644
index 0000000000..39b15b076d
Binary files /dev/null and b/Resources/Textures/Objects/Devices/timer.rsi/timer.png differ
diff --git a/Resources/Textures/Objects/Weapons/Grenades/modular.rsi/complete.png b/Resources/Textures/Objects/Weapons/Grenades/modular.rsi/complete.png
new file mode 100644
index 0000000000..af0997e1f6
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Grenades/modular.rsi/complete.png differ
diff --git a/Resources/Textures/Objects/Weapons/Grenades/modular.rsi/empty.png b/Resources/Textures/Objects/Weapons/Grenades/modular.rsi/empty.png
new file mode 100644
index 0000000000..7e577c3cc6
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Grenades/modular.rsi/empty.png differ
diff --git a/Resources/Textures/Objects/Weapons/Grenades/modular.rsi/meta.json b/Resources/Textures/Objects/Weapons/Grenades/modular.rsi/meta.json
new file mode 100644
index 0000000000..f23b6ec168
--- /dev/null
+++ b/Resources/Textures/Objects/Weapons/Grenades/modular.rsi/meta.json
@@ -0,0 +1,34 @@
+{
+ "version": 1,
+ "license": "CC-BY-SA-3.0",
+ "copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/commit/29c0ed1b000619cb5398ef921000a8d4502ba0b6 and modified by Swept",
+ "size": {
+ "x": 32,
+ "y": 32
+ },
+ "states": [
+ {
+ "name": "empty",
+ "directions": 1
+ },
+ {
+ "name": "wired",
+ "directions": 1
+ },
+ {
+ "name": "no-payload",
+ "directions": 1
+ },
+ {
+ "name": "complete",
+ "directions": 1
+ },
+ {
+ "name": "primed",
+ "directions": 1,
+ "delays": [
+ [ 0.2, 0.2 ]
+ ]
+ }
+ ]
+}
diff --git a/Resources/Textures/Objects/Weapons/Grenades/modular.rsi/no-payload.png b/Resources/Textures/Objects/Weapons/Grenades/modular.rsi/no-payload.png
new file mode 100644
index 0000000000..39d3f2b365
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Grenades/modular.rsi/no-payload.png differ
diff --git a/Resources/Textures/Objects/Weapons/Grenades/modular.rsi/primed.png b/Resources/Textures/Objects/Weapons/Grenades/modular.rsi/primed.png
new file mode 100644
index 0000000000..c5a39eab1d
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Grenades/modular.rsi/primed.png differ
diff --git a/Resources/Textures/Objects/Weapons/Grenades/modular.rsi/wired.png b/Resources/Textures/Objects/Weapons/Grenades/modular.rsi/wired.png
new file mode 100644
index 0000000000..fbdd845527
Binary files /dev/null and b/Resources/Textures/Objects/Weapons/Grenades/modular.rsi/wired.png differ