Staff of Animation Fixes (#35491)

* staff of animation fixes and system

* requested changes

* size back to normal

* Update AnimateSpellSystem.cs

---------

Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com>
This commit is contained in:
ActiveMammmoth
2025-02-27 14:11:57 -05:00
committed by GitHub
parent 3c20f63292
commit cec05d697e
8 changed files with 86 additions and 58 deletions

View File

@@ -0,0 +1,8 @@
using Robust.Shared.GameStates;
namespace Content.Shared.Magic.Components;
// Added to objects when they are made animate
[RegisterComponent, NetworkedComponent]
public sealed partial class AnimateComponent : Component;

View File

@@ -1,16 +0,0 @@
using Content.Shared.Actions;
using Robust.Shared.Prototypes;
namespace Content.Shared.Magic.Events;
public sealed partial class AnimateSpellEvent : EntityTargetActionEvent, ISpeakSpell
{
[DataField]
public string? Speech { get; private set; }
[DataField]
public ComponentRegistry AddComponents = new();
[DataField]
public HashSet<string> RemoveComponents = new();
}

View File

@@ -1,4 +1,4 @@
using Content.Shared.Actions; using Content.Shared.Actions;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
namespace Content.Shared.Magic.Events; namespace Content.Shared.Magic.Events;
@@ -11,14 +11,17 @@ public sealed partial class ChangeComponentsSpellEvent : EntityTargetActionEvent
// TODO allow it to set component data-fields? // TODO allow it to set component data-fields?
// for now a Hackish way to do that is to remove & add, but that doesn't allow you to selectively set specific data fields. // for now a Hackish way to do that is to remove & add, but that doesn't allow you to selectively set specific data fields.
[DataField("toAdd")] [DataField]
[AlwaysPushInheritance] [AlwaysPushInheritance]
public ComponentRegistry ToAdd = new(); public ComponentRegistry ToAdd = new();
[DataField("toRemove")] [DataField]
[AlwaysPushInheritance] [AlwaysPushInheritance]
public HashSet<string> ToRemove = new(); public HashSet<string> ToRemove = new();
[DataField("speech")] [DataField]
public string? Speech { get; private set; } public string? Speech { get; private set; }
[DataField]
public bool DoSpeech { get; private set; }
} }

View File

@@ -1,4 +1,3 @@
using System.Linq;
using System.Numerics; using System.Numerics;
using Content.Shared.Actions; using Content.Shared.Actions;
using Content.Shared.Body.Components; using Content.Shared.Body.Components;
@@ -27,8 +26,6 @@ using Robust.Shared.Audio.Systems;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Map.Components; using Robust.Shared.Map.Components;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems; using Robust.Shared.Physics.Systems;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Random; using Robust.Shared.Random;
@@ -84,7 +81,6 @@ public abstract class SharedMagicSystem : EntitySystem
SubscribeLocalEvent<RandomGlobalSpawnSpellEvent>(OnRandomGlobalSpawnSpell); SubscribeLocalEvent<RandomGlobalSpawnSpellEvent>(OnRandomGlobalSpawnSpell);
SubscribeLocalEvent<MindSwapSpellEvent>(OnMindSwapSpell); SubscribeLocalEvent<MindSwapSpellEvent>(OnMindSwapSpell);
SubscribeLocalEvent<VoidApplauseSpellEvent>(OnVoidApplause); SubscribeLocalEvent<VoidApplauseSpellEvent>(OnVoidApplause);
SubscribeLocalEvent<AnimateSpellEvent>(OnAnimateSpell);
} }
private void OnBeforeCastSpell(Entity<MagicComponent> ent, ref BeforeCastSpellEvent args) private void OnBeforeCastSpell(Entity<MagicComponent> ent, ref BeforeCastSpellEvent args)
@@ -301,7 +297,8 @@ public abstract class SharedMagicSystem : EntitySystem
return; return;
ev.Handled = true; ev.Handled = true;
Speak(ev); if (ev.DoSpeech)
Speak(ev);
RemoveComponents(ev.Target, ev.ToRemove); RemoveComponents(ev.Target, ev.ToRemove);
AddComponents(ev.Target, ev.ToAdd); AddComponents(ev.Target, ev.ToAdd);
@@ -532,33 +529,6 @@ public abstract class SharedMagicSystem : EntitySystem
_stun.TryParalyze(ev.Performer, ev.PerformerStunDuration, true); _stun.TryParalyze(ev.Performer, ev.PerformerStunDuration, true);
} }
#endregion
#region Animation Spells
private void OnAnimateSpell(AnimateSpellEvent ev)
{
if (ev.Handled || !PassesSpellPrerequisites(ev.Action, ev.Performer) || !TryComp<FixturesComponent>(ev.Target, out var fixtures) ||
!TryComp<PhysicsComponent>(ev.Target, out var physics))
return;
ev.Handled = true;
//Speak(ev);
RemoveComponents(ev.Target, ev.RemoveComponents);
AddComponents(ev.Target, ev.AddComponents);
var xform = Transform(ev.Target);
var fixture = fixtures.Fixtures.First();
_transform.Unanchor(ev.Target);
_physics.SetCanCollide(ev.Target, true, true, false, fixtures, physics);
_physics.SetCollisionMask(ev.Target, fixture.Key, fixture.Value, (int)CollisionGroup.FlyingMobMask, fixtures, physics);
_physics.SetCollisionLayer(ev.Target, fixture.Key, fixture.Value, (int)CollisionGroup.FlyingMobLayer, fixtures, physics);
_physics.SetBodyType(ev.Target, BodyType.KinematicController, fixtures, physics, xform);
_physics.SetBodyStatus(ev.Target, physics, BodyStatus.InAir, true);
_physics.SetFixedRotation(ev.Target, false, true, fixtures, physics);
}
#endregion #endregion
// End Spells // End Spells
#endregion #endregion

View File

@@ -0,0 +1,48 @@
using Content.Shared.Magic.Components;
using Content.Shared.Physics;
using Robust.Shared.Containers;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Systems;
using System.Linq;
namespace Content.Shared.Magic.Systems;
public sealed class AnimateSpellSystem : EntitySystem
{
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
public override void Initialize()
{
SubscribeLocalEvent<AnimateComponent, MapInitEvent>(OnAnimate);
}
private void OnAnimate(Entity<AnimateComponent> ent, ref MapInitEvent args)
{
// Physics bullshittery necessary for object to behave properly
if (!TryComp<FixturesComponent>(ent, out var fixtures) || !TryComp<PhysicsComponent>(ent, out var physics))
return;
var xform = Transform(ent);
var fixture = fixtures.Fixtures.First();
_transform.Unanchor(ent); // If left anchored they are effectively stuck/immobile and not a threat
_physics.SetCanCollide(ent, true, true, false, fixtures, physics);
_physics.SetCollisionMask(ent, fixture.Key, fixture.Value, (int)CollisionGroup.FlyingMobMask, fixtures, physics);
_physics.SetCollisionLayer(ent, fixture.Key, fixture.Value, (int)CollisionGroup.FlyingMobLayer, fixtures, physics);
_physics.SetBodyType(ent, BodyType.KinematicController, fixtures, physics, xform);
_physics.SetBodyStatus(ent, physics, BodyStatus.InAir, true);
_physics.SetFixedRotation(ent, false, true, fixtures, physics);
_physics.SetHard(ent, fixture.Value, true, fixtures);
_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);
}
}
[ByRefEvent]
public readonly record struct AnimateSpellEvent;

View File

@@ -9,13 +9,16 @@
itemIconStyle: BigAction itemIconStyle: BigAction
whitelist: whitelist:
components: components:
- Animateable # Currently on: SeatBase, TableBase, ClosetBase, BaseMachine, ConstructibleMachine, BaseComputer, BaseItem, CrateGeneric, StorageTank, GasCanister - Animateable # Currently on: SeatBase, TableBase, ClosetBase, BaseMachine, ConstructibleMachine, BaseComputer, BaseItem, CrateGeneric, StorageTank, GasCanister, BaseTarget
blacklist: blacklist:
components: components:
- MindContainer - MindContainer
- NukeDisk - NukeDisk
- GravityGenerator - GravityGenerator
- AnomalyGenerator - AnomalyGenerator
- TegGenerator
- TegCirculator
- Artifact
canTargetSelf: false canTargetSelf: false
interactOnMiss: false interactOnMiss: false
sound: !type:SoundPathSpecifier sound: !type:SoundPathSpecifier
@@ -23,8 +26,9 @@
icon: icon:
sprite: Objects/Magic/magicactions.rsi sprite: Objects/Magic/magicactions.rsi
state: spell_default state: spell_default
event: !type:AnimateSpellEvent event: !type:ChangeComponentsSpellEvent
addComponents: toAdd:
- type: Animate
- type: MindContainer - type: MindContainer
- type: InputMover - type: InputMover
- type: MobMover - type: MobMover
@@ -65,6 +69,9 @@
collection: MetalBreak collection: MetalBreak
- type: Hands - type: Hands
- type: CanEscapeInventory - type: CanEscapeInventory
removeComponents: toRemove:
- RequireProjectileTarget - RequireProjectileTarget
- BlockMovement
- Item
speech: action-speech-spell-animate speech: action-speech-spell-animate
doSpeech: false

View File

@@ -181,8 +181,6 @@
orGroup: Magics orGroup: Magics
- id: BlinkBook - id: BlinkBook
orGroup: Magics orGroup: Magics
- id: SmiteBook
orGroup: Magics
- id: KnockSpellbook - id: KnockSpellbook
orGroup: Magics orGroup: Magics
- id: FireballSpellbook - id: FireballSpellbook
@@ -203,4 +201,8 @@
orGroup: Magics orGroup: Magics
- id: WeaponStaffPolymorphDoor - id: WeaponStaffPolymorphDoor
orGroup: Magics orGroup: Magics
- id: AnimationStaff
orGroup: Magics
- id: RGBStaff
orGroup: Magics
speech: action-speech-spell-summon-magic speech: action-speech-spell-summon-magic

View File

@@ -27,6 +27,7 @@
hostile: hostile:
- PetsNT - PetsNT
- AllHostile - AllHostile
- Wizard
- type: npcFaction - type: npcFaction
id: Passive id: Passive
@@ -39,6 +40,7 @@
- Zombie - Zombie
- Xeno - Xeno
- AllHostile - AllHostile
- Wizard
- type: npcFaction - type: npcFaction
id: SimpleHostile id: SimpleHostile
@@ -123,7 +125,11 @@
hostile: hostile:
- NanoTrasen - NanoTrasen
- Dragon - Dragon
- Mouse
- Passive
- PetsNT
- SimpleHostile - SimpleHostile
- SimpleNeutral
- Syndicate - Syndicate
- Xeno - Xeno
- Zombie - Zombie