Predicted stamina (#12413)
* Predicted stamina Needed to do some semblence of predicted melee. * Okay now done. * Pause support * Comment
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using Content.Server.Damage.Events;
|
||||
using Content.Server.Weapons.Melee.Events;
|
||||
using Content.Shared.Damage.Events;
|
||||
using Content.Shared.Weapons.Melee;
|
||||
using Content.Shared.Weapons.Melee.Events;
|
||||
using Robust.Shared.Containers;
|
||||
|
||||
namespace Content.Server.Abilities.Boxer
|
||||
|
||||
@@ -3,7 +3,6 @@ using Content.Server.Atmos.Components;
|
||||
using Content.Server.Stunnable;
|
||||
using Content.Server.Temperature.Components;
|
||||
using Content.Server.Temperature.Systems;
|
||||
using Content.Server.Weapons.Melee.Events;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Atmos;
|
||||
@@ -14,6 +13,7 @@ using Content.Shared.Physics;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Rejuvenate;
|
||||
using Content.Shared.Temperature;
|
||||
using Content.Shared.Weapons.Melee.Events;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Chemistry.Components;
|
||||
using Content.Server.Weapons.Melee.Events;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Weapons.Melee;
|
||||
|
||||
@@ -2,6 +2,7 @@ using Content.Shared.Damage;
|
||||
using Content.Shared.MobState.EntitySystems;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Server.Damage.Components;
|
||||
using Content.Shared.Damage.Components;
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
||||
namespace Content.Server.Contests
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Content.Server.Flash.Components;
|
||||
using Content.Server.Light.EntitySystems;
|
||||
using Content.Server.Stunnable;
|
||||
using Content.Server.Weapons.Melee.Events;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Flash;
|
||||
using Content.Shared.IdentityManagement;
|
||||
@@ -11,6 +10,7 @@ using Content.Shared.Inventory;
|
||||
using Content.Shared.Physics;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Tag;
|
||||
using Content.Shared.Weapons.Melee.Events;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
@@ -10,6 +10,7 @@ using Content.Server.Storage.EntitySystems;
|
||||
using Content.Server.Strip;
|
||||
using Content.Server.Stunnable;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.CombatMode;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
|
||||
@@ -1,24 +1,16 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Damage.Components;
|
||||
using Content.Server.Damage.Events;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.Events;
|
||||
using Content.Server.Speech.EntitySystems;
|
||||
using Content.Server.Stunnable.Components;
|
||||
using Content.Server.Weapons.Melee.Events;
|
||||
using Content.Shared.Audio;
|
||||
using Content.Shared.Damage.Events;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Item;
|
||||
using Content.Shared.Jittering;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.StatusEffect;
|
||||
using Content.Shared.Throwing;
|
||||
using Content.Shared.Toggleable;
|
||||
using Robust.Server.GameObjects;
|
||||
using Content.Shared.Weapons.Melee.Events;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Server.Stunnable.Systems
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@ using Content.Server.Chemistry.Components;
|
||||
using Content.Server.Chemistry.Components.SolutionManager;
|
||||
using Content.Server.Chemistry.EntitySystems;
|
||||
using Content.Server.Tools.Components;
|
||||
using Content.Server.Weapons.Melee.Events;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Interaction;
|
||||
@@ -11,6 +10,7 @@ using Content.Shared.Item;
|
||||
using Content.Shared.Temperature;
|
||||
using Content.Shared.Toggleable;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Content.Shared.Weapons.Melee.Events;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Content.Server.CombatMode.Disarm;
|
||||
using Content.Server.Kitchen.Components;
|
||||
using Content.Server.Weapons.Melee.EnergySword.Components;
|
||||
using Content.Server.Weapons.Melee.Events;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Item;
|
||||
@@ -11,6 +10,7 @@ using Content.Shared.Temperature;
|
||||
using Content.Shared.Toggleable;
|
||||
using Content.Shared.Tools.Components;
|
||||
using Content.Shared.Weapons.Melee;
|
||||
using Content.Shared.Weapons.Melee.Events;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
@@ -14,9 +14,9 @@ using Content.Server.Examine;
|
||||
using Content.Server.Hands.Components;
|
||||
using Content.Server.Movement.Systems;
|
||||
using Content.Server.Weapons.Melee.Components;
|
||||
using Content.Server.Weapons.Melee.Events;
|
||||
using Content.Shared.CombatMode;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.IdentityManagement;
|
||||
|
||||
@@ -9,6 +9,7 @@ using Content.Server.Stunnable;
|
||||
using Content.Server.Weapons.Melee;
|
||||
using Content.Server.Weapons.Ranged.Components;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Content.Shared.Weapons.Melee;
|
||||
|
||||
@@ -11,7 +11,7 @@ using Content.Shared.Popups;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Shared.Player;
|
||||
using Content.Server.Actions.Events;
|
||||
using Content.Server.Weapons.Melee.Events;
|
||||
using Content.Shared.Weapons.Melee.Events;
|
||||
|
||||
|
||||
namespace Content.Server.Wieldable
|
||||
|
||||
@@ -12,9 +12,9 @@ using Content.Server.Inventory;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Content.Server.Speech;
|
||||
using Content.Server.Chat.Systems;
|
||||
using Content.Server.Weapons.Melee.Events;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Weapons.Melee.Events;
|
||||
using Content.Shared.Zombies;
|
||||
|
||||
namespace Content.Server.Zombies
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Content.Server.CombatMode
|
||||
namespace Content.Shared.CombatMode
|
||||
{
|
||||
public sealed class DisarmedEvent : HandledEntityEventArgs
|
||||
{
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Content.Server.Damage.Components;
|
||||
namespace Content.Shared.Damage.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Tracks whether an entity has ANY stamina damage for update purposes only.
|
||||
@@ -1,12 +1,13 @@
|
||||
using Content.Server.Damage.Systems;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||
|
||||
namespace Content.Server.Damage.Components;
|
||||
namespace Content.Shared.Damage.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Add to an entity to paralyze it whenever it reaches critical amounts of Stamina DamageType.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed class StaminaComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
@@ -40,8 +41,8 @@ public sealed class StaminaComponent : Component
|
||||
public float CritThreshold = 100f;
|
||||
|
||||
/// <summary>
|
||||
/// Next time we're allowed to decrease stamina damage. Refreshes whenever the stam damage is changed.
|
||||
/// To avoid continuously updating our data we track the last time we updated so we can extrapolate our current stamina.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("decayAccumulator")]
|
||||
public float StaminaDecayAccumulator;
|
||||
[ViewVariables, DataField("lastUpdate", customTypeSerializer:typeof(TimeOffsetSerializer))]
|
||||
public TimeSpan NextUpdate = TimeSpan.Zero;
|
||||
}
|
||||
@@ -1,6 +1,4 @@
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Server.Damage.Components;
|
||||
namespace Content.Shared.Damage.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Applies stamina damage when colliding with an entity.
|
||||
@@ -1,6 +1,4 @@
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Server.Damage.Components;
|
||||
namespace Content.Shared.Damage.Components;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed class StaminaDamageOnHitComponent : Component
|
||||
@@ -1,6 +1,6 @@
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Server.Damage.Events;
|
||||
namespace Content.Shared.Damage.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Attempting to apply stamina damage on a melee hit to an entity.
|
||||
@@ -10,4 +10,10 @@ public struct StaminaDamageOnHitAttemptEvent
|
||||
{
|
||||
public bool Cancelled;
|
||||
public SoundSpecifier? HitSoundOverride;
|
||||
|
||||
public StaminaDamageOnHitAttemptEvent(bool cancelled, SoundSpecifier? hitSoundOverride)
|
||||
{
|
||||
Cancelled = cancelled;
|
||||
HitSoundOverride = hitSoundOverride;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using Content.Shared.Damage.Components;
|
||||
using Robust.Shared.Collections;
|
||||
using Content.Server.Damage.Components;
|
||||
|
||||
namespace Content.Server.Damage.Events;
|
||||
namespace Content.Shared.Damage.Events;
|
||||
|
||||
/// <summary>
|
||||
/// The components in the list are going to be hit,
|
||||
@@ -11,9 +11,10 @@ public sealed class StaminaMeleeHitEvent : HandledEntityEventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// List of hit stamina components.
|
||||
public ValueList<StaminaComponent> HitList;
|
||||
/// </summary>
|
||||
public List<StaminaComponent> HitList;
|
||||
|
||||
/// <summmary>
|
||||
/// <summary>
|
||||
/// The multiplier. Generally, try to use *= or /= instead of overwriting.
|
||||
/// </summary>
|
||||
public float Multiplier = 1;
|
||||
@@ -23,7 +24,7 @@ public sealed class StaminaMeleeHitEvent : HandledEntityEventArgs
|
||||
/// </summary>
|
||||
public float FlatModifier = 0;
|
||||
|
||||
public StaminaMeleeHitEvent(ValueList<StaminaComponent> hitList)
|
||||
public StaminaMeleeHitEvent(List<StaminaComponent> hitList)
|
||||
{
|
||||
HitList = hitList;
|
||||
}
|
||||
@@ -1,59 +1,96 @@
|
||||
using Content.Server.Damage.Components;
|
||||
using Content.Server.Damage.Events;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.CombatMode;
|
||||
using Content.Server.Weapons.Melee.Events;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Rounding;
|
||||
using Content.Shared.Stunnable;
|
||||
using Content.Shared.CombatMode;
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.Damage.Events;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Shared.Collections;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Random;
|
||||
using Content.Shared.Rounding;
|
||||
using Content.Shared.Stunnable;
|
||||
using Content.Shared.Weapons.Melee.Events;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Physics.Events;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
|
||||
namespace Content.Server.Damage.Systems;
|
||||
namespace Content.Shared.Damage.Systems;
|
||||
|
||||
public sealed class StaminaSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly AlertsSystem _alerts = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
[Dependency] private readonly MetaDataSystem _metadata = default!;
|
||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||
[Dependency] private readonly SharedStunSystem _stunSystem = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
|
||||
private const float UpdateCooldown = 2f;
|
||||
private float _accumulator;
|
||||
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
|
||||
|
||||
private const string CollideFixture = "projectile";
|
||||
|
||||
/// <summary>
|
||||
/// How much of a buffer is there between the stun duration and when stuns can be re-applied.
|
||||
/// </summary>
|
||||
private const float StamCritBufferTime = 3f;
|
||||
|
||||
private readonly List<EntityUid> _dirtyEntities = new();
|
||||
private static readonly TimeSpan StamCritBufferTime = TimeSpan.FromSeconds(3f);
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<StaminaComponent, ComponentStartup>(OnStartup);
|
||||
SubscribeLocalEvent<StaminaComponent, ComponentShutdown>(OnShutdown);
|
||||
SubscribeLocalEvent<StaminaComponent, ComponentGetState>(OnStamGetState);
|
||||
SubscribeLocalEvent<StaminaComponent, ComponentHandleState>(OnStamHandleState);
|
||||
SubscribeLocalEvent<StaminaComponent, DisarmedEvent>(OnDisarmed);
|
||||
SubscribeLocalEvent<StaminaDamageOnCollideComponent, StartCollideEvent>(OnCollide);
|
||||
SubscribeLocalEvent<StaminaDamageOnHitComponent, MeleeHitEvent>(OnHit);
|
||||
}
|
||||
|
||||
private void OnStamGetState(EntityUid uid, StaminaComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new StaminaComponentState()
|
||||
{
|
||||
Critical = component.Critical,
|
||||
Decay = component.Decay,
|
||||
CritThreshold = component.CritThreshold,
|
||||
DecayCooldown = component.DecayCooldown,
|
||||
LastUpdate = component.NextUpdate,
|
||||
StaminaDamage = component.StaminaDamage,
|
||||
};
|
||||
}
|
||||
|
||||
private void OnStamHandleState(EntityUid uid, StaminaComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not StaminaComponentState state)
|
||||
return;
|
||||
|
||||
component.Critical = state.Critical;
|
||||
component.Decay = state.Decay;
|
||||
component.CritThreshold = state.CritThreshold;
|
||||
component.DecayCooldown = state.DecayCooldown;
|
||||
component.NextUpdate = state.LastUpdate;
|
||||
component.StaminaDamage = state.StaminaDamage;
|
||||
|
||||
if (component.Critical)
|
||||
EnterStamCrit(uid, component);
|
||||
else
|
||||
{
|
||||
if (component.StaminaDamage > 0f)
|
||||
EnsureComp<ActiveStaminaComponent>(uid);
|
||||
|
||||
ExitStamCrit(uid, component);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnShutdown(EntityUid uid, StaminaComponent component, ComponentShutdown args)
|
||||
{
|
||||
if (MetaData(uid).EntityLifeStage < EntityLifeStage.Terminating)
|
||||
{
|
||||
RemCompDeferred<ActiveStaminaComponent>(uid);
|
||||
}
|
||||
|
||||
SetStaminaAlert(uid);
|
||||
}
|
||||
|
||||
@@ -62,6 +99,17 @@ public sealed class StaminaSystem : EntitySystem
|
||||
SetStaminaAlert(uid, component);
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public float GetStaminaDamage(EntityUid uid, StaminaComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component))
|
||||
return 0f;
|
||||
|
||||
var curTime = _timing.CurTime;
|
||||
var pauseTime = _metadata.GetPauseTime(uid);
|
||||
return MathF.Max(0f, component.StaminaDamage - MathF.Max(0f, (float) (curTime - (component.NextUpdate + pauseTime)).TotalSeconds * component.Decay));
|
||||
}
|
||||
|
||||
private void OnDisarmed(EntityUid uid, StaminaComponent component, DisarmedEvent args)
|
||||
{
|
||||
if (args.Handled || !_random.Prob(args.PushProbability))
|
||||
@@ -102,7 +150,7 @@ public sealed class StaminaSystem : EntitySystem
|
||||
|
||||
args.HitSoundOverride = ev.HitSoundOverride;
|
||||
var stamQuery = GetEntityQuery<StaminaComponent>();
|
||||
var toHit = new ValueList<StaminaComponent>();
|
||||
var toHit = new List<StaminaComponent>();
|
||||
|
||||
// Split stamina damage between all eligible targets.
|
||||
foreach (var ent in args.HitEntities)
|
||||
@@ -155,7 +203,8 @@ public sealed class StaminaSystem : EntitySystem
|
||||
|
||||
public void TakeStaminaDamage(EntityUid uid, float value, StaminaComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component, false) || component.Critical) return;
|
||||
if (!Resolve(uid, ref component, false) || component.Critical)
|
||||
return;
|
||||
|
||||
var oldDamage = component.StaminaDamage;
|
||||
component.StaminaDamage = MathF.Max(0f, component.StaminaDamage + value);
|
||||
@@ -163,7 +212,10 @@ public sealed class StaminaSystem : EntitySystem
|
||||
// Reset the decay cooldown upon taking damage.
|
||||
if (oldDamage < component.StaminaDamage)
|
||||
{
|
||||
component.StaminaDecayAccumulator = component.DecayCooldown;
|
||||
var nextUpdate = _timing.CurTime + TimeSpan.FromSeconds(component.DecayCooldown);
|
||||
|
||||
if (component.NextUpdate < nextUpdate)
|
||||
component.NextUpdate = nextUpdate;
|
||||
}
|
||||
|
||||
var slowdownThreshold = component.CritThreshold / 2f;
|
||||
@@ -177,9 +229,6 @@ public sealed class StaminaSystem : EntitySystem
|
||||
|
||||
SetStaminaAlert(uid, component);
|
||||
|
||||
// Can't do it here as resetting prediction gets cooked.
|
||||
_dirtyEntities.Add(uid);
|
||||
|
||||
if (!component.Critical)
|
||||
{
|
||||
if (component.StaminaDamage >= component.CritThreshold)
|
||||
@@ -194,6 +243,9 @@ public sealed class StaminaSystem : EntitySystem
|
||||
ExitStamCrit(uid, component);
|
||||
}
|
||||
}
|
||||
|
||||
EnsureComp<ActiveStaminaComponent>(uid);
|
||||
Dirty(component);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
@@ -202,35 +254,25 @@ public sealed class StaminaSystem : EntitySystem
|
||||
|
||||
if (!_timing.IsFirstTimePredicted) return;
|
||||
|
||||
_accumulator -= frameTime;
|
||||
|
||||
if (_accumulator > 0f) return;
|
||||
|
||||
var metaQuery = GetEntityQuery<MetaDataComponent>();
|
||||
var stamQuery = GetEntityQuery<StaminaComponent>();
|
||||
|
||||
foreach (var uid in _dirtyEntities)
|
||||
{
|
||||
// Don't need to RemComp as they will get handled below.
|
||||
if (!stamQuery.TryGetComponent(uid, out var comp) || comp.StaminaDamage <= 0f) continue;
|
||||
EnsureComp<ActiveStaminaComponent>(uid);
|
||||
}
|
||||
|
||||
_dirtyEntities.Clear();
|
||||
_accumulator += UpdateCooldown;
|
||||
var curTime = _timing.CurTime;
|
||||
|
||||
foreach (var active in EntityQuery<ActiveStaminaComponent>())
|
||||
{
|
||||
// Just in case we have active but not stamina we'll check and account for it.
|
||||
if (!stamQuery.TryGetComponent(active.Owner, out var comp) ||
|
||||
comp.StaminaDamage <= 0f)
|
||||
comp.StaminaDamage <= 0f && !comp.Critical)
|
||||
{
|
||||
RemComp<ActiveStaminaComponent>(active.Owner);
|
||||
continue;
|
||||
}
|
||||
|
||||
comp.StaminaDecayAccumulator -= UpdateCooldown;
|
||||
// Shouldn't need to consider paused time as we're only iterating non-paused stamina components.
|
||||
var nextUpdate = comp.NextUpdate;
|
||||
|
||||
if (comp.StaminaDecayAccumulator > 0f) continue;
|
||||
if (nextUpdate > curTime)
|
||||
continue;
|
||||
|
||||
// We were in crit so come out of it and continue.
|
||||
if (comp.Critical)
|
||||
@@ -239,8 +281,9 @@ public sealed class StaminaSystem : EntitySystem
|
||||
continue;
|
||||
}
|
||||
|
||||
comp.StaminaDecayAccumulator = 0f;
|
||||
TakeStaminaDamage(comp.Owner, -comp.Decay * UpdateCooldown, comp);
|
||||
comp.NextUpdate += TimeSpan.FromSeconds(1f);
|
||||
TakeStaminaDamage(comp.Owner, -comp.Decay, comp);
|
||||
Dirty(comp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,13 +297,14 @@ public sealed class StaminaSystem : EntitySystem
|
||||
|
||||
component.Critical = true;
|
||||
component.StaminaDamage = component.CritThreshold;
|
||||
component.StaminaDecayAccumulator = 0f;
|
||||
|
||||
var stunTime = TimeSpan.FromSeconds(6);
|
||||
_stunSystem.TryParalyze(uid, stunTime, true);
|
||||
|
||||
// Give them buffer before being able to be re-stunned
|
||||
component.StaminaDecayAccumulator = (float) stunTime.TotalSeconds + StamCritBufferTime;
|
||||
component.NextUpdate = _timing.CurTime + stunTime + StamCritBufferTime;
|
||||
EnsureComp<ActiveStaminaComponent>(uid);
|
||||
Dirty(component);
|
||||
}
|
||||
|
||||
private void ExitStamCrit(EntityUid uid, StaminaComponent? component = null)
|
||||
@@ -270,6 +314,20 @@ public sealed class StaminaSystem : EntitySystem
|
||||
|
||||
component.Critical = false;
|
||||
component.StaminaDamage = 0f;
|
||||
component.NextUpdate = _timing.CurTime;
|
||||
SetStaminaAlert(uid, component);
|
||||
RemComp<ActiveStaminaComponent>(uid);
|
||||
Dirty(component);
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
private sealed class StaminaComponentState : ComponentState
|
||||
{
|
||||
public bool Critical;
|
||||
public float Decay;
|
||||
public float DecayCooldown;
|
||||
public float StaminaDamage;
|
||||
public float CritThreshold;
|
||||
public TimeSpan LastUpdate;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
using Content.Shared.Damage;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Server.Weapons.Melee.Events;
|
||||
namespace Content.Shared.Weapons.Melee.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Raised directed on the melee weapon entity used to attack something in combat mode,
|
||||
@@ -1,11 +1,8 @@
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Clothing.Components;
|
||||
using Content.Shared.CombatMode;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Inventory.Events;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Weapons.Melee.Events;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
Reference in New Issue
Block a user