Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Glimmer Rework 1: "Swingy Glimmer" #1480

Merged
merged 20 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<PanelContainer StyleClasses="BackgroundDark"></PanelContainer>
<BoxContainer Name="SettingsBox" Orientation="Horizontal" HorizontalExpand="True" VerticalExpand="False">
<Label Text="{Loc 'glimmer-monitor-interval'}"/>
<Button Name="IntervalButton6s" Access="Public" Text="6s" StyleClasses="OpenRight"/>
<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"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ public GlimmerMonitorUiFragment()
VerticalExpand = true;

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

IntervalButton1.Pressed = true;
IntervalButton6s.Pressed = true;

IntervalButton6s.OnPressed += _ => UpdateState(_cachedValues);
IntervalButton1.OnPressed += _ => UpdateState(_cachedValues);
IntervalButton5.OnPressed += _ => UpdateState(_cachedValues);
IntervalButton10.OnPressed += _ => UpdateState(_cachedValues);
Expand Down Expand Up @@ -62,14 +64,12 @@ private List<int> FormatGlimmerValues(List<int> glimmerValues)
{
var returnList = glimmerValues;

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

return ClipToFifteen(returnList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private void SpawnEntities(EntityUid uid, PsionicComponent component, EntitySpaw
component.CurrentDampening,
component.CurrentAmplification,
entry.Settings,
_glimmerSystem.Glimmer / 1000,
_glimmerSystem.GlimmerOutput / 1000,
component.CurrentAmplification,
component.CurrentAmplification);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ private void OnPowerUsed(EntityUid uid, PsionicComponent component, PsionicHealO
else ActivatePower(uid, component, args);

if (args.PopupText is not null
&& _glimmer.Glimmer > args.GlimmerPopupThreshold * args.ModifiedDampening)
&& _glimmer.GlimmerOutput > args.GlimmerPopupThreshold * args.ModifiedDampening)
_popupSystem.PopupEntity(Loc.GetString(args.PopupText, ("entity", uid)), uid,
Filter.Pvs(uid).RemoveWhereAttachedEntity(entity => !_examine.InRangeUnOccluded(uid, entity, ExamineRange, null)),
true,
args.PopupType);

if (args.PlaySound
&& _glimmer.Glimmer > args.GlimmerSoundThreshold * args.ModifiedDampening)
&& _glimmer.GlimmerOutput > args.GlimmerSoundThreshold * args.ModifiedDampening)
_audioSystem.PlayPvs(args.SoundUse, uid, args.AudioParams);

// Sanitize the Glimmer inputs because otherwise the game will crash if someone makes MaxGlimmer lower than MinGlimmer.
var minGlimmer = (int) Math.Round(MathF.MinMagnitude(args.MinGlimmer, args.MaxGlimmer)
* args.ModifiedAmplification - args.ModifiedDampening);
var maxGlimmer = (int) Math.Round(MathF.MaxMagnitude(args.MinGlimmer, args.MaxGlimmer)
* args.ModifiedAmplification - args.ModifiedDampening);
var minGlimmer = MathF.MinMagnitude(args.MinGlimmer, args.MaxGlimmer)
* args.ModifiedAmplification - args.ModifiedDampening;
var maxGlimmer = MathF.MaxMagnitude(args.MinGlimmer, args.MaxGlimmer)
* args.ModifiedAmplification - args.ModifiedDampening;

_psionics.LogPowerUsed(uid, args.PowerName, minGlimmer, maxGlimmer);
args.Handled = true;
Expand All @@ -89,7 +89,7 @@ private void AttemptDoAfter(EntityUid uid, PsionicComponent component, PsionicHe
var doAfterArgs = new DoAfterArgs(EntityManager, uid, args.UseDelay, ev, uid, target: args.Target)
{
BreakOnMove = args.BreakOnMove,
Hidden = _glimmer.Glimmer > args.GlimmerDoAfterVisibilityThreshold * args.ModifiedDampening,
Hidden = _glimmer.GlimmerOutput > args.GlimmerDoAfterVisibilityThreshold * args.ModifiedDampening,
};

if (!_doAfterSystem.TryStartDoAfter(doAfterArgs, out var doAfterId))
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Abilities/Psionics/AnomalyPowerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private void OnPowerUsed(EntityUid uid, PsionicComponent component, AnomalyPower
if (!_psionics.OnAttemptPowerUse(args.Performer, args.Settings.PowerName, args.Settings.ManaCost, args.Settings.CheckInsulation))
return;

var overcharged = args.Settings.DoSupercritical ? _glimmerSystem.Glimmer * component.CurrentAmplification
var overcharged = args.Settings.DoSupercritical ? _glimmerSystem.GlimmerOutput * component.CurrentAmplification
> Math.Min(args.Settings.SupercriticalThreshold * component.CurrentDampening, args.Settings.MaxSupercriticalThreshold)
: false;

Expand Down Expand Up @@ -84,7 +84,7 @@ public void DoAnomalySounds(EntityUid uid, PsionicComponent component, AnomalyPo
}

if (args.Settings.PulseSound is null
|| _glimmerSystem.Glimmer < args.Settings.GlimmerSoundThreshold * component.CurrentDampening)
|| _glimmerSystem.GlimmerOutput < args.Settings.GlimmerSoundThreshold * component.CurrentDampening)
return;

_audio.PlayEntity(args.Settings.PulseSound, uid, uid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ public override void OnAddPsionic(
public sealed partial class PsionicModifyGlimmer : PsionicPowerFunction
{
[DataField]
public int GlimmerModifier;
public float GlimmerModifier;

public override void OnAddPsionic(
EntityUid uid,
Expand All @@ -477,7 +477,7 @@ public override void OnAddPsionic(
PsionicPowerPrototype proto)
{
var glimmerSystem = entityManager.System<GlimmerSystem>();
glimmerSystem.Glimmer += GlimmerModifier;
glimmerSystem.DeltaGlimmerInput(GlimmerModifier);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Chapel/SacrificialAltarSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private void OnDoAfter(Entity<SacrificialAltarComponent> ent, ref SacrificeDoAft
_adminLogger.Add(LogType.Action, LogImpact.Extreme, $"{ToPrettyString(args.Args.User):player} sacrificed {ToPrettyString(target):target} on {ToPrettyString(ent):altar}");

// lower glimmer by a random amount
_glimmer.Glimmer -= (int) (ent.Comp.GlimmerReduction * psionic.CurrentAmplification);
_glimmer.DeltaGlimmerInput(ent.Comp.GlimmerReduction * psionic.CurrentAmplification);

if (ent.Comp.RewardPool is not null && _random.Prob(ent.Comp.BaseItemChance * psionic.CurrentDampening))
{
Expand Down
8 changes: 4 additions & 4 deletions Content.Server/Chat/TelepathicChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ public void SendTelepathicChat(EntityUid source, string message, bool hideChat)
}

if (_random.Prob(0.1f))
_glimmerSystem.Glimmer++;
_glimmerSystem.DeltaGlimmerInput(1);

if (_random.Prob(Math.Min(0.33f + (float) _glimmerSystem.Glimmer / 1500, 1)))
if (_random.Prob(Math.Min(0.33f + (float) _glimmerSystem.GlimmerOutput / 1500, 1)))
{
float obfuscation = 0.25f + (float) _glimmerSystem.Glimmer / 2000;
float obfuscation = 0.25f + (float) _glimmerSystem.GlimmerOutput / 2000;
var obfuscated = ObfuscateMessageReadability(message, obfuscation);
_chatManager.ChatMessageToMany(ChatChannel.Telepathic, obfuscated, messageWrap, source, hideChat, false, GetDreamers(clients.normal.Concat(clients.psychog)), Color.PaleVioletRed);
}
Expand Down Expand Up @@ -149,4 +149,4 @@ private string ObfuscateMessageReadability(string message, float chance)

return modifiedMessage.ToString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public sealed partial class ChangeGlimmerReactionEffect : EntityEffect
/// <summary>
/// Added to glimmer when reaction occurs.
/// </summary>
[DataField("count")]
public int Count = 1;
[DataField]
public float Count = 1;

public override void Effect(EntityEffectBaseArgs args)
{
Expand All @@ -25,6 +25,6 @@ public override void Effect(EntityEffectBaseArgs args)

var glimmerSystem = args.EntityManager.EntitySysManager.GetEntitySystem<GlimmerSystem>();

glimmerSystem.Glimmer += Count;
glimmerSystem.DeltaGlimmerInput(Count);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
namespace Content.Server.Objectives.Components;

/// <summary>
/// Requires that the player dies to be complete.
/// Requires that the player ensures glimmer remain above a specific amount.
/// </summary>
[RegisterComponent, Access(typeof(RaiseGlimmerConditionSystem))]
public sealed partial class RaiseGlimmerConditionComponent : Component
{
[DataField("target"), ViewVariables(VVAccess.ReadWrite)]
public int Target;
}
[DataField]
public float Target;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public sealed class RaiseGlimmerConditionSystem : EntitySystem
{
[Dependency] private readonly IEntitySystemManager _sysMan = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly GlimmerSystem _glimmer = default!;
public override void Initialize()
{
base.Initialize();
Expand All @@ -30,10 +31,9 @@ private void OnGetProgress(EntityUid uid, RaiseGlimmerConditionComponent comp, r
args.Progress = GetProgress(comp.Target);
}

private float GetProgress(int target)
private float GetProgress(float target)
{
var glimmer = _sysMan.GetEntitySystem<GlimmerSystem>().Glimmer;
var progress = Math.Min((float) glimmer / (float) target, 1f);
var progress = Math.Min(_glimmer.GlimmerOutput / target, 1f);
return progress;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public override void Update(float frameTime)
{
base.Update(frameTime);

if (_glimmerSystem.Glimmer == 0)
if (_glimmerSystem.GlimmerOutput == 0)
return; // yes, return. Glimmer value is global.

var curTime = _timing.CurTime;
Expand All @@ -38,7 +38,7 @@ public override void Update(float frameTime)
if (!TryComp<IntrinsicRadioTransmitterComponent>(scribe, out var radio))
continue;

var message = Loc.GetString("glimmer-report", ("level", _glimmerSystem.Glimmer));
var message = Loc.GetString("glimmer-report", ("level", _glimmerSystem.GlimmerOutput));
var channel = _prototypeManager.Index<RadioChannelPrototype>("Science");
_radioSystem.SendRadioMessage(scribe, message, channel, scribe);

Expand All @@ -62,7 +62,7 @@ private void OnInteractHand(EntityUid uid, SophicScribeComponent component, Inte

component.StateTime = _timing.CurTime + component.StateCD;

_chat.TrySendInGameICMessage(uid, Loc.GetString("glimmer-report", ("level", _glimmerSystem.Glimmer)), InGameICChatType.Speak, true);
_chat.TrySendInGameICMessage(uid, Loc.GetString("glimmer-report", ("level", _glimmerSystem.GlimmerOutput)), InGameICChatType.Speak, true);
}

private void OnGlimmerEventEnded(GlimmerEventEndedEvent args)
Expand All @@ -79,7 +79,7 @@ private void OnGlimmerEventEnded(GlimmerEventEndedEvent args)
speaker = swapped.OriginalEntity;
}

var message = Loc.GetString(args.Message, ("decrease", args.GlimmerBurned), ("level", _glimmerSystem.Glimmer));
var message = Loc.GetString(args.Message, ("decrease", args.GlimmerBurned), ("level", _glimmerSystem.GlimmerOutput));
var channel = _prototypeManager.Index<RadioChannelPrototype>("Common");
_radioSystem.SendRadioMessage(speaker, message, channel, speaker);
}
Expand Down
11 changes: 8 additions & 3 deletions Content.Server/Psionics/Glimmer/GlimmerCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,29 @@ public sealed class GlimmerShowCommand : IConsoleCommand
public async void Execute(IConsoleShell shell, string argStr, string[] args)
{
var entMan = IoCManager.Resolve<IEntityManager>();
shell.WriteLine(entMan.EntitySysManager.GetEntitySystem<GlimmerSystem>().Glimmer.ToString());
shell.WriteLine(entMan.EntitySysManager.GetEntitySystem<GlimmerSystem>().GlimmerOutput.ToString("#.##"));
}
}

[AdminCommand(AdminFlags.Debug)]
public sealed class GlimmerSetCommand : IConsoleCommand
{
// SetGlimmerOutput cannot accept inputs greater than or equal to this number. The equation spits out imaginary number solutions past this point.
private const int MaxGlimmer = 1000;

public string Command => "glimmerset";
public string Description => Loc.GetString("command-glimmerset-description");
public string Help => Loc.GetString("command-glimmerset-help");

public async void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length != 1
|| !int.TryParse(args[0], out var glimmerValue))
|| !float.TryParse(args[0], out var glimmerValue)
|| glimmerValue >= MaxGlimmer || glimmerValue < 0)
return;

var entMan = IoCManager.Resolve<IEntityManager>();
entMan.EntitySysManager.GetEntitySystem<GlimmerSystem>().Glimmer = glimmerValue;
var glimmerSystem = entMan.System<GlimmerSystem>();
glimmerSystem.SetGlimmerOutput(glimmerValue);
}
}
Loading
Loading