Add EntityEffectOnTrigger and RejuvenateOnTrigger (#40967)

commit
This commit is contained in:
slarticodefast
2025-10-19 16:42:18 +02:00
committed by GitHub
parent 69e2963945
commit 1b7fa85733
10 changed files with 110 additions and 9 deletions

View File

@@ -1,5 +1,4 @@
using Content.Server.Administration.Commands; using Content.Shared.Administration.Systems;
using Content.Server.Administration.Systems;
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes; using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint; using Content.Shared.FixedPoint;

View File

@@ -2,10 +2,10 @@ using System.Linq;
using Content.Server.Administration.Logs; using Content.Server.Administration.Logs;
using Content.Server.Administration.Managers; using Content.Server.Administration.Managers;
using Content.Server.Administration.Notes; using Content.Server.Administration.Notes;
using Content.Server.Administration.Systems;
using Content.Server.Database; using Content.Server.Database;
using Content.Server.EUI; using Content.Server.EUI;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Administration.Systems;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.Eui; using Content.Shared.Eui;
using Content.Shared.Follower; using Content.Shared.Follower;

View File

@@ -9,6 +9,7 @@ using Content.Server.Prayer;
using Content.Server.Silicons.Laws; using Content.Server.Silicons.Laws;
using Content.Server.Station.Systems; using Content.Server.Station.Systems;
using Content.Shared.Administration; using Content.Shared.Administration;
using Content.Shared.Administration.Systems;
using Content.Shared.Chemistry.Components.SolutionManager; using Content.Shared.Chemistry.Components.SolutionManager;
using Content.Shared.Chemistry.EntitySystems; using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Configurable; using Content.Shared.Configurable;

View File

@@ -1,5 +1,5 @@
using Content.Server.Administration.Systems; using Content.Shared.Administration;
using Content.Shared.Administration; using Content.Shared.Administration.Systems;
using Robust.Shared.Toolshed; using Robust.Shared.Toolshed;
using Robust.Shared.Toolshed.Errors; using Robust.Shared.Toolshed.Errors;

View File

@@ -1,9 +1,12 @@
using Content.Shared.Rejuvenate; using Content.Shared.Rejuvenate;
namespace Content.Server.Administration.Systems; namespace Content.Shared.Administration.Systems;
public sealed class RejuvenateSystem : EntitySystem public sealed class RejuvenateSystem : EntitySystem
{ {
/// <summary>
/// Fully heals the target, removing all damage, debuffs or other negative status effects.
/// </summary>
public void PerformRejuvenate(EntityUid target) public void PerformRejuvenate(EntityUid target)
{ {
RaiseLocalEvent(target, new RejuvenateEvent()); RaiseLocalEvent(target, new RejuvenateEvent());

View File

@@ -1,5 +1,9 @@
namespace Content.Shared.Rejuvenate; namespace Content.Shared.Rejuvenate;
public sealed class RejuvenateEvent : EntityEventArgs /// <summary>
{ /// Raised when an entity is supposed to be rejuvenated,
} /// meaning it should heal all damage, debuffs or other negative status effects.
/// Systems should handle healing the entity in a subscription to this event.
/// Used for the Rejuvenate admin verb.
/// </summary>
public sealed class RejuvenateEvent : EntityEventArgs;

View File

@@ -0,0 +1,24 @@
using Content.Shared.EntityEffects;
using Robust.Shared.GameStates;
namespace Content.Shared.Trigger.Components.Effects;
/// <summary>
/// Applies a list of entity effects to the owning entity when triggered.
/// If TargetUser is true then they will be applied to the user instead.
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class EntityEffectOnTriggerComponent : BaseXOnTriggerComponent
{
/// <summary>
/// The effects to apply.
/// </summary>
[DataField, AutoNetworkedField]
public EntityEffect[] Effects;
/// <summary>
/// Optional scale multiplier for the effects.
/// </summary>
[DataField, AutoNetworkedField]
public float Scale = 1f;
}

View File

@@ -0,0 +1,10 @@
using Robust.Shared.GameStates;
namespace Content.Shared.Trigger.Components.Effects;
/// <summary>
/// Rejuvenates the entity when triggered, which fully heals them, removing all damage, debuffs or other negative status effects.
/// If TargetUser is true then the user will be rejuvenated instead.
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class RejuvenateOnTriggerComponent : BaseXOnTriggerComponent;

View File

@@ -0,0 +1,30 @@
using Content.Shared.EntityEffects;
using Content.Shared.Trigger.Components.Effects;
namespace Content.Shared.Trigger.Systems;
public sealed class EntityEffectOnTriggerSystem : EntitySystem
{
[Dependency] private readonly SharedEntityEffectsSystem _effects = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<EntityEffectOnTriggerComponent, TriggerEvent>(OnTrigger);
}
private void OnTrigger(Entity<EntityEffectOnTriggerComponent> ent, ref TriggerEvent args)
{
if (args.Key != null && !ent.Comp.KeysIn.Contains(args.Key))
return;
var target = ent.Comp.TargetUser ? args.User : ent.Owner;
if (target == null)
return;
_effects.ApplyEffects(target.Value, ent.Comp.Effects, ent.Comp.Scale);
args.Handled = true;
}
}

View File

@@ -0,0 +1,30 @@
using Content.Shared.Administration.Systems;
using Content.Shared.Trigger.Components.Effects;
namespace Content.Shared.Trigger.Systems;
public sealed class RejuvenateOnTriggerSystem : EntitySystem
{
[Dependency] private readonly RejuvenateSystem _rejuvenate = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RejuvenateOnTriggerComponent, TriggerEvent>(OnTrigger);
}
private void OnTrigger(Entity<RejuvenateOnTriggerComponent> ent, ref TriggerEvent args)
{
if (args.Key != null && !ent.Comp.KeysIn.Contains(args.Key))
return;
var target = ent.Comp.TargetUser ? args.User : ent.Owner;
if (target == null)
return;
_rejuvenate.PerformRejuvenate(target.Value);
args.Handled = true;
}
}