Fix (#513)
* fix: Ботинки клоуна сново работают * fix: Световое копье теперь исчезает если его передать
This commit is contained in:
@@ -1,89 +1,37 @@
|
|||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using Content.Client.Gravity;
|
using Content.Shared._White.Animations;
|
||||||
using Content.Shared.Rotation;
|
|
||||||
using Content.Shared.Movement.Components;
|
using Content.Shared.Movement.Components;
|
||||||
using Content.Shared.Movement.Events;
|
|
||||||
using Robust.Client.Animations;
|
using Robust.Client.Animations;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Shared.Animations;
|
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 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()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
SubscribeLocalEvent<WaddleAnimationComponent, MoveInputEvent>(OnMovementInput);
|
|
||||||
SubscribeLocalEvent<WaddleAnimationComponent, StartedWaddlingEvent>(OnStartedWalking);
|
|
||||||
SubscribeLocalEvent<WaddleAnimationComponent, StoppedWaddlingEvent>(OnStoppedWalking);
|
|
||||||
SubscribeLocalEvent<WaddleAnimationComponent, AnimationCompletedEvent>(OnAnimationCompleted);
|
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
|
if (!Timing.IsFirstTimePredicted)
|
||||||
// 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)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
component.IsCurrentlyWaddling = true;
|
if (!TryComp<WaddleAnimationComponent>(uid, out var component))
|
||||||
|
|
||||||
var started = new StartedWaddlingEvent(entity);
|
|
||||||
|
|
||||||
RaiseLocalEvent(entity, ref started);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnStartedWalking(EntityUid uid, WaddleAnimationComponent component, StartedWaddlingEvent args)
|
|
||||||
{
|
|
||||||
if (_animation.HasRunningAnimation(uid, component.KeyName))
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (!TryComp<InputMoverComponent>(uid, out var mover))
|
if (!TryComp<InputMoverComponent>(uid, out var mover))
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (_gravity.IsWeightless(uid))
|
if (_animation.HasRunningAnimation(uid, component.KeyName))
|
||||||
{
|
|
||||||
return;
|
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 tumbleIntensity = component.LastStep ? 360 - component.TumbleIntensity : component.TumbleIntensity;
|
||||||
var len = mover.Sprinting ? component.AnimationLength * component.RunAnimationLengthMultiplier : component.AnimationLength;
|
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);
|
_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))
|
if (!TryComp<SpriteComponent>(uid, out var sprite))
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
_animation.Stop(uid, component.KeyName);
|
||||||
|
|
||||||
sprite.Offset = new Vector2();
|
sprite.Offset = new Vector2();
|
||||||
sprite.Rotation = Angle.FromDegrees(0);
|
sprite.Rotation = Angle.FromDegrees(0);
|
||||||
@@ -142,13 +91,9 @@ public sealed class WaddleAnimationSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnAnimationCompleted(EntityUid uid, WaddleAnimationComponent component, AnimationCompletedEvent args)
|
private void OnAnimationCompleted(EntityUid uid, WaddleAnimationComponent component, AnimationCompletedEvent args)
|
||||||
{
|
{
|
||||||
if (args.Key is not "Waddle") // WD EDIT
|
if (args.Key != component.KeyName)
|
||||||
{
|
|
||||||
component.IsCurrentlyWaddling = false;
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
var started = new StartedWaddlingEvent(uid);
|
PlayAnimation(uid);
|
||||||
RaiseLocalEvent(uid, ref started);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
16
Content.Server/_White/Animations/WaddleAnimationSystem.cs
Normal file
16
Content.Server/_White/Animations/WaddleAnimationSystem.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using Content.Shared._White.Animations;
|
||||||
|
|
||||||
|
namespace Content.Server._White.Animations;
|
||||||
|
|
||||||
|
public sealed class WaddleAnimationSystem : SharedWaddledAnimationSystem
|
||||||
|
{
|
||||||
|
protected override void PlayAnimation(EntityUid user)
|
||||||
|
{
|
||||||
|
RaiseNetworkEvent(new StartedWaddlingEvent(GetNetEntity(user)));
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void StopAnimation(EntityUid user)
|
||||||
|
{
|
||||||
|
RaiseNetworkEvent(new StoppedWaddlingEvent(GetNetEntity(user)));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -69,12 +69,18 @@ public sealed class OfferItemSystem : SharedOfferItemSystem
|
|||||||
|
|
||||||
_popup.PopupEntity(Loc.GetString("offer-item-give",
|
_popup.PopupEntity(Loc.GetString("offer-item-give",
|
||||||
("item", Identity.Entity(offerItem.Item.Value, EntityManager)),
|
("item", Identity.Entity(offerItem.Item.Value, EntityManager)),
|
||||||
("target", Identity.Entity(uid, EntityManager))), component.Target.Value, component.Target.Value);
|
("target", Identity.Entity(uid, EntityManager))),
|
||||||
|
component.Target.Value,
|
||||||
|
component.Target.Value);
|
||||||
_popup.PopupEntity(Loc.GetString("offer-item-give-other",
|
_popup.PopupEntity(Loc.GetString("offer-item-give-other",
|
||||||
("user", Identity.Entity(component.Target.Value, EntityManager)),
|
("user", Identity.Entity(component.Target.Value, EntityManager)),
|
||||||
("item", Identity.Entity(offerItem.Item.Value, EntityManager)),
|
("item", Identity.Entity(offerItem.Item.Value, EntityManager)),
|
||||||
("target", Identity.Entity(uid, EntityManager)))
|
("target", Identity.Entity(uid, EntityManager))),
|
||||||
, component.Target.Value, Filter.PvsExcept(component.Target.Value, entityManager: EntityManager), true);
|
component.Target.Value,
|
||||||
|
Filter.PvsExcept(component.Target.Value, entityManager: EntityManager),
|
||||||
|
true);
|
||||||
|
|
||||||
|
RaiseLocalEvent(offerItem.Item.Value, new HandedEvent(component.Target.Value, uid));
|
||||||
}
|
}
|
||||||
|
|
||||||
offerItem.Item = null;
|
offerItem.Item = null;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
using Content.Shared.Clothing.Components;
|
using Content.Shared._White.Animations;
|
||||||
using Content.Shared.Movement.Components;
|
using Content.Shared.Clothing.Components;
|
||||||
using Content.Shared.Inventory.Events;
|
using Content.Shared.Inventory.Events;
|
||||||
|
|
||||||
namespace Content.Client.Clothing.Systems;
|
namespace Content.Shared.Clothing.EntitySystems;
|
||||||
|
|
||||||
public sealed class WaddleClothingSystem : EntitySystem
|
public sealed class WaddleClothingSystem : EntitySystem
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
using Content.Shared.Movement.Events;
|
||||||
|
using Content.Shared.Standing.Systems;
|
||||||
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
|
namespace Content.Shared._White.Animations;
|
||||||
|
|
||||||
|
public abstract class SharedWaddledAnimationSystem : EntitySystem
|
||||||
|
{
|
||||||
|
[Dependency] protected readonly IGameTiming Timing = default!;
|
||||||
|
[Dependency] private readonly SharedStandingStateSystem _standingState = default!;
|
||||||
|
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
base.Initialize();
|
||||||
|
|
||||||
|
SubscribeLocalEvent<WaddleAnimationComponent, MoveInputEvent>(OnMovementInput);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnMovementInput(EntityUid uid, WaddleAnimationComponent component, MoveInputEvent args)
|
||||||
|
{
|
||||||
|
if (!Timing.IsFirstTimePredicted)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_standingState.IsDown(uid))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!args.HasDirectionalMovement && component.IsCurrentlyWaddling)
|
||||||
|
{
|
||||||
|
component.IsCurrentlyWaddling = false;
|
||||||
|
|
||||||
|
StopAnimation(uid);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (component.IsCurrentlyWaddling || !args.HasDirectionalMovement)
|
||||||
|
return;
|
||||||
|
|
||||||
|
component.IsCurrentlyWaddling = true;
|
||||||
|
|
||||||
|
PlayAnimation(uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void PlayAnimation(EntityUid user);
|
||||||
|
|
||||||
|
protected abstract void StopAnimation(EntityUid user);
|
||||||
|
}
|
||||||
@@ -1,30 +1,20 @@
|
|||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
namespace Content.Shared.Movement.Components;
|
namespace Content.Shared._White.Animations;
|
||||||
|
|
||||||
/// <summary>
|
[Serializable, NetSerializable]
|
||||||
/// Declares that an entity has started to waddle like a duck/clown.
|
public sealed class StartedWaddlingEvent(NetEntity user) : EntityEventArgs
|
||||||
/// </summary>
|
|
||||||
/// <param name="Entity">The newly be-waddled.</param>
|
|
||||||
[ByRefEvent]
|
|
||||||
public record struct StartedWaddlingEvent(EntityUid Entity)
|
|
||||||
{
|
{
|
||||||
public EntityUid Entity = Entity;
|
public NetEntity User = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
[Serializable, NetSerializable]
|
||||||
/// Declares that an entity has stopped waddling like a duck/clown.
|
public sealed class StoppedWaddlingEvent(NetEntity user) : EntityEventArgs
|
||||||
/// </summary>
|
|
||||||
/// <param name="Entity">The former waddle-er.</param>
|
|
||||||
[ByRefEvent]
|
|
||||||
public record struct StoppedWaddlingEvent(EntityUid Entity)
|
|
||||||
{
|
{
|
||||||
public EntityUid Entity = Entity;
|
public NetEntity User = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Defines something as having a waddle animation when it moves.
|
|
||||||
/// </summary>
|
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public sealed partial class WaddleAnimationComponent : Component
|
public sealed partial class WaddleAnimationComponent : Component
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Content.Shared._White.OfferItem;
|
||||||
using Content.Shared.Body.Components;
|
using Content.Shared.Body.Components;
|
||||||
using Content.Shared.Hands.EntitySystems;
|
using Content.Shared.Hands.EntitySystems;
|
||||||
using Content.Shared.Implants.Components;
|
using Content.Shared.Implants.Components;
|
||||||
@@ -30,6 +31,7 @@ public sealed class HardlightSpearSystem : EntitySystem
|
|||||||
|
|
||||||
SubscribeLocalEvent<HardlightSpearComponent, LandEvent>(OnLand);
|
SubscribeLocalEvent<HardlightSpearComponent, LandEvent>(OnLand);
|
||||||
SubscribeLocalEvent<HardlightSpearComponent, DroppedEvent>(OnDrop);
|
SubscribeLocalEvent<HardlightSpearComponent, DroppedEvent>(OnDrop);
|
||||||
|
SubscribeLocalEvent<HardlightSpearComponent, HandedEvent>(OnHanded);
|
||||||
SubscribeLocalEvent<HardlightSpearComponent, EntGotInsertedIntoContainerMessage>(OnInsert);
|
SubscribeLocalEvent<HardlightSpearComponent, EntGotInsertedIntoContainerMessage>(OnInsert);
|
||||||
SubscribeLocalEvent<HardlightSpearComponent, GettingPickedUpAttemptEvent>(OnPickupAttempt);
|
SubscribeLocalEvent<HardlightSpearComponent, GettingPickedUpAttemptEvent>(OnPickupAttempt);
|
||||||
SubscribeLocalEvent<HardlightSpearComponent, PreventCollideEvent>(OnPreventCollision);
|
SubscribeLocalEvent<HardlightSpearComponent, PreventCollideEvent>(OnPreventCollision);
|
||||||
@@ -96,4 +98,9 @@ public sealed class HardlightSpearSystem : EntitySystem
|
|||||||
if (!HasComp<BodyComponent>(args.Container.Owner))
|
if (!HasComp<BodyComponent>(args.Container.Owner))
|
||||||
EnsureComp<TimedDespawnComponent>(uid);
|
EnsureComp<TimedDespawnComponent>(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnHanded(EntityUid uid, HardlightSpearComponent component, ref HandedEvent args)
|
||||||
|
{
|
||||||
|
EnsureComp<TimedDespawnComponent>(uid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,3 +156,11 @@ public abstract partial class SharedOfferItemSystem : EntitySystem
|
|||||||
return entity != null && Resolve(entity.Value, ref component, false) && component.IsInOfferMode;
|
return entity != null && Resolve(entity.Value, ref component, false) && component.IsInOfferMode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public sealed class HandedEvent(EntityUid user, EntityUid target) : EntityEventArgs
|
||||||
|
{
|
||||||
|
public EntityUid User = user;
|
||||||
|
public EntityUid Target = target;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user