* 1 warning in KudzuVisualizerSystem * 2 warnings in ChameleonProjectorSystem * 1 warning in MarkerSystem * 2 warnings in ItemSystem * 1 warning in GhostToggleSelfVisibility * 1 warning in FoamVisualizerSystem * 1 warning in ClickableTest * 1 warning in ThrownItemVisualizerSystem * 2 warnings in InfantSystem * 1 warning in ChasmFallingVisualsSystem * 1 warning in PotencyVisualsSystem * 2 warnings in OrbitVisualsSystem * 2 warnings in BeamSystem * 1 warning in JitteringSystem * 1 warning in CardboardBoxSystem * 2 warnings in StationAiSystem * 2 warnings in FirelockSystem * 2 warnings in CargoSystem.Telepad * 1 warning in StasisBedSystem * 2 warnings in WeldableVisualizerSystem * 2 warnings in DeliveryVisualizerSystem * 1 warning in TimerTriggerVisualizerSystem * 1 warning in StorageFillVisualizerSystem * 2 warnings in RadiationCollectorSystem * 2 warnings in BorgSwitchableTypeSystem * 1 warning in TurnstileSystem * 1 warning in SurveillanceCameraVisualsSystem * 1 warning in BurnStateVisualizerSystem * 2 warnings in CableVisualizerSystem * 1 warning in JetpackSystem
107 lines
3.4 KiB
C#
107 lines
3.4 KiB
C#
using Content.Shared.Cargo;
|
|
using Content.Shared.Cargo.Components;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.Animations;
|
|
using Robust.Client.GameObjects;
|
|
using Robust.Client.Graphics;
|
|
|
|
namespace Content.Client.Cargo.Systems;
|
|
|
|
public sealed partial class CargoSystem
|
|
{
|
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
|
[Dependency] private readonly SpriteSystem _sprite = default!;
|
|
|
|
private static readonly Animation CargoTelepadBeamAnimation = new()
|
|
{
|
|
Length = TimeSpan.FromSeconds(0.5),
|
|
AnimationTracks =
|
|
{
|
|
new AnimationTrackSpriteFlick
|
|
{
|
|
LayerKey = CargoTelepadLayers.Beam,
|
|
KeyFrames =
|
|
{
|
|
new AnimationTrackSpriteFlick.KeyFrame(new RSI.StateId("beam"), 0f)
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
private static readonly Animation CargoTelepadIdleAnimation = new()
|
|
{
|
|
Length = TimeSpan.FromSeconds(0.8),
|
|
AnimationTracks =
|
|
{
|
|
new AnimationTrackSpriteFlick
|
|
{
|
|
LayerKey = CargoTelepadLayers.Beam,
|
|
KeyFrames =
|
|
{
|
|
new AnimationTrackSpriteFlick.KeyFrame(new RSI.StateId("idle"), 0f)
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
private const string TelepadBeamKey = "cargo-telepad-beam";
|
|
private const string TelepadIdleKey = "cargo-telepad-idle";
|
|
|
|
private void InitializeCargoTelepad()
|
|
{
|
|
SubscribeLocalEvent<CargoTelepadComponent, AppearanceChangeEvent>(OnCargoAppChange);
|
|
SubscribeLocalEvent<CargoTelepadComponent, AnimationCompletedEvent>(OnCargoAnimComplete);
|
|
}
|
|
|
|
private void OnCargoAppChange(EntityUid uid, CargoTelepadComponent component, ref AppearanceChangeEvent args)
|
|
{
|
|
OnChangeData(uid, args.Sprite);
|
|
}
|
|
|
|
private void OnCargoAnimComplete(EntityUid uid, CargoTelepadComponent component, AnimationCompletedEvent args)
|
|
{
|
|
OnChangeData(uid);
|
|
}
|
|
|
|
private void OnChangeData(EntityUid uid, SpriteComponent? sprite = null)
|
|
{
|
|
if (!Resolve(uid, ref sprite))
|
|
return;
|
|
|
|
if (!TryComp<AnimationPlayerComponent>(uid, out var player))
|
|
return;
|
|
|
|
_appearance.TryGetData<CargoTelepadState?>(uid, CargoTelepadVisuals.State, out var state);
|
|
|
|
switch (state)
|
|
{
|
|
case CargoTelepadState.Teleporting:
|
|
_player.Stop((uid, player), TelepadIdleKey);
|
|
if (!_player.HasRunningAnimation(uid, TelepadBeamKey))
|
|
_player.Play((uid, player), CargoTelepadBeamAnimation, TelepadBeamKey);
|
|
break;
|
|
case CargoTelepadState.Unpowered:
|
|
_sprite.LayerSetVisible((uid, sprite), CargoTelepadLayers.Beam, false);
|
|
_player.Stop(uid, player, TelepadBeamKey);
|
|
_player.Stop(uid, player, TelepadIdleKey);
|
|
break;
|
|
default:
|
|
_sprite.LayerSetVisible((uid, sprite), CargoTelepadLayers.Beam, true);
|
|
|
|
if (_player.HasRunningAnimation(uid, player, TelepadIdleKey) ||
|
|
_player.HasRunningAnimation(uid, player, TelepadBeamKey))
|
|
return;
|
|
|
|
_player.Play((uid, player), CargoTelepadIdleAnimation, TelepadIdleKey);
|
|
break;
|
|
}
|
|
}
|
|
|
|
[UsedImplicitly]
|
|
private enum CargoTelepadLayers : byte
|
|
{
|
|
Base = 0,
|
|
Beam = 1,
|
|
}
|
|
}
|