Merge master (fire control) into codex/mining
Conflict in Zone.cs: kept master's TryGetShot, kept Cut 1's deletion of the BeltUpdates field. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
fc90e93618
57 changed files with 12116 additions and 822 deletions
|
|
@ -162,6 +162,16 @@ public partial class @AetheriaInput: IInputActionCollection2, IDisposable
|
|||
""initialStateCheck"": false,
|
||||
""priority"": 0
|
||||
},
|
||||
{
|
||||
""name"": ""Cycle Target Item"",
|
||||
""type"": ""Button"",
|
||||
""id"": ""3f9a2f0a-6e3f-4a53-9f5e-1a9c1e6d9f7b"",
|
||||
""expectedControlType"": ""Button"",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false,
|
||||
""priority"": 0
|
||||
},
|
||||
{
|
||||
""name"": ""Toggle Heatsinks"",
|
||||
""type"": ""Button"",
|
||||
|
|
@ -409,6 +419,17 @@ public partial class @AetheriaInput: IInputActionCollection2, IDisposable
|
|||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""8c2d5e77-4b18-4f0b-9a2e-6d3f7c1a5e90"",
|
||||
""path"": ""<Keyboard>/j"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": ""Keyboard&Mouse"",
|
||||
""action"": ""Cycle Target Item"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""71ac6088-1e18-4810-86be-1179918dd4a2"",
|
||||
|
|
@ -1178,6 +1199,7 @@ public partial class @AetheriaInput: IInputActionCollection2, IDisposable
|
|||
m_Player_TargetPrevious = m_Player.FindAction("Target Previous", throwIfNotFound: true);
|
||||
m_Player_TargetNext = m_Player.FindAction("Target Next", throwIfNotFound: true);
|
||||
m_Player_TargetNearest = m_Player.FindAction("Target Nearest", throwIfNotFound: true);
|
||||
m_Player_CycleTargetItem = m_Player.FindAction("Cycle Target Item", throwIfNotFound: true);
|
||||
m_Player_ToggleHeatsinks = m_Player.FindAction("Toggle Heatsinks", throwIfNotFound: true);
|
||||
m_Player_ToggleShield = m_Player.FindAction("Toggle Shield", throwIfNotFound: true);
|
||||
m_Player_ToggleStance = m_Player.FindAction("Toggle Stance", throwIfNotFound: true);
|
||||
|
|
@ -1294,6 +1316,7 @@ public partial class @AetheriaInput: IInputActionCollection2, IDisposable
|
|||
private readonly InputAction m_Player_TargetPrevious;
|
||||
private readonly InputAction m_Player_TargetNext;
|
||||
private readonly InputAction m_Player_TargetNearest;
|
||||
private readonly InputAction m_Player_CycleTargetItem;
|
||||
private readonly InputAction m_Player_ToggleHeatsinks;
|
||||
private readonly InputAction m_Player_ToggleShield;
|
||||
private readonly InputAction m_Player_ToggleStance;
|
||||
|
|
@ -1342,6 +1365,10 @@ public partial class @AetheriaInput: IInputActionCollection2, IDisposable
|
|||
/// </summary>
|
||||
public InputAction @TargetNearest => m_Wrapper.m_Player_TargetNearest;
|
||||
/// <summary>
|
||||
/// Provides access to the underlying input action "Player/CycleTargetItem".
|
||||
/// </summary>
|
||||
public InputAction @CycleTargetItem => m_Wrapper.m_Player_CycleTargetItem;
|
||||
/// <summary>
|
||||
/// Provides access to the underlying input action "Player/ToggleHeatsinks".
|
||||
/// </summary>
|
||||
public InputAction @ToggleHeatsinks => m_Wrapper.m_Player_ToggleHeatsinks;
|
||||
|
|
@ -1420,6 +1447,9 @@ public partial class @AetheriaInput: IInputActionCollection2, IDisposable
|
|||
@TargetNearest.started += instance.OnTargetNearest;
|
||||
@TargetNearest.performed += instance.OnTargetNearest;
|
||||
@TargetNearest.canceled += instance.OnTargetNearest;
|
||||
@CycleTargetItem.started += instance.OnCycleTargetItem;
|
||||
@CycleTargetItem.performed += instance.OnCycleTargetItem;
|
||||
@CycleTargetItem.canceled += instance.OnCycleTargetItem;
|
||||
@ToggleHeatsinks.started += instance.OnToggleHeatsinks;
|
||||
@ToggleHeatsinks.performed += instance.OnToggleHeatsinks;
|
||||
@ToggleHeatsinks.canceled += instance.OnToggleHeatsinks;
|
||||
|
|
@ -1476,6 +1506,9 @@ public partial class @AetheriaInput: IInputActionCollection2, IDisposable
|
|||
@TargetNearest.started -= instance.OnTargetNearest;
|
||||
@TargetNearest.performed -= instance.OnTargetNearest;
|
||||
@TargetNearest.canceled -= instance.OnTargetNearest;
|
||||
@CycleTargetItem.started -= instance.OnCycleTargetItem;
|
||||
@CycleTargetItem.performed -= instance.OnCycleTargetItem;
|
||||
@CycleTargetItem.canceled -= instance.OnCycleTargetItem;
|
||||
@ToggleHeatsinks.started -= instance.OnToggleHeatsinks;
|
||||
@ToggleHeatsinks.performed -= instance.OnToggleHeatsinks;
|
||||
@ToggleHeatsinks.canceled -= instance.OnToggleHeatsinks;
|
||||
|
|
@ -1964,6 +1997,13 @@ public partial class @AetheriaInput: IInputActionCollection2, IDisposable
|
|||
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||
void OnTargetNearest(InputAction.CallbackContext context);
|
||||
/// <summary>
|
||||
/// Method invoked when associated input action "Cycle Target Item" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||
/// </summary>
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||
void OnCycleTargetItem(InputAction.CallbackContext context);
|
||||
/// <summary>
|
||||
/// Method invoked when associated input action "Toggle Heatsinks" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||
/// </summary>
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||
|
|
|
|||
252
Assets/Scripts/Editor/ShipPrefabAuthoring.cs
Normal file
252
Assets/Scripts/Editor/ShipPrefabAuthoring.cs
Normal file
|
|
@ -0,0 +1,252 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
// New ship models own their presentation anchors. The catalog still owns the schematic and gameplay rules.
|
||||
public static class ShipPrefabAuthoring
|
||||
{
|
||||
public const string ModelDirectory = "Assets/Models/Ships/";
|
||||
public const string PrefabDirectory = "Assets/Content/Prefabs/Ships/";
|
||||
|
||||
private const string ShieldPath = "Assets/Content/Prefabs/Shield.prefab";
|
||||
private const string TractorPath = "Assets/Content/Prefabs/Tractor Beam.prefab";
|
||||
private const string PingPath = "Assets/Content/Prefabs/PingEffect.prefab";
|
||||
private const string ExplosionPath = "Assets/Prefabs/Fire & Explosion Effects/Prefabs/BigExplosion.prefab";
|
||||
private const string InvisiblePath = "Assets/Materials/Invisible.mat";
|
||||
private const string MapMaterialPath = "Assets/Materials/UI/Map Icons.mat";
|
||||
|
||||
[MenuItem("Aetheria/Build Ship Prefab From Selected Model")]
|
||||
private static void BuildSelected()
|
||||
{
|
||||
var path = AssetDatabase.GetAssetPath(Selection.activeObject);
|
||||
try { Debug.Log($"Ship prefab built: {Build(path)}"); }
|
||||
catch (Exception ex) { Debug.LogError($"Ship prefab build failed for {path}: {ex.Message}"); }
|
||||
}
|
||||
|
||||
[MenuItem("Aetheria/Build Ship Prefab From Selected Model", true)]
|
||||
private static bool CanBuildSelected() => IsShipModel(AssetDatabase.GetAssetPath(Selection.activeObject));
|
||||
|
||||
public static bool IsShipModel(string path) =>
|
||||
!string.IsNullOrEmpty(path) && path.StartsWith(ModelDirectory, StringComparison.Ordinal) &&
|
||||
path.EndsWith(".fbx", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
public static string Build(string modelPath)
|
||||
{
|
||||
if (!IsShipModel(modelPath)) throw new InvalidOperationException($"Expected an FBX in {ModelDirectory}");
|
||||
var model = AssetDatabase.LoadAssetAtPath<GameObject>(modelPath);
|
||||
if (model == null) throw new InvalidOperationException($"Could not load model {modelPath}");
|
||||
|
||||
var shipName = System.IO.Path.GetFileNameWithoutExtension(modelPath);
|
||||
var outputPath = PrefabDirectory + shipName + ".prefab";
|
||||
var instance = (GameObject)PrefabUtility.InstantiatePrefab(model);
|
||||
if (instance == null) throw new InvalidOperationException($"Could not instantiate model {modelPath}");
|
||||
try
|
||||
{
|
||||
instance.name = shipName;
|
||||
instance.transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity);
|
||||
Configure(instance);
|
||||
PrefabUtility.SaveAsPrefabAsset(instance, outputPath, out var saved);
|
||||
if (!saved) throw new InvalidOperationException($"Unity did not save {outputPath}");
|
||||
return outputPath;
|
||||
}
|
||||
finally { Object.DestroyImmediate(instance); }
|
||||
}
|
||||
|
||||
// Takes an imported model instance. Every ship-specific reference comes from its named hierarchy.
|
||||
public static void Configure(GameObject root)
|
||||
{
|
||||
var nodes = root.GetComponentsInChildren<Transform>(true);
|
||||
var named = new Dictionary<string, Transform>(StringComparer.Ordinal);
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
if (!Reserved(node.name)) continue;
|
||||
if (!named.TryAdd(node.name, node))
|
||||
throw new InvalidOperationException($"Duplicate reserved name {node.name}");
|
||||
}
|
||||
|
||||
Transform Required(string name) => named.TryGetValue(name, out var found)
|
||||
? found : throw new InvalidOperationException($"Missing {name}");
|
||||
|
||||
var mapIcon = Required("SHIP.MapIcon").GetComponent<MeshRenderer>();
|
||||
if (mapIcon == null) throw new InvalidOperationException("SHIP.MapIcon needs a mesh renderer");
|
||||
var hull = Required("SHIP.HullCollider");
|
||||
var hullFilter = hull.GetComponent<MeshFilter>();
|
||||
var hullMesh = hullFilter != null ? hullFilter.sharedMesh : null;
|
||||
if (hullMesh == null) throw new InvalidOperationException("SHIP.HullCollider needs a mesh");
|
||||
var shieldMarker = Required("SHIP.Shield");
|
||||
var tractorMarker = Required("SHIP.TractorBeam");
|
||||
if (!PositiveScale(shieldMarker.localScale))
|
||||
throw new InvalidOperationException("SHIP.Shield scale must have three positive radii");
|
||||
|
||||
var shieldPrefab = LoadComponent<ShieldManager>(ShieldPath);
|
||||
var tractorPrefab = LoadComponent<TractorBeam>(TractorPath);
|
||||
var ping = LoadComponent<Transform>(PingPath);
|
||||
var explosion = LoadAsset<GameObject>(ExplosionPath);
|
||||
var invisible = LoadAsset<Material>(InvisiblePath);
|
||||
var mapMaterial = LoadAsset<Material>(MapMaterialPath);
|
||||
var minimapLayer = LayerMask.NameToLayer("Minimap");
|
||||
var combatLayer = LayerMask.NameToLayer("Combat");
|
||||
if (minimapLayer < 0 || combatLayer < 0) throw new InvalidOperationException("Minimap or Combat layer is missing");
|
||||
|
||||
var equipment = new List<Transform>();
|
||||
var thrusters = new List<ThrusterHardpoint>();
|
||||
var weapons = new List<WeaponHardpoint>();
|
||||
var radiators = new List<RadiatorHardpoint>();
|
||||
var pivots = new List<ArticulationPoint>();
|
||||
foreach (var pair in named.OrderBy(x => x.Key, StringComparer.Ordinal))
|
||||
{
|
||||
var name = pair.Key;
|
||||
var node = pair.Value;
|
||||
if (name.StartsWith("HP.", StringComparison.Ordinal))
|
||||
{
|
||||
var parts = name.Split('.');
|
||||
if (parts.Length != 3 || string.IsNullOrWhiteSpace(parts[2]))
|
||||
throw new InvalidOperationException($"Invalid hardpoint name {name}");
|
||||
equipment.Add(node);
|
||||
switch (parts[1])
|
||||
{
|
||||
case "Equipment": break;
|
||||
case "Thruster":
|
||||
var emitter = DirectChild(node, "Emitter")?.GetComponent<MeshRenderer>();
|
||||
if (emitter == null) throw new InvalidOperationException($"{name} needs an Emitter mesh child");
|
||||
AddOrGet<ThrusterHardpoint>(node.gameObject).Emitter = emitter;
|
||||
thrusters.Add(node.GetComponent<ThrusterHardpoint>());
|
||||
break;
|
||||
case "Weapon":
|
||||
var muzzles = node.Cast<Transform>()
|
||||
.Where(x => x.name.StartsWith("Muzzle.", StringComparison.Ordinal))
|
||||
.Select(x => (node: x, number: MuzzleNumber(x.name)))
|
||||
.OrderBy(x => x.number).ToArray();
|
||||
if (muzzles.Length == 0 || muzzles.Select(x => x.number).Distinct().Count() != muzzles.Length)
|
||||
throw new InvalidOperationException($"{name} needs uniquely numbered Muzzle.<n> children");
|
||||
AddOrGet<WeaponHardpoint>(node.gameObject).FiringPoint = muzzles.Select(x => x.node).ToArray();
|
||||
weapons.Add(node.GetComponent<WeaponHardpoint>());
|
||||
break;
|
||||
case "Radiator":
|
||||
var mesh = DirectChild(node, "RadiatorMesh")?.GetComponent<MeshRenderer>();
|
||||
if (mesh == null) throw new InvalidOperationException($"{name} needs a RadiatorMesh child");
|
||||
AddOrGet<RadiatorHardpoint>(node.gameObject).Mesh = mesh;
|
||||
radiators.Add(node.GetComponent<RadiatorHardpoint>());
|
||||
break;
|
||||
default: throw new InvalidOperationException($"Unknown hardpoint role in {name}");
|
||||
}
|
||||
}
|
||||
else if (name.StartsWith("Pivot.", StringComparison.Ordinal))
|
||||
{
|
||||
var values = name.Split('.');
|
||||
if (values.Length != 7) throw new InvalidOperationException($"Invalid pivot name {name}");
|
||||
var pivot = AddOrGet<ArticulationPoint>(node.gameObject);
|
||||
pivot.Group = ParseInt(values[1], name);
|
||||
pivot.YawMin = ParseInt(values[2], name);
|
||||
pivot.YawMax = ParseInt(values[3], name);
|
||||
pivot.PitchMin = ParseInt(values[4], name);
|
||||
pivot.PitchMax = ParseInt(values[5], name);
|
||||
pivot.Speed = ParseInt(values[6], name);
|
||||
if (pivot.YawMin > pivot.YawMax || pivot.PitchMin > pivot.PitchMax || pivot.Speed <= 0)
|
||||
throw new InvalidOperationException($"Invalid articulation range or speed in {name}");
|
||||
pivots.Add(pivot);
|
||||
}
|
||||
else if (name.StartsWith("SHIP.", StringComparison.Ordinal) &&
|
||||
name != "SHIP.MapIcon" && name != "SHIP.HullCollider" &&
|
||||
name != "SHIP.Shield" && name != "SHIP.TractorBeam")
|
||||
throw new InvalidOperationException($"Unknown ship anchor {name}");
|
||||
}
|
||||
if (equipment.Count == 0) throw new InvalidOperationException("Ship has no HP.* hardpoints");
|
||||
|
||||
mapIcon.sharedMaterial = mapMaterial;
|
||||
mapIcon.gameObject.layer = minimapLayer;
|
||||
hull.gameObject.layer = combatLayer;
|
||||
var hullRenderer = hull.GetComponent<MeshRenderer>();
|
||||
if (hullRenderer != null) hullRenderer.forceRenderingOff = true;
|
||||
var collider = AddOrGet<MeshCollider>(hull.gameObject);
|
||||
collider.sharedMesh = hullMesh;
|
||||
collider.convex = true;
|
||||
var hullSurface = AddOrGet<HullCollider>(hull.gameObject);
|
||||
|
||||
var shield = (ShieldManager)PrefabUtility.InstantiatePrefab(shieldPrefab, shieldMarker);
|
||||
shield.transform.localPosition = Vector3.zero;
|
||||
shield.transform.localRotation = Quaternion.identity;
|
||||
if (shield.GetComponent<ShieldEnvelope>() == null) shield.gameObject.AddComponent<ShieldEnvelope>();
|
||||
var tractor = (TractorBeam)PrefabUtility.InstantiatePrefab(tractorPrefab, tractorMarker);
|
||||
tractor.transform.localPosition = Vector3.zero;
|
||||
tractor.transform.localRotation = Quaternion.identity;
|
||||
|
||||
var ship = AddOrGet<ShipInstance>(root);
|
||||
ship.MapIcon = mapIcon;
|
||||
ship.InfluencePrefab = null;
|
||||
ship.PingPrefab = ping;
|
||||
ship.InvisibleMaterial = invisible;
|
||||
ship.Shield = shield;
|
||||
ship.HullColliders = new[] { hullSurface };
|
||||
ship.EquipmentHardpoints = equipment.ToArray();
|
||||
ship.ThrusterHardpoints = thrusters.ToArray();
|
||||
ship.WeaponHardpoints = weapons.ToArray();
|
||||
ship.RadiatorHardpoints = radiators.ToArray();
|
||||
ship.ArticulationPoints = pivots.ToArray();
|
||||
ship.DestroyEffect = explosion;
|
||||
ship.TractorBeam = tractor;
|
||||
}
|
||||
|
||||
private static bool Reserved(string name) => name.StartsWith("HP.", StringComparison.Ordinal) ||
|
||||
name.StartsWith("Pivot.", StringComparison.Ordinal) || name.StartsWith("SHIP.", StringComparison.Ordinal);
|
||||
|
||||
private static bool PositiveScale(Vector3 scale) => scale.x > 0 && scale.y > 0 && scale.z > 0;
|
||||
|
||||
private static Transform DirectChild(Transform parent, string name) =>
|
||||
parent.Cast<Transform>().FirstOrDefault(x => x.name == name);
|
||||
|
||||
private static int MuzzleNumber(string name)
|
||||
{
|
||||
if (!int.TryParse(name.Substring("Muzzle.".Length), NumberStyles.None, CultureInfo.InvariantCulture, out var n))
|
||||
throw new InvalidOperationException($"Invalid muzzle name {name}");
|
||||
return n;
|
||||
}
|
||||
|
||||
private static int ParseInt(string part, string name)
|
||||
{
|
||||
if (!int.TryParse(part, NumberStyles.Integer, CultureInfo.InvariantCulture, out var value))
|
||||
throw new InvalidOperationException($"Invalid numeric field in {name}");
|
||||
return value;
|
||||
}
|
||||
|
||||
private static T AddOrGet<T>(GameObject gameObject) where T : Component
|
||||
{
|
||||
var component = gameObject.GetComponent<T>();
|
||||
return component != null ? component : gameObject.AddComponent<T>();
|
||||
}
|
||||
|
||||
private static T LoadAsset<T>(string path) where T : Object
|
||||
{
|
||||
var asset = AssetDatabase.LoadAssetAtPath<T>(path);
|
||||
return asset != null ? asset : throw new InvalidOperationException($"Missing shared asset {path}");
|
||||
}
|
||||
|
||||
private static T LoadComponent<T>(string path) where T : Component
|
||||
{
|
||||
var prefab = LoadAsset<GameObject>(path);
|
||||
var component = prefab.GetComponent<T>();
|
||||
return component != null ? component : throw new InvalidOperationException($"{path} needs {typeof(T).Name}");
|
||||
}
|
||||
}
|
||||
|
||||
// Model import finishes before generated prefabs read its hierarchy. Invalid exports leave the last valid prefab.
|
||||
public sealed class ShipModelImport : AssetPostprocessor
|
||||
{
|
||||
private static void OnPostprocessAllAssets(string[] imported, string[] deleted, string[] moved, string[] movedFrom)
|
||||
{
|
||||
var models = imported.Concat(moved).Where(ShipPrefabAuthoring.IsShipModel).Distinct().ToArray();
|
||||
if (models.Length == 0) return;
|
||||
EditorApplication.delayCall += () =>
|
||||
{
|
||||
foreach (var model in models)
|
||||
{
|
||||
try { Debug.Log($"Ship prefab built: {ShipPrefabAuthoring.Build(model)}"); }
|
||||
catch (Exception ex) { Debug.LogError($"Ship prefab build failed for {model}: {ex.Message}"); }
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Editor/ShipPrefabAuthoring.cs.meta
Normal file
2
Assets/Scripts/Editor/ShipPrefabAuthoring.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 59713c487d73ab3418750d958e24d777
|
||||
80
Assets/Scripts/Editor/ShipPrefabAuthoringSmoke.cs
Normal file
80
Assets/Scripts/Editor/ShipPrefabAuthoringSmoke.cs
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
using System;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
// Focused Editor witness for the naming contract. Run with -executeMethod ShipPrefabAuthoringSmoke.Run.
|
||||
public static class ShipPrefabAuthoringSmoke
|
||||
{
|
||||
public static void Run()
|
||||
{
|
||||
GameObject root = null;
|
||||
try
|
||||
{
|
||||
root = new GameObject("Fixture");
|
||||
Primitive(root, "SHIP.MapIcon");
|
||||
Primitive(root, "SHIP.HullCollider");
|
||||
Child(root, "SHIP.Shield").localScale = new Vector3(2, 3, 4);
|
||||
Child(root, "SHIP.TractorBeam");
|
||||
var thruster = Child(root, "HP.Thruster.PortAft");
|
||||
Primitive(thruster.gameObject, "Emitter");
|
||||
var weapon = Child(root, "HP.Weapon.PortGun");
|
||||
Child(weapon.gameObject, "Muzzle.1");
|
||||
Child(weapon.gameObject, "Muzzle.0");
|
||||
var radiator = Child(root, "HP.Radiator.Port");
|
||||
Primitive(radiator.gameObject, "RadiatorMesh");
|
||||
Child(root, "HP.Equipment.Reactor");
|
||||
Child(root, "Pivot.2.-90.90.-80.80.60");
|
||||
|
||||
ShipPrefabAuthoring.Configure(root);
|
||||
var ship = root.GetComponent<ShipInstance>();
|
||||
Require(ship != null && ship.EquipmentHardpoints.Length == 4, "equipment references");
|
||||
Require(ship.ThrusterHardpoints.Length == 1 && ship.ThrusterHardpoints[0].Emitter != null, "thruster emitter");
|
||||
Require(ship.WeaponHardpoints.Length == 1 && ship.WeaponHardpoints[0].FiringPoint.Length == 2, "weapon muzzles");
|
||||
Require(ship.WeaponHardpoints[0].FiringPoint[0].name == "Muzzle.0", "numeric muzzle order");
|
||||
Require(ship.RadiatorHardpoints.Length == 1 && ship.RadiatorHardpoints[0].Mesh != null, "radiator mesh");
|
||||
Require(ship.ArticulationPoints.Length == 1 && ship.ArticulationPoints[0].Group == 2, "articulation");
|
||||
Require(ship.HullColliders.Length == 1 && ship.HullColliders[0].GetComponent<MeshCollider>().convex, "hull collision");
|
||||
Require(ship.Shield != null && ship.Shield.GetComponent<ShieldEnvelope>() != null, "shield envelope");
|
||||
Require(ship.TractorBeam != null && ship.PingPrefab != null && ship.DestroyEffect != null, "shared assets");
|
||||
Require(ship.MapIcon != null && ship.MapIcon.gameObject.layer == LayerMask.NameToLayer("Minimap"), "map icon");
|
||||
|
||||
var invalid = Child(root, "HP.Weapon.Broken");
|
||||
var refused = false;
|
||||
try { ShipPrefabAuthoring.Configure(root); }
|
||||
catch (InvalidOperationException ex) { refused = ex.Message.Contains("Muzzle"); }
|
||||
Require(refused, "invalid hierarchy refusal");
|
||||
Object.DestroyImmediate(invalid.gameObject);
|
||||
|
||||
Debug.Log("ShipPrefabAuthoringSmoke: named hierarchy and refusal passed");
|
||||
if (Application.isBatchMode) EditorApplication.Exit(0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogException(ex);
|
||||
if (Application.isBatchMode) EditorApplication.Exit(1);
|
||||
else throw;
|
||||
}
|
||||
finally { if (root != null) Object.DestroyImmediate(root); }
|
||||
}
|
||||
|
||||
private static Transform Child(GameObject parent, string name)
|
||||
{
|
||||
var child = new GameObject(name).transform;
|
||||
child.SetParent(parent.transform, false);
|
||||
return child;
|
||||
}
|
||||
|
||||
private static GameObject Primitive(GameObject parent, string name)
|
||||
{
|
||||
var mesh = GameObject.CreatePrimitive(PrimitiveType.Cube);
|
||||
mesh.name = name;
|
||||
mesh.transform.SetParent(parent.transform, false);
|
||||
return mesh;
|
||||
}
|
||||
|
||||
private static void Require(bool condition, string claim)
|
||||
{
|
||||
if (!condition) throw new InvalidOperationException($"ShipPrefabAuthoringSmoke failed: {claim}");
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Editor/ShipPrefabAuthoringSmoke.cs.meta
Normal file
2
Assets/Scripts/Editor/ShipPrefabAuthoringSmoke.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 67d84765dc5ea3243b0ab09bc7f1015e
|
||||
|
|
@ -405,11 +405,8 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
// Cut 2 (docs/fire-control-cut.md): cycles the aim point among the current target's revealed
|
||||
// subsystems -- decides nothing itself, only calls the one writer (TrySelectTargetItem), same
|
||||
// predicate (FireControl.IsRevealed) the AI path uses. No generated typed accessor exists for this
|
||||
// action yet (it was hand-authored into Aetheria.inputactions rather than regenerated through the
|
||||
// Unity Input Actions editor, unavailable here), so it is looked up by name instead of through
|
||||
// Input.Player.
|
||||
Input.asset.FindAction("Player/Cycle Target Item").performed += context =>
|
||||
// predicate (FireControl.IsRevealed) the AI path uses.
|
||||
Input.Player.CycleTargetItem.performed += context =>
|
||||
{
|
||||
var target = CurrentEntity.Target.Value;
|
||||
if (target == null) return;
|
||||
|
|
@ -521,10 +518,29 @@ public class ActionGameManager : MonoBehaviour
|
|||
var itemName = string.Join(" ", args);
|
||||
var item = ItemManager.ItemData.GetAll<EquippableItemData>()
|
||||
.FirstOrDefault(itemData => string.Equals(itemData.Name, itemName, StringComparison.InvariantCultureIgnoreCase));
|
||||
if (item != null)
|
||||
if (item == null)
|
||||
{
|
||||
_currentEntity.CargoBays.First().TryStore(ItemManager.CreateInstance(ItemManager.CreateLot(item, default, .95f)));
|
||||
ConsoleController.Instance.AppendLogLine($"No equippable item named \"{itemName}\"");
|
||||
return;
|
||||
}
|
||||
if (item is HullData hull)
|
||||
{
|
||||
if (hull.HullType != HullType.Ship)
|
||||
{
|
||||
ConsoleController.Instance.AppendLogLine($"Refused: {item.Name} is a {hull.HullType} hull, not a ship");
|
||||
return;
|
||||
}
|
||||
if (DockedEntity == null)
|
||||
{
|
||||
ConsoleController.Instance.AppendLogLine($"Refused: dock to take delivery of a {item.Name}");
|
||||
return;
|
||||
}
|
||||
CommissionShip(ItemManager.CreateInstance(ItemManager.CreateLot(item, default, .95f)) as EquippableItem);
|
||||
ConsoleController.Instance.AppendLogLine($"{item.Name} moored at {DockedEntity.Name}");
|
||||
return;
|
||||
}
|
||||
if (!_currentEntity.CargoBays.First().TryStore(ItemManager.CreateInstance(ItemManager.CreateLot(item, default, .95f))))
|
||||
ConsoleController.Instance.AppendLogLine($"Refused: no cargo space for {item.Name}");
|
||||
});
|
||||
|
||||
ConsoleController.AddCommand("trackmissile",
|
||||
|
|
@ -535,7 +551,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
missileManager.OnFireGuided.Where(x => x.source == _currentEntity).Take(1).Subscribe(x =>
|
||||
{
|
||||
FollowCamera.Follow = x.missile.transform;
|
||||
FollowCamera.LookAt = x.target;
|
||||
FollowCamera.LookAt = x.target ? x.target : x.missile.transform;
|
||||
x.missile.OnKill += () =>
|
||||
{
|
||||
FollowCamera.LookAt = ZoneRenderer.EntityInstances[CurrentEntity].LookAtPoint;
|
||||
|
|
@ -877,6 +893,15 @@ public class ActionGameManager : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
// A ship hull acquired while docked becomes a bare player ship moored at the docked entity. It takes no docking
|
||||
// bay: mothballed ships do not need one. Buying from the trade menu and the give command both land here.
|
||||
public Ship CommissionShip(EquippableItem hull)
|
||||
{
|
||||
var ship = new Ship(ItemManager, Zone, hull, ItemManager.GameplaySettings.DefaultEntitySettings) { IsPlayerShip = true };
|
||||
ship.SetParent(DockedEntity);
|
||||
return ship;
|
||||
}
|
||||
|
||||
private void DoDock(Entity entity, EquippedDockingBay dockingBay)
|
||||
{
|
||||
TradeMenu.Inventory = entity.CargoBays.First();
|
||||
|
|
@ -1282,6 +1307,13 @@ public class ActionGameManager : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
private static string ResultLabel(ShotResult result) => result switch
|
||||
{
|
||||
ShotResult.Hit => "HIT",
|
||||
ShotResult.Burst => "BURST",
|
||||
_ => "MISS"
|
||||
};
|
||||
|
||||
private void UpdateFireControlDebug(Entity target)
|
||||
{
|
||||
if (DebugInfoText == null) return;
|
||||
|
|
@ -1310,7 +1342,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
var shot = CurrentEntity.Zone.PendingShots[i];
|
||||
if (shot.Source != CurrentEntity || shot.Weapon != selectedItem) continue;
|
||||
if (shot.Committed)
|
||||
pendingLine = $"shot {shot.ShotId}: committed {(shot.Outcome.Hit ? "HIT" : "MISS")}";
|
||||
pendingLine = $"shot {shot.ShotId}: committed {ResultLabel(shot.Outcome.Result)}";
|
||||
else
|
||||
{
|
||||
var pDeviation = FireControl.DeviationProbability(shot, CurrentEntity.Zone.Time, out var deviation);
|
||||
|
|
@ -1324,11 +1356,16 @@ public class ActionGameManager : MonoBehaviour
|
|||
}
|
||||
|
||||
var lastLine = _debugLastShots.TryGetValue(selectedItem, out var lastShot)
|
||||
? $"last {lastShot.ShotId}: {(lastShot.Hit ? "HIT" : "MISS")} cell {lastShot.Cell.x},{lastShot.Cell.y}"
|
||||
? $"last {lastShot.ShotId}: {ResultLabel(lastShot.Result)} cell {lastShot.Cell.x},{lastShot.Cell.y}"
|
||||
: "last: none";
|
||||
var gates = target == null
|
||||
? "target: none"
|
||||
: $"gates vis {d.Visible} range {d.InRange} arc {d.InArc} lock {d.Locked}";
|
||||
: $"gates designated {d.Designated} arc {d.InArc}";
|
||||
|
||||
// A fused weapon's forecast is its outcome, not a hit chance: the burst point or the refusal.
|
||||
var outcomeLine = d.Outcome == FireOutcome.Burst ? $"burst at {d.BurstReach:F0}"
|
||||
: d.Outcome == FireOutcome.Refused ? "refused: arming distance exceeds range"
|
||||
: $"base {d.PBase:P1}";
|
||||
|
||||
DebugInfoText.text =
|
||||
$"FIRE CONTROL - {selectedItem.Data.Name}\n" +
|
||||
|
|
@ -1337,7 +1374,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
$"info {d.Info:F3}/{d.InfoDemandCeiling:F3} sensor {d.PSensor:F3}\n" +
|
||||
$"accuracy {d.Accuracy:F3} spread {d.PSpread:F3} hull {d.POnHull:F3}\n" +
|
||||
$"precision {d.Precision:F3} tracking {d.Tracking:F1}\n" +
|
||||
$"base {d.PBase:P1}\n" +
|
||||
$"{outcomeLine}\n" +
|
||||
$"{pendingLine}\n" +
|
||||
lastLine;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -203,8 +203,11 @@ public class EntityInstance : MonoBehaviour
|
|||
// Cut 3 (docs/fire-control-cut.md): carries the ShotId FireControl.Fire assigned so the
|
||||
// effect manager (and whatever it spawns) can bind its presentation to Zone.ShotCommitted /
|
||||
// ShotResolved instead of deciding or applying anything itself.
|
||||
// The target handed to the effect is the shot's own, not the shooter's selection: a fused round
|
||||
// whose selected target was invalid, or out of arc, flies at none (FireControl.Fire) and the
|
||||
// effect must not chase one.
|
||||
instantWeapon.OnFire += shotId =>
|
||||
_instantWeaponManagers[data].Fire(instantWeapon, item, this, entity.Target.Value != null && ZoneRenderer.EntityInstances.ContainsKey(entity.Target.Value) ? ZoneRenderer.EntityInstances[entity.Target.Value] : null, shotId);
|
||||
_instantWeaponManagers[data].Fire(instantWeapon, item, this, ShotTarget(shotId), shotId);
|
||||
|
||||
if (behavior is ChargedWeapon chargedWeapon)
|
||||
{
|
||||
|
|
@ -277,10 +280,11 @@ public class EntityInstance : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
// Cut 3 (docs/fire-control-cut.md): DamageSchematic and both HullCollider subscriptions (Splash, Hit)
|
||||
// are deleted -- FireControl decides hits now and Entity.ApplyHit/DamageSchematic (ServerShared) apply
|
||||
// them, the single owner in place of what used to exist once per Unity effect. HullColliders no longer
|
||||
// publish Hit/Splash at all (R8).
|
||||
// Cut 3 (docs/fire-control-cut.md): DamageSchematic and both HullCollider subscriptions (blast, Hit)
|
||||
// are deleted -- FireControl decides hits now and applies them through Entity.ArmorAbsorb/ItemAbsorb/
|
||||
// DamageHull (ServerShared, Cut 12.3/12.4(b); DamageSchematic, the old per-cell single-lane absorb path
|
||||
// and ApplyHit are all gone), the single owner in place of what used to exist once per Unity effect.
|
||||
// HullColliders no longer publish Hit or a blast event at all (R8).
|
||||
|
||||
LookAtPoint = new GameObject($"{entity.Name} Look Point").transform;
|
||||
|
||||
|
|
@ -335,6 +339,10 @@ public class EntityInstance : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
private EntityInstance ShotTarget(int shotId) =>
|
||||
Entity.Zone.TryGetShot(shotId, out var shot) && shot.Target != null &&
|
||||
ZoneRenderer.EntityInstances.TryGetValue(shot.Target, out var instance) ? instance : null;
|
||||
|
||||
private void OnSensorPingEnd()
|
||||
{
|
||||
Destroy(_currentPing.transform.gameObject);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ using CultMath.UnityBridge;
|
|||
|
||||
// Cut 4 (docs/fire-control-cut.md): Hit, Splash, SendHit and SendSplash are deleted -- their last callers
|
||||
// (ConstantLaser, ConstantLightning, ConstantParticleWeapon, HitscanEffect, Mine) are gone too (see those
|
||||
// files and FireControl.Splash). Nothing decides or applies damage through a Unity collider any more (R8):
|
||||
// files and FireControl.Detonate, 12.4(b)'s renamed Splash). Nothing decides or applies damage through a Unity
|
||||
// collider any more (R8):
|
||||
// this component is now purely a physics surface for ship-on-ship collision impulse and Mine's own proximity
|
||||
// arming query (Q7), neither of which is hit detection.
|
||||
public class HullCollider : MonoBehaviour
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ public class GuidedProjectile : MonoBehaviour
|
|||
private float _prevDist;
|
||||
private bool _active;
|
||||
private bool _alive;
|
||||
private float _spawnTime;
|
||||
private Vector3 _targetVelocity;
|
||||
private Vector3 _previousTargetPosition;
|
||||
|
||||
|
|
@ -46,11 +47,74 @@ public class GuidedProjectile : MonoBehaviour
|
|||
public Vector3 Velocity { get; set; }
|
||||
public Entity SourceEntity { get; set; }
|
||||
|
||||
// How long after spawn the round keeps its binding to the simulation's verdict: the shot's own flight time (the
|
||||
// manager sets it from the committed shot's ArrivalTime), so a round that faded out early still lives to show
|
||||
// the detonation the simulation resolves at arrival. 0 (the default) kills the round when its fade ends.
|
||||
public float BindingLifetime { get; set; }
|
||||
|
||||
public event Action OnKill;
|
||||
|
||||
// The simulation's verdict on this round, bound by GuidedProjectileManager to Zone.ShotCommitted and
|
||||
// ShotResolved for its ShotId: this object flies and looks, and neither decides where the round bursts nor when.
|
||||
// The one owner of the subscription's lifetime: a new binding disposes the one it replaces, Kill disposes it,
|
||||
// and so does destruction, so a projectile torn down with its scene never leaves an observer on the zone's
|
||||
// subjects to touch a destroyed transform.
|
||||
public IDisposable Binding
|
||||
{
|
||||
get => _binding;
|
||||
set
|
||||
{
|
||||
_binding?.Dispose();
|
||||
_binding = value;
|
||||
}
|
||||
}
|
||||
|
||||
private IDisposable _binding;
|
||||
|
||||
void OnDestroy() => Binding = null;
|
||||
|
||||
// The commit named a burst point: fly to it, whatever this round was homing on (a target it would have
|
||||
// passed, or a Range clamp it would have overshot). The point is a static target, so the old target's motion
|
||||
// is dropped with it: the jump to the new point must not feed the guidance a target velocity.
|
||||
public void BurstAt(Vector3 point)
|
||||
{
|
||||
Target = null;
|
||||
TargetPosition = () => point;
|
||||
_previousTargetPosition = point;
|
||||
_targetVelocity = Vector3.zero;
|
||||
}
|
||||
|
||||
// The resolution. A round that detonated (a hit, or a burst) bursts now, at the simulation's burst point when
|
||||
// it has one; a round the simulation resolved without a detonation (a contact or delayed round that missed,
|
||||
// one whose target is gone) just falls away, with no explosion to show.
|
||||
public void Resolve(bool detonated, Vector3? point)
|
||||
{
|
||||
// A round that already faded out (overshot, out of flight) still shows the simulation's detonation: only a
|
||||
// round that has been killed is done. The fade is stopped so it cannot Kill the round a second time.
|
||||
if (!_alive) return;
|
||||
if (!detonated)
|
||||
{
|
||||
if (_active) StartCoroutine(FadeOut());
|
||||
return;
|
||||
}
|
||||
StopAllCoroutines();
|
||||
// A hit carries no burst point: the effect plays where the round was homing (a round that faded out has stopped
|
||||
// short of it), and is skipped when the round never knew where its target was.
|
||||
Vector3? effectAt = point ?? (TargetPosition != null ? TargetPosition() : Target ? Target.position : (Vector3?) null);
|
||||
if (point.HasValue) transform.position = point.Value;
|
||||
if (HitEffect != null && effectAt.HasValue)
|
||||
{
|
||||
var ht = HitEffect.Instantiate<Transform>();
|
||||
ht.position = effectAt.Value;
|
||||
}
|
||||
StartCoroutine(Kill());
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
_active = _alive = true;
|
||||
_spawnTime = Time.time;
|
||||
BindingLifetime = 0f; // a pooled round starts unbound; the manager binds it after enabling
|
||||
_phase = Random.value * 100;
|
||||
_prevDist = Single.MaxValue;
|
||||
Particles.startColor = Color.white;
|
||||
|
|
@ -84,14 +148,11 @@ public class GuidedProjectile : MonoBehaviour
|
|||
var targetDist = diff.magnitude;
|
||||
var sourceDist = length(StartPosition.xz - position.xz);
|
||||
|
||||
// Out of range, or flown past its target: the round falls away. Only the simulation's detonation
|
||||
// (Resolve) shows an explosion; a round that merely ran out of flight has none.
|
||||
if (sourceDist > Range || dot(diff.ToCultMath(), Velocity.ToCultMath()) < 0)
|
||||
{
|
||||
StartCoroutine(FadeOut());
|
||||
if (HitEffect != null)
|
||||
{
|
||||
var ht = HitEffect.Instantiate<Transform>();
|
||||
ht.position = t.position;
|
||||
}
|
||||
return;
|
||||
}
|
||||
_prevDist = targetDist;
|
||||
|
|
@ -165,11 +226,16 @@ public class GuidedProjectile : MonoBehaviour
|
|||
yield return null;
|
||||
}
|
||||
|
||||
// The wait holds still: a round waiting on the verdict must not drift off its last position.
|
||||
Velocity = Vector3.zero;
|
||||
// Faded, but the simulation's verdict has not necessarily arrived: wait for it until the shot's flight is over.
|
||||
while (Time.time - _spawnTime < BindingLifetime) yield return null;
|
||||
StartCoroutine(Kill());
|
||||
}
|
||||
|
||||
IEnumerator Kill()
|
||||
{
|
||||
Binding = null;
|
||||
_active = false;
|
||||
_alive = false;
|
||||
Particles.Stop(true, ParticleSystemStopBehavior.StopEmitting);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,22 @@ using static CultMath.math;
|
|||
|
||||
public class GuidedProjectileManager : InstantWeaponEffectManager
|
||||
{
|
||||
// Presentation follows the committed shot (FireControl): the round retargets to the burst point the commit
|
||||
// names and bursts when the shot resolves, rather than predicting either from its own homing.
|
||||
private static void Bind(GuidedProjectile p, Zone zone, int shotId)
|
||||
{
|
||||
Vector3 At(ShotOutcome o) => new Vector3(o.BurstPoint.x, p.transform.position.y, o.BurstPoint.y);
|
||||
var bindings = new CompositeDisposable();
|
||||
zone.ShotCommitted.Where(o => o.ShotId == shotId && o.HasBurstPoint).Subscribe(o => p.BurstAt(At(o))).AddTo(bindings);
|
||||
zone.ShotResolved.Where(o => o.ShotId == shotId)
|
||||
.Subscribe(o => p.Resolve(o.Result == ShotResult.Hit || o.Result == ShotResult.Burst, o.HasBurstPoint ? At(o) : (Vector3?) null))
|
||||
.AddTo(bindings);
|
||||
// The binding outlives a fade-out until the shot's own arrival (the moment the simulation resolves it), plus a
|
||||
// second of margin; a shot no longer pending has nothing left to resolve.
|
||||
p.BindingLifetime = zone.TryGetShot(shotId, out var shot) ? max(0f, shot.ArrivalTime - zone.Time) + 1f : 0f;
|
||||
p.Binding = bindings; // replaces, and so disposes, any binding the projectile already had
|
||||
}
|
||||
|
||||
public Prototype ProjectilePrototype;
|
||||
|
||||
public Subject<(Entity source, Transform target, GuidedProjectile missile)> OnFireGuided = new Subject<(Entity source, Transform target, GuidedProjectile missile)>();
|
||||
|
|
@ -17,12 +33,17 @@ public class GuidedProjectileManager : InstantWeaponEffectManager
|
|||
{
|
||||
if(weapon.Data is LauncherData launcher)
|
||||
{
|
||||
if (target == null) return;
|
||||
// A round the simulation fired at no target (FireControl.Fire: a fused round with no valid targeting
|
||||
// data, or out of arc) flies to the point it bursts at; one with no target and no burst is not a shot.
|
||||
PendingShot shot = default;
|
||||
if (target == null && !(source.Entity.Zone.TryGetShot(shotId, out shot) && shot.Fuse != null)) return;
|
||||
var burst = shot.BurstPosition.ToUnity();
|
||||
var p = ProjectilePrototype.Instantiate<GuidedProjectile>();
|
||||
p.ShotId = shotId;
|
||||
p.Source = source.transform;
|
||||
p.SourceEntity = source.Entity;
|
||||
p.Target = target.transform;
|
||||
if (target != null) p.Target = target.transform;
|
||||
else p.TargetPosition = () => burst;
|
||||
p.Frequency = launcher.DodgeFrequency;
|
||||
var hp = source.Entity.Hardpoints[item.Position.x, item.Position.y];
|
||||
var barrel = source.GetBarrel(hp);
|
||||
|
|
@ -34,7 +55,9 @@ public class GuidedProjectileManager : InstantWeaponEffectManager
|
|||
p.Velocity = barrel.forward * weapon.Velocity;
|
||||
p.Thrust = item.Evaluate(launcher.Thrust);
|
||||
p.TopSpeed = item.Evaluate(launcher.MissileVelocity);
|
||||
OnFireGuided.OnNext((source.Entity, target.transform, p));
|
||||
Bind(p, source.Entity.Zone, shotId);
|
||||
// A round with no target (a fused round fired at none) has no transform to hand a listener.
|
||||
OnFireGuided.OnNext((source.Entity, target != null ? target.transform : null, p));
|
||||
}
|
||||
else if(weapon.Data is GuidedWeaponData guidance)
|
||||
{
|
||||
|
|
@ -54,6 +77,7 @@ public class GuidedProjectileManager : InstantWeaponEffectManager
|
|||
p.Thrust = item.Evaluate(guidance.Thrust);
|
||||
p.TopSpeed = item.Evaluate(guidance.MissileVelocity);
|
||||
p.TargetPosition = () => (source.Entity.Position + length(source.LookAtPoint.position.ToCultMath() - source.Entity.Position) * source.Entity.LookDirection).ToUnity();
|
||||
Bind(p, source.Entity.Zone, shotId);
|
||||
}
|
||||
else Debug.LogError($"Weapon {item.Data.Name} linked to {name} effect, but is not a Launcher!");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,15 +88,16 @@ public class Mine : MonoBehaviour
|
|||
}
|
||||
|
||||
// Cut 4 (docs/fire-control-cut.md, Q7): the arming OverlapSphere above stays -- that is contact detection,
|
||||
// not hit detection. Blast damage is not: it goes through the same FireControl.Splash every splash-shaped
|
||||
// weapon uses now, over the zone's own planar entities, not a Unity collider query. Presentation (ShowHit)
|
||||
// goes with the query it depended on -- nothing here decides who was hit any more, so nothing here can
|
||||
// point a hit effect at them; a future pass can rebuild that off FireControl-published state if the mine
|
||||
// ever ships (R9 keeps it regardless).
|
||||
// not hit detection. Blast damage is not: it goes through the same FireControl.Detonate every blast-shaped
|
||||
// weapon uses now (12.4(b) renamed Splash), over the zone's own planar entities, not a Unity collider
|
||||
// query. Presentation (ShowHit) goes with the query it depended on -- nothing here decides who was hit any
|
||||
// more, so nothing here can point a hit effect at them; a future pass can rebuild that off
|
||||
// FireControl-published state if the mine ever ships (R9 keeps it regardless). F12-6: BlastRange stays a
|
||||
// presentation-side input -- Mine has no catalog weapon record carrying Fuse/BlastRadius.
|
||||
public void Explode()
|
||||
{
|
||||
var position = transform.position;
|
||||
FireControl.Splash(Source.Entity.Zone, position.ToCultMath(), BlastRange, Damage, DamageType);
|
||||
FireControl.Detonate(Source.Entity.Zone, position.ToCultMath().xz, BlastRange, Damage, DamageType);
|
||||
|
||||
var ht = HitEffect.Instantiate<Transform>();
|
||||
ht.position = position;
|
||||
|
|
|
|||
|
|
@ -5,10 +5,10 @@ using static CultMath.math;
|
|||
// Cut 3 (docs/fire-control-cut.md): the raycast, shield branch and SendHit are deleted -- FireControl already
|
||||
// decided this shot's fate before this object was ever spawned (R8). What is left is pure flight-path
|
||||
// presentation: fly, and disappear at Range or ShotId's resolution, whichever comes first.
|
||||
// Cut 6b, 6.2: the flak-round blast now resolves in the simulation (FireControl.Step calls Splash instead of
|
||||
// Apply at arrival) -- a MonoBehaviour calling Splash would be exactly the authority Cut 3 spent itself
|
||||
// deleting, so the blast-distance/blast-radius fields this object used to carry for that are gone. This
|
||||
// object's job stays fly-and-disappear.
|
||||
// Cut 6b, 6.2 (12.4(b): Apply's own switch on the frozen Fuse decides this now, not Step): the flak-round
|
||||
// blast resolves in the simulation, through FireControl.Detonate -- a MonoBehaviour calling it would be
|
||||
// exactly the authority Cut 3 spent itself deleting, so the blast-distance/blast-radius fields this object
|
||||
// used to carry for that are gone. This object's job stays fly-and-disappear.
|
||||
public class Projectile : MonoBehaviour
|
||||
{
|
||||
public TrailRenderer Trail;
|
||||
|
|
|
|||
|
|
@ -29,22 +29,10 @@ public static class AetheriaStores
|
|||
cache.AllStoredDocuments.All(stored => stored.Descriptor != descriptor));
|
||||
if (missing != null)
|
||||
throw new InvalidOperationException($"Catalog {catalogPath} has no {missing.SchemaName} record; catalog globals are authored, never invented.");
|
||||
// R-heat (docs/stats-and-power-cut.md): every equippable design's heat response must describe a
|
||||
// coherent range before anything reads it. Fails loudly, naming the item.
|
||||
foreach (var data in cache.GetAll<EquippableItemData>())
|
||||
{
|
||||
StatValidation.ValidateHeatResponse(data);
|
||||
StatValidation.ValidateStatModifiers(data.Name, data.Behaviors);
|
||||
// Cut 7 (docs/stats-and-power-cut.md): a stat naming a role its design lacks is refused.
|
||||
StatValidation.ValidateRoleUsage(data.Name, data.Roles, data.Behaviors);
|
||||
}
|
||||
// Cut 2 (docs/stats-and-power-cut.md): a consumable's own StatModifierData needs the same check;
|
||||
// consumables carry no heat response, so this is not folded into the loop above.
|
||||
foreach (var data in cache.GetAll<ConsumableItemData>())
|
||||
{
|
||||
StatValidation.ValidateStatModifiers(data.Name, data.Behaviors);
|
||||
StatValidation.ValidateRoleUsage(data.Name, data.Roles, data.Behaviors);
|
||||
}
|
||||
// Every catalog document is held to the one check Upsert applies on write: R-heat (docs/stats-and-power-
|
||||
// cut.md), stat modifiers, role usage (Cut 7). Fails loudly, naming the item.
|
||||
foreach (var data in cache.GetAll<EquippableItemData>()) CultRecordRefs.Validate(data);
|
||||
foreach (var data in cache.GetAll<ConsumableItemData>()) CultRecordRefs.Validate(data);
|
||||
return cache;
|
||||
}
|
||||
catch
|
||||
|
|
|
|||
|
|
@ -57,10 +57,12 @@ public class CombatState : BaseState
|
|||
var group = _agent.Ship.WeaponGroups[i];
|
||||
var dps = 0f;
|
||||
foreach (var weapon in group.weapons)
|
||||
if (weapon.Item.Online.Value &&
|
||||
weapon.MinRange < targetDistance &&
|
||||
targetDistance < weapon.Range &&
|
||||
(weapon is ConstantWeapon ||
|
||||
// The range test is FireControl's (Designated), and a weapon Solve refuses adds nothing to a group's
|
||||
// damage.
|
||||
if (weapon.Item.Online.Value &&
|
||||
FireControl.Designated(weapon, _agent.Ship, target, out _) &&
|
||||
!FireControl.Refuses(weapon, _agent.Ship) &&
|
||||
(weapon is ConstantWeapon ||
|
||||
weapon is InstantWeapon instantWeapon && instantWeapon.CanFire))
|
||||
{
|
||||
if(weapon is LockWeapon lockWeapon)
|
||||
|
|
@ -111,13 +113,12 @@ public class CombatState : BaseState
|
|||
toTarget = normalize(predictedPosition - _agent.Ship.Position);
|
||||
}
|
||||
|
||||
// Cut 3: replaces Cut 1's bare InArc, which HitProbability already subsumes (it returns zero out
|
||||
// of arc) -- this is the AI's own "worth it" heuristic layered on top of the shared gate, not a
|
||||
// second gate.
|
||||
var shouldFire = FireControl.HitProbability(testWeapon, _agent.Ship, target) >= _agent.Settings.AgentMinHitProbability;
|
||||
// Each weapon decides for itself (operator ruling 2026-09-30): a group shares a trigger, not a
|
||||
// verdict. FireControl.AgentFires is the AI's "worth it" heuristic for a weapon that hits what it
|
||||
// fires at, and "the target is designated" for a fused one.
|
||||
foreach (var weapon in _agent.Ship.WeaponGroups[selectedGroup].weapons)
|
||||
{
|
||||
if (shouldFire)
|
||||
if (FireControl.AgentFires(weapon, _agent.Ship, target))
|
||||
weapon.Activate();
|
||||
else if (weapon.Firing)
|
||||
weapon.Deactivate();
|
||||
|
|
|
|||
|
|
@ -160,7 +160,10 @@ public class ChargedWeapon : InstantWeapon
|
|||
|
||||
public override void Activate()
|
||||
{
|
||||
if(!_charging && !_coolingDown)
|
||||
// CanFire also holds a weapon whose released charge has a burst pending: its cooldown starts at its first round,
|
||||
// so a charge started before then would overlap it.
|
||||
// A refused weapon never starts charging: it would pay charge heat and audio for a shot Trigger drops.
|
||||
if(!_charging && CanFire && !FireControl.Refuses(this, Entity))
|
||||
{
|
||||
OnStartCharging?.Invoke();
|
||||
Item.FireAudioEvent(ChargedWeaponAudioEvent.Start);
|
||||
|
|
|
|||
|
|
@ -91,7 +91,13 @@ public class ConstantWeapon : Weapon, IProgressBehavior, IEventBehavior, IPowerC
|
|||
// Cut 5 (docs/fire-control-cut.md, 5.3, Soul finding 9): StanceAllowsFire alone let a side-mounted beam
|
||||
// fire forward -- ArcAllowsFire joins it here, matching InstantWeapon.cs's player arc gate (Q2: manual and
|
||||
// programmatic are one truth, and a continuous weapon is no exception).
|
||||
public float PowerRequest(float dt) => _firing && StanceAllowsFire && ArcAllowsFire ? EvaluateNominalPower(_data.Energy) * dt : 0f;
|
||||
// Operator ruling 2026-09-30: a refused round is free, and a beam is a stream of rounds, so a fused beam whose
|
||||
// arming distance exceeds its Range fires nothing and draws nothing -- no power, ammo, wear, heat or
|
||||
// visibility. FireControl.Refuses is the one arming test; it reads the Range Execute last refreshed, the same
|
||||
// one-tick lag every PowerRequest reads its stats with.
|
||||
private bool MayFire => StanceAllowsFire && ArcAllowsFire && !FireControl.Refuses(this, Entity);
|
||||
|
||||
public float PowerRequest(float dt) => _firing && MayFire ? EvaluateNominalPower(_data.Energy) * dt : 0f;
|
||||
|
||||
// Cut 5 (docs/stats-and-power-cut.md §1.3, PowerTiers.cs): Low -- offense, same as InstantWeapon.
|
||||
public int DefaultPowerTier => PowerTiers.Low;
|
||||
|
|
@ -99,10 +105,11 @@ public class ConstantWeapon : Weapon, IProgressBehavior, IEventBehavior, IPowerC
|
|||
public override bool Execute(float dt)
|
||||
{
|
||||
base.Execute(dt);
|
||||
if (_firing && !(StanceAllowsFire && ArcAllowsFire))
|
||||
if (_firing && !MayFire)
|
||||
{
|
||||
// Safed: shooter has a target and hasn't declared hostility toward it, or the target no longer
|
||||
// bears (5.3: a beam obeys its arc exactly as InstantWeapon's trigger does).
|
||||
// bears (5.3: a beam obeys its arc exactly as InstantWeapon's trigger does), or a fused round is
|
||||
// refused.
|
||||
_firing = false;
|
||||
OnStopFiring?.Invoke();
|
||||
return false;
|
||||
|
|
@ -187,7 +194,9 @@ public class ConstantWeapon : Weapon, IProgressBehavior, IEventBehavior, IPowerC
|
|||
|
||||
public override void Activate()
|
||||
{
|
||||
if(!_firing && !_reloading)
|
||||
// A refused beam never starts (operator ruling 2026-09-30): OnStartFiring drives the beam's visuals and
|
||||
// audio, so starting it only for Execute to stop it a tick later would flash a beam that fires nothing.
|
||||
if(!_firing && !_reloading && !FireControl.Refuses(this, Entity))
|
||||
{
|
||||
_firing = true;
|
||||
OnStartFiring?.Invoke();
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior, IPowerCo
|
|||
protected readonly InputCapacitor _capacitor = new InputCapacitor();
|
||||
|
||||
protected int _burstRemaining;
|
||||
private bool _burstPaid;
|
||||
private bool _burstStarted;
|
||||
private float _burstTimer;
|
||||
private float _burstInterval;
|
||||
protected float _cooldown; // Normalized
|
||||
|
|
@ -52,7 +54,8 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior, IPowerCo
|
|||
public float Cooldown { get; protected set; }
|
||||
public virtual bool CanFire
|
||||
{
|
||||
get => !_coolingDown;
|
||||
// A triggered burst that has not yet fired a round is not ready either: its cooldown has not started.
|
||||
get => !_coolingDown && (_burstStarted || _burstRemaining == 0);
|
||||
}
|
||||
|
||||
public override float DamagePerSecond => Damage / Cooldown;
|
||||
|
|
@ -103,16 +106,20 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior, IPowerCo
|
|||
// through -- a player's action-bar Activate() reaches this exactly the same way Combat.cs's and
|
||||
// TurretController.cs's Activate() calls do.
|
||||
if (!ArcAllowsFire) return;
|
||||
// A refused round is free (operator ruling 2026-09-30): no ammo, energy or cooldown is spent on a burst
|
||||
// whose first round FireControl would refuse.
|
||||
if (FireControl.Refuses(this, Entity)) return;
|
||||
|
||||
// If 1 ammo is consumed per burst, perform ammo and energy consumption here
|
||||
// UseAmmo returns false when triggering reload; cancel firing if that is the case
|
||||
if(_data.SingleAmmoBurst && (!TrySpendActivationEnergy() || !UseAmmo())) return;
|
||||
|
||||
// A burst that pays once (SingleAmmoBurst) pays at its first round that is not refused, in Execute, judged
|
||||
// with the Range that round flies with: paying here would judge with the Range of the previous tick, and a
|
||||
// Range that fell in between would spend the ammo on rounds Fire then refuses.
|
||||
_burstPaid = false;
|
||||
_burstRemaining = (int) BurstCount;
|
||||
_burstInterval = BurstTime / _burstRemaining;
|
||||
_burstTimer = 0;
|
||||
_cooldown = 1;
|
||||
_coolingDown = true;
|
||||
// The cooldown starts with the burst's first round that is not refused (Execute), not here: a burst whose
|
||||
// every round is refused fires nothing and leaves no cooldown behind.
|
||||
_burstStarted = false;
|
||||
}
|
||||
|
||||
protected override void UpdateStats()
|
||||
|
|
@ -227,16 +234,32 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior, IPowerCo
|
|||
_burstTimer += dt;
|
||||
while (_burstRemaining > 0 && _burstTimer > 0)
|
||||
{
|
||||
// If multiple ammo is consumed per burst, perform ammo and energy consumption here
|
||||
// UseAmmo returns false when triggering reload; cancel firing if that is the case
|
||||
if (!_data.SingleAmmoBurst && (!TrySpendActivationEnergy() || !UseAmmo()))
|
||||
// A fused round whose arming distance Range cannot reach is refused, per round, before anything is
|
||||
// spent (operator ruling 2026-09-30): it costs no ammo, energy, sound, heat, wear or visibility.
|
||||
// The decision is FireControl's; Fire makes the same one.
|
||||
var refused = FireControl.Refuses(this, Entity);
|
||||
// Ammo and energy are consumed here, per round, or once per burst at its first unrefused round
|
||||
// (SingleAmmoBurst). UseAmmo returns false when triggering reload; cancel firing if that is the case
|
||||
if (!refused && !_burstPaid && (!TrySpendActivationEnergy() || !UseAmmo()))
|
||||
{
|
||||
_burstRemaining = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!refused)
|
||||
{
|
||||
_burstPaid = _data.SingleAmmoBurst;
|
||||
if (!_burstStarted)
|
||||
{
|
||||
_burstStarted = true;
|
||||
_cooldown = 1 - dt / Cooldown;
|
||||
// The round starts the cooldown after this tick's decrement above: charge the tick to it, so the cadence stays Cooldown
|
||||
_coolingDown = true;
|
||||
}
|
||||
}
|
||||
|
||||
_burstRemaining--;
|
||||
_burstTimer -= _burstInterval;
|
||||
if (refused) continue;
|
||||
// Cut 3: this is fire authority's one entry point. FireControl.Fire freezes the payload snapshot
|
||||
// (Q6 -- the gun's own stats at this exact instant, base.Execute(dt) above already refreshed them
|
||||
// this tick) and queues a PendingShot; nothing downstream re-evaluates a stat.
|
||||
|
|
|
|||
|
|
@ -73,16 +73,12 @@ public class TurretController : Behavior, IInitializableBehavior
|
|||
}
|
||||
else
|
||||
Entity.LookDirection = normalize(diff);
|
||||
var dist = length(diff);
|
||||
|
||||
foreach (var x in _weapons)
|
||||
{
|
||||
var data = x.Data as WeaponData;
|
||||
// Cut 3 (docs/fire-control-cut.md): the same gate and threshold Combat.cs uses -- HitProbability
|
||||
// already subsumes the bare arc test (zero out of arc), so this is the "worth it" heuristic, not
|
||||
// a parallel arc check.
|
||||
var fire = FireControl.HitProbability(x, Entity, Entity.Target.Value) >= Entity.ItemManager.GameplaySettings.AgentMinHitProbability;
|
||||
if (x.Evaluate(data.Range) > dist && fire)
|
||||
// The same per-weapon decision Combat.cs makes; the range test is part of it (a shot out of range
|
||||
// is not designated and prices at zero).
|
||||
if (FireControl.AgentFires(x, Entity, Entity.Target.Value))
|
||||
{
|
||||
x.Activate();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,16 +107,8 @@ public abstract class Weapon : Behavior, IActivatedBehavior
|
|||
// gate, not the gate itself. With no target set, behaviour is unchanged (nothing to bear on).
|
||||
// Cut 5, 5.4 (Soul finding 11): the point-blank special case this used to carry moved into InArc itself --
|
||||
// one bearing test, one owner, so every caller (not just this one) gets a point-blank shot that bears.
|
||||
public bool ArcAllowsFire
|
||||
{
|
||||
get
|
||||
{
|
||||
var target = Entity.Target.Value;
|
||||
if (target == null) return true;
|
||||
var toTarget = target.Position - Entity.Position;
|
||||
return FireControl.InArc(Item, toTarget);
|
||||
}
|
||||
}
|
||||
// FireControl owns the gate, including its one exemption: a fused weapon fires out of arc.
|
||||
public bool ArcAllowsFire => FireControl.ArcPermitsFire(this, Entity);
|
||||
|
||||
public Weapon(WeaponData data, EquippedItem item) : base(data, item)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -329,54 +329,78 @@ public abstract class Entity
|
|||
? TargetItem.Value
|
||||
: null;
|
||||
|
||||
// Cut 3 (docs/fire-control-cut.md): the damage rule moved verbatim from EntityInstance.cs's Unity
|
||||
// HullCollider subscription (DamageSchematic) -- same arithmetic, same order, same thresholds. The only
|
||||
// thing that changed is the owner: this entity's own schematic, armor and hull, not a Unity component
|
||||
// reacting to a physics collision.
|
||||
public void DamageSchematic(float damage, Shape hitShape)
|
||||
// Cut 12.3 (docs/fire-control-cut.md): "armour absorbs first" -- the per-cell armour phase, split out of
|
||||
// what used to be Absorb's own first half (moved verbatim from DamageSchematic's per-cell body, Cut 3) so
|
||||
// Cut 12.3's fix batch (proportional multi-lane item absorption, below) can call the armour phase once per
|
||||
// cell -- always local to one lane, since armour never spans cells -- while deferring the item phase to
|
||||
// ItemAbsorb's own pool for EVERY occupied cell, not only ones shared with another lane: a lane that turns
|
||||
// out to be an item's only contributor still pools through a list of one (ItemAbsorb's own degenerate
|
||||
// case), never a separate solo path. ArmorDamage fires only for incoming > 0.
|
||||
public float ArmorAbsorb(int2 cell, float damage)
|
||||
{
|
||||
var hullData = ItemManager.GetData(Hull) as HullData;
|
||||
foreach (var v in hitShape.Coordinates)
|
||||
hitShape[v] = hitShape[v] && hullData.Shape[v];
|
||||
var d = damage;
|
||||
|
||||
float hullDamage = 0;
|
||||
var damagePerCell = damage / hitShape.Coordinates.Length;
|
||||
foreach (var v in hitShape.Coordinates)
|
||||
if (d > 0f)
|
||||
{
|
||||
var d = damagePerCell;
|
||||
|
||||
// Subtract surface damage from armor, passing on the remainder to the item and then to the hull
|
||||
var prev = Armor[v.x, v.y];
|
||||
Armor[v.x, v.y] = max(prev - d, 0);
|
||||
ArmorDamage.OnNext((v, d));
|
||||
d = max(d - prev, 0);
|
||||
|
||||
if (d > 0.1f)
|
||||
{
|
||||
var item = GearOccupancy[v.x, v.y];
|
||||
if (item != null)
|
||||
{
|
||||
prev = item.EquippableItem.Durability;
|
||||
item.EquippableItem.Durability = max(prev - d, 0);
|
||||
ItemDamage.OnNext((item, d));
|
||||
d = max(d - prev, 0);
|
||||
}
|
||||
}
|
||||
|
||||
hullDamage += d;
|
||||
var prevArmor = Armor[cell.x, cell.y];
|
||||
Armor[cell.x, cell.y] = max(prevArmor - d, 0);
|
||||
ArmorDamage.OnNext((cell, d));
|
||||
d = max(d - prevArmor, 0);
|
||||
}
|
||||
|
||||
if (hullDamage > .1f)
|
||||
return d;
|
||||
}
|
||||
|
||||
// Cut 12.3 fix batch (one apply path, operator ruling 2026-09-25 "do not expect items taking up multiple
|
||||
// cells to be an exception, this should be one code path"): the ONE function that decides an item's own
|
||||
// absorption, whatever the item's shape or however many lanes of one shot reach it. `incoming` holds every
|
||||
// contributing lane's own post-armour remainder for this resolve, one lane's worth included -- a
|
||||
// single-lane item is this rule's own degenerate case, not a separate function or a separate threshold.
|
||||
// The existing .1f threshold is decided once, on the POOLED total, never per contribution (a pooled path
|
||||
// that gated each contribution separately would let two shares under .1f each slip past an item that a
|
||||
// single .08f solo hit would already have stopped at). Absorbed durability is split back across `incoming`
|
||||
// in place, pro-rata to what each lane brought -- the divide below never sees total <= 0.1f, so it never
|
||||
// sees zero (the guard above already returned). ItemDamage fires once per contributing lane, reporting its
|
||||
// own INCOMING share -- not the post-clamp amount, the same convention ArmorAbsorb already uses -- and only
|
||||
// when that lane's own share is itself > 0, so a zero-deposit contributor (a lane whose armour ate its
|
||||
// whole share before reaching this item) never fires a phantom event. `item` is never null here: both
|
||||
// callers (`FireControl.ApplyPooled`'s `Resolve`, one lane's worth of contributions included, and
|
||||
// `FireControl.Detonate`'s own per-entity item-pool resolution, one covered cell's worth included) already
|
||||
// guarantee it -- a pool is only ever opened under a non-null `GearOccupancy` cell.
|
||||
public void ItemAbsorb(EquippedItem item, Span<float> incoming)
|
||||
{
|
||||
var total = 0f;
|
||||
for (var i = 0; i < incoming.Length; i++) total += incoming[i];
|
||||
if (total <= 0.1f) return;
|
||||
|
||||
var before = item.EquippableItem.Durability;
|
||||
var absorbed = min(total, before);
|
||||
item.EquippableItem.Durability = max(before - absorbed, 0f);
|
||||
var fraction = absorbed / total;
|
||||
for (var i = 0; i < incoming.Length; i++)
|
||||
{
|
||||
Hull.Durability -= hullDamage;
|
||||
HullDamage.OnNext(hullDamage);
|
||||
if (incoming[i] > 0f) ItemDamage.OnNext((item, incoming[i]));
|
||||
incoming[i] -= incoming[i] * fraction;
|
||||
}
|
||||
}
|
||||
|
||||
// Cut 12.3: moved verbatim from DamageSchematic's own tail (Cut 3) -- the >.1f threshold and the one
|
||||
// HullDamage event are unchanged. FireControl.Apply calls this once per resolved hit, with the summed
|
||||
// remainder every lane's own walk left over (Q12-3 = A: a lane's remainder goes to the hull wherever the
|
||||
// lane ends -- penetration exhausted, a gap, or the far side).
|
||||
public void DamageHull(float damage)
|
||||
{
|
||||
if (damage > .1f)
|
||||
{
|
||||
Hull.Durability -= damage;
|
||||
HullDamage.OnNext(damage);
|
||||
}
|
||||
}
|
||||
|
||||
// Cut 12.1 (docs/fire-control-cut.md): the one schematic-frame owner. Maps a world-planar vector into this
|
||||
// entity's own schematic frame -- x = starboard, y = bow -- so ApplyHit's penetration march and
|
||||
// FireControl.Splash's directional half both read the same transform instead of each carrying their own
|
||||
// copy of forward/right.
|
||||
// entity's own schematic frame -- x = starboard, y = bow -- so FireControl.Apply's lane walk and
|
||||
// FireControl.Detonate's per-entity point conversion both read the same transform instead of each carrying
|
||||
// their own copy of forward/right.
|
||||
public float2 ToSchematic(float2 worldPlanar)
|
||||
{
|
||||
var forward = normalize(Direction);
|
||||
|
|
@ -384,38 +408,29 @@ public abstract class Entity
|
|||
return float2(dot(worldPlanar, right), dot(worldPlanar, forward));
|
||||
}
|
||||
|
||||
// Cut 3: the shape construction moved from EntityInstance.cs's Unity HullCollider subscription -- the hit
|
||||
// cell is the rolled Cell FireControl already chose, not a UV texture coordinate.
|
||||
// Cut 12.2 (docs/fire-control-cut.md): `bearing` is already in this entity's own schematic frame -- the
|
||||
// committed ShotOutcome.Bearing FireControl.Commit computed once, at the commit tick -- so the ToSchematic
|
||||
// call this used to make internally (12.1) is gone; ApplyHit no longer touches a world direction or this
|
||||
// entity's own Direction at all.
|
||||
public void ApplyHit(Entity source, int2 cell, float spread, float penetration, float damage, float2 bearing)
|
||||
// Cut 12.4(b) (docs/fire-control-cut.md, "Area, per entity"): the world<->schematic POINT owners, built on
|
||||
// ToSchematic's frame -- the entity's own position is the schematic's centre of mass. FireControl.Detonate
|
||||
// uses ToSchematicPoint to find where a blast sits in each candidate's own schematic (the host of a contact
|
||||
// or delayed blast included: it is treated like any other entity in the radius, its cells found again
|
||||
// here, not carried over from the commit). ToWorldPoint is the inverse, used once, to convert a contact or
|
||||
// delayed fuse point (found on the committed lane, in the host's schematic frame at commit) into the one
|
||||
// world point Detonate's single input shape takes -- the round trip through the host's own pose at arrival
|
||||
// is what fixes the host's damage to the commit (R4) while every bystander is judged live.
|
||||
public float2 ToSchematicPoint(float2 worldPlanar)
|
||||
{
|
||||
IncomingHit.OnNext(source);
|
||||
|
||||
var hullData = ItemManager.GetData(Hull) as HullData;
|
||||
var hitShape = new Shape(hullData.Shape.Width, hullData.Shape.Height);
|
||||
hitShape[cell] = true;
|
||||
var cellSize = ItemManager.GameplaySettings.SchematicCellSize;
|
||||
return ToSchematic(worldPlanar - Position.xz) / cellSize + hullData.Shape.CenterOfMass;
|
||||
}
|
||||
|
||||
for (var i = 0; i < (int) floor(spread + .5f); i++)
|
||||
hitShape = hitShape.Expand();
|
||||
|
||||
if (penetration > .5f)
|
||||
{
|
||||
var penetrationVector = normalize(bearing);
|
||||
|
||||
var penetrationPoint = (float2) cell + float2(.5f);
|
||||
var penetrationDistance = 0f;
|
||||
while (penetrationDistance < penetration && hullData.Shape[int2(penetrationPoint)])
|
||||
{
|
||||
penetrationDistance += .5f;
|
||||
hitShape[int2(penetrationPoint)] = true;
|
||||
penetrationPoint += penetrationVector * .5f;
|
||||
}
|
||||
}
|
||||
|
||||
DamageSchematic(damage, hitShape);
|
||||
public float2 ToWorldPoint(float2 schematicPoint)
|
||||
{
|
||||
var hullData = ItemManager.GetData(Hull) as HullData;
|
||||
var cellSize = ItemManager.GameplaySettings.SchematicCellSize;
|
||||
var local = (schematicPoint - hullData.Shape.CenterOfMass) * cellSize;
|
||||
var forward = normalize(Direction);
|
||||
var right = float2(forward.y, -forward.x);
|
||||
return Position.xz + local.x * right + local.y * forward;
|
||||
}
|
||||
|
||||
// Another entity's stance toward THIS one, as far as this entity can perceive it: unknown (null)
|
||||
|
|
@ -501,7 +516,10 @@ public abstract class Entity
|
|||
Death = HullDamage.Where(_ => Hull.Durability < .01f).Select(_ => CauseOfDeath.HullDestroyed)
|
||||
.Merge(HeatstrokeDeath.Select(_ => CauseOfDeath.Heatstroke))
|
||||
.Merge(HypothermiaDeath.Select(_ => CauseOfDeath.Hypothermia))
|
||||
.Merge(ItemDestroyed.Where(i=>i.GetBehavior<Cockpit>()!=null).Select(_ => CauseOfDeath.CockpitDestroyed));
|
||||
.Merge(ItemDestroyed.Where(i=>i.GetBehavior<Cockpit>()!=null).Select(_ => CauseOfDeath.CockpitDestroyed))
|
||||
// Death is terminal: the first cause ends the stream, so no damage path (a blast whose cockpit kill is
|
||||
// followed by its own hull damage, a second item, a heat tick) can raise it twice to any subscriber.
|
||||
.Take(1);
|
||||
|
||||
//CurrentSecurityLevel.Value = SecurityLevel.Open;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,6 +107,15 @@ public enum WeaponModifiers
|
|||
Cluster = 1 << 6
|
||||
}
|
||||
|
||||
// Cut 12.4(a) (docs/fire-control-cut.md): what a weapon's blast radius (WeaponItemData.BlastRadius) detonates
|
||||
// as. Null means no blast at all -- WeaponItemData.Fuse is frozen null unless BlastRadius > 0 (FireControl.Fire).
|
||||
public enum WeaponFuse
|
||||
{
|
||||
Contact,
|
||||
Proximity,
|
||||
Delayed
|
||||
}
|
||||
|
||||
public enum DamageType
|
||||
{
|
||||
Kinetic,
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -490,12 +490,20 @@ public class WeaponItemData : GearData
|
|||
[Inspectable, JsonProperty("modifiers"), Key(28)]
|
||||
public WeaponModifiers WeaponModifiers;
|
||||
|
||||
// Cut 6b (docs/fire-control-cut.md, 6.2): the authored blast radius an Airburst-flagged weapon's shot
|
||||
// splashes with at arrival, frozen into PendingShot.BurstRadius at fire. Zero (and unread) for a weapon
|
||||
// without the Airburst flag. No authored value exists yet -- the flag is wired and unexercised until Cut
|
||||
// 6a or a later authoring pass sets it.
|
||||
[Inspectable, JsonProperty("airburstRange"), Key(29)]
|
||||
public float? AirburstRange;
|
||||
// Cut 12.4(a) (docs/fire-control-cut.md): the authored blast radius a weapon's shot detonates with, in
|
||||
// world units. Renamed from slot 29's old airburst-range field -- the slot and type are unchanged, so
|
||||
// CultCache opens the catalog as compatible drift. Null (every shipped record) means no blast; WeaponModifiers
|
||||
// no longer decides this (Q12-6, "WeaponModifiers are labels, not behaviour").
|
||||
[Inspectable, JsonProperty("blastRadius"), Key(29)]
|
||||
public float? BlastRadius;
|
||||
|
||||
// Cut 12.4(a): what kind of blast BlastRadius describes. Nullable under the 7.4 rule -- null means no
|
||||
// blast, and every shipped record reads null. FireControl.Fire freezes this from the weapon only when
|
||||
// BlastRadius > 0; a fuse without a radius, or a radius without a fuse, is inert and resolves as a direct
|
||||
// hit (nothing polices that, per Q12-6). Key 30 and 31 belong to EquippableItemData's OptimalTemperature
|
||||
// and PlateauWidth, inherited here -- the next free key across WeaponItemData's own ancestry is 32.
|
||||
[Inspectable, JsonProperty("fuse"), Key(32)]
|
||||
public WeaponFuse? Fuse;
|
||||
}
|
||||
|
||||
[CultDocument("aetheria.hulldata", "1"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
||||
|
|
|
|||
|
|
@ -43,6 +43,21 @@ public class Zone
|
|||
private int _nextShotId;
|
||||
public int NextShotId() => ++_nextShotId;
|
||||
|
||||
// The committed shot a presentation was handed the id of by OnFire. It carries what the simulation decided
|
||||
// -- the target it flies at (null for a round that carries none) and where it bursts -- so a presentation
|
||||
// reads that rather than the shooter's current selection.
|
||||
public bool TryGetShot(int shotId, out PendingShot shot)
|
||||
{
|
||||
foreach (var pending in PendingShots)
|
||||
if (pending.ShotId == shotId)
|
||||
{
|
||||
shot = pending;
|
||||
return true;
|
||||
}
|
||||
shot = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
public float Time
|
||||
{
|
||||
get => (float) _time;
|
||||
|
|
|
|||
|
|
@ -207,17 +207,39 @@ public static class ZoneGenerator
|
|||
|
||||
var storyStations = galaxyZone.Locations.Where(story => story.Type == LocationType.Station).ToArray();
|
||||
var stationCount = (int)(random.NextFloat() * (factionPresence + 1)) + storyStations.Length;
|
||||
// Enemy count below is based on this pre-override value, so the tutorial entrance doesn't gain an enemy
|
||||
// just because its station got forced.
|
||||
var baseStationCount = stationCount;
|
||||
// Operator ruling, 2026-09-25 (docs/locomotion-cut.md, "Tutorial station"): the entrance zone always
|
||||
// gets a generated faction station with a docking bay, deterministically. Galaxy.cs halves influence and
|
||||
// picks the lowest-influence unowned zone for Entrance, which otherwise rolls stationCount 0 on every
|
||||
// seed. galaxy.Entrance is reference-identity, not a name comparison.
|
||||
var isTutorialEntrance = isTutorial && galaxyZone == galaxy.Entrance;
|
||||
if (isTutorialEntrance && stationCount < 1) stationCount = 1;
|
||||
var potentialLagrangePoints = planets
|
||||
.Where(p => p.Parent != null && p.Parent.Children
|
||||
.TrueForAll(c => !(c != p && abs(c.Distance - p.Distance) < .1f))) // Filter Rosettes
|
||||
.OrderBy(p => p.Distance)
|
||||
.ToArray();
|
||||
// The entrance's own station count is the floor above; its orbit always comes from this same selection.
|
||||
// Ordinarily that selection is potentialLagrangePoints (non-rosette planet orbits). If the entrance zone
|
||||
// has none of those (a boring single-body system, or a system that is entirely one rosette), widen to
|
||||
// every planet orbit ordinary placement's own candidate pool is drawn from before the rosette filter --
|
||||
// still a real, parented planet orbit with a positive Distance -- rather than inventing an unparented,
|
||||
// zero-distance orbit (that gave PlaceTurret's phase = 20*multiplier/orbit.Distance a division by zero,
|
||||
// and left an orbit record with no planet behind it).
|
||||
var lagrangeCandidates = potentialLagrangePoints;
|
||||
if (isTutorialEntrance && lagrangeCandidates.Length == 0)
|
||||
lagrangeCandidates = planets.Where(p => p.Parent != null).OrderBy(p => p.Distance).ToArray();
|
||||
// Pick a selection from the middle of the distribution
|
||||
var selectedStationOrbits = potentialLagrangePoints
|
||||
.Skip(potentialLagrangePoints.Length / 2)
|
||||
var selectedStationOrbits = lagrangeCandidates
|
||||
.Skip(lagrangeCandidates.Length / 2)
|
||||
.Take(stationCount)
|
||||
.Select(p=>orbitMap[p])
|
||||
.ToArray();
|
||||
if (isTutorialEntrance && lagrangeCandidates.Length == 0)
|
||||
throw new InvalidOperationException(
|
||||
"The tutorial entrance zone must always get a station, but it has no candidate orbit at all -- every planet in the zone is a parentless root.");
|
||||
|
||||
var loadoutGenerators = new Dictionary<Faction, LoadoutGenerator>();
|
||||
|
||||
|
|
@ -234,7 +256,7 @@ public static class ZoneGenerator
|
|||
{
|
||||
Parent = baseOrbit.Parent,
|
||||
Distance = baseOrbit.Distance,
|
||||
Phase = baseOrbit.Phase + PI / 3 * sign(random.NextFloat() - .5f)
|
||||
Phase = baseOrbit.Phase + PI / 3 * sign(random.NextFloat() - .5f),
|
||||
};
|
||||
pack.Orbits.Add(cache.Upsert(lagrangeOrbit));
|
||||
return lagrangeOrbit;
|
||||
|
|
@ -294,7 +316,13 @@ public static class ZoneGenerator
|
|||
|
||||
var lagrangeOrbit = CreateLagrangeOrbit(orbit);
|
||||
var station = GetLoadoutGenerator(nearestFaction).GenerateStationLoadout();
|
||||
if (station == null) continue;
|
||||
if (station == null)
|
||||
{
|
||||
if (isTutorialEntrance)
|
||||
throw new InvalidOperationException(
|
||||
$"The tutorial entrance zone must always get a station, but {nearestFaction?.Name} has no station loadout to generate.");
|
||||
continue;
|
||||
}
|
||||
station.Orbit = cache.RefOf(lagrangeOrbit);
|
||||
station.SecurityLevel = security;
|
||||
station.SecurityRadius = pack.Radius;
|
||||
|
|
@ -303,7 +331,7 @@ public static class ZoneGenerator
|
|||
PlaceTurrets(lagrangeOrbit, GetLoadoutGenerator(nearestFaction), 2);
|
||||
}
|
||||
|
||||
var enemyCount = (int)(random.NextFloat() * factionPresence * 2) + stationCount;
|
||||
var enemyCount = (int)(random.NextFloat() * factionPresence * 2) + baseStationCount;
|
||||
for (int i = 0; i < enemyCount; i++)
|
||||
{
|
||||
var ship = GetLoadoutGenerator(nearestFaction).GenerateShipLoadout();
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@ public class ConsoleView : MonoBehaviour {
|
|||
|
||||
Keyboard.current.onTextInput += c =>
|
||||
{
|
||||
if (!Visible || c == '`') return;
|
||||
// Text input also delivers control characters (backspace as '\b', enter as '\r'); editing keys are
|
||||
// handled in Update, so only printable characters are text.
|
||||
if (!Visible || c == '`' || char.IsControl(c)) return;
|
||||
InputString += c;
|
||||
};
|
||||
InputString = "";
|
||||
|
|
@ -81,7 +83,7 @@ public class ConsoleView : MonoBehaviour {
|
|||
|
||||
if (!Visible) return;
|
||||
|
||||
if(keyboard.deleteKey.wasPressedThisFrame && InputString.Length>0)
|
||||
if((keyboard.backspaceKey.wasPressedThisFrame || keyboard.deleteKey.wasPressedThisFrame) && InputString.Length>0)
|
||||
{
|
||||
InputString = InputString.Substring(0, InputString.Length - 1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -374,8 +374,7 @@ public class TradeMenu : MonoBehaviour
|
|||
{
|
||||
if (hullData.HullType != HullType.Ship) throw new ArgumentException("Attempted to buy non-ship hull from station, WTF are you doing?!");
|
||||
|
||||
var ship = new Ship(GameManager.ItemManager, GameManager.Zone, item as EquippableItem, GameManager.ItemManager.GameplaySettings.DefaultEntitySettings) { IsPlayerShip = true };
|
||||
ship.SetParent(GameManager.DockedEntity);
|
||||
GameManager.CommissionShip(item as EquippableItem);
|
||||
|
||||
GameManager.Credits -= data.Price;
|
||||
UpdateCreditsLabel();
|
||||
|
|
|
|||
Loading…
Reference in a new issue