Remove warnings from cargo system (#36159)

* Remove warnings from cargo system

* Guard statement early exit and cleaner object instantiation

* Whitespace

* Add AnimationPlayer as a component of telepads
This commit is contained in:
J
2025-03-30 01:11:04 +00:00
committed by GitHub
parent 99e675c506
commit 2f58fdf1e1
2 changed files with 7 additions and 4 deletions

View File

@@ -67,8 +67,10 @@ public sealed partial class CargoSystem
if (!Resolve(uid, ref sprite)) if (!Resolve(uid, ref sprite))
return; return;
if (!TryComp<AnimationPlayerComponent>(uid, out var player))
return;
_appearance.TryGetData<CargoTelepadState?>(uid, CargoTelepadVisuals.State, out var state); _appearance.TryGetData<CargoTelepadState?>(uid, CargoTelepadVisuals.State, out var state);
AnimationPlayerComponent? player = null;
switch (state) switch (state)
{ {
@@ -76,7 +78,7 @@ public sealed partial class CargoSystem
if (_player.HasRunningAnimation(uid, TelepadBeamKey)) if (_player.HasRunningAnimation(uid, TelepadBeamKey))
return; return;
_player.Stop(uid, player, TelepadIdleKey); _player.Stop(uid, player, TelepadIdleKey);
_player.Play(uid, player, CargoTelepadBeamAnimation, TelepadBeamKey); _player.Play((uid, player), CargoTelepadBeamAnimation, TelepadBeamKey);
break; break;
case CargoTelepadState.Unpowered: case CargoTelepadState.Unpowered:
sprite.LayerSetVisible(CargoTelepadLayers.Beam, false); sprite.LayerSetVisible(CargoTelepadLayers.Beam, false);
@@ -90,7 +92,7 @@ public sealed partial class CargoSystem
_player.HasRunningAnimation(uid, player, TelepadBeamKey)) _player.HasRunningAnimation(uid, player, TelepadBeamKey))
return; return;
_player.Play(uid, player, CargoTelepadIdleAnimation, TelepadIdleKey); _player.Play((uid, player), CargoTelepadIdleAnimation, TelepadIdleKey);
break; break;
} }
} }

View File

@@ -1,4 +1,4 @@
- type: entity - type: entity
id: CargoTelepad id: CargoTelepad
parent: [ BaseMachinePowered, ConstructibleMachine ] parent: [ BaseMachinePowered, ConstructibleMachine ]
name: cargo telepad name: cargo telepad
@@ -49,3 +49,4 @@
- type: CollideOnAnchor - type: CollideOnAnchor
- type: NameIdentifier - type: NameIdentifier
group: CargoTelepads group: CargoTelepads
- type: AnimationPlayer