Files
Delta-v/Content.Client/_EE/Flight/FlightSystem.cs
e945f5869a Harpies Flightless No More! (#4888)
* Initial port of EE Harpy flying (#919)

* Added better friction and acceleration modifiers.

* Moved server's flight system to shared. I don't know why it isn't in the first place.

* Shifting things around.

* Code tweaks to make it better

* Comment fixes

* Fixed footsteps and footstep sounds

* Added a quick conditional if InitialStaminaCost greater than zero

* Removed a pop-up that wasn't showing

* Additional adjustments

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fixed a few more systems to call the Flying system instead of the component

* Comment consistency. DeltaV comments where I made it better. EE comments where they originally had things

* YAML fixes

* Guidebook

* Apply suggestions from code review

Co-authored-by: Tobias Berger <toby@tobot.dev>
Signed-off-by: Vanessa <908648+ShepardToTheStars@users.noreply.github.com>

* Removed DoAfterDashEvent

* Fixed suggestions

* Updated comment

* Added new copyright free wingflaps with proper attribution

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Appeased YAML gods

---------

Signed-off-by: Vanessa <908648+ShepardToTheStars@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Tobias Berger <toby@tobot.dev>
2025-12-08 14:58:52 +01:00

65 lines
2.0 KiB
C#

using Robust.Client.GameObjects;
using Content.Shared._EE.Flight;
using Content.Shared._EE.Flight.Events;
using Content.Client._EE.Flight.Components;
namespace Content.Client._EE.Flight;
public sealed class FlightSystem : SharedFlightSystem
{
[Dependency] private readonly IEntityManager _entityManager = default!;
public override void Initialize()
{
base.Initialize();
SubscribeNetworkEvent<FlightEvent>(OnFlight);
}
private void OnFlight(FlightEvent args)
{
var uid = GetEntity(args.Uid);
if (!_entityManager.TryGetComponent(uid, out SpriteComponent? sprite)
|| !args.IsAnimated
|| !_entityManager.TryGetComponent(uid, out FlightComponent? flight))
return;
int? targetLayer = null;
if (flight.IsLayerAnimated && flight.Layer is not null)
{
targetLayer = GetAnimatedLayer(uid, flight.Layer, sprite);
if (targetLayer == null)
return;
}
if (args.IsFlying && args.IsAnimated && flight.AnimationKey != "default")
{
var comp = new FlightVisualsComponent
{
AnimateLayer = flight.IsLayerAnimated,
AnimationKey = flight.AnimationKey,
Multiplier = flight.ShaderMultiplier,
Offset = flight.ShaderOffset,
Speed = flight.ShaderSpeed,
TargetLayer = targetLayer,
};
AddComp(uid, comp);
}
if (!args.IsFlying)
RemComp<FlightVisualsComponent>(uid);
}
public int? GetAnimatedLayer(EntityUid uid, string targetLayer, SpriteComponent? sprite = null)
{
if (!Resolve(uid, ref sprite))
return null;
var index = 0;
foreach (var layer in sprite.AllLayers)
{
// This feels like absolute shitcode, isn't there a better way to check for it?
if (layer.Rsi?.Path.ToString() == targetLayer)
return index;
index++;
}
return null;
}
}