Event-ify Rejuvenate (#11145)

This commit is contained in:
Visne
2022-09-14 19:30:56 +02:00
committed by GitHub
parent 81eee73995
commit 356a6b8d2e
13 changed files with 100 additions and 61 deletions

View File

@@ -5,6 +5,7 @@ using Content.Shared.Inventory;
using Content.Shared.MobState;
using Content.Shared.MobState.Components;
using Content.Shared.Radiation.Events;
using Content.Shared.Rejuvenate;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
@@ -21,6 +22,7 @@ namespace Content.Shared.Damage
SubscribeLocalEvent<DamageableComponent, ComponentHandleState>(DamageableHandleState);
SubscribeLocalEvent<DamageableComponent, ComponentGetState>(DamageableGetState);
SubscribeLocalEvent<DamageableComponent, OnIrradiatedEvent>(OnIrradiated);
SubscribeLocalEvent<DamageableComponent, RejuvenateEvent>(OnRejuvenate);
}
/// <summary>
@@ -245,6 +247,11 @@ namespace Content.Shared.Damage
TryChangeDamage(uid, damage);
}
private void OnRejuvenate(EntityUid uid, DamageableComponent component, RejuvenateEvent args)
{
SetAllDamage(component, 0);
}
private void DamageableHandleState(EntityUid uid, DamageableComponent component, ref ComponentHandleState args)
{
if (args.Current is not DamageableComponentState state)

View File

@@ -1,3 +1,4 @@
using Content.Shared.Rejuvenate;
using Content.Shared.StatusEffect;
using Robust.Shared.GameStates;
using Robust.Shared.Timing;
@@ -22,6 +23,7 @@ namespace Content.Shared.Jittering
{
SubscribeLocalEvent<JitteringComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<JitteringComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<JitteringComponent, RejuvenateEvent>(OnRejuvenate);
}
private void OnGetState(EntityUid uid, JitteringComponent component, ref ComponentGetState args)
@@ -38,6 +40,11 @@ namespace Content.Shared.Jittering
component.Frequency = jitteringState.Frequency;
}
private void OnRejuvenate(EntityUid uid, JitteringComponent component, RejuvenateEvent args)
{
EntityManager.RemoveComponentDeferred<JitteringComponent>(uid);
}
/// <summary>
/// Applies a jitter effect to the specified entity.
/// You can apply this to any entity whatsoever, so be careful what you use it on!

View File

@@ -0,0 +1,5 @@
namespace Content.Shared.Rejuvenate;
public sealed class RejuvenateEvent : EntityEventArgs
{
}

View File

@@ -1,5 +1,6 @@
using System.Diagnostics.CodeAnalysis;
using Content.Shared.Alert;
using Content.Shared.Rejuvenate;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
@@ -22,6 +23,7 @@ namespace Content.Shared.StatusEffect
SubscribeLocalEvent<StatusEffectsComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<StatusEffectsComponent, ComponentHandleState>(OnHandleState);
SubscribeLocalEvent<StatusEffectsComponent, RejuvenateEvent>(OnRejuvenate);
}
public override void Update(float frameTime)
@@ -82,6 +84,11 @@ namespace Content.Shared.StatusEffect
}
}
private void OnRejuvenate(EntityUid uid, StatusEffectsComponent component, RejuvenateEvent args)
{
TryRemoveAllStatusEffects(uid, component);
}
/// <summary>
/// Tries to add a status effect to an entity, with a given component added as well.
/// </summary>