From 029e5ad7ff7468fb47fe061c2353aebf475b6c13 Mon Sep 17 00:00:00 2001 From: Golinth Date: Sun, 6 Oct 2024 08:33:02 -0500 Subject: [PATCH] Fully Revert Clown Waddling (#32652) Fully revert Clown Waddling (revival of #29161) A sad day, see #29156 for discussion --- .../Movement/Systems/WaddleAnimationSystem.cs | 149 ------------------ .../Movement/Systems/WaddleAnimationSystem.cs | 5 - .../Components/WaddleWhenWornComponent.cs | 36 ----- .../EntitySystems/WaddleClothingSystem.cs | 32 ---- .../Components/WaddleAnimationComponent.cs | 74 --------- .../Systems/SharedWaddleAnimationSystem.cs | 106 ------------- .../Entities/Clothing/Shoes/misc.yml | 2 - .../Entities/Clothing/Shoes/specific.yml | 1 - 8 files changed, 405 deletions(-) delete mode 100644 Content.Client/Movement/Systems/WaddleAnimationSystem.cs delete mode 100644 Content.Server/Movement/Systems/WaddleAnimationSystem.cs delete mode 100644 Content.Shared/Clothing/Components/WaddleWhenWornComponent.cs delete mode 100644 Content.Shared/Clothing/EntitySystems/WaddleClothingSystem.cs delete mode 100644 Content.Shared/Movement/Components/WaddleAnimationComponent.cs delete mode 100644 Content.Shared/Movement/Systems/SharedWaddleAnimationSystem.cs diff --git a/Content.Client/Movement/Systems/WaddleAnimationSystem.cs b/Content.Client/Movement/Systems/WaddleAnimationSystem.cs deleted file mode 100644 index 0ed2d04f694af5..00000000000000 --- a/Content.Client/Movement/Systems/WaddleAnimationSystem.cs +++ /dev/null @@ -1,149 +0,0 @@ -using System.Numerics; -using Content.Client.Buckle; -using Content.Client.Gravity; -using Content.Shared.ActionBlocker; -using Content.Shared.Mobs.Systems; -using Content.Shared.Movement.Components; -using Content.Shared.Movement.Systems; -using Robust.Client.Animations; -using Robust.Client.GameObjects; -using Robust.Shared.Animations; - -namespace Content.Client.Movement.Systems; - -public sealed class WaddleAnimationSystem : SharedWaddleAnimationSystem -{ - [Dependency] private readonly AnimationPlayerSystem _animation = default!; - [Dependency] private readonly GravitySystem _gravity = default!; - [Dependency] private readonly ActionBlockerSystem _actionBlocker = default!; - [Dependency] private readonly BuckleSystem _buckle = default!; - [Dependency] private readonly MobStateSystem _mobState = default!; - - public override void Initialize() - { - base.Initialize(); - - SubscribeAllEvent(OnStartWaddling); - SubscribeLocalEvent(OnAnimationCompleted); - SubscribeAllEvent(OnStopWaddling); - } - - private void OnStartWaddling(StartedWaddlingEvent msg, EntitySessionEventArgs args) - { - if (TryComp(GetEntity(msg.Entity), out var comp)) - StartWaddling((GetEntity(msg.Entity), comp)); - } - - private void OnStopWaddling(StoppedWaddlingEvent msg, EntitySessionEventArgs args) - { - if (TryComp(GetEntity(msg.Entity), out var comp)) - StopWaddling((GetEntity(msg.Entity), comp)); - } - - private void StartWaddling(Entity entity) - { - if (_animation.HasRunningAnimation(entity.Owner, entity.Comp.KeyName)) - return; - - if (!TryComp(entity.Owner, out var mover)) - return; - - if (_gravity.IsWeightless(entity.Owner)) - return; - - if (!_actionBlocker.CanMove(entity.Owner, mover)) - return; - - // Do nothing if buckled in - if (_buckle.IsBuckled(entity.Owner)) - return; - - // Do nothing if crit or dead (for obvious reasons) - if (_mobState.IsIncapacitated(entity.Owner)) - return; - - PlayWaddleAnimationUsing( - (entity.Owner, entity.Comp), - CalculateAnimationLength(entity.Comp, mover), - CalculateTumbleIntensity(entity.Comp) - ); - } - - private static float CalculateTumbleIntensity(WaddleAnimationComponent component) - { - return component.LastStep ? 360 - component.TumbleIntensity : component.TumbleIntensity; - } - - private static float CalculateAnimationLength(WaddleAnimationComponent component, InputMoverComponent mover) - { - return mover.Sprinting ? component.AnimationLength * component.RunAnimationLengthMultiplier : component.AnimationLength; - } - - private void OnAnimationCompleted(Entity entity, ref AnimationCompletedEvent args) - { - if (args.Key != entity.Comp.KeyName) - return; - - if (!TryComp(entity.Owner, out var mover)) - return; - - PlayWaddleAnimationUsing( - (entity.Owner, entity.Comp), - CalculateAnimationLength(entity.Comp, mover), - CalculateTumbleIntensity(entity.Comp) - ); - } - - private void StopWaddling(Entity entity) - { - if (!_animation.HasRunningAnimation(entity.Owner, entity.Comp.KeyName)) - return; - - _animation.Stop(entity.Owner, entity.Comp.KeyName); - - if (!TryComp(entity.Owner, out var sprite)) - return; - - sprite.Offset = new Vector2(); - sprite.Rotation = Angle.FromDegrees(0); - } - - private void PlayWaddleAnimationUsing(Entity entity, float len, float tumbleIntensity) - { - entity.Comp.LastStep = !entity.Comp.LastStep; - - var anim = new Animation() - { - Length = TimeSpan.FromSeconds(len), - AnimationTracks = - { - new AnimationTrackComponentProperty() - { - ComponentType = typeof(SpriteComponent), - Property = nameof(SpriteComponent.Rotation), - InterpolationMode = AnimationInterpolationMode.Linear, - KeyFrames = - { - new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(0), 0), - new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(tumbleIntensity), len/2), - new AnimationTrackProperty.KeyFrame(Angle.FromDegrees(0), len/2), - } - }, - new AnimationTrackComponentProperty() - { - ComponentType = typeof(SpriteComponent), - Property = nameof(SpriteComponent.Offset), - InterpolationMode = AnimationInterpolationMode.Linear, - KeyFrames = - { - new AnimationTrackProperty.KeyFrame(new Vector2(), 0), - new AnimationTrackProperty.KeyFrame(entity.Comp.HopIntensity, len/2), - new AnimationTrackProperty.KeyFrame(new Vector2(), len/2), - } - } - } - }; - - _animation.Play(entity.Owner, anim, entity.Comp.KeyName); - } -} diff --git a/Content.Server/Movement/Systems/WaddleAnimationSystem.cs b/Content.Server/Movement/Systems/WaddleAnimationSystem.cs deleted file mode 100644 index e6083210e1bffa..00000000000000 --- a/Content.Server/Movement/Systems/WaddleAnimationSystem.cs +++ /dev/null @@ -1,5 +0,0 @@ -using Content.Shared.Movement.Systems; - -namespace Content.Server.Movement.Systems; - -public sealed class WaddleAnimationSystem : SharedWaddleAnimationSystem; diff --git a/Content.Shared/Clothing/Components/WaddleWhenWornComponent.cs b/Content.Shared/Clothing/Components/WaddleWhenWornComponent.cs deleted file mode 100644 index fb7490ef4fbec5..00000000000000 --- a/Content.Shared/Clothing/Components/WaddleWhenWornComponent.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Numerics; -using Robust.Shared.GameStates; - -namespace Content.Shared.Clothing.Components; - -/// -/// Defines something as causing waddling when worn. -/// -[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] -public sealed partial class WaddleWhenWornComponent : Component -{ - /// - /// How high should they hop during the waddle? Higher hop = more energy. - /// - [DataField, AutoNetworkedField] - public Vector2 HopIntensity = new(0, 0.25f); - - /// - /// How far should they rock backward and forward during the waddle? - /// Each step will alternate between this being a positive and negative rotation. More rock = more scary. - /// - [DataField, AutoNetworkedField] - public float TumbleIntensity = 20.0f; - - /// - /// How long should a complete step take? Less time = more chaos. - /// - [DataField, AutoNetworkedField] - public float AnimationLength = 0.66f; - - /// - /// How much shorter should the animation be when running? - /// - [DataField, AutoNetworkedField] - public float RunAnimationLengthMultiplier = 0.568f; -} diff --git a/Content.Shared/Clothing/EntitySystems/WaddleClothingSystem.cs b/Content.Shared/Clothing/EntitySystems/WaddleClothingSystem.cs deleted file mode 100644 index b445eb258e9a1a..00000000000000 --- a/Content.Shared/Clothing/EntitySystems/WaddleClothingSystem.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Content.Shared.Clothing; -using Content.Shared.Clothing.Components; -using Content.Shared.Movement.Components; -using Content.Shared.Inventory.Events; - -namespace Content.Shared.Clothing.EntitySystems; - -public sealed class WaddleClothingSystem : EntitySystem -{ - public override void Initialize() - { - base.Initialize(); - - SubscribeLocalEvent(OnGotEquipped); - SubscribeLocalEvent(OnGotUnequipped); - } - - private void OnGotEquipped(EntityUid entity, WaddleWhenWornComponent comp, ClothingGotEquippedEvent args) - { - var waddleAnimComp = EnsureComp(args.Wearer); - - waddleAnimComp.AnimationLength = comp.AnimationLength; - waddleAnimComp.HopIntensity = comp.HopIntensity; - waddleAnimComp.RunAnimationLengthMultiplier = comp.RunAnimationLengthMultiplier; - waddleAnimComp.TumbleIntensity = comp.TumbleIntensity; - } - - private void OnGotUnequipped(EntityUid entity, WaddleWhenWornComponent comp, ClothingGotUnequippedEvent args) - { - RemComp(args.Wearer); - } -} diff --git a/Content.Shared/Movement/Components/WaddleAnimationComponent.cs b/Content.Shared/Movement/Components/WaddleAnimationComponent.cs deleted file mode 100644 index 3cd9a3749e81c1..00000000000000 --- a/Content.Shared/Movement/Components/WaddleAnimationComponent.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System.Numerics; -using Robust.Shared.Serialization; - -namespace Content.Shared.Movement.Components; - -/// -/// Declares that an entity has started to waddle like a duck/clown. -/// -/// The newly be-waddled. -[Serializable, NetSerializable] -public sealed class StartedWaddlingEvent(NetEntity entity) : EntityEventArgs -{ - public NetEntity Entity = entity; -} - -/// -/// Declares that an entity has stopped waddling like a duck/clown. -/// -/// The former waddle-er. -[Serializable, NetSerializable] -public sealed class StoppedWaddlingEvent(NetEntity entity) : EntityEventArgs -{ - public NetEntity Entity = entity; -} - -/// -/// Defines something as having a waddle animation when it moves. -/// -[RegisterComponent, AutoGenerateComponentState] -public sealed partial class WaddleAnimationComponent : Component -{ - /// - /// What's the name of this animation? Make sure it's unique so it can play along side other animations. - /// This prevents someone accidentally causing two identical waddling effects to play on someone at the same time. - /// - [DataField] - public string KeyName = "Waddle"; - - /// - /// How high should they hop during the waddle? Higher hop = more energy. - /// - [DataField, AutoNetworkedField] - public Vector2 HopIntensity = new(0, 0.25f); - - /// - /// How far should they rock backward and forward during the waddle? - /// Each step will alternate between this being a positive and negative rotation. More rock = more scary. - /// - [DataField, AutoNetworkedField] - public float TumbleIntensity = 20.0f; - - /// - /// How long should a complete step take? Less time = more chaos. - /// - [DataField, AutoNetworkedField] - public float AnimationLength = 0.66f; - - /// - /// How much shorter should the animation be when running? - /// - [DataField, AutoNetworkedField] - public float RunAnimationLengthMultiplier = 0.568f; - - /// - /// Stores which step we made last, so if someone cancels out of the animation mid-step then restarts it looks more natural. - /// - public bool LastStep; - - /// - /// Stores if we're currently waddling so we can start/stop as appropriate and can tell other systems our state. - /// - [AutoNetworkedField] - public bool IsCurrentlyWaddling; -} diff --git a/Content.Shared/Movement/Systems/SharedWaddleAnimationSystem.cs b/Content.Shared/Movement/Systems/SharedWaddleAnimationSystem.cs deleted file mode 100644 index cebae8093b4015..00000000000000 --- a/Content.Shared/Movement/Systems/SharedWaddleAnimationSystem.cs +++ /dev/null @@ -1,106 +0,0 @@ -using Content.Shared.Buckle.Components; -using Content.Shared.Gravity; -using Content.Shared.Movement.Components; -using Content.Shared.Movement.Events; -using Content.Shared.Movement.Systems; -using Content.Shared.Standing; -using Content.Shared.Stunnable; -using Robust.Shared.Timing; - -namespace Content.Shared.Movement.Systems; - -public abstract class SharedWaddleAnimationSystem : EntitySystem -{ - [Dependency] private readonly IGameTiming _timing = default!; - - public override void Initialize() - { - // Startup - SubscribeLocalEvent(OnComponentStartup); - - // Start moving possibilities - SubscribeLocalEvent(OnMovementInput); - SubscribeLocalEvent(OnStood); - - // Stop moving possibilities - SubscribeLocalEvent((Entity ent, ref StunnedEvent _) => StopWaddling(ent)); - SubscribeLocalEvent((Entity ent, ref DownedEvent _) => StopWaddling(ent)); - SubscribeLocalEvent((Entity ent, ref BuckledEvent _) => StopWaddling(ent)); - SubscribeLocalEvent(OnGravityChanged); - } - - private void OnGravityChanged(Entity ent, ref GravityChangedEvent args) - { - if (!args.HasGravity && ent.Comp.IsCurrentlyWaddling) - StopWaddling(ent); - } - - private void OnComponentStartup(Entity entity, ref ComponentStartup args) - { - if (!TryComp(entity.Owner, out var moverComponent)) - return; - - // If the waddler is currently moving, make them start waddling - if ((moverComponent.HeldMoveButtons & MoveButtons.AnyDirection) == MoveButtons.AnyDirection) - { - RaiseNetworkEvent(new StartedWaddlingEvent(GetNetEntity(entity.Owner))); - } - } - - private void OnMovementInput(Entity entity, ref MoveInputEvent args) - { - // Prediction mitigation. Prediction means that MoveInputEvents are spammed repeatedly, even though you'd assume - // they're once-only for the user actually doing something. As such do nothing if we're just repeating this FoR. - if (!_timing.IsFirstTimePredicted) - { - return; - } - - if (!args.HasDirectionalMovement && entity.Comp.IsCurrentlyWaddling) - { - StopWaddling(entity); - - return; - } - - // Only start waddling if we're not currently AND we're actually moving. - if (entity.Comp.IsCurrentlyWaddling || !args.HasDirectionalMovement) - return; - - entity.Comp.IsCurrentlyWaddling = true; - - RaiseNetworkEvent(new StartedWaddlingEvent(GetNetEntity(entity.Owner))); - } - - private void OnStood(Entity entity, ref StoodEvent args) - { - // Prediction mitigation. Prediction means that MoveInputEvents are spammed repeatedly, even though you'd assume - // they're once-only for the user actually doing something. As such do nothing if we're just repeating this FoR. - if (!_timing.IsFirstTimePredicted) - { - return; - } - - if (!TryComp(entity.Owner, out var mover)) - { - return; - } - - if ((mover.HeldMoveButtons & MoveButtons.AnyDirection) == MoveButtons.None) - return; - - if (entity.Comp.IsCurrentlyWaddling) - return; - - entity.Comp.IsCurrentlyWaddling = true; - - RaiseNetworkEvent(new StartedWaddlingEvent(GetNetEntity(entity.Owner))); - } - - private void StopWaddling(Entity entity) - { - entity.Comp.IsCurrentlyWaddling = false; - - RaiseNetworkEvent(new StoppedWaddlingEvent(GetNetEntity(entity.Owner))); - } -} diff --git a/Resources/Prototypes/Entities/Clothing/Shoes/misc.yml b/Resources/Prototypes/Entities/Clothing/Shoes/misc.yml index ea4c9d9c7cdd78..61dda89d13720f 100644 --- a/Resources/Prototypes/Entities/Clothing/Shoes/misc.yml +++ b/Resources/Prototypes/Entities/Clothing/Shoes/misc.yml @@ -47,8 +47,6 @@ collection: FootstepDuck params: variation: 0.07 - - type: WaddleWhenWorn - tumbleIntensity: 10 # smaller than clown shoes - type: Construction graph: ClothingShoeSlippersDuck node: shoes diff --git a/Resources/Prototypes/Entities/Clothing/Shoes/specific.yml b/Resources/Prototypes/Entities/Clothing/Shoes/specific.yml index bd37135e98d7d1..a4fbe012c52a5b 100644 --- a/Resources/Prototypes/Entities/Clothing/Shoes/specific.yml +++ b/Resources/Prototypes/Entities/Clothing/Shoes/specific.yml @@ -15,7 +15,6 @@ parent: [ClothingShoesBaseButcherable, ClothingSlotBase] id: ClothingShoesClownBase components: - - type: WaddleWhenWorn - type: ItemSlots slots: item: