Skip to content

Commit

Permalink
Maintainer feedback time.
Browse files Browse the repository at this point in the history
  • Loading branch information
VMSolidus committed Jan 10, 2025
1 parent 758f550 commit 5a4c2aa
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 20 deletions.
62 changes: 42 additions & 20 deletions Content.Server/Abilities/Psionics/Abilities/AssayPowerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public override void Initialize()
SubscribeLocalEvent<PsionicComponent, AssayDoAfterEvent>(OnDoAfter);
}

/// <summary>
/// This power activates when scanning any entity, displaying to the player's chat window a variety of psionic related statistics about the target.
/// </summary>
private void OnPowerUsed(EntityUid uid, PsionicComponent psionic, AssayPowerActionEvent args)
{
if (!_psionics.OnAttemptPowerUse(args.Performer, "assay")
Expand All @@ -52,54 +55,73 @@ private void OnPowerUsed(EntityUid uid, PsionicComponent psionic, AssayPowerActi
args.Handled = true;
}

private void OnDoAfter(EntityUid uid, PsionicComponent userPsionic, AssayDoAfterEvent args)
/// <summary>
/// Assuming the DoAfter wasn't canceled, the user wasn't mindbroken, and the target still exists, prepare the scan results!
/// </summary>
private void OnDoAfter(EntityUid uid, PsionicComponent component, AssayDoAfterEvent args)
{
if (userPsionic is null)
if (component is null)
return;
userPsionic.DoAfter = null;
component.DoAfter = null;

var user = uid;
var target = args.Target;
if (target == null || args.Cancelled
|| !_playerManager.TryGetSessionByEntity(user, out var session))
return;

if (target == user)
{
var userAmp = MathF.Round(userPsionic.CurrentAmplification, 2).ToString("#.##");
var userDamp = MathF.Round(userPsionic.CurrentDampening, 2).ToString("#.##");
var userPotentia = MathF.Round(userPsionic.Potentia, 2).ToString("#.##");
var assayBody = Loc.GetString("assay-body", ("entity", target), ("amplification", userAmp), ("dampening", userDamp), ("potentia", userPotentia));
var userFeedback = $"[font size={args.FontSize}][color={args.FontColor}]{assayBody}[/color][/font]";
SendDescToChat(userFeedback, session);

var assaySelf = Loc.GetString("assay-self", ("entity", target));
_popups.PopupEntity(assaySelf, user, user, PopupType.LargeCaution);

var assaySelfFeedback = $"[font size={args.FontSize}][color={args.FontColor}]{assaySelf}[/color][/font]";
SendDescToChat(assaySelfFeedback, session);
if (InspectSelf(uid, args, session))
return;
}

if (!TryComp<PsionicComponent>(target, out var targetPsionic))
{
var noPowers = Loc.GetString("no-powers", ("entity", target));
_popups.PopupEntity(noPowers, user, user, PopupType.LargeCaution);

// Incredibly spooky message for non-psychic targets.
var noPowersFeedback = $"[font size={args.FontSize}][color={args.FontColor}]{noPowers}[/color][/font]";
SendDescToChat(noPowersFeedback, session);
return;
}

InspectOther(targetPsionic, args, session);
}

/// <summary>
/// This is a special use-case for scanning yourself with the power. The player receives a unique feedback message if they do so.
/// It however displays significantly less information when doing so. Consider this an intriguing easter egg.
/// </summary>
private bool InspectSelf(EntityUid uid, AssayDoAfterEvent args, ICommonSession session)
{
if (args.Target == args.User)
return false;

var user = uid;
var target = args.Target;

var assaySelf = Loc.GetString("assay-self", ("entity", target!.Value));
_popups.PopupEntity(assaySelf, user, user, PopupType.LargeCaution);

var assaySelfFeedback = $"[font size=20][color=#ff0000]{assaySelf}[/color][/font]";
SendDescToChat(assaySelfFeedback, session);
return true;
}

/// <summary>
/// If the target turns out to be a psychic, display their feedback messages in chat.
/// </summary>
private void InspectOther(PsionicComponent targetPsionic, AssayDoAfterEvent args, ICommonSession session)
{
var target = args.Target;
var targetAmp = MathF.Round(targetPsionic.CurrentAmplification, 2).ToString("#.##");
var targetDamp = MathF.Round(targetPsionic.CurrentDampening, 2).ToString("#.##");
var targetPotentia = MathF.Round(targetPsionic.Potentia, 2).ToString("#.##");
var message = $"[font size={args.FontSize}][color={args.FontColor}]{Loc.GetString("assay-body", ("entity", target), ("amplification", targetAmp), ("dampening", targetDamp), ("potentia", targetPotentia))}[/color][/font]";
var message = $"[font size={args.FontSize}][color={args.FontColor}]{Loc.GetString("assay-body", ("entity", target!.Value), ("amplification", targetAmp), ("dampening", targetDamp), ("potentia", targetPotentia))}[/color][/font]";
SendDescToChat(message, session);

foreach (var feedback in targetPsionic.AssayFeedback)
{
var locale = Loc.GetString(feedback, ("entity", target));
var locale = Loc.GetString(feedback, ("entity", target!.Value));
var feedbackMessage = $"[font size={args.FontSize}][color={args.FontColor}]{locale}[/color][/font]";
SendDescToChat(feedbackMessage, session);
}
Expand Down
1 change: 1 addition & 0 deletions Content.Shared/Actions/Events/AssayPowerActionEvent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Robust.Shared.Audio;

namespace Content.Shared.Actions.Events;

public sealed partial class AssayPowerActionEvent : EntityTargetActionEvent
{
[DataField]
Expand Down

0 comments on commit 5a4c2aa

Please sign in to comment.