Skip to content

Commit

Permalink
Psionics (#44)
Browse files Browse the repository at this point in the history
* Psionics

It's a ton of stuff relating to the basic Psionics system and all the powers.

I'm saving this as a bit of a sanity check before moving forward.

Left to do:
1. Implementing the Psionic faction so that the chat works as intended.
2. Adding the start-state cooldown timers to the actions.

* Cleaned up everything with the word 'Psionic' on it.

Got the psionic chat working. Got some other stuff working

* Some final psionic cleanup.

The last batch of content.

* Update RobustToolbox

* rebased

* Revert "Update RobustToolbox"

This reverts commit c0cf35d.

* Update RobustToolbox

* Revert "Update RobustToolbox"

This reverts commit c4dc828.

* Update RobustToolbox

* Psionics

It's a ton of stuff relating to the basic Psionics system and all the powers.

I'm saving this as a bit of a sanity check before moving forward.

Left to do:
1. Implementing the Psionic faction so that the chat works as intended.
2. Adding the start-state cooldown timers to the actions.

* Cleaned up everything with the word 'Psionic' on it.

Got the psionic chat working. Got some other stuff working

* Some final psionic cleanup.

The last batch of content.

* rebased

* Cleaned up everything with the word 'Psionic' on it.

Got the psionic chat working. Got some other stuff working

* Broken Commit

With these changes in place, the unit does not work. Recording them so i don't lose my work.

* Brings it All Together.

Dawn of the final Commit. Rebase completed.

* Update RobustToolbox

* Changed 'Station Events' to 'StationEvents' and cleaned up the Delta-V Events.yml file of duplicate events.

* Delete ghost_roles.yml

Duplicate.

* Update familiars.yml

* Update familiars.yml

* Update GlimmerReactiveSystem.cs

* Makes tinfoil hats craftable.

* Decided I'm not dealing with adding fugitives or Glimmer Wisps right now.

* Psionic invisibility won't work now that Eye component exists. Or at least, the integrator test won't psas.

* Update special.yml

* Added #nyanotrasen code or //Nyanotrasen code to many, many files.

* Properly fixes comments.

---------

Signed-off-by: Colin-Tel <[email protected]>
Signed-off-by: PHCodes <[email protected]>
Co-authored-by: Debug <[email protected]>
Co-authored-by: Colin-Tel <[email protected]>
  • Loading branch information
3 people authored Oct 8, 2023
1 parent 531d99c commit 93c3b03
Show file tree
Hide file tree
Showing 259 changed files with 6,512 additions and 115 deletions.
12 changes: 11 additions & 1 deletion Content.Client/Chat/Managers/ChatManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ internal sealed class ChatManager : IChatManager
[Dependency] private readonly IEntitySystemManager _systems = default!;

private ISawmill _sawmill = default!;

public event Action? PermissionsUpdated; //Nyano - Summary: need to be able to update perms for new psionics.
public void Initialize()
{
_sawmill = Logger.GetSawmill("chat");
Expand Down Expand Up @@ -67,9 +67,19 @@ public void SendMessage(string text, ChatSelectChannel channel)
_consoleHost.ExecuteCommand($"whisper \"{CommandParsing.Escape(str)}\"");
break;

//Nyano - Summary: sends the command for telepath communication.
case ChatSelectChannel.Telepathic:
_consoleHost.ExecuteCommand($"tsay \"{CommandParsing.Escape(str)}\"");
break;

default:
throw new ArgumentOutOfRangeException(nameof(channel), channel, null);
}
}
//Nyano - Summary: fires off the update permissions script.
public void UpdatePermissions()
{
PermissionsUpdated?.Invoke();
}
}
}
6 changes: 6 additions & 0 deletions Content.Client/Chat/Managers/IChatManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ public interface IChatManager
void Initialize();

public void SendMessage(string text, ChatSelectChannel channel);

/// <summary>
/// Nyano - Summary:. Will refresh perms.
/// </summary>
event Action PermissionsUpdated;
public void UpdatePermissions();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
using Content.Client.UserInterface.Fragments;
using Content.Shared.CartridgeLoader.Cartridges;
using Content.Shared.CartridgeLoader;

namespace Content.Client.Nyanotrasen.CartridgeLoader.Cartridges;

public sealed partial class GlimmerMonitorUi : UIFragment
{
private GlimmerMonitorUiFragment? _fragment;

public override Control GetUIFragmentRoot()
{
return _fragment!;
}

public override void Setup(BoundUserInterface userInterface, EntityUid? fragmentOwner)
{
_fragment = new GlimmerMonitorUiFragment();

_fragment.OnSync += _ => SendSyncMessage(userInterface);
}

public override void UpdateState(BoundUserInterfaceState state)
{
if (state is not GlimmerMonitorUiState monitorState)
return;

_fragment?.UpdateState(monitorState.GlimmerValues);
}

private void SendSyncMessage(BoundUserInterface userInterface)
{
var syncMessage = new GlimmerMonitorSyncMessageEvent();
var message = new CartridgeUiMessage(syncMessage);
userInterface.SendMessage(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<cartridges:GlimmerMonitorUiFragment xmlns:cartridges="clr-namespace:Content.Client.Nyanotrasen.CartridgeLoader.Cartridges"
xmlns="https://spacestation14.io" Margin="1 0 2 0">
<PanelContainer StyleClasses="BackgroundDark"></PanelContainer>
<BoxContainer Name="SettingsBox" Orientation="Horizontal" HorizontalExpand="True" VerticalExpand="False">
<Label Text="{Loc 'glimmer-monitor-interval'}"/>
<Button Name="IntervalButton1" Access="Public" Text="1m" StyleClasses="OpenRight"/>
<Button Name="IntervalButton5" Access="Public" Text="5m" StyleClasses="OpenBoth"/>
<Button Name="IntervalButton10" Access="Public" Text="10m" StyleClasses="OpenLeft"/>
<Button Name="SyncButton" Access="Public" Text="{Loc 'glimmer-monitor-sync'}" Margin="200 0 0 0" />
</BoxContainer>
<BoxContainer Name="MonitorBox" Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True">
</BoxContainer>
</cartridges:GlimmerMonitorUiFragment>
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
using System.Linq;
using System.Numerics;
using Robust.Client.AutoGenerated;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Content.Client.Nyanotrasen.UserInterface.CustomControls;

namespace Content.Client.Nyanotrasen.CartridgeLoader.Cartridges;

[GenerateTypedNameReferences]
public sealed partial class GlimmerMonitorUiFragment : BoxContainer
{
[Dependency] private readonly IResourceCache _resourceCache = default!;

public event Action<bool>? OnSync;
private List<int> _cachedValues = new();

public GlimmerMonitorUiFragment()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);

Orientation = LayoutOrientation.Vertical;
HorizontalExpand = true;
VerticalExpand = true;

var intervalGroup = new ButtonGroup();
IntervalButton1.Group = intervalGroup;
IntervalButton5.Group = intervalGroup;
IntervalButton10.Group = intervalGroup;

IntervalButton1.Pressed = true;

IntervalButton1.OnPressed += _ => UpdateState(_cachedValues);
IntervalButton5.OnPressed += _ => UpdateState(_cachedValues);
IntervalButton10.OnPressed += _ => UpdateState(_cachedValues);

SyncButton.OnPressed += _ => OnSync?.Invoke(true);
}

public void UpdateState(List<int> glimmerValues)
{
_cachedValues = glimmerValues;
if (glimmerValues.Count < 1)
return;

MonitorBox.RemoveAllChildren();

var glimmerLabel = new Label();
glimmerLabel.Text = Loc.GetString("glimmer-monitor-current-glimmer", ("glimmer", glimmerValues[^1]));
MonitorBox.AddChild(glimmerLabel);

var formattedValues = FormatGlimmerValues(glimmerValues);
var graph = new GlimmerGraph(_resourceCache, formattedValues);
graph.SetSize = new Vector2(450, 250);
MonitorBox.AddChild(graph);
}


private List<int> FormatGlimmerValues(List<int> glimmerValues)
{
var returnList = glimmerValues;

if (IntervalButton5.Pressed)
{
returnList = GetAveragedList(glimmerValues, 5);
}
else if (IntervalButton10.Pressed)
{
returnList = GetAveragedList(glimmerValues, 10);
}

return ClipToFifteen(returnList);
}

/// <summary>
/// Format glimmer values to get <=15 data points correctly.
/// </summary>
private List<int> ClipToFifteen(List<int> glimmerValues)
{
List<int> returnList;

if (glimmerValues.Count <= 15)
{
returnList = glimmerValues;
}
else
{
returnList = glimmerValues.Skip(glimmerValues.Count - 15).ToList();
}

return returnList;
}

private List<int> GetAveragedList(IEnumerable<int> glimmerValues, int interval)
{
var returnList = new List<int>();
var subtotal = 0;
var elementsPassed = 0;
for (int i = 0; i < glimmerValues.Count(); ++i)
{
subtotal += glimmerValues.ElementAt(i);
++elementsPassed;
if (elementsPassed == interval)
{
returnList.Add(subtotal / interval);
subtotal = 0;
elementsPassed = 0;
}
}
if (elementsPassed != 0)
returnList.Add(subtotal / elementsPassed);
return returnList;
}
}
32 changes: 32 additions & 0 deletions Content.Client/Nyanotrasen/Chat/PsionicChatUpdateSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Content.Shared.Abilities.Psionics;
using Content.Client.Chat.Managers;
using Robust.Client.Player;

namespace Content.Client.Nyanotrasen.Chat
{
public sealed class PsionicChatUpdateSystem : EntitySystem
{
[Dependency] private readonly IChatManager _chatManager = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PsionicComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<PsionicComponent, ComponentRemove>(OnRemove);
}

public PsionicComponent? Player => CompOrNull<PsionicComponent>(_playerManager.LocalPlayer?.ControlledEntity);
public bool IsPsionic => Player != null;

private void OnInit(EntityUid uid, PsionicComponent component, ComponentInit args)
{
_chatManager.UpdatePermissions();
}

private void OnRemove(EntityUid uid, PsionicComponent component, ComponentRemove args)
{
_chatManager.UpdatePermissions();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace Content.Client.Psionics.Glimmer;

public enum GlimmerReactiveVisualLayers : byte
{
GlimmerEffect,
}
42 changes: 42 additions & 0 deletions Content.Client/Nyanotrasen/Psionics/UI/AcceptPsionicsEUI.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Content.Client.Eui;
using Content.Shared.Psionics;
using JetBrains.Annotations;
using Robust.Client.Graphics;

namespace Content.Client.Psionics.UI
{
[UsedImplicitly]
public sealed class AcceptPsionicsEui : BaseEui
{
private readonly AcceptPsionicsWindow _window;

public AcceptPsionicsEui()
{
_window = new AcceptPsionicsWindow();

_window.DenyButton.OnPressed += _ =>
{
SendMessage(new AcceptPsionicsChoiceMessage(AcceptPsionicsUiButton.Deny));
_window.Close();
};

_window.AcceptButton.OnPressed += _ =>
{
SendMessage(new AcceptPsionicsChoiceMessage(AcceptPsionicsUiButton.Accept));
_window.Close();
};
}

public override void Opened()
{
IoCManager.Resolve<IClyde>().RequestWindowAttention();
_window.OpenCentered();
}

public override void Closed()
{
_window.Close();
}

}
}
62 changes: 62 additions & 0 deletions Content.Client/Nyanotrasen/Psionics/UI/AcceptPsionicsWindow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System.Numerics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Localization;
using static Robust.Client.UserInterface.Controls.BoxContainer;

namespace Content.Client.Psionics.UI
{
public sealed class AcceptPsionicsWindow : DefaultWindow
{
public readonly Button DenyButton;
public readonly Button AcceptButton;

public AcceptPsionicsWindow()
{

Title = Loc.GetString("accept-psionics-window-title");

Contents.AddChild(new BoxContainer
{
Orientation = LayoutOrientation.Vertical,
Children =
{
new BoxContainer
{
Orientation = LayoutOrientation.Vertical,
Children =
{
(new Label()
{
Text = Loc.GetString("accept-psionics-window-prompt-text-part")
}),
new BoxContainer
{
Orientation = LayoutOrientation.Horizontal,
Align = AlignMode.Center,
Children =
{
(AcceptButton = new Button
{
Text = Loc.GetString("accept-cloning-window-accept-button"),
}),

(new Control()
{
MinSize = new Vector2(20, 0)
}),

(DenyButton = new Button
{
Text = Loc.GetString("accept-cloning-window-deny-button"),
})
}
},
}
},
}
});
}
}
}
Loading

0 comments on commit 93c3b03

Please sign in to comment.