]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
AdminLogOnTrigger (#41474)
authorāda <ss.adasts@gmail.com>
Wed, 19 Nov 2025 02:08:04 +0000 (20:08 -0600)
committerGitHub <noreply@github.com>
Wed, 19 Nov 2025 02:08:04 +0000 (02:08 +0000)
* commit

* requested

* also requested

* Update Content.Shared/Trigger/Components/Effects/AdminLogOnTriggerComponent.cs

---------

Co-authored-by: iaada <iaada@users.noreply.github.com>
Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Content.Shared/Trigger/Components/Effects/AdminLogOnTriggerComponent.cs [new file with mode: 0644]
Content.Shared/Trigger/Systems/AdminLogOnTriggerSystem.cs [new file with mode: 0644]

diff --git a/Content.Shared/Trigger/Components/Effects/AdminLogOnTriggerComponent.cs b/Content.Shared/Trigger/Components/Effects/AdminLogOnTriggerComponent.cs
new file mode 100644 (file)
index 0000000..4045f8c
--- /dev/null
@@ -0,0 +1,34 @@
+using Content.Shared.Database;
+using Content.Shared.Random;
+using Content.Shared.Trigger.Components.Triggers;
+using Robust.Shared.GameStates;
+using Robust.Shared.Prototypes;
+
+namespace Content.Shared.Trigger.Components.Effects;
+
+/// <summary>
+/// This component creates an admin log when receiving a trigger.
+/// <see cref="BaseXOnTriggerComponent.TargetUser"/> is ignored.
+/// </summary>
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
+public sealed partial class AdminLogOnTriggerComponent : BaseXOnTriggerComponent
+{
+    /// <summary>
+    /// The message displayed in the logs describing what specifically was done by this trigger.
+    /// This entity and the user will be included alongside the message.
+    /// </summary>
+    [DataField(required: true), AutoNetworkedField]
+    public LocId Message = string.Empty;
+
+    /// <summary>
+    /// What type of action took place?
+    /// </summary>
+    [DataField, AutoNetworkedField]
+    public LogType LogType = LogType.Trigger;
+
+    /// <summary>
+    /// How important is this trigger?
+    /// </summary>
+    [DataField, AutoNetworkedField]
+    public LogImpact LogImpact = LogImpact.Low;
+}
diff --git a/Content.Shared/Trigger/Systems/AdminLogOnTriggerSystem.cs b/Content.Shared/Trigger/Systems/AdminLogOnTriggerSystem.cs
new file mode 100644 (file)
index 0000000..0adf483
--- /dev/null
@@ -0,0 +1,19 @@
+using Content.Shared.Administration.Logs;
+using Content.Shared.Trigger.Components.Effects;
+
+namespace Content.Shared.Trigger.Systems;
+
+public sealed class AdminLogOnTriggerSystem : XOnTriggerSystem<AdminLogOnTriggerComponent>
+{
+    [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
+
+    protected override void OnTrigger(Entity<AdminLogOnTriggerComponent> ent, EntityUid target, ref TriggerEvent args)
+    {
+        _adminLogger.Add(
+            ent.Comp.LogType,
+            ent.Comp.LogImpact,
+            $"{ToPrettyString(args.User)} sent a trigger using {ToPrettyString(ent)}: {Loc.GetString(ent.Comp.Message)}"
+            );
+        // Intentionally does not handle the event since this shouldn't affect the gamestate.
+    }
+}