]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Staff of Animation Fixes & Recharging (#37021)
authorActiveMammmoth <140334666+ActiveMammmoth@users.noreply.github.com>
Tue, 29 Apr 2025 19:40:49 +0000 (15:40 -0400)
committerGitHub <noreply@github.com>
Tue, 29 Apr 2025 19:40:49 +0000 (20:40 +0100)
Content.Server/Actions/ActionOnInteractComponent.cs
Content.Server/Actions/ActionOnInteractSystem.cs
Content.Server/NPC/Systems/NPCUtilitySystem.cs
Content.Shared/Magic/Systems/AnimateSpellSystem.cs
Resources/Prototypes/Magic/animate_spell.yml
Resources/Prototypes/Magic/staves.yml

index 3a7e15649b0e965960dc5d1197387de64c659c49..4ae3d9e5f7a4ed5aaf613c95d7835f73f46fca15 100644 (file)
@@ -1,6 +1,5 @@
 using Content.Shared.Interaction;
 using Robust.Shared.Prototypes;
-using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
 
 namespace Content.Server.Actions;
 
@@ -20,8 +19,10 @@ namespace Content.Server.Actions;
 [RegisterComponent]
 public sealed partial class ActionOnInteractComponent : Component
 {
-    [DataField(required:true)]
+    [DataField(required: true)]
     public List<EntProtoId>? Actions;
 
     [DataField] public List<EntityUid>? ActionEntities;
+
+    [DataField] public bool RequiresCharge;
 }
index af9b0b1ddbd512291130e72d790f0e813356414b..c658b3f90a4ee974bdf8229f44aa30eefadccb1a 100644 (file)
@@ -1,5 +1,7 @@
 using System.Linq;
 using Content.Shared.Actions;
+using Content.Shared.Charges.Components;
+using Content.Shared.Charges.Systems;
 using Content.Shared.Interaction;
 using Robust.Shared.Random;
 using Robust.Shared.Timing;
@@ -15,6 +17,7 @@ public sealed class ActionOnInteractSystem : EntitySystem
     [Dependency] private readonly IGameTiming _timing = default!;
     [Dependency] private readonly SharedActionsSystem _actions = default!;
     [Dependency] private readonly ActionContainerSystem _actionContainer = default!;
+    [Dependency] private readonly SharedChargesSystem _charges = default!;
 
     public override void Initialize()
     {
@@ -54,6 +57,9 @@ public sealed class ActionOnInteractSystem : EntitySystem
         if (options.Count == 0)
             return;
 
+        if (!TryUseCharge((uid, component)))
+            return;
+
         var (actId, act) = _random.Pick(options);
         _actions.PerformAction(args.User, null, actId, act, act.Event, _timing.CurTime, false);
         args.Handled = true;
@@ -85,6 +91,9 @@ public sealed class ActionOnInteractSystem : EntitySystem
 
             if (entOptions.Count > 0)
             {
+                if (!TryUseCharge((uid, component)))
+                    return;
+
                 var (entActId, entAct) = _random.Pick(entOptions);
                 if (entAct.Event != null)
                 {
@@ -108,6 +117,9 @@ public sealed class ActionOnInteractSystem : EntitySystem
 
         if (entWorldOptions.Count > 0)
         {
+            if (!TryUseCharge((uid, component)))
+                return;
+
             var (entActId, entAct) = _random.Pick(entWorldOptions);
             if (entAct.Event != null)
             {
@@ -132,6 +144,9 @@ public sealed class ActionOnInteractSystem : EntitySystem
         if (options.Count == 0)
             return;
 
+        if (!TryUseCharge((uid, component)))
+            return;
+
         var (actId, act) = _random.Pick(options);
         if (act.Event != null)
         {
@@ -163,4 +178,17 @@ public sealed class ActionOnInteractSystem : EntitySystem
 
         return valid;
     }
+
+    private bool TryUseCharge(Entity<ActionOnInteractComponent> ent)
+    {
+        if (!ent.Comp.RequiresCharge)
+            return true;
+
+        Entity<LimitedChargesComponent?> charges = ent.Owner;
+        if (_charges.IsEmpty(charges))
+            return false;
+
+        _charges.TryUseCharge(charges);
+        return true;
+    }
 }
index eff4f2772b44f0305acc756216a49380993af6ed..7b485eeb96f62c290988219451e010707815d36c 100644 (file)
@@ -232,6 +232,9 @@ public sealed class NPCUtilitySystem : EntitySystem
             {
                 if (_container.TryGetContainingContainer(targetUid, out var container))
                 {
+                    if (container.Owner == owner)
+                        return 0f;
+
                     if (TryComp<EntityStorageComponent>(container.Owner, out var storageComponent))
                     {
                         if (storageComponent is { Open: false } && _weldable.IsWelded(container.Owner))
index 458336dea1481daa059979dabe0c41e3e36340c5..202605a338578d3cd885b1aab7f1476974c2f942 100644 (file)
@@ -40,7 +40,7 @@ public sealed class AnimateSpellSystem : EntitySystem
         _container.AttachParentToContainerOrGrid((ent, xform)); // Items animated inside inventory now exit, they can't be picked up and so can't escape otherwise
 
         var ev = new AnimateSpellEvent();
-        RaiseLocalEvent(ref ev);
+        RaiseLocalEvent(ent, ref ev);
     }
 }
 
index d36afb49d911d64639add850cc07977114ca8714..6d1319944b4b5bf7392bc3b1f17b48f495217388 100644 (file)
@@ -3,14 +3,12 @@
   name: Animate
   description: Bring an inanimate object to life!
   components:
-  - type: LimitedCharges
-    maxCharges: 5
   - type: EntityTargetAction
     useDelay: 0
     itemIconStyle: BigAction
     whitelist:
       components:
-      - Animateable # Currently on: SeatBase, TableBase, ClosetBase, BaseMachine, ConstructibleMachine, BaseComputer, BaseItem, CrateGeneric, StorageTank, GasCanister, BaseTarget
+      - Animateable # Currently on: SeatBase, TableBase, ClosetBase, BaseMachine, ConstructibleMachine, BaseComputer, BaseItem, CrateGeneric, StorageTank, GasCanister
     blacklist:
       components:
       - MindContainer
@@ -19,7 +17,7 @@
       - AnomalyGenerator
       - TegGenerator
       - TegCirculator
-      - Artifact
+      - XenoArtifact
     canTargetSelf: false
     interactOnMiss: false
     sound: !type:SoundPathSpecifier
               collection: MetalBreak
       - type: Hands
       - type: CanEscapeInventory
+      - type: MobCollision
       toRemove:
       - RequireProjectileTarget
       - BlockMovement
       - Item
+      - MeleeRequiresWield
       speech: action-speech-spell-animate
       doSpeech: false
index 8bfb30b88708ea5e4ca9cfd7fc9a7c474936761b..ff43db866e745ac7b7dcaa2649094fd1e10c1df1 100644 (file)
@@ -7,6 +7,10 @@
   name: RGB staff
   description: Helps fix the underabundance of RGB gear on the station.
   components:
+  - type: LimitedCharges
+    maxCharges: 25
+  - type: AutoRecharge
+    rechargeDuration: 30
   - type: Sprite
     sprite: Objects/Weapons/Guns/Basic/staves.rsi
     layers:
@@ -14,6 +18,7 @@
     - state: nothing-unshaded
       shader: unshaded
   - type: ActionOnInteract
+    requiresCharge: true
     actions:
     - ActionRgbLight
   - type: Item
   name: staff of animation
   description: Brings inanimate objects to life!
   components:
+  - type: LimitedCharges
+    maxCharges: 5
+  - type: AutoRecharge
+    rechargeDuration: 30
   - type: Sprite
     sprite: Objects/Weapons/Guns/Basic/staves.rsi
     layers:
     - state: animation
   - type: ActionOnInteract
+    requiresCharge: true
     actions:
     - ActionAnimateSpell
   - type: Item
@@ -59,8 +69,6 @@
 - type: entity
   id: ActionRgbLight
   components:
-  - type: LimitedCharges
-    maxCharges: 25
   - type: EntityTargetAction
     whitelist: { components: [ PointLight ] }
     sound: /Audio/Magic/blink.ogg