feat: add a component for rejuvenateable status effects (#39025)
* feat: add a component for rejuvenateable effects * feat: let god mode'd entities get buffs * fix: handle old status effect system Didn't realize BeforeStatusEffectAddedEvent was called by both systems, oops. * refactor: rename to RejuvenateRemovedStatusEffect * fix: make forced sleeping a debuff again Missed in rebase. * refactor: make BeforeStatusEffectAdded two events
This commit is contained in:
@@ -1,14 +1,19 @@
|
|||||||
using Content.Shared.Damage.Components;
|
using Content.Shared.Damage.Components;
|
||||||
using Content.Shared.Damage.Events;
|
using Content.Shared.Damage.Events;
|
||||||
using Content.Shared.Destructible;
|
using Content.Shared.Destructible;
|
||||||
|
using Content.Shared.Prototypes;
|
||||||
using Content.Shared.Rejuvenate;
|
using Content.Shared.Rejuvenate;
|
||||||
using Content.Shared.Slippery;
|
using Content.Shared.Slippery;
|
||||||
|
using Content.Shared.StatusEffect;
|
||||||
using Content.Shared.StatusEffectNew;
|
using Content.Shared.StatusEffectNew;
|
||||||
|
using Content.Shared.StatusEffectNew.Components;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Shared.Damage.Systems;
|
namespace Content.Shared.Damage.Systems;
|
||||||
|
|
||||||
public abstract class SharedGodmodeSystem : EntitySystem
|
public abstract class SharedGodmodeSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IPrototypeManager _protoMan = default!;
|
||||||
[Dependency] private readonly DamageableSystem _damageable = default!;
|
[Dependency] private readonly DamageableSystem _damageable = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
@@ -17,6 +22,7 @@ public abstract class SharedGodmodeSystem : EntitySystem
|
|||||||
|
|
||||||
SubscribeLocalEvent<GodmodeComponent, BeforeDamageChangedEvent>(OnBeforeDamageChanged);
|
SubscribeLocalEvent<GodmodeComponent, BeforeDamageChangedEvent>(OnBeforeDamageChanged);
|
||||||
SubscribeLocalEvent<GodmodeComponent, BeforeStatusEffectAddedEvent>(OnBeforeStatusEffect);
|
SubscribeLocalEvent<GodmodeComponent, BeforeStatusEffectAddedEvent>(OnBeforeStatusEffect);
|
||||||
|
SubscribeLocalEvent<GodmodeComponent, BeforeOldStatusEffectAddedEvent>(OnBeforeOldStatusEffect);
|
||||||
SubscribeLocalEvent<GodmodeComponent, BeforeStaminaDamageEvent>(OnBeforeStaminaDamage);
|
SubscribeLocalEvent<GodmodeComponent, BeforeStaminaDamageEvent>(OnBeforeStaminaDamage);
|
||||||
SubscribeLocalEvent<GodmodeComponent, SlipAttemptEvent>(OnSlipAttempt);
|
SubscribeLocalEvent<GodmodeComponent, SlipAttemptEvent>(OnSlipAttempt);
|
||||||
SubscribeLocalEvent<GodmodeComponent, DestructionAttemptEvent>(OnDestruction);
|
SubscribeLocalEvent<GodmodeComponent, DestructionAttemptEvent>(OnDestruction);
|
||||||
@@ -34,6 +40,13 @@ public abstract class SharedGodmodeSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnBeforeStatusEffect(EntityUid uid, GodmodeComponent component, ref BeforeStatusEffectAddedEvent args)
|
private void OnBeforeStatusEffect(EntityUid uid, GodmodeComponent component, ref BeforeStatusEffectAddedEvent args)
|
||||||
{
|
{
|
||||||
|
if (_protoMan.Index(args.Effect).HasComponent<RejuvenateRemovedStatusEffectComponent>(Factory))
|
||||||
|
args.Cancelled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnBeforeOldStatusEffect(Entity<GodmodeComponent> ent, ref BeforeOldStatusEffectAddedEvent args)
|
||||||
|
{
|
||||||
|
// Old status effect system doesn't distinguish between good and bad status effects
|
||||||
args.Cancelled = true;
|
args.Cancelled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ namespace Content.Shared.StatusEffect
|
|||||||
if (!Resolve(uid, ref status, false))
|
if (!Resolve(uid, ref status, false))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var ev = new BeforeStatusEffectAddedEvent(key);
|
var ev = new BeforeOldStatusEffectAddedEvent(key);
|
||||||
RaiseLocalEvent(uid, ref ev);
|
RaiseLocalEvent(uid, ref ev);
|
||||||
if (ev.Cancelled)
|
if (ev.Cancelled)
|
||||||
return false;
|
return false;
|
||||||
@@ -481,6 +481,13 @@ namespace Content.Shared.StatusEffect
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raised on an entity before a status effect is added to determine if adding it should be cancelled.
|
||||||
|
/// Obsolete version of <see cref="BeforeStatusEffectAddedEvent" />
|
||||||
|
/// </summary>
|
||||||
|
[ByRefEvent, Obsolete("Migration to StatusEffectNew.StatusEffectsSystem is required")]
|
||||||
|
public record struct BeforeOldStatusEffectAddedEvent(string EffectKey, bool Cancelled = false);
|
||||||
|
|
||||||
public readonly struct StatusEffectAddedEvent
|
public readonly struct StatusEffectAddedEvent
|
||||||
{
|
{
|
||||||
public readonly EntityUid Uid;
|
public readonly EntityUid Uid;
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
using Content.Shared.Damage.Components;
|
||||||
|
using Content.Shared.Rejuvenate;
|
||||||
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
|
namespace Content.Shared.StatusEffectNew.Components;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Marker component for a status effect that should be removed on rejuvenation
|
||||||
|
/// and should not be applied on targets with <see cref="GodmodeComponent" />.
|
||||||
|
/// Only applies to effects using the new <see cref="StatusEffectsSystem" />.
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="RejuvenateEvent"/>
|
||||||
|
[RegisterComponent, NetworkedComponent]
|
||||||
|
public sealed partial class RejuvenateRemovedStatusEffectComponent : Component;
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using Content.Shared.Movement.Events;
|
using Content.Shared.Movement.Events;
|
||||||
using Content.Shared.Movement.Systems;
|
using Content.Shared.Movement.Systems;
|
||||||
|
using Content.Shared.Rejuvenate;
|
||||||
using Content.Shared.StatusEffectNew.Components;
|
using Content.Shared.StatusEffectNew.Components;
|
||||||
using Content.Shared.Stunnable;
|
using Content.Shared.Stunnable;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
@@ -12,6 +13,7 @@ public sealed partial class StatusEffectsSystem
|
|||||||
{
|
{
|
||||||
SubscribeLocalEvent<StatusEffectContainerComponent, LocalPlayerAttachedEvent>(RelayStatusEffectEvent);
|
SubscribeLocalEvent<StatusEffectContainerComponent, LocalPlayerAttachedEvent>(RelayStatusEffectEvent);
|
||||||
SubscribeLocalEvent<StatusEffectContainerComponent, LocalPlayerDetachedEvent>(RelayStatusEffectEvent);
|
SubscribeLocalEvent<StatusEffectContainerComponent, LocalPlayerDetachedEvent>(RelayStatusEffectEvent);
|
||||||
|
SubscribeLocalEvent<StatusEffectContainerComponent, RejuvenateEvent>(RelayStatusEffectEvent);
|
||||||
|
|
||||||
SubscribeLocalEvent<StatusEffectContainerComponent, RefreshMovementSpeedModifiersEvent>(RelayStatusEffectEvent);
|
SubscribeLocalEvent<StatusEffectContainerComponent, RefreshMovementSpeedModifiersEvent>(RelayStatusEffectEvent);
|
||||||
SubscribeLocalEvent<StatusEffectContainerComponent, UpdateCanMoveEvent>(RelayStatusEffectEvent);
|
SubscribeLocalEvent<StatusEffectContainerComponent, UpdateCanMoveEvent>(RelayStatusEffectEvent);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
using Content.Shared.Rejuvenate;
|
||||||
using Content.Shared.StatusEffectNew.Components;
|
using Content.Shared.StatusEffectNew.Components;
|
||||||
using Content.Shared.Whitelist;
|
using Content.Shared.Whitelist;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
@@ -32,6 +33,8 @@ public sealed partial class StatusEffectsSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<StatusEffectContainerComponent, EntInsertedIntoContainerMessage>(OnEntityInserted);
|
SubscribeLocalEvent<StatusEffectContainerComponent, EntInsertedIntoContainerMessage>(OnEntityInserted);
|
||||||
SubscribeLocalEvent<StatusEffectContainerComponent, EntRemovedFromContainerMessage>(OnEntityRemoved);
|
SubscribeLocalEvent<StatusEffectContainerComponent, EntRemovedFromContainerMessage>(OnEntityRemoved);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<RejuvenateRemovedStatusEffectComponent, StatusEffectRelayedEvent<RejuvenateEvent>>(OnRejuvenate);
|
||||||
|
|
||||||
_containerQuery = GetEntityQuery<StatusEffectContainerComponent>();
|
_containerQuery = GetEntityQuery<StatusEffectContainerComponent>();
|
||||||
_effectQuery = GetEntityQuery<StatusEffectComponent>();
|
_effectQuery = GetEntityQuery<StatusEffectComponent>();
|
||||||
}
|
}
|
||||||
@@ -115,6 +118,12 @@ public sealed partial class StatusEffectsSystem : EntitySystem
|
|||||||
Dirty(args.Entity, statusComp);
|
Dirty(args.Entity, statusComp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnRejuvenate(Entity<RejuvenateRemovedStatusEffectComponent> ent,
|
||||||
|
ref StatusEffectRelayedEvent<RejuvenateEvent> args)
|
||||||
|
{
|
||||||
|
PredictedQueueDel(ent.Owner);
|
||||||
|
}
|
||||||
|
|
||||||
private void SetStatusEffectTime(EntityUid effect, TimeSpan? duration)
|
private void SetStatusEffectTime(EntityUid effect, TimeSpan? duration)
|
||||||
{
|
{
|
||||||
if (!_effectQuery.TryComp(effect, out var effectComp))
|
if (!_effectQuery.TryComp(effect, out var effectComp))
|
||||||
|
|||||||
@@ -19,8 +19,17 @@
|
|||||||
components:
|
components:
|
||||||
- MobState
|
- MobState
|
||||||
|
|
||||||
|
# Things that should be removed by rejuvenation should parent to this
|
||||||
|
# Also blocks the status effect being added to godmode-ed entities.
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: StatusEffectBase
|
parent: MobStatusEffectBase
|
||||||
|
id: MobStatusEffectDebuff
|
||||||
|
abstract: true
|
||||||
|
components:
|
||||||
|
- type: RejuvenateRemovedStatusEffect
|
||||||
|
|
||||||
|
- type: entity
|
||||||
|
parent: MobStatusEffectDebuff
|
||||||
id: MobStandStatusEffectBase
|
id: MobStandStatusEffectBase
|
||||||
abstract: true
|
abstract: true
|
||||||
components:
|
components:
|
||||||
@@ -36,7 +45,7 @@
|
|||||||
|
|
||||||
# The creature sleeps so heavily that nothing can wake him up. Not even its own death.
|
# The creature sleeps so heavily that nothing can wake him up. Not even its own death.
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: MobStatusEffectBase
|
parent: MobStatusEffectDebuff
|
||||||
id: StatusEffectForcedSleeping
|
id: StatusEffectForcedSleeping
|
||||||
name: forced sleep
|
name: forced sleep
|
||||||
components:
|
components:
|
||||||
@@ -46,7 +55,7 @@
|
|||||||
|
|
||||||
# This creature is asleep because it's disconnected from the game.
|
# This creature is asleep because it's disconnected from the game.
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: MobStatusEffectBase
|
parent: MobStatusEffectBase # Not even rejuvenate can cure SSD...
|
||||||
id: StatusEffectSSDSleeping
|
id: StatusEffectSSDSleeping
|
||||||
name: forced sleep
|
name: forced sleep
|
||||||
components:
|
components:
|
||||||
@@ -56,7 +65,7 @@
|
|||||||
|
|
||||||
# Blurs your vision and makes you randomly fall asleep
|
# Blurs your vision and makes you randomly fall asleep
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: MobStatusEffectBase
|
parent: MobStatusEffectDebuff
|
||||||
id: StatusEffectDrowsiness
|
id: StatusEffectDrowsiness
|
||||||
name: drowsiness
|
name: drowsiness
|
||||||
components:
|
components:
|
||||||
@@ -64,7 +73,7 @@
|
|||||||
|
|
||||||
# Adds drugs overlay
|
# Adds drugs overlay
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: MobStatusEffectBase
|
parent: MobStatusEffectDebuff
|
||||||
id: StatusEffectSeeingRainbow
|
id: StatusEffectSeeingRainbow
|
||||||
name: hallucinations
|
name: hallucinations
|
||||||
components:
|
components:
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
- type: entity
|
- type: entity
|
||||||
parent: MobStatusEffectBase
|
parent: MobStatusEffectDebuff
|
||||||
id: StatusEffectSlowdown
|
id: StatusEffectSlowdown
|
||||||
abstract: true
|
abstract: true
|
||||||
name: slowdown
|
name: slowdown
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
# Makes you more slippery, or perhaps less slippery.
|
# Makes you more slippery, or perhaps less slippery.
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: MobStatusEffectBase
|
parent: MobStatusEffectDebuff # Debatable if this should be MobStatusEffectBase or not
|
||||||
id: StatusEffectFriction
|
id: StatusEffectFriction
|
||||||
name: friction
|
name: friction
|
||||||
components:
|
components:
|
||||||
@@ -44,7 +44,7 @@
|
|||||||
# Stunnable Status Effect
|
# Stunnable Status Effect
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: MobStatusEffectBase
|
parent: MobStatusEffectDebuff
|
||||||
id: StatusEffectStunned
|
id: StatusEffectStunned
|
||||||
name: stunned
|
name: stunned
|
||||||
components:
|
components:
|
||||||
|
|||||||
Reference in New Issue
Block a user