mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 05:59:03 +03:00
# Description
This PR adds a generic system which gives an entity the ability to fly.
Optionally increasing their speed in exchange for a continuous stamina
drain, which can, and **will** stamcrit them if left unchecked.
---
# Technical Details?
We normally dont have this section but I'd like to outline the changes
since I messed with quite a few systems:
- Introduces a `FlightComponent` which can be added to any entity in
YML, needs to be tied to an action with an event of type
`ToggleFlightEvent` This component holds properties for:
- Toggling animations on and off, either at the entity level or the
layer level.
- Altering shader animation properties
- Altering speed, stamina drain, sounds played, delay between sounds,
etc etc.
- Adds a `FlyingVisualizerSystem` that can take a given `AnimationKey`
which points to a shader, and optionally can apply it to either the
entire sprite, or a given layer.
- Adds a check in `SharedGravitySystem` for making the entity weightless
when it has the `FlightComponent` and is flying.
- Adds a check in `SharedCuffableSystem` to disable cuffing when the
target has the `FlightComponent` and is flying.
- Introduces a new field in the `StaminaComponent` which serves as a
dictionary for persistent drains, with the key being the source (UID) of
where it came from. The drains can also indicate if they should apply
the stamina slowdown or not (relevant for both this PR, and for an
eventual sprinting PR)
---
<details><summary><h1>Media</h1></summary>
<p>
[](https://youtu.be/Wndv9hYaZ_s
"Flight Demo")
</p>
</details>
---
# Changelog
🆑 Mocho
- add: Harpies are now able to fly on station for limited periods of
time, moving faster at the cost of stamina.
---------
Signed-off-by: gluesniffler <159397573+gluesniffler@users.noreply.github.com>
Co-authored-by: VMSolidus <evilexecutive@gmail.com>
102 lines
2.7 KiB
C#
102 lines
2.7 KiB
C#
using Robust.Shared.Audio;
|
|
using Robust.Shared.GameStates;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
|
|
|
namespace Content.Shared.Flight;
|
|
|
|
/// <summary>
|
|
/// Adds an action that allows the user to become temporarily
|
|
/// weightless at the cost of stamina and hand usage.
|
|
/// </summary>
|
|
[RegisterComponent, NetworkedComponent(), AutoGenerateComponentState]
|
|
public sealed partial class FlightComponent : Component
|
|
{
|
|
[DataField(customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
|
public string? ToggleAction = "ActionToggleFlight";
|
|
|
|
[DataField, AutoNetworkedField]
|
|
public EntityUid? ToggleActionEntity;
|
|
|
|
/// <summary>
|
|
/// Is the user flying right now?
|
|
/// </summary>
|
|
[DataField, AutoNetworkedField]
|
|
public bool On;
|
|
|
|
/// <summary>
|
|
/// Stamina drain per second when flying
|
|
/// </summary>
|
|
[DataField, AutoNetworkedField]
|
|
public float StaminaDrainRate = 6.0f;
|
|
|
|
/// <summary>
|
|
/// DoAfter delay until the user becomes weightless.
|
|
/// </summary>
|
|
[DataField, AutoNetworkedField]
|
|
public float ActivationDelay = 1.0f;
|
|
|
|
/// <summary>
|
|
/// Speed modifier while in flight
|
|
/// </summary>
|
|
[DataField, AutoNetworkedField]
|
|
public float SpeedModifier = 2.0f;
|
|
|
|
/// <summary>
|
|
/// Path to a sound specifier or collection for the noises made during flight
|
|
/// </summary>
|
|
[DataField]
|
|
public SoundSpecifier FlapSound = new SoundCollectionSpecifier("WingFlaps");
|
|
|
|
/// <summary>
|
|
/// Is the flight animated?
|
|
/// </summary>
|
|
[DataField]
|
|
public bool IsAnimated = true;
|
|
|
|
/// <summary>
|
|
/// Does the animation animate a layer?.
|
|
/// </summary>
|
|
[DataField]
|
|
public bool IsLayerAnimated;
|
|
|
|
/// <summary>
|
|
/// Which RSI layer path does this animate?
|
|
/// </summary>
|
|
[DataField]
|
|
public string? Layer;
|
|
|
|
/// <summary>
|
|
/// Whats the speed of the shader?
|
|
/// </summary>
|
|
[DataField]
|
|
public float ShaderSpeed = 6.0f;
|
|
|
|
/// <summary>
|
|
/// How much are the values in the shader's calculations multiplied by?
|
|
/// </summary>
|
|
[DataField]
|
|
public float ShaderMultiplier = 0.01f;
|
|
|
|
/// <summary>
|
|
/// What is the offset on the shader?
|
|
/// </summary>
|
|
[DataField]
|
|
public float ShaderOffset = 0.25f;
|
|
|
|
/// <summary>
|
|
/// What animation does the flight use?
|
|
/// </summary>
|
|
|
|
[DataField]
|
|
public string AnimationKey = "default";
|
|
|
|
/// <summary>
|
|
/// Time between sounds being played
|
|
/// </summary>
|
|
[DataField]
|
|
public float FlapInterval = 1.0f;
|
|
|
|
public float TimeUntilFlap;
|
|
}
|