-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
144a3fe
commit 2916358
Showing
4 changed files
with
152 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
}, | ||
} | ||
}, | ||
} | ||
}, | ||
} | ||
}); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
Content.Server/ADT/ShowMessageOnItemUse/ShowMessageOnItemUseSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
} |
11 changes: 11 additions & 0 deletions
11
Content.Shared/ADT/ShowMessageOnItemUse/ShowMessageOnItemUseComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |