mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-29 11:37:24 +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>
73 lines
2.7 KiB
C#
73 lines
2.7 KiB
C#
using Robust.Shared.GameStates;
|
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
|
|
|
namespace Content.Shared.Damage.Components;
|
|
|
|
/// <summary>
|
|
/// Add to an entity to paralyze it whenever it reaches critical amounts of Stamina DamageType.
|
|
/// </summary>
|
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true), AutoGenerateComponentPause]
|
|
public sealed partial class StaminaComponent : Component
|
|
{
|
|
/// <summary>
|
|
/// Have we reached peak stamina damage and been paralyzed?
|
|
/// </summary>
|
|
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
|
public bool Critical;
|
|
|
|
/// <summary>
|
|
/// How much stamina reduces per second.
|
|
/// </summary>
|
|
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
|
public float Decay = 3f;
|
|
|
|
/// <summary>
|
|
/// How much time after receiving damage until stamina starts decreasing.
|
|
/// </summary>
|
|
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
|
public float Cooldown = 3f;
|
|
|
|
/// <summary>
|
|
/// How much stamina damage this entity has taken.
|
|
/// </summary>
|
|
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
|
public float StaminaDamage;
|
|
|
|
/// <summary>
|
|
/// How much stamina damage is required to entire stam crit.
|
|
/// </summary>
|
|
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
|
public float CritThreshold = 100f;
|
|
|
|
/// <summary>
|
|
/// A dictionary of active stamina drains, with the key being the source of the drain,
|
|
/// DrainRate how much it changes per tick, and ModifiesSpeed if it should slow down the user.
|
|
/// </summary>
|
|
[DataField, AutoNetworkedField]
|
|
public Dictionary<EntityUid, (float DrainRate, bool ModifiesSpeed)> ActiveDrains = new();
|
|
|
|
/// <summary>
|
|
/// How long will this mob be stunned for?
|
|
/// </summary>
|
|
[ViewVariables(VVAccess.ReadWrite), DataField]
|
|
public TimeSpan StunTime = TimeSpan.FromSeconds(6);
|
|
|
|
/// <summary>
|
|
/// To avoid continuously updating our data we track the last time we updated so we can extrapolate our current stamina.
|
|
/// </summary>
|
|
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField]
|
|
[AutoPausedField]
|
|
public TimeSpan NextUpdate = TimeSpan.Zero;
|
|
|
|
/// <summary>
|
|
/// Minimum factor of the crit threshold that the mob must receive in stamina damage in order to start slowing down.
|
|
/// </summary>
|
|
[DataField, AutoNetworkedField]
|
|
public float SlowdownThresholdFactor = 0.5f;
|
|
|
|
/// <summary>
|
|
/// Speed multiplier for entities that are slowed down due to low stamina. Multiplied by how close the mob is to stamcrit.
|
|
/// </summary>
|
|
[DataField, AutoNetworkedField]
|
|
public float SlowdownMultiplier = 0.75f;
|
|
} |