* 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

@@ -0,0 +1,31 @@
using Content.Shared._White.Animations;
using Content.Shared.Clothing.Components;
using Content.Shared.Inventory.Events;
namespace Content.Shared.Clothing.EntitySystems;
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

@@ -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);
}

View File

@@ -1,30 +1,20 @@
using System.Numerics;
using Robust.Shared.Serialization;
namespace Content.Shared.Movement.Components;
namespace Content.Shared._White.Animations;
/// <summary>
/// Declares that an entity has started to waddle like a duck/clown.
/// </summary>
/// <param name="Entity">The newly be-waddled.</param>
[ByRefEvent]
public record struct StartedWaddlingEvent(EntityUid Entity)
[Serializable, NetSerializable]
public sealed class StartedWaddlingEvent(NetEntity user) : EntityEventArgs
{
public EntityUid Entity = Entity;
public NetEntity User = user;
}
/// <summary>
/// Declares that an entity has stopped waddling like a duck/clown.
/// </summary>
/// <param name="Entity">The former waddle-er.</param>
[ByRefEvent]
public record struct StoppedWaddlingEvent(EntityUid Entity)
[Serializable, NetSerializable]
public sealed class StoppedWaddlingEvent(NetEntity user) : EntityEventArgs
{
public EntityUid Entity = Entity;
public NetEntity User = user;
}
/// <summary>
/// Defines something as having a waddle animation when it moves.
/// </summary>
[RegisterComponent]
public sealed partial class WaddleAnimationComponent : Component
{

View File

@@ -1,4 +1,5 @@
using System.Linq;
using Content.Shared._White.OfferItem;
using Content.Shared.Body.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Implants.Components;
@@ -30,6 +31,7 @@ public sealed class HardlightSpearSystem : EntitySystem
SubscribeLocalEvent<HardlightSpearComponent, LandEvent>(OnLand);
SubscribeLocalEvent<HardlightSpearComponent, DroppedEvent>(OnDrop);
SubscribeLocalEvent<HardlightSpearComponent, HandedEvent>(OnHanded);
SubscribeLocalEvent<HardlightSpearComponent, EntGotInsertedIntoContainerMessage>(OnInsert);
SubscribeLocalEvent<HardlightSpearComponent, GettingPickedUpAttemptEvent>(OnPickupAttempt);
SubscribeLocalEvent<HardlightSpearComponent, PreventCollideEvent>(OnPreventCollision);
@@ -96,4 +98,9 @@ public sealed class HardlightSpearSystem : EntitySystem
if (!HasComp<BodyComponent>(args.Container.Owner))
EnsureComp<TimedDespawnComponent>(uid);
}
private void OnHanded(EntityUid uid, HardlightSpearComponent component, ref HandedEvent args)
{
EnsureComp<TimedDespawnComponent>(uid);
}
}

View File

@@ -156,3 +156,11 @@ public abstract partial class SharedOfferItemSystem : EntitySystem
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;
}