Files
IC.Rebuild/Core/HeightActivation.cs

18 lines
581 B
C#

namespace ICRebuild.Core;
// Session state only. Editing the saved preset never changes the applied height.
public sealed class HeightActivation
{
private float applied;
public float Applied => Volatile.Read(ref applied);
public bool IsApplied => Applied!=0;
public float Toggle(bool moduleEnabled,float preset)
{
if(!moduleEnabled || IsApplied) { Reset(); return 0; }
var next=Policies.FiniteClamp(preset,-10,10);
Volatile.Write(ref applied,next);
return next;
}
public void Reset() => Volatile.Write(ref applied,0);
}