diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index beca6b5d3..ab43a162f 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -1820,8 +1820,21 @@ static void RequireDaemonRenderQueryAuthority(string root) "public double ConvergenceMinimumDistance { get; }", "public double HypothermiaTemperature { get; }", "public double HeatstrokeTemperature { get; }", + "public double SevereHeatstrokeRiskThreshold { get; }", + "public double TargetDetectionInfoThreshold { get; }", + "public double LockIndicatorNoiseAmplitude { get; }", "public double NormalizeThermalRisk(double temperature)", + "public double NormalizeHeatstrokePost(double heatstroke)", + "public double NormalizeSevereHeatstrokePost(double heatstroke)", + "public double NormalizeDetectionProgress(double infoGathered)", + "public double NormalizeTargetVisibilityFill(double infoGathered)", + "public double NormalizeVisibilityToTargetFill(double infoGathered)", + "public double ResolveLockIndicatorNoiseAmplitude(double lockProgress)", + "public double ResolveLockIndicatorNoiseFrequency(double lockProgress)", + "public double ResolveLockSpinSpeed(double lockProgress)", "public AetheriaRuntimeExponentialCurve TemperatureEmissionCurve { get; }", + "public AetheriaRuntimeExponentialLerp LockIndicatorFrequency { get; }", + "public AetheriaRuntimeExponentialLerp LockSpinSpeed { get; }", "public static AetheriaRuntimeGravityInfluenceBrush[] QueryGravityInfluences(", "AetheriaRuntimeZoneSnapshotCommit? zone", "public static int QueryGravityInfluences(", @@ -2171,6 +2184,50 @@ static void RequireDaemonRenderQueryAuthority(string root) throw new InvalidOperationException( "HUD thermal presentation no longer flows through the shared daemon render settings bridge."); } + + var requiredActionGameManagerRenderSymbols = new[] + { + "renderSettings.NormalizeDetectionProgress(", + "renderSettings.NormalizeHeatstrokePost(", + "renderSettings.NormalizeSevereHeatstrokePost(", + "renderSettings.NormalizeTargetVisibilityFill(", + "renderSettings.NormalizeVisibilityToTargetFill(", + "renderSettings.ResolveLockIndicatorNoiseAmplitude(", + "renderSettings.ResolveLockIndicatorNoiseFrequency(", + "renderSettings.ResolveLockSpinSpeed(", + "new AetheriaRuntimeExponentialLerp(", + "Settings.GameplaySettings.TargetDetectionInfoThreshold", + "Settings.GameplaySettings.SevereHeatstrokeRiskThreshold", + "Settings.GameplaySettings.LockIndicatorNoiseAmplitude" + }; + + var missingActionGameManagerRenderSymbols = requiredActionGameManagerRenderSymbols + .Where(symbol => !actionGameManager.Contains(symbol, StringComparison.Ordinal)) + .ToArray(); + if (missingActionGameManagerRenderSymbols.Length > 0) + { + throw new InvalidOperationException( + "ActionGameManager no longer bridges Unity render tuning through shared daemon render settings: " + + string.Join(", ", missingActionGameManagerRenderSymbols)); + } + + var forbiddenRenderLoopSymbols = new[] + { + "Settings.GameplaySettings.TargetDetectionInfoThreshold", + "Settings.GameplaySettings.SevereHeatstrokeRiskThreshold", + "Settings.GameplaySettings.LockIndicatorNoiseAmplitude", + "Settings.GameplaySettings.LockIndicatorFrequency", + "Settings.GameplaySettings.LockSpinSpeed" + }; + var renderLoopHits = FindMethodScopedLineHits(actionGameManager, forbiddenRenderLoopSymbols) + .Where(hit => hit.MethodName is "Update" or "UpdateTargetIndicators") + .ToArray(); + if (renderLoopHits.Length > 0) + { + throw new InvalidOperationException( + "ActionGameManager render loops must interpret observed state through shared daemon render settings instead of Unity GameSettings: " + + string.Join(", ", renderLoopHits.Select(hit => $"{hit.MethodName}:{hit.LineNumber}:{hit.Line.Trim()}"))); + } } static void RequireTypedZoneConstructionKeys(string root) diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index 972d418c3..78a9567c1 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -569,9 +569,20 @@ public class ActionGameManager : MonoBehaviour emissionCurve.Exponent, emissionCurve.Multiplier, emissionCurve.Constant), + new AetheriaRuntimeExponentialLerp( + Settings.GameplaySettings.LockIndicatorFrequency.Exponent, + Settings.GameplaySettings.LockIndicatorFrequency.Minimum, + Settings.GameplaySettings.LockIndicatorFrequency.Maximum), + new AetheriaRuntimeExponentialLerp( + Settings.GameplaySettings.LockSpinSpeed.Exponent, + Settings.GameplaySettings.LockSpinSpeed.Minimum, + Settings.GameplaySettings.LockSpinSpeed.Maximum), Settings.GameplaySettings.ConvergenceMinimumDistance, Settings.GameplaySettings.HypothermiaTemperature, - Settings.GameplaySettings.HeatstrokeTemperature); + Settings.GameplaySettings.HeatstrokeTemperature, + Settings.GameplaySettings.SevereHeatstrokeRiskThreshold, + Settings.GameplaySettings.TargetDetectionInfoThreshold, + Settings.GameplaySettings.LockIndicatorNoiseAmplitude); } private readonly (float2 direction, string name)[] _directions = { @@ -3344,7 +3355,7 @@ public class ActionGameManager : MonoBehaviour AetheriaRuntimeDaemonRenderQueries.QueryEntityContacts( FindCurrentDaemonZoneSnapshot(), CurrentEntity.DaemonEntityIndex, - Settings.GameplaySettings.TargetDetectionInfoThreshold, + ZoneRenderer.RenderSettings.TargetDetectionInfoThreshold, true, _observedVisibleContacts); @@ -3644,6 +3655,7 @@ public class ActionGameManager : MonoBehaviour // ItemManager.Time = _time; if(IsCurrentEntityObservedUndocked()) { + var renderSettings = ZoneRenderer.RenderSettings; var observedTarget = GetObservedTarget(CurrentEntity); ReconcileVisibleTargetIndicators(); foreach (var indicator in _visibleHostileIndicators) @@ -3656,9 +3668,9 @@ public class ActionGameManager : MonoBehaviour { var infoGatheredByHostile = GetObservedInfoGathered(indicator.Key, CurrentEntity); indicator.Value.Fill.fillAmount = - Saturate(infoGatheredByHostile / Settings.GameplaySettings.TargetDetectionInfoThreshold); + (float)renderSettings.NormalizeDetectionProgress(infoGatheredByHostile); indicator.Value.Fill.enabled = - !(infoGatheredByHostile > Settings.GameplaySettings.TargetDetectionInfoThreshold) || + !(infoGatheredByHostile > renderSettings.TargetDetectionInfoThreshold) || Mathf.Sin(TargetSpottedBlinkFrequency * Time.time) + TargetSpottedBlinkOffset > 0; } } @@ -3673,7 +3685,7 @@ public class ActionGameManager : MonoBehaviour indicator.Value.Fill.enabled = true; var infoGatheredByFriendly = GetObservedInfoGathered(indicator.Key, CurrentEntity); indicator.Value.Fill.fillAmount = - Saturate(infoGatheredByFriendly / Settings.GameplaySettings.TargetDetectionInfoThreshold); + (float)renderSettings.NormalizeDetectionProgress(infoGatheredByFriendly); } } var look = Input.Player.Look.ReadValue(); @@ -3682,8 +3694,8 @@ public class ActionGameManager : MonoBehaviour Mathf.Clamp(_entityYawPitch.y + look.y * Sensitivity.y, -.45f * Mathf.PI, .45f * Mathf.PI)); _viewDirection = Quaternion.Euler(_entityYawPitch.y * Mathf.Rad2Deg, _entityYawPitch.x * Mathf.Rad2Deg, 0) * Vector3.forward; RequestLookDirection(_viewDirection); - HeatstrokePost.weight = Saturate(Unlerp(0, Settings.GameplaySettings.SevereHeatstrokeRiskThreshold, CurrentEntity.Heatstroke)); - var severeHeatstrokeLerp = Saturate(Unlerp(Settings.GameplaySettings.SevereHeatstrokeRiskThreshold, 1, CurrentEntity.Heatstroke)); + HeatstrokePost.weight = (float)renderSettings.NormalizeHeatstrokePost(CurrentEntity.Heatstroke); + var severeHeatstrokeLerp = (float)renderSettings.NormalizeSevereHeatstrokePost(CurrentEntity.Heatstroke); SevereHeatstrokePost.weight = severeHeatstrokeLerp + severeHeatstrokeLerp * (1 - severeHeatstrokeLerp) * Mathf.Max(Settings.HeatstrokePhasingFloor, Mathf.Sin(Time.time * Settings.HeatstrokePhasingFrequency)); @@ -3697,11 +3709,10 @@ public class ActionGameManager : MonoBehaviour var target = observedTarget; if (target != null) { - var threshold = Settings.GameplaySettings.TargetDetectionInfoThreshold; var targetInfoGathered = GetObservedInfoGathered(CurrentEntity, target); var visibilityToTarget = GetObservedInfoGathered(target, CurrentEntity); - TargetVisibilityFill.fillAmount = Mathf.Lerp(.25f, .75f, (targetInfoGathered - threshold) / (1 - threshold)); - VisibilityToTargetFill.fillAmount = Mathf.Lerp(.25f, .75f, visibilityToTarget / threshold); + TargetVisibilityFill.fillAmount = (float)renderSettings.NormalizeTargetVisibilityFill(targetInfoGathered); + VisibilityToTargetFill.fillAmount = (float)renderSettings.NormalizeVisibilityToTargetFill(visibilityToTarget); var targetHull = FindTypedRuntimeItem(target.Hull); var targetMaxDurability = targetHull?.Durability > 0 ? (float)targetHull.Durability @@ -4275,9 +4286,10 @@ public class ActionGameManager : MonoBehaviour if(showLockingIndicator) { indicator.Target = observedTarget.Position; - indicator.NoiseAmplitude = Settings.GameplaySettings.LockIndicatorNoiseAmplitude * (1 - targetLock.Lock); - indicator.NoiseFrequency = Settings.GameplaySettings.LockIndicatorFrequency.Evaluate(targetLock.Lock); - spin.Speed = Settings.GameplaySettings.LockSpinSpeed.Evaluate(targetLock.Lock); + var renderSettings = ZoneRenderer.RenderSettings; + indicator.NoiseAmplitude = (float)renderSettings.ResolveLockIndicatorNoiseAmplitude(targetLock.Lock); + indicator.NoiseFrequency = (float)renderSettings.ResolveLockIndicatorNoiseFrequency(targetLock.Lock); + spin.Speed = (float)renderSettings.ResolveLockSpinSpeed(targetLock.Lock); } } } diff --git a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonRenderQueries.cs b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonRenderQueries.cs index 9def43d8f..3829e962f 100644 --- a/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonRenderQueries.cs +++ b/Packages/org.gamecult.aetheria.state/Runtime/AetheriaRuntimeDaemonRenderQueries.cs @@ -51,20 +51,35 @@ namespace GameCult.Aetheria.State.Verse { public AetheriaRuntimeDaemonRenderSettings( AetheriaRuntimeExponentialCurve temperatureEmissionCurve, + AetheriaRuntimeExponentialLerp lockIndicatorFrequency, + AetheriaRuntimeExponentialLerp lockSpinSpeed, double convergenceMinimumDistance, double hypothermiaTemperature, - double heatstrokeTemperature) + double heatstrokeTemperature, + double severeHeatstrokeRiskThreshold, + double targetDetectionInfoThreshold, + double lockIndicatorNoiseAmplitude) { TemperatureEmissionCurve = temperatureEmissionCurve; + LockIndicatorFrequency = lockIndicatorFrequency; + LockSpinSpeed = lockSpinSpeed; ConvergenceMinimumDistance = convergenceMinimumDistance; HypothermiaTemperature = hypothermiaTemperature; HeatstrokeTemperature = heatstrokeTemperature; + SevereHeatstrokeRiskThreshold = severeHeatstrokeRiskThreshold; + TargetDetectionInfoThreshold = targetDetectionInfoThreshold; + LockIndicatorNoiseAmplitude = lockIndicatorNoiseAmplitude; } public AetheriaRuntimeExponentialCurve TemperatureEmissionCurve { get; } + public AetheriaRuntimeExponentialLerp LockIndicatorFrequency { get; } + public AetheriaRuntimeExponentialLerp LockSpinSpeed { get; } public double ConvergenceMinimumDistance { get; } public double HypothermiaTemperature { get; } public double HeatstrokeTemperature { get; } + public double SevereHeatstrokeRiskThreshold { get; } + public double TargetDetectionInfoThreshold { get; } + public double LockIndicatorNoiseAmplitude { get; } public double NormalizeThermalRisk(double temperature) { @@ -74,6 +89,69 @@ namespace GameCult.Aetheria.State.Verse return Math.Max(0.0, Math.Min(1.0, (temperature - HypothermiaTemperature) / range)); } + + public double NormalizeHeatstrokePost(double heatstroke) + { + if (SevereHeatstrokeRiskThreshold <= 0) + return heatstroke > 0 ? 1.0 : 0.0; + + return Saturate(heatstroke / SevereHeatstrokeRiskThreshold); + } + + public double NormalizeSevereHeatstrokePost(double heatstroke) + { + var range = 1.0 - SevereHeatstrokeRiskThreshold; + if (range <= 0) + return heatstroke >= 1.0 ? 1.0 : 0.0; + + return Saturate((heatstroke - SevereHeatstrokeRiskThreshold) / range); + } + + public double NormalizeDetectionProgress(double infoGathered) + { + return TargetDetectionInfoThreshold <= 0 + ? (infoGathered > 0 ? 1.0 : 0.0) + : Saturate(infoGathered / TargetDetectionInfoThreshold); + } + + public double NormalizeTargetVisibilityFill(double infoGathered) + { + var denominator = 1.0 - TargetDetectionInfoThreshold; + var normalized = denominator <= 0 + ? (infoGathered >= 1.0 ? 1.0 : 0.0) + : (infoGathered - TargetDetectionInfoThreshold) / denominator; + return Lerp(0.25, 0.75, normalized); + } + + public double NormalizeVisibilityToTargetFill(double infoGathered) + { + return Lerp(0.25, 0.75, NormalizeDetectionProgress(infoGathered)); + } + + public double ResolveLockIndicatorNoiseAmplitude(double lockProgress) + { + return LockIndicatorNoiseAmplitude * (1.0 - Saturate(lockProgress)); + } + + public double ResolveLockIndicatorNoiseFrequency(double lockProgress) + { + return LockIndicatorFrequency.Evaluate(lockProgress); + } + + public double ResolveLockSpinSpeed(double lockProgress) + { + return LockSpinSpeed.Evaluate(lockProgress); + } + + private static double Saturate(double value) + { + return Math.Max(0.0, Math.Min(1.0, value)); + } + + private static double Lerp(double minimum, double maximum, double value) + { + return minimum + Saturate(value) * (maximum - minimum); + } } public readonly struct AetheriaRuntimeGravityInfluenceBrush