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

Update GlimmerSystem.cs #1694

Merged
merged 2 commits into from
Jan 31, 2025
Merged
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
29 changes: 27 additions & 2 deletions 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 Prometheus;

namespace Content.Shared.Psionics.Glimmer;

Expand All @@ -13,6 +14,15 @@ public sealed class GlimmerSystem : EntitySystem
{
[Dependency] private readonly IConfigurationManager _cfg = default!;

private static readonly Gauge GlimmerInputCount = Metrics.CreateGauge(
"glimmer_input",
"Amount of Input Glimmer");

private static readonly Gauge GlimmerOutputCount = Metrics.CreateGauge(
"glimmer_output",
"Amount of Output Glimmer");


private float _glimmerInput = 0;

/// <summary>
Expand Down Expand Up @@ -73,7 +83,10 @@ public override void Initialize()
private void Reset(RoundRestartCleanupEvent args)
{
GlimmerInput = 0;
GlimmerInputCount.Set(GlimmerInput);

GlimmerOutput = 0;
GlimmerOutputCount.Set(GlimmerOutput);
}

/// <summary>
Expand Down Expand Up @@ -118,7 +131,10 @@ public void DeltaGlimmerInput(float delta)
if (_enabled && delta != 0)
{
GlimmerInput += delta;
GlimmerOutput = 2000 / (1 + MathF.Pow(MathF.E, -.0022f * GlimmerInput)) - 1000;
GlimmerInputCount.Set(GlimmerInput);

GlimmerOutput = Math.Clamp(2000 / (1 + MathF.Pow(MathF.E, -.0022f * GlimmerInput)) - 1000, 0, 999.999999f);
GlimmerOutputCount.Set(GlimmerOutput);
}
}

Expand All @@ -132,7 +148,10 @@ public void DeltaGlimmerOutput(float delta)
if (_enabled && delta != 0)
{
GlimmerOutput += delta;
GlimmerInput = 2000 / (1 + MathF.Pow(MathF.E, -.0022f * GlimmerOutput)) - 1000;
GlimmerOutputCount.Set(GlimmerOutput);

GlimmerInput = Math.Max(2000 / (1 + MathF.Pow(MathF.E, -.0022f * GlimmerOutput)) - 1000, 0);
GlimmerInputCount.Set(GlimmerInput);
}
}

Expand All @@ -146,7 +165,10 @@ public void SetGlimmerOutput(float set)
if (_enabled && set != 0)
{
GlimmerOutput = Math.Clamp(set, 0, 999.999f);
GlimmerOutputCount.Set(GlimmerOutput);

GlimmerInput = 2000 / (1 + MathF.Pow(MathF.E, -.0022f * GlimmerOutput)) - 1000;
GlimmerInputCount.Set(GlimmerInput);
}
}

Expand All @@ -160,7 +182,10 @@ public void SetGlimmerInput(float set)
if (_enabled && set >= 0)
{
GlimmerInput = set;
GlimmerInputCount.Set(GlimmerInput);

GlimmerOutput = 2000 / (1 + MathF.Pow(MathF.E, -.0022f * GlimmerOutput)) - 1000;
GlimmerOutputCount.Set(GlimmerOutput);
}
}

Expand Down
Loading