mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 13:37:47 +03:00
* init * yupp * stuff for tonigth * death sprite * cleanup * added speech and passive regen * more cleanup * that if for today * stuff * fixed falling animation * yml split, and localisation * moved scale to serverside, linked bingle to pit for upgrade * Apply suggestions from durk Co-authored-by: Aiden <aiden@djkraz.com> * fixes * added upgrade sprite, added combat indicator * pit animation * added check for spawning in nullspace * trying to fix check error * test * Revert "test" * test 2 --------- Co-authored-by: unknown <Administrator@DESKTOP-PMRIVVA.kommune.indresogn.no> Co-authored-by: Fishbait <Fishbait@git.ml> Co-authored-by: Aiden <aiden@djkraz.com> (cherry picked from commit 6608e6eb74a870a882288ecd2af1cea6dcfc7a1a)
81 lines
2.7 KiB
C#
81 lines
2.7 KiB
C#
using Robust.Client.Animations;
|
|
using Robust.Client.GameObjects;
|
|
using Robust.Shared.Animations;
|
|
using Content.Shared._Goobstation.Bingle;
|
|
|
|
namespace Content.Client._Goobstation.Bingle;
|
|
|
|
/// <summary>
|
|
/// Handles the falling animation for entities that fall into a Binglepit. shamlesly copied from chasm
|
|
/// </summary>
|
|
public sealed class BingleFallingVisualsSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly AnimationPlayerSystem _anim = default!;
|
|
|
|
private readonly string _chasmFallAnimationKey = "chasm_fall";
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<BinglePitFallingComponent, ComponentInit>(OnComponentInit);
|
|
SubscribeLocalEvent<BinglePitFallingComponent, ComponentRemove>(OnComponentRemove);
|
|
}
|
|
|
|
private void OnComponentInit(EntityUid uid, BinglePitFallingComponent component, ComponentInit args)
|
|
{
|
|
if (!TryComp<SpriteComponent>(uid, out var sprite) ||
|
|
TerminatingOrDeleted(uid))
|
|
{
|
|
return;
|
|
}
|
|
|
|
component.OriginalScale = sprite.Scale;
|
|
|
|
var player = EnsureComp<AnimationPlayerComponent>(uid);
|
|
if (_anim.HasRunningAnimation(player, _chasmFallAnimationKey))
|
|
return;
|
|
|
|
_anim.Play((uid, player), GetFallingAnimation(component), _chasmFallAnimationKey);
|
|
}
|
|
|
|
private void OnComponentRemove(EntityUid uid, BinglePitFallingComponent component, ComponentRemove args)
|
|
{
|
|
if (!TryComp<SpriteComponent>(uid, out var sprite) || TerminatingOrDeleted(uid))
|
|
return;
|
|
|
|
if (!TryComp<AnimationPlayerComponent>(uid, out var player))
|
|
return;
|
|
|
|
//var player = EnsureComp<AnimationPlayerComponent>(uid);
|
|
if (_anim.HasRunningAnimation(player, _chasmFallAnimationKey))
|
|
_anim.Stop(player, _chasmFallAnimationKey);
|
|
|
|
sprite.Scale = component.OriginalScale;
|
|
}
|
|
|
|
private Animation GetFallingAnimation(BinglePitFallingComponent component)
|
|
{
|
|
var length = component.AnimationTime;
|
|
|
|
return new Animation()
|
|
{
|
|
Length = length,
|
|
AnimationTracks =
|
|
{
|
|
new AnimationTrackComponentProperty()
|
|
{
|
|
ComponentType = typeof(SpriteComponent),
|
|
Property = nameof(SpriteComponent.Scale),
|
|
KeyFrames =
|
|
{
|
|
new AnimationTrackProperty.KeyFrame(component.OriginalScale, 0.0f),
|
|
new AnimationTrackProperty.KeyFrame(component.AnimationScale, length.Seconds),
|
|
},
|
|
InterpolationMode = AnimationInterpolationMode.Cubic
|
|
}
|
|
}
|
|
};
|
|
}
|
|
}
|