mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-09-29 23:57:29 +00:00
* 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>
54 lines
1.8 KiB
C#
54 lines
1.8 KiB
C#
using System.Numerics;
|
|
using Robust.Shared.Map;
|
|
using Content.Shared._EE.Flight.Events;
|
|
|
|
namespace Content.Shared.Gravity;
|
|
|
|
/// <summary>
|
|
/// Handles offsetting a sprite when there is no gravity
|
|
/// </summary>
|
|
public abstract partial class SharedFloatingVisualizerSystem : EntitySystem // DeltaV - Made Partial for Harpy Flying
|
|
{
|
|
[Dependency] private readonly SharedGravitySystem _gravity = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<FloatingVisualsComponent, ComponentStartup>(OnComponentStartup);
|
|
SubscribeLocalEvent<FloatingVisualsComponent, WeightlessnessChangedEvent>(OnWeightlessnessChanged);
|
|
|
|
SubscribeNetworkEvent<FlightEvent>(OnFlight);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Offsets a sprite with a linear interpolation animation
|
|
/// </summary>
|
|
public virtual void FloatAnimation(EntityUid uid, Vector2 offset, string animationKey, float animationTime, bool stop = false) { }
|
|
|
|
protected bool CanFloat(Entity<FloatingVisualsComponent> entity)
|
|
{
|
|
entity.Comp.CanFloat = _gravity.IsWeightless(entity.Owner);
|
|
Dirty(entity);
|
|
return entity.Comp.CanFloat;
|
|
}
|
|
|
|
private void OnComponentStartup(Entity<FloatingVisualsComponent> entity, ref ComponentStartup args)
|
|
{
|
|
if (CanFloat(entity))
|
|
FloatAnimation(entity, entity.Comp.Offset, entity.Comp.AnimationKey, entity.Comp.AnimationTime);
|
|
}
|
|
|
|
private void OnWeightlessnessChanged(Entity<FloatingVisualsComponent> entity, ref WeightlessnessChangedEvent args)
|
|
{
|
|
if (entity.Comp.CanFloat == args.Weightless)
|
|
return;
|
|
|
|
entity.Comp.CanFloat = CanFloat(entity);
|
|
Dirty(entity);
|
|
|
|
if (args.Weightless)
|
|
FloatAnimation(entity, entity.Comp.Offset, entity.Comp.AnimationKey, entity.Comp.AnimationTime);
|
|
}
|
|
}
|