Merge origin/master (8a98aef5 sim-mines presenter) into eureka/aetheria-release-controls-mount-aim

This commit is contained in:
Meta Vens 2026-10-08 18:00:34 +02:00
commit 594d347704
37 changed files with 2255 additions and 54 deletions

View file

@ -341,6 +341,19 @@ public class ActionGameManager : MonoBehaviour
foreach (var wormhole in ZoneRenderer.WormholeInstances.Keys)
{
if (!(length(wormhole.Position - CurrentEntity.Position.xz) < Settings.GameplaySettings.WormholeExitRadius)) continue;
if (wormhole.Exit)
{
// The exit gate leads nowhere: RunGoal decides whether it is open, and an open one ends the run.
if (RunGoal.ExitOpen(Zone)) Win();
else
{
Dialog.Clear();
Dialog.Title.text = $"The exit gate is sealed. {RunGoal.Boss(Zone)?.Name ?? "Its guardian"} holds it shut.";
Dialog.Show();
Dialog.MoveToCursor();
}
return;
}
EnterWormhole(wormhole);
}
Dock();
@ -1185,9 +1198,9 @@ public class ActionGameManager : MonoBehaviour
return float3(pose.x, Settings.PlanetSettings.AsteroidVerticalOffset, pose.y);
}
private void Die(CauseOfDeath cause)
// The one way a run ends, won or lost: the run is cleared and the main menu returns.
private void EndRun()
{
var deathTime = Time.time;
UnbindEntity();
CurrentEntity = null;
MainMenu.gameObject.SetActive(true);
@ -1195,6 +1208,21 @@ public class ActionGameManager : MonoBehaviour
CurrentGalaxy = null;
RunSave.Clear(CultCache);
SavePlayerSettings();
}
private void Win()
{
EndRun();
Dialog.Clear();
Dialog.Title.text = "You have escaped the Terminus. This was the demo; the whole of it is yet to come.";
Dialog.Show();
Dialog.MoveToCursor();
}
private void Die(CauseOfDeath cause)
{
var deathTime = Time.time;
EndRun();
Observable.EveryUpdate()
.Where(_ => Time.time - deathTime < DeathPostTransitionTime)
.Subscribe(_ =>
@ -1395,7 +1423,7 @@ public class ActionGameManager : MonoBehaviour
: $"base {d.PBase:P1}";
DebugInfoText.text =
$"FIRE CONTROL - {selectedItem.Data.Name}\n" +
$"FIRE CONTROL - {ItemManager.Title(selectedItem.EquippableItem)}\n" +
$"{gates}\n" +
$"range {d.Range:F0} [{d.MinRange:F0}..{d.MaxRange:F0}]\n" +
$"info {d.Info:F3}/{d.InfoDemandCeiling:F3} sensor {d.PSensor:F3}\n" +

View file

@ -187,7 +187,8 @@ public class EntityInstance : MonoBehaviour
sensor.OnPingEnd += OnSensorPingEnd;
}
if (behavior is InstantWeapon instantWeapon)
// A mine layer's presentation is the mine it lays (MineInstance, drawn by ZoneRenderer from Zone.Mines).
if (behavior is InstantWeapon instantWeapon && !FireControl.IsMineLayer(instantWeapon))
{
var data = (InstantWeaponData) instantWeapon.Data;
if (!_instantWeaponManagers.ContainsKey(data))

View file

@ -0,0 +1,74 @@
using CultMath;
using CultMath.UnityBridge;
using UnityEngine;
using static CultMath.math;
using Random = UnityEngine.Random;
// How one laid mine looks. Zone owns the mine's every fact (position, arming, trigger, end); this reads them and
// draws, and writes nothing back. The pose is the latest sim body, spun for show; the pulse runs in real time
// (rulings unity-presents-only-r3 and sim-speed-presentation).
public class MineInstance : MonoBehaviour
{
public MeshRenderer MeshRenderer;
public int EmissionSubmesh = 2;
public AnimationCurve EmissionCurve;
public float ActiveCycleDuration = 1f;
public float ArmedCycleDuration = .25f;
public float ActiveEmission = 100f;
public float ArmedEmission = 1000f;
public float RotationSpeed = 1f;
public float GridOffset;
// The blast's particles; the effect prefab destroys itself when its particle system stops.
public GameObject HitEffect;
public float HitEffectScale = 10f;
private Zone _zone;
private Mine _mine;
private Material _material;
private float _timeOffset;
private float _pulse;
private float _emission;
public void Bind(Zone zone, Mine mine)
{
_zone = zone;
_mine = mine;
_material = MeshRenderer.materials[EmissionSubmesh];
_timeOffset = Random.value * 100;
Place();
}
private void Update()
{
Place();
transform.localRotation = Quaternion.Euler(
sin(Time.time - _timeOffset * RotationSpeed) * 90, 0, cos(Time.time - _timeOffset * RotationSpeed) * 90);
// None before the mine arms, then slow while it waits and fast once its fuse is lit.
var armed = _mine.Armed(_zone.Time);
var counting = _mine.TriggeredAt != null;
var target = !armed ? 0f : counting ? ArmedEmission : ActiveEmission;
_emission = lerp(_emission, target, Time.deltaTime * 10);
_pulse = (_pulse + Time.deltaTime / (counting ? ArmedCycleDuration : ActiveCycleDuration)) % 1;
_material.SetFloat("_Emission", _emission * EmissionCurve.Evaluate(_pulse));
}
private void Place()
{
var p = _mine.Body.Position;
transform.position = new Vector3(p.x, _zone.GetHeight(p) + GridOffset, p.y);
}
// The mine left Zone.Mines, which only its blast does: show it where it was drawn last.
public void Blast()
{
var effect = Instantiate(HitEffect, transform.position, Quaternion.identity);
effect.transform.localScale = Vector3.one * HitEffectScale;
Destroy(gameObject);
}
private void OnDestroy()
{
if (_material) Destroy(_material);
}
}

View file

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 35c62f5e26769f645b1a1614a70422e1