]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Damage popup type can now be changed with a left click if allowed via component boole...
authorDae <60460608+ZeroDayDaemon@users.noreply.github.com>
Fri, 5 Apr 2024 07:19:41 +0000 (03:19 -0400)
committerGitHub <noreply@github.com>
Fri, 5 Apr 2024 07:19:41 +0000 (03:19 -0400)
* Update DamagePopupSystem.cs

* Update DamagePopupSystem.cs

* Add ability to allow or deny type change via component bool

Content.Server/Damage/Components/DamagePopupComponent.cs
Content.Server/Damage/Systems/DamagePopupSystem.cs
Resources/Prototypes/Entities/Objects/Specific/Security/target.yml

index b1216069f5e6597b2acefb4e4b3d26aa817c9e91..37c5d57cf45a14bacc458bcbcba6777c6736f7a1 100644 (file)
@@ -5,6 +5,11 @@ namespace Content.Server.Damage.Components;
 [RegisterComponent, Access(typeof(DamagePopupSystem))]
 public sealed partial class DamagePopupComponent : Component
 {
+    /// <summary>
+    /// Bool that will be used to determine if the popup type can be changed with a left click.
+    /// </summary>
+    [DataField("allowTypeChange")] [ViewVariables(VVAccess.ReadWrite)]
+    public bool AllowTypeChange = false;
     /// <summary>
     /// Enum that will be used to determine the type of damage popup displayed.
     /// </summary>
index 12fd894ac6f8980546a32a4716d075ca6ee4ebc5..3386c92129f75bdf233d0ea26262e0f6c960d576 100644 (file)
@@ -1,7 +1,8 @@
+using System.Linq;
 using Content.Server.Damage.Components;
 using Content.Server.Popups;
 using Content.Shared.Damage;
-using Robust.Shared.Player;
+using Content.Shared.Interaction;
 
 namespace Content.Server.Damage.Systems;
 
@@ -13,6 +14,7 @@ public sealed class DamagePopupSystem : EntitySystem
     {
         base.Initialize();
         SubscribeLocalEvent<DamagePopupComponent, DamageChangedEvent>(OnDamageChange);
+        SubscribeLocalEvent<DamagePopupComponent, InteractHandEvent>(OnInteractHand);
     }
 
     private void OnDamageChange(EntityUid uid, DamagePopupComponent component, DamageChangedEvent args)
@@ -33,4 +35,20 @@ public sealed class DamagePopupSystem : EntitySystem
             _popupSystem.PopupEntity(msg, uid);
         }
     }
+
+    private void OnInteractHand(EntityUid uid, DamagePopupComponent component, InteractHandEvent args)
+    {
+        if (component.AllowTypeChange)
+        {
+            if (component.Type == Enum.GetValues(typeof(DamagePopupType)).Cast<DamagePopupType>().Last())
+            {
+                component.Type = Enum.GetValues(typeof(DamagePopupType)).Cast<DamagePopupType>().First();
+            }
+            else
+            {
+                component.Type = (DamagePopupType) (int) component.Type + 1;
+            }
+            _popupSystem.PopupEntity("Target set to type: " + component.Type.ToString(), uid);
+        }
+    }
 }
index adbb7cde40b770d25864757d8464e1e9ca2ba0ef..a17c892169de2d0a89ca584952e6de1a44b3b8db 100644 (file)
@@ -9,6 +9,7 @@
     noRot: true
   - type: Repairable
   - type: DamagePopup
+    allowTypeChange: true
     damagePopupType: Combined
   - type: Fixtures
     fixtures: