diff --git a/Content.Client/ADT/ShowMessageOnItemUse/AdtAmnesiaEui.cs b/Content.Client/ADT/ShowMessageOnItemUse/AdtAmnesiaEui.cs new file mode 100644 index 00000000000..7d30fe29c50 --- /dev/null +++ b/Content.Client/ADT/ShowMessageOnItemUse/AdtAmnesiaEui.cs @@ -0,0 +1,79 @@ +using System.Numerics; +using Content.Client.Eui; +using Robust.Client.Graphics; +using Robust.Client.UserInterface; +using Robust.Client.UserInterface.Controls; +using Robust.Client.UserInterface.CustomControls; +using static Robust.Client.UserInterface.Controls.BoxContainer; + +public sealed partial class AdtAmnesiaEui : BaseEui +{ + private readonly AdtAmnesiaWindow _window; + + public AdtAmnesiaEui() + { + _window = new(); + _window.OkButton.OnPressed += _ => + { + _window.Close(); + }; + } + + public override void Opened() + { + IoCManager.Resolve().RequestWindowAttention(); + _window.OpenCentered(); + base.Opened(); + } + + public override void Closed() + { + _window.Close(); + } +} + +public sealed class AdtAmnesiaWindow : DefaultWindow +{ + public readonly Button OkButton; + + public AdtAmnesiaWindow() + { + Title = Loc.GetString("accept-adt_amnesia-window-title"); + + Contents.AddChild(new BoxContainer + { + Orientation = LayoutOrientation.Vertical, + Children = + { + new BoxContainer + { + Orientation = LayoutOrientation.Vertical, + Children = + { + new Label() + { + Text = Loc.GetString("adt_amnesia-window-prompt-text-part") + }, + new BoxContainer + { + Orientation = LayoutOrientation.Horizontal, + Align = AlignMode.Center, + Children = + { + (OkButton = new Button + { + Text = "OK", + }), + + new Control() + { + MinSize = new Vector2(20, 0) + }, + } + }, + } + }, + } + }); + } +} diff --git a/Content.Server/ADT/ShowMessageOnItemUse/ShowMessageOnItemUseSystem.cs b/Content.Server/ADT/ShowMessageOnItemUse/ShowMessageOnItemUseSystem.cs new file mode 100644 index 00000000000..1a28b8f347e --- /dev/null +++ b/Content.Server/ADT/ShowMessageOnItemUse/ShowMessageOnItemUseSystem.cs @@ -0,0 +1,53 @@ +using Content.Server.EUI; +using Content.Server.Mind; +using Content.Shared.Charges.Components; +using Content.Shared.Charges.Systems; +using Content.Shared.Flash; +using Content.Shared.Interaction.Events; +using Content.Shared.Mind.Components; + +namespace Content.Server.ADT.ShowMessageOnItemUse; + +public sealed partial class ShowMessageOnItemUseSystem : EntitySystem +{ + [Dependency] private readonly EuiManager _euiManager = default!; + [Dependency] private readonly MindSystem _mind = default!; + [Dependency] private readonly EntityLookupSystem _entityLookup = default!; + [Dependency] private readonly SharedChargesSystem _charges = default!; + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(ItemUsed); + } + + private void ItemUsed(EntityUid uid, MindFlushComponent component, UseInHandEvent args) + { + if (TryComp(uid, out var charges)) + if (_charges.IsEmpty(uid, charges)) + return; + + var transform = EntityManager.GetComponent(uid); + var flashableQuery = GetEntityQuery(); + + foreach (var entity in _entityLookup.GetEntitiesInRange(transform.Coordinates, component.Range)) + { + if (!flashableQuery.TryGetComponent(entity, out var _)) + continue; + if (entity == args.User) + continue; + if (TryComp(entity, out var mindContainer)) + { + if (_mind.TryGetSession(mindContainer.Mind, out var session)) + { + _euiManager.OpenEui(new AdtAmnesiaEui(), session); + Console.WriteLine($"entity {entity} mind was flushed."); + } + } + + } + } +} + +public sealed class AdtAmnesiaEui : BaseEui +{ +} diff --git a/Content.Shared/ADT/ShowMessageOnItemUse/ShowMessageOnItemUseComponent.cs b/Content.Shared/ADT/ShowMessageOnItemUse/ShowMessageOnItemUseComponent.cs new file mode 100644 index 00000000000..7eb4e9ac3ce --- /dev/null +++ b/Content.Shared/ADT/ShowMessageOnItemUse/ShowMessageOnItemUseComponent.cs @@ -0,0 +1,11 @@ +[RegisterComponent] +public sealed partial class MindFlushComponent : Component +{ + /// + /// entities mind will be flushed in that range. + /// + [DataField("range")] + [ViewVariables(VVAccess.ReadWrite)] + public float Range { get; set; } = 7f; + +} diff --git a/Resources/Prototypes/ADT/_TimePatrol/flash.yml b/Resources/Prototypes/ADT/_TimePatrol/flash.yml new file mode 100644 index 00000000000..397fcf5dab4 --- /dev/null +++ b/Resources/Prototypes/ADT/_TimePatrol/flash.yml @@ -0,0 +1,9 @@ +- type: entity + name: flash + parent: Flash + id: MindFlushingFlash + description: Mind flusher. Keep eyes safe. + suffix: Time patrol + components: + type: MindFlush + range: 7 \ No newline at end of file