Skip to content

Commit

Permalink
mind flusher
Browse files Browse the repository at this point in the history
  • Loading branch information
modern-nm authored and Schrodinger71 committed Sep 5, 2024
1 parent 144a3fe commit 2916358
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 0 deletions.
79 changes: 79 additions & 0 deletions Content.Client/ADT/ShowMessageOnItemUse/AdtAmnesiaEui.cs
Original file line number Diff line number Diff line change
@@ -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<IClyde>().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)
},
}
},
}
},
}
});
}
}
Original file line number Diff line number Diff line change
@@ -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<MindFlushComponent, UseInHandEvent>(ItemUsed);
}

private void ItemUsed(EntityUid uid, MindFlushComponent component, UseInHandEvent args)
{
if (TryComp<LimitedChargesComponent>(uid, out var charges))
if (_charges.IsEmpty(uid, charges))
return;

var transform = EntityManager.GetComponent<TransformComponent>(uid);
var flashableQuery = GetEntityQuery<FlashableComponent>();

foreach (var entity in _entityLookup.GetEntitiesInRange(transform.Coordinates, component.Range))
{
if (!flashableQuery.TryGetComponent(entity, out var _))
continue;
if (entity == args.User)
continue;
if (TryComp<MindContainerComponent>(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
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[RegisterComponent]
public sealed partial class MindFlushComponent : Component
{
/// <summary>
/// entities mind will be flushed in that range.
/// </summary>
[DataField("range")]
[ViewVariables(VVAccess.ReadWrite)]
public float Range { get; set; } = 7f;

}
9 changes: 9 additions & 0 deletions Resources/Prototypes/ADT/_TimePatrol/flash.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2916358

Please sign in to comment.