diff --git a/Content.Shared/Trigger/Components/Effects/AddTagsOnTriggerComponent.cs b/Content.Shared/Trigger/Components/Effects/AddTagsOnTriggerComponent.cs new file mode 100644 index 0000000000..9e73a60741 --- /dev/null +++ b/Content.Shared/Trigger/Components/Effects/AddTagsOnTriggerComponent.cs @@ -0,0 +1,20 @@ +using Content.Shared.Tag; +using Robust.Shared.GameStates; +using Robust.Shared.Prototypes; + +namespace Content.Shared.Trigger.Components.Effects; + +/// +/// Adds the given tags when triggered. +/// If TargetUser is true the tags will be added to the user instead. +/// +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +public sealed partial class AddTagsOnTriggerComponent : BaseXOnTriggerComponent +{ + /// + /// The tags to add. + /// + [DataField, AutoNetworkedField] + public List> Tags = new(); +} + diff --git a/Content.Shared/Trigger/Components/Effects/JitterOnTriggerComponent.cs b/Content.Shared/Trigger/Components/Effects/JitterOnTriggerComponent.cs new file mode 100644 index 0000000000..340ad6cb01 --- /dev/null +++ b/Content.Shared/Trigger/Components/Effects/JitterOnTriggerComponent.cs @@ -0,0 +1,47 @@ +using Content.Shared.StatusEffect; +using Robust.Shared.GameStates; + +namespace Content.Shared.Trigger.Components.Effects; + +/// +/// Makes the entity play a jitter animation when triggered. +/// If TargetUser is true the user will jitter instead. +/// +/// +/// The target requires . +/// TODO: Convert jitter to the new status effects system. +/// +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +public sealed partial class JitterOnTriggerComponent : BaseXOnTriggerComponent +{ + /// + /// Jitteriness of the animation. + /// + [DataField, AutoNetworkedField] + public float Amplitude = 10.0f; + + /// + /// Frequency for jittering. + /// + [DataField, AutoNetworkedField] + public float Frequency = 4.0f; + + /// + /// For how much time to apply the effect. + /// + [DataField, AutoNetworkedField] + public TimeSpan Time = TimeSpan.FromSeconds(2); + + /// + /// The status effect cooldown should be refreshed (true) or accumulated (false). + /// + [DataField, AutoNetworkedField] + public bool Refresh; + + /// + /// Whether to change any existing jitter value even if they're greater than the ones we're setting. + /// + [DataField, AutoNetworkedField] + public bool ForceValueChange; +} + diff --git a/Content.Shared/Trigger/Components/Effects/RemoveTagsOnTriggerComponent.cs b/Content.Shared/Trigger/Components/Effects/RemoveTagsOnTriggerComponent.cs new file mode 100644 index 0000000000..8e4d0e4611 --- /dev/null +++ b/Content.Shared/Trigger/Components/Effects/RemoveTagsOnTriggerComponent.cs @@ -0,0 +1,20 @@ +using Content.Shared.Tag; +using Robust.Shared.GameStates; +using Robust.Shared.Prototypes; + +namespace Content.Shared.Trigger.Components.Effects; + +/// +/// Remove the given tags when triggered. +/// If TargetUser is true the tags will be added to the user instead. +/// +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +public sealed partial class RemoveTagsOnTriggerComponent : BaseXOnTriggerComponent +{ + /// + /// The tags to remove. + /// + [DataField, AutoNetworkedField] + public List> Tags = new(); +} + diff --git a/Content.Shared/Trigger/Components/Effects/SwapLocationOnTriggerComponent.cs b/Content.Shared/Trigger/Components/Effects/SwapLocationOnTriggerComponent.cs new file mode 100644 index 0000000000..33cec1d56d --- /dev/null +++ b/Content.Shared/Trigger/Components/Effects/SwapLocationOnTriggerComponent.cs @@ -0,0 +1,10 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared.Trigger.Components.Effects; + +/// +/// Swaps the location of the target and the user of the trigger when triggered. +/// is ignored. +/// +[RegisterComponent, NetworkedComponent, AutoGenerateComponentState] +public sealed partial class SwapLocationOnTriggerComponent : BaseXOnTriggerComponent; diff --git a/Content.Shared/Trigger/Systems/JitterOnTriggerSystem.cs b/Content.Shared/Trigger/Systems/JitterOnTriggerSystem.cs new file mode 100644 index 0000000000..5a9e0463ed --- /dev/null +++ b/Content.Shared/Trigger/Systems/JitterOnTriggerSystem.cs @@ -0,0 +1,20 @@ +using Content.Shared.Jittering; +using Content.Shared.Trigger.Components.Effects; +using Robust.Shared.Network; + +namespace Content.Shared.Trigger.Systems; + +public sealed class JitterOnTriggerSystem : XOnTriggerSystem +{ + [Dependency] private readonly SharedJitteringSystem _jittering = default!; + [Dependency] private readonly INetManager _net = default!; + + protected override void OnTrigger(Entity ent, EntityUid target, ref TriggerEvent args) + { + // DoJitter mispredicts at the moment. + // TODO: Fix this and remove the IsServer check. + if (_net.IsServer) + _jittering.DoJitter(target, ent.Comp.Time, ent.Comp.Refresh, ent.Comp.Amplitude, ent.Comp.Frequency, ent.Comp.ForceValueChange); + args.Handled = true; + } +} diff --git a/Content.Shared/Trigger/Systems/SwapLocationOnTriggerSystem.cs b/Content.Shared/Trigger/Systems/SwapLocationOnTriggerSystem.cs new file mode 100644 index 0000000000..7b3004ad59 --- /dev/null +++ b/Content.Shared/Trigger/Systems/SwapLocationOnTriggerSystem.cs @@ -0,0 +1,30 @@ +using Content.Shared.Trigger.Components.Effects; +using Robust.Shared.Network; + +namespace Content.Shared.Trigger.Systems; + +public sealed class SwapLocationOnTriggerSystem : EntitySystem +{ + [Dependency] private readonly SharedTransformSystem _transform = default!; + [Dependency] private readonly INetManager _net = default!; + + public override void Initialize() + { + SubscribeLocalEvent(OnTrigger); + } + + private void OnTrigger(Entity ent, ref TriggerEvent args) + { + if (args.Key != null && !ent.Comp.KeysIn.Contains(args.Key)) + return; + + if (args.User == null) + return; + + // SwapPositions mispredicts at the moment. + // TODO: Fix this and remove the IsServer check. + if (_net.IsServer) + _transform.SwapPositions(ent.Owner, args.User.Value); + args.Handled = true; + } +} diff --git a/Content.Shared/Trigger/Systems/TagOnTriggerSystem.cs b/Content.Shared/Trigger/Systems/TagOnTriggerSystem.cs new file mode 100644 index 0000000000..d636593d43 --- /dev/null +++ b/Content.Shared/Trigger/Systems/TagOnTriggerSystem.cs @@ -0,0 +1,26 @@ +using Content.Shared.Tag; +using Content.Shared.Trigger.Components.Effects; + +namespace Content.Shared.Trigger.Systems; + +public sealed class AddTagsOnTriggerSystem : XOnTriggerSystem +{ + [Dependency] private readonly TagSystem _tag = default!; + + protected override void OnTrigger(Entity ent, EntityUid target, ref TriggerEvent args) + { + _tag.AddTags(target, ent.Comp.Tags); + args.Handled = true; + } +} + +public sealed class RemoveTagsOnTriggerSystem : XOnTriggerSystem +{ + [Dependency] private readonly TagSystem _tag = default!; + + protected override void OnTrigger(Entity ent, EntityUid target, ref TriggerEvent args) + { + _tag.RemoveTags(target, ent.Comp.Tags); + args.Handled = true; + } +}