* fix: Ботинки клоуна сново работают

* fix: Световое копье теперь исчезает если его передать
This commit is contained in:
Spatison
2024-07-30 03:13:05 +03:00
committed by GitHub
parent 74e1f3c618
commit 397e74079b
8 changed files with 115 additions and 96 deletions

View File

@@ -1,31 +0,0 @@
using Content.Shared.Clothing.Components;
using Content.Shared.Movement.Components;
using Content.Shared.Inventory.Events;
namespace Content.Client.Clothing.Systems;
public sealed class WaddleClothingSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<WaddleWhenWornComponent, GotEquippedEvent>(OnGotEquipped);
SubscribeLocalEvent<WaddleWhenWornComponent, GotUnequippedEvent>(OnGotUnequipped);
}
private void OnGotEquipped(EntityUid entity, WaddleWhenWornComponent comp, GotEquippedEvent args)
{
var waddleAnimComp = EnsureComp<WaddleAnimationComponent>(args.Equipee);
waddleAnimComp.AnimationLength = comp.AnimationLength;
waddleAnimComp.HopIntensity = comp.HopIntensity;
waddleAnimComp.RunAnimationLengthMultiplier = comp.RunAnimationLengthMultiplier;
waddleAnimComp.TumbleIntensity = comp.TumbleIntensity;
}
private void OnGotUnequipped(EntityUid entity, WaddleWhenWornComponent comp, GotUnequippedEvent args)
{
RemComp<WaddleAnimationComponent>(args.Equipee);
}
}

View File

@@ -1,89 +1,37 @@
using System.Numerics;
using Content.Client.Gravity;
using Content.Shared.Rotation;
using Content.Shared._White.Animations;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Events;
using Robust.Client.Animations;
using Robust.Client.GameObjects;
using Robust.Shared.Animations;
using Robust.Shared.Timing;
namespace Content.Client.Movement.Systems;
namespace Content.Client._White.Animations;
public sealed class WaddleAnimationSystem : EntitySystem
public sealed class WaddleAnimationSystem : SharedWaddledAnimationSystem
{
[Dependency] private readonly AnimationPlayerSystem _animation = default!;
[Dependency] private readonly GravitySystem _gravity = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly AppearanceSystem _appearance = default!; // WD EDIT
public override void Initialize()
{
SubscribeLocalEvent<WaddleAnimationComponent, MoveInputEvent>(OnMovementInput);
SubscribeLocalEvent<WaddleAnimationComponent, StartedWaddlingEvent>(OnStartedWalking);
SubscribeLocalEvent<WaddleAnimationComponent, StoppedWaddlingEvent>(OnStoppedWalking);
SubscribeLocalEvent<WaddleAnimationComponent, AnimationCompletedEvent>(OnAnimationCompleted);
SubscribeAllEvent<StartedWaddlingEvent>(ev => PlayAnimation(GetEntity(ev.User)));
SubscribeAllEvent<StoppedWaddlingEvent>(ev => StopAnimation(GetEntity(ev.User)));
}
private void OnMovementInput(EntityUid entity, WaddleAnimationComponent component, MoveInputEvent args)
protected override void PlayAnimation(EntityUid uid)
{
// 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;
}
// WD EDIT
_appearance.TryGetData<RotationState>(entity, RotationVisuals.RotationState, out var state);
if (state is RotationState.Horizontal)
return;
// WD EDIT
if (!args.HasDirectionalMovement && component.IsCurrentlyWaddling)
{
component.IsCurrentlyWaddling = false;
var stopped = new StoppedWaddlingEvent(entity);
RaiseLocalEvent(entity, ref stopped);
return;
}
// Only start waddling if we're not currently AND we're actually moving.
if (component.IsCurrentlyWaddling || !args.HasDirectionalMovement)
if (!Timing.IsFirstTimePredicted)
return;
component.IsCurrentlyWaddling = true;
var started = new StartedWaddlingEvent(entity);
RaiseLocalEvent(entity, ref started);
}
private void OnStartedWalking(EntityUid uid, WaddleAnimationComponent component, StartedWaddlingEvent args)
{
if (_animation.HasRunningAnimation(uid, component.KeyName))
{
if (!TryComp<WaddleAnimationComponent>(uid, out var component))
return;
}
if (!TryComp<InputMoverComponent>(uid, out var mover))
{
return;
}
if (_gravity.IsWeightless(uid))
{
if (_animation.HasRunningAnimation(uid, component.KeyName))
return;
}
// WD EDIT
_appearance.TryGetData<RotationState>(uid, RotationVisuals.RotationState, out var state);
if (TryComp<SpriteComponent>(uid, out var sprite) && TryComp<RotationVisualsComponent>(uid, out var rotat) && state is RotationState.Horizontal)
return;
// WD EDIT
var tumbleIntensity = component.LastStep ? 360 - component.TumbleIntensity : component.TumbleIntensity;
var len = mover.Sprinting ? component.AnimationLength * component.RunAnimationLengthMultiplier : component.AnimationLength;
@@ -126,14 +74,15 @@ public sealed class WaddleAnimationSystem : EntitySystem
_animation.Play(uid, anim, component.KeyName);
}
private void OnStoppedWalking(EntityUid uid, WaddleAnimationComponent component, StoppedWaddlingEvent args)
protected override void StopAnimation(EntityUid uid)
{
_animation.Stop(uid, component.KeyName);
if (!TryComp<WaddleAnimationComponent>(uid, out var component))
return;
if (!TryComp<SpriteComponent>(uid, out var sprite))
{
return;
}
_animation.Stop(uid, component.KeyName);
sprite.Offset = new Vector2();
sprite.Rotation = Angle.FromDegrees(0);
@@ -142,13 +91,9 @@ public sealed class WaddleAnimationSystem : EntitySystem
private void OnAnimationCompleted(EntityUid uid, WaddleAnimationComponent component, AnimationCompletedEvent args)
{
if (args.Key is not "Waddle") // WD EDIT
{
component.IsCurrentlyWaddling = false;
if (args.Key != component.KeyName)
return;
}
var started = new StartedWaddlingEvent(uid);
RaiseLocalEvent(uid, ref started);
PlayAnimation(uid);
}
}