Skip to content

Commit

Permalink
More glimmer updates
Browse files Browse the repository at this point in the history
  • Loading branch information
VMSolidus committed Jun 28, 2024
1 parent c5b0e49 commit 2ed8c5d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
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 @@ -46,6 +46,8 @@ public override void Update(float frameTime)

_glimmerSystem.DeltaGlimmerOutput(-glimmerDecay);

GlimmerValues.Add((int) Math.Round(_glimmerSystem.GlimmerOutput));

NextUpdateTime = curTime + TargetUpdatePeriod;
LastUpdateTime = curTime;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,13 @@ public override void Update(float frameTime)
source.Accumulator -= source.SecondsPerGlimmer;
if (source.AddToGlimmer)
{
_glimmerSystem.DeltaGlimmerInput(1);
//If we're above the equilibrium point of 500, increase the output of passive glimmer sources to help fight against linear decay
//Even with this, don't expect probers to ever get to mind swap levels of power without any help
_glimmerSystem.DeltaGlimmerInput(_glimmerSystem.GlimmerOutput > 500 ? MathF.Round(_glimmerSystem.GlimmerOutput / 100) : 1f);
}
else
{
_glimmerSystem.DeltaGlimmerInput(1);
_glimmerSystem.DeltaGlimmerInput(-1);
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion Content.Shared/Psionics/Glimmer/GlimmerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Robust.Shared.Configuration;
using Content.Shared.CCVar;
using Content.Shared.GameTicking;
using Content.Shared.Mobs;

namespace Content.Shared.Psionics.Glimmer
{
Expand Down Expand Up @@ -36,7 +37,7 @@ public float GlimmerInput
public float GlimmerOutput
{
get { return _glimmerOutput; }
private set { _glimmerOutput = _enabled ? Math.Max(value, 0) : 0; }
private set { _glimmerOutput = _enabled ? Math.Clamp(value, 0, 999.999f) : 0; }
}
private bool _enabled;
public override void Initialize()
Expand Down

0 comments on commit 2ed8c5d

Please sign in to comment.