Staff of Animation Fixes & Recharging (#37021)

This commit is contained in:
ActiveMammmoth
2025-04-29 15:40:49 -04:00
committed by GitHub
parent b9b854e179
commit a8ff930763
6 changed files with 49 additions and 9 deletions

View File

@@ -1,6 +1,5 @@
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
namespace Content.Server.Actions; namespace Content.Server.Actions;
@@ -20,8 +19,10 @@ namespace Content.Server.Actions;
[RegisterComponent] [RegisterComponent]
public sealed partial class ActionOnInteractComponent : Component public sealed partial class ActionOnInteractComponent : Component
{ {
[DataField(required:true)] [DataField(required: true)]
public List<EntProtoId>? Actions; public List<EntProtoId>? Actions;
[DataField] public List<EntityUid>? ActionEntities; [DataField] public List<EntityUid>? ActionEntities;
[DataField] public bool RequiresCharge;
} }

View File

@@ -1,5 +1,7 @@
using System.Linq; using System.Linq;
using Content.Shared.Actions; using Content.Shared.Actions;
using Content.Shared.Charges.Components;
using Content.Shared.Charges.Systems;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Robust.Shared.Random; using Robust.Shared.Random;
using Robust.Shared.Timing; using Robust.Shared.Timing;
@@ -15,6 +17,7 @@ public sealed class ActionOnInteractSystem : EntitySystem
[Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly SharedActionsSystem _actions = default!; [Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly ActionContainerSystem _actionContainer = default!; [Dependency] private readonly ActionContainerSystem _actionContainer = default!;
[Dependency] private readonly SharedChargesSystem _charges = default!;
public override void Initialize() public override void Initialize()
{ {
@@ -54,6 +57,9 @@ public sealed class ActionOnInteractSystem : EntitySystem
if (options.Count == 0) if (options.Count == 0)
return; return;
if (!TryUseCharge((uid, component)))
return;
var (actId, act) = _random.Pick(options); var (actId, act) = _random.Pick(options);
_actions.PerformAction(args.User, null, actId, act, act.Event, _timing.CurTime, false); _actions.PerformAction(args.User, null, actId, act, act.Event, _timing.CurTime, false);
args.Handled = true; args.Handled = true;
@@ -85,6 +91,9 @@ public sealed class ActionOnInteractSystem : EntitySystem
if (entOptions.Count > 0) if (entOptions.Count > 0)
{ {
if (!TryUseCharge((uid, component)))
return;
var (entActId, entAct) = _random.Pick(entOptions); var (entActId, entAct) = _random.Pick(entOptions);
if (entAct.Event != null) if (entAct.Event != null)
{ {
@@ -108,6 +117,9 @@ public sealed class ActionOnInteractSystem : EntitySystem
if (entWorldOptions.Count > 0) if (entWorldOptions.Count > 0)
{ {
if (!TryUseCharge((uid, component)))
return;
var (entActId, entAct) = _random.Pick(entWorldOptions); var (entActId, entAct) = _random.Pick(entWorldOptions);
if (entAct.Event != null) if (entAct.Event != null)
{ {
@@ -132,6 +144,9 @@ public sealed class ActionOnInteractSystem : EntitySystem
if (options.Count == 0) if (options.Count == 0)
return; return;
if (!TryUseCharge((uid, component)))
return;
var (actId, act) = _random.Pick(options); var (actId, act) = _random.Pick(options);
if (act.Event != null) if (act.Event != null)
{ {
@@ -163,4 +178,17 @@ public sealed class ActionOnInteractSystem : EntitySystem
return valid; 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;
}
} }

View File

@@ -232,6 +232,9 @@ public sealed class NPCUtilitySystem : EntitySystem
{ {
if (_container.TryGetContainingContainer(targetUid, out var container)) if (_container.TryGetContainingContainer(targetUid, out var container))
{ {
if (container.Owner == owner)
return 0f;
if (TryComp<EntityStorageComponent>(container.Owner, out var storageComponent)) if (TryComp<EntityStorageComponent>(container.Owner, out var storageComponent))
{ {
if (storageComponent is { Open: false } && _weldable.IsWelded(container.Owner)) if (storageComponent is { Open: false } && _weldable.IsWelded(container.Owner))

View 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 _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(); var ev = new AnimateSpellEvent();
RaiseLocalEvent(ref ev); RaiseLocalEvent(ent, ref ev);
} }
} }

View File

@@ -3,14 +3,12 @@
name: Animate name: Animate
description: Bring an inanimate object to life! description: Bring an inanimate object to life!
components: components:
- type: LimitedCharges
maxCharges: 5
- type: EntityTargetAction - type: EntityTargetAction
useDelay: 0 useDelay: 0
itemIconStyle: BigAction itemIconStyle: BigAction
whitelist: whitelist:
components: 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: blacklist:
components: components:
- MindContainer - MindContainer
@@ -19,7 +17,7 @@
- AnomalyGenerator - AnomalyGenerator
- TegGenerator - TegGenerator
- TegCirculator - TegCirculator
- Artifact - XenoArtifact
canTargetSelf: false canTargetSelf: false
interactOnMiss: false interactOnMiss: false
sound: !type:SoundPathSpecifier sound: !type:SoundPathSpecifier
@@ -70,9 +68,11 @@
collection: MetalBreak collection: MetalBreak
- type: Hands - type: Hands
- type: CanEscapeInventory - type: CanEscapeInventory
- type: MobCollision
toRemove: toRemove:
- RequireProjectileTarget - RequireProjectileTarget
- BlockMovement - BlockMovement
- Item - Item
- MeleeRequiresWield
speech: action-speech-spell-animate speech: action-speech-spell-animate
doSpeech: false doSpeech: false

View File

@@ -7,6 +7,10 @@
name: RGB staff name: RGB staff
description: Helps fix the underabundance of RGB gear on the station. description: Helps fix the underabundance of RGB gear on the station.
components: components:
- type: LimitedCharges
maxCharges: 25
- type: AutoRecharge
rechargeDuration: 30
- type: Sprite - type: Sprite
sprite: Objects/Weapons/Guns/Basic/staves.rsi sprite: Objects/Weapons/Guns/Basic/staves.rsi
layers: layers:
@@ -14,6 +18,7 @@
- state: nothing-unshaded - state: nothing-unshaded
shader: unshaded shader: unshaded
- type: ActionOnInteract - type: ActionOnInteract
requiresCharge: true
actions: actions:
- ActionRgbLight - ActionRgbLight
- type: Item - type: Item
@@ -38,11 +43,16 @@
name: staff of animation name: staff of animation
description: Brings inanimate objects to life! description: Brings inanimate objects to life!
components: components:
- type: LimitedCharges
maxCharges: 5
- type: AutoRecharge
rechargeDuration: 30
- type: Sprite - type: Sprite
sprite: Objects/Weapons/Guns/Basic/staves.rsi sprite: Objects/Weapons/Guns/Basic/staves.rsi
layers: layers:
- state: animation - state: animation
- type: ActionOnInteract - type: ActionOnInteract
requiresCharge: true
actions: actions:
- ActionAnimateSpell - ActionAnimateSpell
- type: Item - type: Item
@@ -59,8 +69,6 @@
- type: entity - type: entity
id: ActionRgbLight id: ActionRgbLight
components: components:
- type: LimitedCharges
maxCharges: 25
- type: EntityTargetAction - type: EntityTargetAction
whitelist: { components: [ PointLight ] } whitelist: { components: [ PointLight ] }
sound: /Audio/Magic/blink.ogg sound: /Audio/Magic/blink.ogg