mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
StatusEffect On Trigger (#43665)
commit Co-authored-by: iaada <iaada@users.noreply.github.com>
This commit is contained in:
parent
39be43c60f
commit
5ca65503f7
3 changed files with 68 additions and 0 deletions
|
|
@ -0,0 +1,19 @@
|
|||
using Content.Shared.StatusEffectNew.Components;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared.Trigger.Components.Effects;
|
||||
|
||||
/// <summary>
|
||||
/// Removes a status effect when triggered.
|
||||
/// If TargetUser is true the user loses the status.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
public sealed partial class RemoveStatusEffectOnTriggerComponent : BaseXOnTriggerComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Status effect to be removed.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public EntProtoId<StatusEffectComponent> Status;
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
using Content.Shared.StatusEffectNew.Components;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared.Trigger.Components.Effects;
|
||||
|
||||
/// <summary>
|
||||
/// Adds a status effect when triggered.
|
||||
/// If TargetUser is true the user will gain the effect.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
public sealed partial class SetStatusEffectOnTriggerComponent : BaseXOnTriggerComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Status effect to be added.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public EntProtoId<StatusEffectComponent> Status;
|
||||
|
||||
/// <summary>
|
||||
/// How long the status lasts. Permanent until removed if null.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public TimeSpan? Duration;
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
using Content.Shared.StatusEffectNew;
|
||||
using Content.Shared.Trigger.Components.Effects;
|
||||
|
||||
namespace Content.Shared.Trigger.Systems;
|
||||
|
||||
public sealed class SetStatusEffectOnTriggerSystem : XOnTriggerSystem<SetStatusEffectOnTriggerComponent>
|
||||
{
|
||||
[Dependency] private readonly StatusEffectsSystem _status = default!;
|
||||
|
||||
protected override void OnTrigger(Entity<SetStatusEffectOnTriggerComponent> ent, EntityUid target, ref TriggerEvent args)
|
||||
{
|
||||
args.Handled |= _status.TrySetStatusEffectDuration(target, ent.Comp.Status, ent.Comp.Duration);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class RemoveStatusEffectOnTriggerSystem : XOnTriggerSystem<RemoveStatusEffectOnTriggerComponent>
|
||||
{
|
||||
[Dependency] private readonly StatusEffectsSystem _status = default!;
|
||||
|
||||
protected override void OnTrigger(Entity<RemoveStatusEffectOnTriggerComponent> ent, EntityUid target, ref TriggerEvent args)
|
||||
{
|
||||
args.Handled |= _status.TryRemoveStatusEffect(target, ent.Comp.Status);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue