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
Binary file not shown.
File diff suppressed because it is too large
Load diff
|
|
@ -13,7 +13,7 @@ OcclusionCullingSettings:
|
|||
--- !u!104 &2
|
||||
RenderSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 9
|
||||
serializedVersion: 10
|
||||
m_Fog: 0
|
||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
m_FogMode: 3
|
||||
|
|
@ -38,13 +38,12 @@ RenderSettings:
|
|||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 0}
|
||||
m_IndirectSpecularColor: {r: 0.023674645, g: 0.04639011, b: 0.122535154, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 12
|
||||
m_GIWorkflowMode: 1
|
||||
serializedVersion: 13
|
||||
m_BakeOnSceneLoad: 0
|
||||
m_GISettings:
|
||||
serializedVersion: 2
|
||||
m_BounceScale: 1
|
||||
|
|
@ -67,9 +66,6 @@ LightmapSettings:
|
|||
m_LightmapParameters: {fileID: 0}
|
||||
m_LightmapsBakeMode: 1
|
||||
m_TextureCompression: 1
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherFiltering: 1
|
||||
m_FinalGatherRayCount: 256
|
||||
m_ReflectionCompression: 2
|
||||
m_MixedBakeMode: 2
|
||||
m_BakeBackend: 1
|
||||
|
|
@ -104,7 +100,7 @@ NavMeshSettings:
|
|||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_BuildSettings:
|
||||
serializedVersion: 2
|
||||
serializedVersion: 3
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
|
|
@ -117,7 +113,7 @@ NavMeshSettings:
|
|||
cellSize: 0.16666667
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
accuratePlacement: 0
|
||||
buildHeightMesh: 0
|
||||
maxJobWorkers: 0
|
||||
preserveTilesOutsideBounds: 0
|
||||
debug:
|
||||
|
|
@ -155,7 +151,6 @@ RectTransform:
|
|||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 815358592}
|
||||
m_RootOrder: 5
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
|
|
@ -296,7 +291,6 @@ RectTransform:
|
|||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 815358592}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
|
|
@ -308,6 +302,7 @@ PrefabInstance:
|
|||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 815358592}
|
||||
m_Modifications:
|
||||
- target: {fileID: 257019179550429270, guid: 426f9dcb510530d4dbfa678c9f727ec1,
|
||||
|
|
@ -360,6 +355,11 @@ PrefabInstance:
|
|||
propertyPath: m_text
|
||||
value: Aetheric Field Tester
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7131821417072393581, guid: 426f9dcb510530d4dbfa678c9f727ec1,
|
||||
type: 3}
|
||||
propertyPath: 'm_ActiveFontFeatures.Array.data[0]'
|
||||
value: 1801810542
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7131821417165215474, guid: 426f9dcb510530d4dbfa678c9f727ec1,
|
||||
type: 3}
|
||||
propertyPath: m_Enabled
|
||||
|
|
@ -481,6 +481,9 @@ PrefabInstance:
|
|||
value: Properties
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 426f9dcb510530d4dbfa678c9f727ec1, type: 3}
|
||||
--- !u!114 &401779935 stripped
|
||||
MonoBehaviour:
|
||||
|
|
@ -505,6 +508,7 @@ PrefabInstance:
|
|||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 815358592}
|
||||
m_Modifications:
|
||||
- target: {fileID: 9194050151789067659, guid: 5c3a7b786419db74a8c1d17039fd4f67,
|
||||
|
|
@ -663,6 +667,9 @@ PrefabInstance:
|
|||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 5c3a7b786419db74a8c1d17039fd4f67, type: 3}
|
||||
--- !u!224 &415327856 stripped
|
||||
RectTransform:
|
||||
|
|
@ -713,7 +720,6 @@ RectTransform:
|
|||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1112533349}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 180}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
|
|
@ -812,13 +818,13 @@ Transform:
|
|||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 699508825}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 5
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &815358588
|
||||
GameObject:
|
||||
|
|
@ -896,7 +902,9 @@ Canvas:
|
|||
m_OverrideSorting: 0
|
||||
m_OverridePixelPerfect: 0
|
||||
m_SortingBucketNormalizedSize: 0
|
||||
m_VertexColorAlwaysGammaSpace: 0
|
||||
m_AdditionalShaderChannelsFlag: 25
|
||||
m_UpdateRectTransformForStandalone: 0
|
||||
m_SortingLayerID: 0
|
||||
m_SortingOrder: 0
|
||||
m_TargetDisplay: 0
|
||||
|
|
@ -919,7 +927,6 @@ RectTransform:
|
|||
- {fileID: 415327856}
|
||||
- {fileID: 87891009}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
|
|
@ -931,6 +938,7 @@ PrefabInstance:
|
|||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 411033920054375063, guid: fe47fadcdb5ae5c4caca516b4af6fde6,
|
||||
|
|
@ -1008,7 +1016,39 @@ PrefabInstance:
|
|||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2212592724187910978, guid: fe47fadcdb5ae5c4caca516b4af6fde6,
|
||||
type: 3}
|
||||
propertyPath: m_Enabled
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents:
|
||||
- targetCorrespondingSourceObject: {fileID: 411033920054375063, guid: fe47fadcdb5ae5c4caca516b4af6fde6,
|
||||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 909026487}
|
||||
- targetCorrespondingSourceObject: {fileID: 411033920054375063, guid: fe47fadcdb5ae5c4caca516b4af6fde6,
|
||||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 909026488}
|
||||
- targetCorrespondingSourceObject: {fileID: 411033920054375063, guid: fe47fadcdb5ae5c4caca516b4af6fde6,
|
||||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 909026489}
|
||||
- targetCorrespondingSourceObject: {fileID: 411033920054375063, guid: fe47fadcdb5ae5c4caca516b4af6fde6,
|
||||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 909026490}
|
||||
- targetCorrespondingSourceObject: {fileID: 411033920054375063, guid: fe47fadcdb5ae5c4caca516b4af6fde6,
|
||||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 909026492}
|
||||
- targetCorrespondingSourceObject: {fileID: 411033920054375063, guid: fe47fadcdb5ae5c4caca516b4af6fde6,
|
||||
type: 3}
|
||||
insertIndex: -1
|
||||
addedObject: {fileID: 909026491}
|
||||
m_SourcePrefab: {fileID: 100100000, guid: fe47fadcdb5ae5c4caca516b4af6fde6, type: 3}
|
||||
--- !u!1 &909026486 stripped
|
||||
GameObject:
|
||||
|
|
@ -1024,9 +1064,17 @@ MeshCollider:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 909026486}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 0
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 4
|
||||
serializedVersion: 5
|
||||
m_Convex: 1
|
||||
m_CookingOptions: 30
|
||||
m_Mesh: {fileID: -5495902117074765545, guid: dd6644c1aa6c16c47bb9fea9822ce805, type: 3}
|
||||
|
|
@ -1043,11 +1091,9 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Camera: {fileID: 1153356615}
|
||||
FrontTwist: 0
|
||||
RearTwist: 0
|
||||
TestMagnitude: 0.5
|
||||
Throttle:
|
||||
x: 0
|
||||
y: 0
|
||||
ThrottleDecay: 5
|
||||
FlowSpeed: 2
|
||||
FlowSpeedThrottleExponent: 1
|
||||
WaveThrottleExponent: 0
|
||||
|
|
@ -1084,8 +1130,8 @@ MonoBehaviour:
|
|||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 52538a3309c36fc4583c964a1c0b705f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &909026490
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -1096,8 +1142,40 @@ MonoBehaviour:
|
|||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d8f4aa77146e46a2a4b28d9fefb98496, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &909026491
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 909026486}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fdca6a832d764b6e89fc83fdcf7b42d7, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::ShieldInterceptor
|
||||
Envelope: {fileID: 909026492}
|
||||
PanelPrototype: {fileID: 1087039186}
|
||||
MaxLivePanels: 12
|
||||
PanelRadius: 2
|
||||
EnergyScale: 1
|
||||
ReuseFraction: 1
|
||||
DeathMargin: 0.25
|
||||
PatternByDamageType:
|
||||
--- !u!114 &909026492
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 909026486}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e25c67ee83c01364fb121caeda952606, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::ShieldEnvelope
|
||||
--- !u!1 &1012179276
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -1138,13 +1216,13 @@ Transform:
|
|||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1012179276}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1012179280
|
||||
MonoBehaviour:
|
||||
|
|
@ -1186,11 +1264,14 @@ MonoBehaviour:
|
|||
type: 3}
|
||||
m_DeselectOnBackgroundClick: 1
|
||||
m_PointerBehavior: 0
|
||||
m_CursorLockBehavior: 0
|
||||
m_ScrollDeltaPerTick: 6
|
||||
--- !u!1001 &1080184620
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 105552333169325610, guid: 4a3db6090789ca24cb57c43666754017,
|
||||
|
|
@ -1275,7 +1356,101 @@ PrefabInstance:
|
|||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents:
|
||||
- {fileID: 7577392600424441103, guid: 4a3db6090789ca24cb57c43666754017, type: 3}
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 4a3db6090789ca24cb57c43666754017, type: 3}
|
||||
--- !u!1 &1087039185
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1087039188}
|
||||
- component: {fileID: 1087039187}
|
||||
- component: {fileID: 1087039186}
|
||||
m_Layer: 0
|
||||
m_Name: Panel
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
--- !u!114 &1087039186
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1087039185}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1281fe44325f9b548aa42dc331b17266, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::Prototype
|
||||
--- !u!114 &1087039187
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1087039185}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: c1b180b85c234a4488cf0662b75ac77f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::ShieldField.ShieldPanel
|
||||
tiling: 3
|
||||
panelRadius: 5
|
||||
cellSize: 0.35
|
||||
mergeRhombs: 1
|
||||
takeDual: 0
|
||||
seed: 1337
|
||||
sim: {fileID: 7200000, guid: 1d17c100121b5ba47af9c75de451a2f1, type: 3}
|
||||
panelShader: {fileID: 4800000, guid: 6a7f034931432c2418a0f0f0b9af0b93, type: 3}
|
||||
growDuration: 0.35
|
||||
wavefrontSpeed: 8
|
||||
delayJitter: 0.06
|
||||
waveSpeed2: 26
|
||||
damping: 1.6
|
||||
stressClamp: 4
|
||||
substeps: 6
|
||||
fixedSubstepDt: 0.0025
|
||||
echoDelaySteps: 5
|
||||
echoReflect: -0.65
|
||||
tensileStrength: 0.9
|
||||
temperInit: 0.55
|
||||
temperErosion: 2.2
|
||||
storedEnergyGain: 0.8
|
||||
damageGain: 6
|
||||
breakAt: 0.75
|
||||
crackStart: 0.18
|
||||
breakBudgetFraction: 0.02
|
||||
radialKick: 1.6
|
||||
lateralKick: 2.2
|
||||
normalKick: 1.1
|
||||
spinKick: 7
|
||||
shardLife: 2.5
|
||||
shardDrag: 0.7
|
||||
maxShards: 6
|
||||
conduitGain: 2.5
|
||||
--- !u!4 &1087039188
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1087039185}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1112013867
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -1300,6 +1475,7 @@ Transform:
|
|||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1112013867}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0.05948526, y: -0.910067, z: 0.14047916, w: 0.38536373}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
|
|
@ -1307,7 +1483,6 @@ Transform:
|
|||
m_Children:
|
||||
- {fileID: 1153356611}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 17.55, y: -134.1, z: 0}
|
||||
--- !u!114 &1112013869
|
||||
MonoBehaviour:
|
||||
|
|
@ -1353,7 +1528,6 @@ RectTransform:
|
|||
m_Children:
|
||||
- {fileID: 602735389}
|
||||
m_Father: {fileID: 815358592}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 1, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
|
|
@ -1387,13 +1561,13 @@ Transform:
|
|||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1153356610}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: -50}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1112013868}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1153356612
|
||||
MonoBehaviour:
|
||||
|
|
@ -1492,9 +1666,17 @@ Camera:
|
|||
m_projectionMatrixMode: 1
|
||||
m_GateFitMode: 2
|
||||
m_FOVAxisMode: 0
|
||||
m_Iso: 200
|
||||
m_ShutterSpeed: 0.005
|
||||
m_Aperture: 16
|
||||
m_FocusDistance: 10
|
||||
m_FocalLength: 50
|
||||
m_BladeCount: 5
|
||||
m_Curvature: {x: 2, y: 11}
|
||||
m_BarrelClipping: 0.25
|
||||
m_Anamorphism: 0
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_FocalLength: 50
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
|
|
@ -1564,9 +1746,17 @@ BoxCollider:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1424996955}
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_IsTrigger: 1
|
||||
m_ProvidesContacts: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
serializedVersion: 3
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!4 &1424996958
|
||||
|
|
@ -1576,13 +1766,13 @@ Transform:
|
|||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1424996955}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -1.4908371, y: -143.55145, z: 0.8193531}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1618381683
|
||||
GameObject:
|
||||
|
|
@ -1617,7 +1807,6 @@ RectTransform:
|
|||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 815358592}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
|
|
@ -1691,3 +1880,15 @@ CanvasRenderer:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1618381683}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1660057539 &9223372036854775807
|
||||
SceneRoots:
|
||||
m_ObjectHideFlags: 0
|
||||
m_Roots:
|
||||
- {fileID: 909026485}
|
||||
- {fileID: 1424996958}
|
||||
- {fileID: 1112013868}
|
||||
- {fileID: 815358592}
|
||||
- {fileID: 1012179279}
|
||||
- {fileID: 699508827}
|
||||
- {fileID: 1080184620}
|
||||
- {fileID: 1087039188}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
21
CLAUDE.md
Normal file
21
CLAUDE.md
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
# Aetheria agent doctrine
|
||||
|
||||
## Data tooling: AetherDb
|
||||
|
||||
`tools/AetherDb` is the agent's tool for reading and writing Aetheria's CultCache stores (`GameData/Aetheria.cc`,
|
||||
`run.cc`, `player.cc`). The simulation lives in `Aetheria.Shared` (the headless build of
|
||||
`Assets/Scripts/ServerShared`) and needs no Unity; Unity is only the shell for graphics and input.
|
||||
|
||||
- When a task needs a catalog or save capability AetherDb lacks (authoring or cloning designs, setting fields,
|
||||
fixtures for a play smoke, a query), add it to AetherDb as a command. Do not write a scratch console project,
|
||||
a loose `.cs` script, a Python or PowerShell reader of the `.cc` bytes, or a Unity editor script instead.
|
||||
Loose scripts were retired in `9f9149bd` because they ran against stale schemas.
|
||||
- A command dry-runs by default and writes only with `apply`, validates with `CultRecordRefs.Validate` and
|
||||
commits in one `CultCache.Commit` batch, like the existing migrations in `tools/AetherDb/Program.cs`.
|
||||
- Deep copies of records use CultCache's own options,
|
||||
`CultDocumentMessagePackSerialization.OptionsFor(typeof(ItemData).Assembly)`; MessagePack's standard options
|
||||
cannot serialise `CultMath` types or `CultRecordRef`.
|
||||
- The headless build refuses to compile unless CultLib is a clean checkout at the revisions pinned in
|
||||
`Directory.Build.props` (`Directory.Build.targets` enforces it). When `F:\Projects\CultLib` is elsewhere, point
|
||||
`CULTLIB_ROOT` and `CULTMATH_ROOT` at detached worktrees of those revisions; never move the shared checkout.
|
||||
- CultCache Studio is the operator's GUI over the same files. It is not an agent path.
|
||||
BIN
GameData/Aetheria.cc
(Stored with Git LFS)
BIN
GameData/Aetheria.cc
(Stored with Git LFS)
Binary file not shown.
File diff suppressed because one or more lines are too long
|
|
@ -1 +0,0 @@
|
|||
{"inkVersion":20,"root":[[{"#":"constraint: DistanceFrom start = 0"},{"#":"type: Station"},{"#":"security: Open"},{"#":"faction: Miss Terri"},{"#":"name: Test Location 1"},{"#":"nameZone: Start Zone"},{"->":"start"},["done",{"#f":5,"#n":"g-0"}],null],"done",{"start":[["^This is the start of the location story.","\n","ev","str","^Go to location A1","/str","/ev",{"*":".^.c-0","flg":4},["ev",{"^->":"start.0.8.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":".^.^.c-1","flg":18},{"s":["^This will end the story.",{"->":"$r","var":true},null]}],{"c-0":["^ ",{"->":"A1"},"\n",{"->":".^.^.g-0"},{"#f":5}],"c-1":["ev",{"^->":"start.0.c-1.$r2"},"/ev",{"temp=":"$r"},{"->":".^.^.8.s"},[{"#n":"$r2"}],"\n",{"->":".^.^.g-0"},{"#f":5}],"g-0":["^They lived happily ever after.","\n","end",{"#f":5}]}],{"#f":1}],"A1":[["^This content is in location A1","\n","ev","str","^Return to start","/str","/ev",{"*":".^.c-0","flg":4},["ev",{"^->":"A1.0.8.$r1"},{"temp=":"$r"},"str",{"->":".^.s"},[{"#n":"$r1"}],"/str","/ev",{"*":"A1.0.c-1","flg":2},{"s":["^Choice in location A1 ",{"->":"$r","var":true},null]}],{"c-0":["^ ",{"->":"start"},"\n",{"#f":5}],"c-1":["ev",{"^->":"A1.0.c-1.$r2"},"/ev",{"temp=":"$r"},{"->":"A1.0.8.s"},[{"#n":"$r2"}],"end","\n",{"#f":5}]}],{"#f":1}],"#f":1}],"listDefs":{}}
|
||||
|
|
@ -1 +0,0 @@
|
|||
{"inkVersion":20,"root":[[["done",{"#f":5,"#n":"g-0"}],null],"done",{"A1":[[{"#":"location: TestA"},{"#":"required"},"ev","str","^This choice is being injected from TestQuest","/str","/ev",{"*":".^.c-0","flg":4},{"c-0":["^ ",{"->":"A1A"},"\n",{"#f":5}]}],{"#f":1}],"A1A":[["^This is a branch thread being injected by TestQuest","\n","ev","str","^Exit the injected thread","/str","/ev",{"*":".^.c-0","flg":20},{"c-0":["^ ","end","\n",{"#f":5}]}],{"#f":1}],"#f":1}],"listDefs":{}}
|
||||
|
|
@ -738,7 +738,8 @@ is ready to write the moment the mint path is.
|
|||
|
||||
## 9. Blockers, mechanism gaps, and operator forks
|
||||
|
||||
**F1 — Only one spare ship prefab exists, and two hulls are specified.**
|
||||
**F1 — Resolved by the 2026-09-26 hull restore.** The following was the authoring baseline when this batch was
|
||||
mapped. Both Longinus and Djinni prefabs are now referenced by live hull records in `GameData/Aetheria.cc`.
|
||||
`ZoneRenderer.cs:295` instantiates `EngineAssets.Load<GameObject>(hullData.Prefab)` and calls
|
||||
`GetComponent<ShipInstance>()`. A hull with no prefab GUID renders nothing and null-refs. The
|
||||
project holds exactly two ship prefabs: `Assets/Content/Prefabs/Ships/Longinus.prefab` (used by
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
940
docs/locomotion-cut.md
Normal file
940
docs/locomotion-cut.md
Normal file
|
|
@ -0,0 +1,940 @@
|
|||
# Locomotion: Control Allocation and Capability-Aware AI
|
||||
|
||||
Date: 2026-09-22
|
||||
|
||||
Status: target and cut map, from an Imagination pass revised on 2026-09-22. Cut 1 (the Longinus and Djinni hulls,
|
||||
five thruster designs, and tutorial entrance station rule) landed on `codex/locomotion-cut1` and was merged into
|
||||
`codex/fire-control-12` at `e160bbe5` on 2026-09-26. Cuts 2 to 5 remain target work. The operator's Q1, Q2,
|
||||
Q3 and Q5 rulings below still govern that work. **The cuts were renumbered by the 2026-09-22 revision**: the
|
||||
content restore became Cut 1, and what the first committed version called Cuts 1 to 4 became Cuts 2 to 5.
|
||||
Historical anchors below are against `origin/codex/item-provenance` at `cd846916`; the then-current working tree
|
||||
on `codex/fire-control-10` (`e8fbb6a6`) had an identical tree for every file named below. The first half of this
|
||||
document is the **target** (the ends). The second half is the **cut map** (the means). When the campaign closes,
|
||||
split the target out as
|
||||
`docs/locomotion-target.md` and keep this file as history.
|
||||
|
||||
Claims marked **(probe)** come from running code: scratch builds of `Aetheria.Shared` from `cd846916` against
|
||||
CultLib `45c2f40`, run in the session scratchpad. That covers catalog dumps, a legacy-msgpack decode, base-commit
|
||||
flight measurements and a solver comparison. None of the probe sources are kept. Each result below says what was
|
||||
run. The base suite passes 244/244 in that scratch copy.
|
||||
|
||||
## Rulings
|
||||
|
||||
Operator, 2026-09-22:
|
||||
|
||||
- **Problem statement.** "We're gonna need much smarter locomotion AI if they're to survive getting a thruster
|
||||
shot out. Longinus (non X) had one big thruster in the back and two attitude thrusters in the front. Losing an
|
||||
attitude thruster means you can't rotate that way anymore. Losing a thruster on the Djinn usually means some form
|
||||
of crab walking just became optimal. Naively trying to use a thruster that's been shot out makes them real easy
|
||||
to cheese."
|
||||
- **R1, two layers.** (1) **Control allocation owns which thrusters fire.** Each live actuator contributes a
|
||||
body-frame wrench (Fx, Fy, τ) per unit throttle, with throttle in [0,1]. A bounded least-squares solve finds the
|
||||
throttles for the desired wrench (Johansen & Fossen 2013 control-allocation survey). This replaces the rotation
|
||||
buckets and the strafe torque compensation. Thrusters that are destroyed, unpowered, disabled or degraded drop
|
||||
out of the matrix or scale down in it. (2) **The AI plans with the allocator's achievable set.** For a desired
|
||||
Δv it scores candidate headings by achievable acceleration along Δv plus turn time in the directions the ship can
|
||||
still rotate. Crab walking and the long way round emerge from that scoring; neither is special-cased.
|
||||
- **R2, the same-inputs invariant.** "Player and AI are controlling the same ship with the same inputs, this is an
|
||||
Aetheria invariant." The player's controls go through the same allocator, through the same input surface the AI
|
||||
writes. Any second path that bypasses it is a forbidden writer.
|
||||
- **R3.** A capability-aware **combat facing/tactics** layer is wanted as its own later cut. Example: a one-way
|
||||
turner keeps its target drifting the way it can turn and leans on its turret arcs. This document maps it at
|
||||
target-shape level only.
|
||||
- **R4.** If CultMath lacks a bounded least-squares solver, CultMath gets one, as a CultLib cut. Aetheria does not
|
||||
grow a local helper. CultMath has none (probe: `packages/cultmath/src/CultMath` at `45c2f40` holds vector types,
|
||||
`math`, `BatchMath`, `Voronoi` and `Random`, with no linear solver of any kind).
|
||||
|
||||
Self, relaying an operator answer, 2026-09-22. This is the layer split, stated precisely:
|
||||
|
||||
- **Below the inputs**, shared by player and AI, is the ship's own controller plus the allocator. It turns toward
|
||||
`LookDirection` and realises `MovementDirection` with whatever actuators are live. **Choosing a feasible turn
|
||||
direction belongs here**, including the long way round when one rotation direction is dead. If it lived in the
|
||||
AI planner, a player ship with a dead attitude thruster would still stick when looking toward its dead side.
|
||||
Holding heading against torque coupling (strafing with an off-centre thruster) also belongs here.
|
||||
- **Above the inputs**, AI only, is the heading planner. It decides what to write into
|
||||
`LookDirection`/`MovementDirection`, for example to turn sideways and crab-walk. The player makes that choice by
|
||||
hand.
|
||||
- The long-way test therefore belongs to the shared-controller cut and drives `LookDirection` directly, as the
|
||||
player would. The crab-walk test belongs to the planner cut.
|
||||
|
||||
Operator rulings on this map, 2026-09-22, relayed by Self:
|
||||
|
||||
- **Q1 = A, the divergence is accepted.** "The divergence is fine." A small divergence from base behaviour on
|
||||
intact thruster ships is accepted: the Longinus's forward creep of about 10.7 m/s² while turning in place, and
|
||||
the Djinn's roughly 9% faster strafe. Base is pinned exactly only where the old mixer and the allocator agree,
|
||||
and the accepted divergences are named with their measured magnitudes in Cut 3's verification, so Soul can tell
|
||||
an accepted divergence from a regression. **No per-thruster role rules are reintroduced to match base.**
|
||||
- **Q2 = B, differential main thrust is allowed.** "That's absolutely viable and can be a better decision than
|
||||
turning around the long way, I wouldn't introduce a thruster exclusion for this." Any live actuator's torque may
|
||||
be spent on rotation, mains included. A damaged ship turning toward its dead side lurches forward, and the
|
||||
planner may prefer that to the long way round when it is faster.
|
||||
- **Q3, fixtures follow the data.** "Good catch on the Longinus main thrusters, I was misremembering." Two aft 2×2
|
||||
mains, as both legacy catalogs author them.
|
||||
- **Restore the legacy thruster hulls.** Asked whether the lost layouts could come back: "can we restore these
|
||||
layouts?" They become Cut 1, the campaign's first cut, ahead of the solver.
|
||||
|
||||
Second round, same day:
|
||||
|
||||
- **Cut 1 is approved as inventoried, optional gear included.** "Yes and yes": the Longinus and Djinni hulls,
|
||||
Medium Drive, and Small Drive, Victoire, Talaria and RevvITup 2.0 as well.
|
||||
- **The second hull behaviour is not `VelocityConversion`.** "I don't think VelocityConversion was on either
|
||||
hull." The decode agrees: it is `VelocityLimitData`. See Cut 1.
|
||||
- **Q5 is dissolved, not answered: the rotation demand is not sized at all.** "It should only do that if the
|
||||
ship's controller also *wants* to accelerate forwards that much, but I'm not sure how to encode that while
|
||||
allowing the lurch. Like, lurch burn to compensate for a missing attitude thruster is also only a good move when
|
||||
you both need to turn a bit and don't mind being all the way over there after. It doesn't help when, say,
|
||||
there's a guy to port and your aft thruster is out, because you'd just end up turning in a great big circle
|
||||
without changing your bearing at all." On the shape that replaced it: "Yeah, that's better."
|
||||
- **Cut 3** now runs one weighted least-squares solve over the whole desired wrench (Fx, Fy, yaw) at once,
|
||||
under throttle bounds. No separate rotation demand, no `TorqueFloor`-sized demand, no piecewise fall-back, and
|
||||
no branch anywhere on whether a ship can turn a given way. The weights are the design knob, and both error
|
||||
terms share a currency because each axis is normalized by what that ship can actually achieve on it.
|
||||
- **Cut 4** chooses manoeuvres by predicted outcome over a short horizon, simulating each candidate, never by a
|
||||
rule. The operator's case above is its test.
|
||||
|
||||
---
|
||||
|
||||
# Part I: Target
|
||||
|
||||
## Objective
|
||||
|
||||
A ship that loses actuators keeps flying as well as its remaining actuators allow, whether a player or an AI is
|
||||
flying it. The AI picks headings and thrust directions from what the ship can still do, so shooting out a thruster
|
||||
creates a real handicap and not an exploit.
|
||||
|
||||
## Invariants
|
||||
|
||||
1. **Same inputs.** A ship is commanded only through `Ship.MovementDirection` (body frame, each component a
|
||||
fraction of the ship's capacity along that half-axis) and `Entity.LookDirection` (world-frame heading command;
|
||||
the controller reads only its `xz`). The player writes both (`Gameplay/ActionGameManager.cs:1254`, `:1263`). The
|
||||
AI writes the same two fields. Nothing else commands a ship's actuators. Identical inputs to identical ships give
|
||||
identical actuator throttles, whoever wrote them.
|
||||
2. **One owner for actuator commands.** The ship controller (new, `ShipControl`, below) is the only writer of
|
||||
`Thruster` and `AetherDrive` throttles. `Ship.cs`'s mixer, its rotation buckets and its strafe compensation stop
|
||||
existing, and do not survive as a mode or a fallback.
|
||||
3. **The allocator reads live actuator state every tick.** An actuator's column is derived each tick from its live
|
||||
stats and liveness: `EquippedItem.Active` (enabled, thermally online, durability online), a power grant above the
|
||||
same epsilon `Thruster.Execute` uses, and the current resolved `Thrust` (or the drive's own stats) with its
|
||||
durability, heat and power curves applied. No bucket, cache or event-pruned set decides whether an actuator
|
||||
counts. A repaired or re-powered actuator rejoins by the same read that dropped it.
|
||||
4. **Manual and programmatic inputs share one commit path.** A player keypress, an AI state write, and any future
|
||||
scripted or network input all land in the same two fields, and they reach the actuators by the same
|
||||
`ShipControl` step inside `Ship.Update`. No input source writes `Thruster.Axis`, `AetherDrive.Axis` or
|
||||
`Entity.Direction` directly.
|
||||
5. **Heading changes only through actuators.** `Entity.Direction` is written by actuator execution
|
||||
(`Thruster.Execute`, `AetherDrive.Execute`), by wormhole scripting (`Ship.ExitWormhole`), by spawn placement
|
||||
(`ActionGameManager.cs:848`) and by save unpack (`EntitySerializer.cs:66`). The controller does not write it.
|
||||
Today's snap-to-look lerp (`Ship.cs:280-284`) is a free, thrusterless rotation, and it goes.
|
||||
6. **Kinematic rotation is retained.** Rotation stays kinematic: yaw rate is proportional to live throttle
|
||||
(`Thruster.cs:106-107`, `AetherDrive.cs:154-155`), with no angular momentum. Nothing found here argues for
|
||||
raising it. It keeps turn time exact (angle divided by rate), which is what lets the planner compare a long
|
||||
way round against a slow lurching turn without simulating either.
|
||||
7. **A dead actuator never receives throttle.** A destroyed, disabled or unpowered actuator gets zero throttle,
|
||||
not a saturated request it cannot honour.
|
||||
8. **Capability is one model.** What a ship can do is computed in one place (`ShipControl`), from the same live
|
||||
column matrix the allocator solves with: the achievable extremes, the turn-direction comparison, and the solve
|
||||
itself. The AI reads those and predicts with the controller's own step; it never keeps a private estimate of
|
||||
what the ship can do, and never branches on which actuators are missing.
|
||||
|
||||
## Canonical implementations
|
||||
|
||||
- **Solver:** CultMath (`F:\Projects\CultLib\packages\cultmath`), a box-constrained linear least-squares solver,
|
||||
added by Cut 2. It is the only numerical authority. Aetheria composes the problem and calls it.
|
||||
- **Allocation reference:** T. A. Johansen and T. I. Fossen, "Control allocation: A survey," *Automatica* 49(5),
|
||||
2013. Its weighted-least-squares form with priorities is what `ShipControl` states. The active-set method follows
|
||||
O. Härkegård, "Efficient active set algorithms for solving constrained least squares problems in aircraft control
|
||||
allocation," CDC 2002, which is bounded-variable least squares in Stark and Parker's sense.
|
||||
|
||||
## Out of scope
|
||||
|
||||
- **Fire-control Cut 12** (edge-on hit placement in `FireControl.cs`, `Entity.ApplyHit`, `DamageSchematic`) is
|
||||
being mapped concurrently by another Imagination pass. Cuts 2 to 4 here touch none of those files. The allocator
|
||||
is a read-only downstream consumer of item destruction (`ItemDamage`, `Entity.cs:488`). **Overlap:** Cut 5 (combat
|
||||
facing) will rewrite `Agents/States/Combat.cs:88-127`, and presenting armour edge-on is exactly what Cut 12's hit
|
||||
placement rewards. Cut 5 must be mapped after Cut 12 lands. Cut 1 restores catalog content, and the only file it
|
||||
and Cut 12 could both touch is `GameData/Aetheria.cc`; Cut 1 must not be in flight while another cut writes the
|
||||
catalog.
|
||||
- **The old AetheriaEve/CultMesh/daemon rebuild** is taxidermy. It is not precedent and not a consumer.
|
||||
- Thruster geometry (the normalized moment-arm `Thruster.Torque`, `Thruster.cs:64-69`, which ignores lever length
|
||||
and uses unweighted shape cells for centre of mass) is the game's model and stays as authored. Arrival braking in
|
||||
`MoveToState`, docking approach and formation flight are also out.
|
||||
|
||||
## Not consumers
|
||||
|
||||
- `Assets/Scripts/Gameplay/*` presentation (`ShipInstance` particles, audio parameters) reads throttles and never
|
||||
writes them.
|
||||
- `TurretController` writes `Entity.LookDirection` for turret entities. That is the AI above the inputs for a
|
||||
non-ship, and it does not drive ship actuators. See the audit.
|
||||
|
||||
## 0b: identity, lifecycle, authority
|
||||
|
||||
Nothing persistent changes. Actuator wrench columns, capacities, the chosen turn direction and planner state are
|
||||
runtime-derived per tick, or per planner cadence, and are never saved.
|
||||
|
||||
| Kind | Named by | Lifecycle | Decides |
|
||||
|---|---|---|---|
|
||||
| Actuator column (runtime) | the `Thruster`/`AetherDrive` behaviour instance on an `EquippedItem` | rebuilt every tick from live stats; appears and disappears with liveness | `ShipControl` derives; item state (durability, heat, power, `Enabled`) is owned by `EquippedItem`/`PowerBus` as today |
|
||||
| `MovementDirection`, `LookDirection` (runtime) | fields on `Ship`/`Entity` | overwritten each frame by whoever flies the ship | player (`ActionGameManager`) or AI (`Agent` layer), never both on one ship (`Zone.cs:111` gives agents only to `!IsPlayerShip`) |
|
||||
| Committed turn direction, planner plan (runtime) | fields on `ShipControl` / `Agent` | reset on wormhole, dock, spawn | `ShipControl` / `Agent` |
|
||||
| `ThrusterData`, `AetherDriveData`, `HullData.Hardpoints/Shape` (persisted, catalog) | catalog record key | authored | unchanged; read only |
|
||||
| `GameplaySettings.TorqueMultiplier`, `AetherTorqueMultiplier` (authored, `Settings.cs:206-207`; values in `Assets/Resources/Settings.asset`: 0.1, 0.1) | field name | authored | unchanged. `TorqueFloor` (`:205`, authored 0.5) loses its last consumer in Cut 3 and is deleted with its authored value |
|
||||
|
||||
This campaign adds no authored **field**. Cut 1 adds authored **records** (hulls, thruster designs and their
|
||||
products) to `GameData/Aetheria.cc` using the schema as it stands. If Hands finds it needs a tunable, that is an
|
||||
operator question, and any new field on a persisted CultCache document must be nullable (MessagePack nil rule).
|
||||
|
||||
---
|
||||
|
||||
# Part II: Body map (what the probes established)
|
||||
|
||||
## The mixer today
|
||||
|
||||
`Ship.Update` (`Ship.cs:251-292`) runs before `base.Update` executes behaviours. The agents' writes come earlier
|
||||
still, because `Zone.cs:170-173` updates agents before entities. The steps:
|
||||
|
||||
1. `RecalculateThrust` (`Ship.cs:147-247`) sums per-bucket thrust over thrusters whose item is `Active`.
|
||||
2. It zeroes every thruster's `Axis` (`:256`).
|
||||
3. Strafe: the right and left buckets get `±MovementDirection.x`, minus a torque compensation for the thrusters
|
||||
whose torque sign matches the bucket total (`:257-274`).
|
||||
4. Forward and reverse buckets add `±MovementDirection.y` (`:275-276`).
|
||||
5. Rotation: `deltaRot = sqrt(|dot(look, right)|)·sign` (`:278-285`) is added to the clockwise bucket and subtracted
|
||||
from the counter-clockwise bucket (`:287-288`).
|
||||
6. `AetherDrive.Axis = (MovementDirection.y, MovementDirection.x, deltaRot)` (`:291`). There is no allocation for
|
||||
drives at all.
|
||||
|
||||
Buckets are built once in `Activate` from mount rotation and from `Thruster.Torque` against
|
||||
`TorqueFloor` (`:102-118`). `RemoveThruster` prunes them permanently on `ItemDestroyed` (`:123`, `:133-143`).
|
||||
|
||||
`Thruster.Axis` saturates to [0,1] (`Thruster.cs:45-49`). `Execute` (`:94-115`) applies `Velocity -= facing·input·
|
||||
Thrust/Mass·dt`, then rotates `Direction` kinematically by `input·Torque·Thrust·TorqueMultiplier/Mass·dt`. Its gate
|
||||
is `input > .01 && PowerSupply > 1e-4`.
|
||||
|
||||
## Findings (probe)
|
||||
|
||||
Fixtures here are built from the legacy catalog (next section): hull shape, hardpoints, thruster items with
|
||||
constant `Thrust` (Large Drive 250000, Medium Drive 200000; mass 100 each), `TorqueFloor` 0.5, `TorqueMultiplier`
|
||||
0.1. Each ship sits at (37, −12) facing `normalize(0.8, 0.6)`, runs 3 warm-up ticks, is reset, and is measured over
|
||||
one tick at dt 0.02. Body-frame acceleration is (r, f) in m/s². Heading rate is compass degrees per second,
|
||||
clockwise positive.
|
||||
|
||||
**Torque factors** (`Thruster.Torque`, the sine of the moment arm): Longinus mains ±0.159 (below the floor, so
|
||||
never used for rotation), attitude thrusters ±0.998. Djinni stern 0 / ±0.161, laterals ±0.727 (aft) and ±0.867
|
||||
(fore), bow 0.
|
||||
|
||||
**Base flight table** (`cd846916`, after warm-up). These are the Cut 3 pins:
|
||||
|
||||
| Input | Longinus (r, f, °/s) | Djinni (r, f, °/s) |
|
||||
|---|---|---|
|
||||
| forward `(0,1)` | 2.37, 172.38, 0 | 0.11, 55.56, 0 |
|
||||
| reverse `(0,−1)` | 0, 0, 0 | 0, −18.52, 0 |
|
||||
| strafe right `(1,0)` | 0, 0, 0 (compensation zeroes the lone attitude thruster) | 34.03, 0.42, 0 (axes 1.00 / 0.84) |
|
||||
| strafe left `(−1,0)` | 0, 0, 0 | −34.03, 0.42, 0 |
|
||||
| look 90° right | 68.97, 0, +394.33 | 0.01, 0.59, +169.13 |
|
||||
| look 90° left | −68.97, 0, −394.33 | 0.01, −0.50, −169.13 |
|
||||
| look 30° right | 48.77, 0, +278.84 | 0, 0.30, +119.59 |
|
||||
| look directly behind | 0, 0, 0, **and `|Direction|` falls to 0.96** | same |
|
||||
| forward+strafe `(.707,.707)` | 1.18, 121.89, 0 | 24.12, 39.49, 0 |
|
||||
|
||||
The small cross terms (2.37, 0.42) are real. `Execute` rotates `Direction` thruster by thruster within one tick, so
|
||||
later thrusters push along an already-rotated nose. The allocator cannot see this, so pins need a tolerance for it.
|
||||
|
||||
**Defects the table exposes:**
|
||||
|
||||
- **Dead-side stick.** On a Longinus with `Th.CCW` destroyed, looking 90° left gives a heading error of 90.0°
|
||||
after 30 s. It never turns. Looking right, it reaches within 2° in 0.32 s, the same as intact.
|
||||
- **Main-thruster cheese.** On a Djinni with all three stern thrusters destroyed, `Agent` plus `MoveToState` toward
|
||||
a point 300 m to port leaves the ship at speed 0 after 120 s. `Agent.Accelerate` points at Δv and burns forward
|
||||
thrusters only (`Agent.cs:64-68`), and it never reaches the strafe branch. Intact, the same run arrives in
|
||||
4.34 s. With only Stern 2 lost it arrives in 4.98 s; with only Port Aft lost, 4.40 s.
|
||||
- **Snap-to-look.** Inside `|sin error| < .01`, `Ship.cs:283` lerps `Direction` toward the look vector, which is a
|
||||
rotation no thruster pays for. When the look is directly behind, the lerp goes through the origin and shrinks
|
||||
`|Direction|`, and thruster force scales with that length (`Thruster.cs:105` uses the unnormalized item
|
||||
direction). Base also turns *slower* as error passes 90°: `deltaRot` follows `sin`, so it is zero at 180°.
|
||||
- **First tick.** Items are not yet `Active` on the first `Update` after `Activate`, so the first-tick strafe
|
||||
compensation divides by a zero count (NaN, unused) and the strafe fires uncompensated.
|
||||
- **`TurnTime` is wrong and unused.** `Ship.cs:61-66` divides angle by the sum of torque *factors* over mass, which
|
||||
is unitless nonsense: 261535 s for a Longinus 90° turn. It has no consumer.
|
||||
- **Permanent pruning.** `RemoveThruster` never restores a thruster whose durability comes back, and `Recalculate*`
|
||||
reads `Active` while the mixer still commands inactive thrusters.
|
||||
- **The live catalog's only ship flies on a drive.** `GameData/Aetheria.cc` holds one ship hull, **LonginusX**
|
||||
(mass 2500, drag 0.1, 6×17), with an `AetherDrive` hardpoint and **no `Thruster` hardpoint**. It moves on
|
||||
"Traction" (rotor mass (30,20,5), λ (0.5,1,1), MaxRpm 40000..80000). Two thruster designs exist ("deep space
|
||||
burnout", "Large Drive"), but no live ship can mount them (`docs/content-batch-one.md` §1 says the same).
|
||||
**AetherDrive is therefore the load-bearing actuator for the player today**, and the allocator must reproduce its
|
||||
base behaviour exactly. Cut 1 restores the thruster hulls, which is what makes any play check on a thruster ship
|
||||
possible at all.
|
||||
- **Existing tests sit on an off-centre thruster.** `BrownoutTests`/`ConditionRatioTests` equip a one-cell thruster
|
||||
by `TryFindSpace` onto a 5×5 hull. It lands at (1,1) with `Torque` −0.707, and `MovementDirection (0,−1)` fires it
|
||||
while it spins the ship. Under an allocator that holds heading, a lone off-centre thruster cannot fire without
|
||||
rotating, so those fixtures must be re-seated (Cut 3).
|
||||
|
||||
## Legacy hull layouts (probe)
|
||||
|
||||
The live catalog is the post-breach minimal rebuild, so absence there proves nothing. The layouts come from the
|
||||
git-LFS objects of `GameData/Legacy/AetherDB.2021-03-05.msgpack` (`142998fd…`) and `AetherDB.2021-04-14.msgpack`
|
||||
(`21ce7bd2…`), both present in `.git/lfs/objects`, decoded with MessagePack `ConvertToJson`. Shape cells are
|
||||
`bool[w,h]`, flattened as `x*h + y`, with y = 0 at the stern.
|
||||
|
||||
**Longinus** (2021-04-14: mass 2500, drag 0.1, 6×17; the 2021-03-05 copy has mass 5000). The shape matches the
|
||||
live LonginusX's. Rows from y = 0: `.####.` ×4, `######` ×5, `.####.` ×2, `..##..` ×6.
|
||||
|
||||
| Hardpoint | Pos | Shape | Rotation |
|
||||
|---|---|---|---|
|
||||
| Th.L | (1,0) | 2×2 | Reversed (pushes forward) |
|
||||
| Th.R | (3,0) | 2×2 | Reversed |
|
||||
| Th.CW | (2,14) | 1×2 | CounterClockwise (pushes starboard, nose right) |
|
||||
| Th.CCW | (3,14) | 1×2 | Clockwise (pushes port, nose left) |
|
||||
|
||||
**The data has two aft 2×2 thrusters, not one.** The operator remembered "one big thruster" and ruled on it,
|
||||
2026-09-22: "Good catch on the Longinus main thrusters, I was misremembering." Fixtures follow the data.
|
||||
|
||||
**Djinni** (mass 10000, drag 0.2, 14×17). Rows from y = 0: `....######....`, `...########...`,
|
||||
`..##########..`, `.############.` ×2, `##############` ×5, `.############.`, `...########...` ×3,
|
||||
`....######....`, `.....####.....`, `......##......`.
|
||||
|
||||
| Hardpoint | Pos | Shape | Rotation |
|
||||
|---|---|---|---|
|
||||
| Stern 1 | (6,0) | 2×1 | Reversed |
|
||||
| Stern 2 | (5,1) | 2×1 | Reversed |
|
||||
| Stern 3 | (7,1) | 2×1 | Reversed |
|
||||
| Port Aft | (4,4) | 1×2 | CounterClockwise |
|
||||
| Port Fore | (4,11) | 1×2 | CounterClockwise |
|
||||
| Starboard Aft | (9,4) | 1×2 | Clockwise |
|
||||
| Starboard Fore | (9,11) | 1×2 | Clockwise |
|
||||
| Bow | (6,14) | 2×1 | None (pushes aft) |
|
||||
|
||||
Legacy thruster items used for the fixtures: Large Drive 2×2, 250000 thrust, mass 100. Medium Drive 2×1, thrust
|
||||
100000..300000 (fixtures use a constant 200000), mass 100. Small Drive 1×1, 75000.
|
||||
|
||||
## Solver choice (probe)
|
||||
|
||||
The comparison ran on the fixtures' own normalized columns, plus a 16-column doubled Djinni: 2000 random wrench
|
||||
demands each, cost measured against a 20000-iteration projected-gradient reference, double precision,
|
||||
allocation-heavy scratch C#, Release build.
|
||||
|
||||
| Method | Worst excess cost | Suboptimal cases | Mean time |
|
||||
|---|---|---|---|
|
||||
| Primal active set (bounded-variable LS, Härkegård WLS form) | ≤ 7e-15 | 0 in every case | 1.8–9.5 µs (n 3–8), 32–38 µs (n 15–16); ≤ 30 iterations cold |
|
||||
| Redistributed pseudo-inverse | up to 4e3 | 270–1564 of 2000 (n ≤ 8) | about half the active set's time |
|
||||
|
||||
**Pick the active set.** It is exact, its cold-start cost is bounded, and it warm-starts from last tick's solution.
|
||||
The redistributed pseudo-inverse saves about half the time and is wrong in up to 78% of cases on these very
|
||||
matrices. A production float implementation without allocations will be faster than the scratch numbers.
|
||||
|
||||
## Consumer audit
|
||||
|
||||
`cd846916`, every `*.cs` outside `Assets/Plugins`. "Dies" means deleted, not deprecated.
|
||||
|
||||
| Surface | Readers / writers | Fate |
|
||||
|---|---|---|
|
||||
| `Ship.MovementDirection` (`Ship.cs:27`) | W: `ActionGameManager.cs:1263` (player), `Agent.cs:67,73,77` (AI); tests `BrownoutTests.cs:143,402`, `ConditionRatioTests.cs:184,193,243,258`. R: `Ship.cs:261-291` | **Survives** as the translation input. Its meaning is defined by `ShipControl` (fraction of capacity per half-axis) |
|
||||
| `Entity.LookDirection` (`Entity.cs:55`) | W: `ActionGameManager.cs:1254` (player), `Agent.cs:66`, `MoveTo.cs:26`, `Combat.cs:126`, `TurretController.cs:72,75` (turret entities; no `EntityTypeRestriction`, `TurretController.cs:14-15`). R (as heading): `Ship.cs:278`. R (as aim): `LockWeapon.cs:94`, `GuidedProjectileManager.cs:56`, `EntityInstance.cs:404`, `ShipInstance.cs:117` (tractor), `ZoneRenderer.cs:432`, `ActionGameManager.cs:376` (reticle target pick) | **Survives** as heading command *and* aim. `MoveTo.cs:26` dies in Cut 4 (a double writer: `Accelerate` overwrites it when Δv > 20). The heading/aim conflation is Cut 5's question (Q4) |
|
||||
| `Thruster.Axis` (`Thruster.cs:45-49`) | W: `Ship.cs:256-288` only. R: `ShipInstance.cs:139` (particles), `Thruster.cs:88` (power request), `:96` (audio), `:102-111` | Getter **survives**. The public setter **dies**; only `ShipControl` commands throttle |
|
||||
| `AetherDrive.Axis` (`AetherDrive.cs:81-85`) | W: `Ship.cs:291` only. R: drive internals, audio `:170` | Same as `Thruster.Axis` |
|
||||
| `IAnalogBehavior` (`Behaviors.cs:96-99`) | implemented by `Thruster.cs:40`; consumer only a comment, `Entity.cs:2007` | **Dies** (Cut 3 deletes first) |
|
||||
| Bucket sets `_forward/_reverse/_right/_left/_clockwise/_counterClockwiseThrusters`, `_thrusterItems`, `_aetherDrives`, `_aetherDriveItems` (`Ship.cs:30-39`) | `Ship.cs` only | **Die** |
|
||||
| `ForwardThrust`, `ReverseThrust`, `LeftStrafeThrust`, `RightStrafeThrust`, `ClockwiseTorque`, `CounterClockwiseTorque`, `Left/RightStrafeTotalTorque`, `Left/RightStrafeTorqueThrusters` (`Ship.cs:50-59`) | written by `RecalculateThrust`, read by the mixer; **no reader outside `Ship.cs`** (grep, including Unity side and tests) | **Die** |
|
||||
| `Ship.TurnTime` (`Ship.cs:61-66`) | no consumer | **Dies**; replaced by `ShipControl.TurnTime` (Cut 3), consumed in Cut 4 |
|
||||
| `RemoveThruster`, `RemoveAetherDrive`, their `ItemDestroyed` subscriptions (`Ship.cs:123-143`) | internal | **Die**; liveness is read live (invariant 3) |
|
||||
| `Agent.Accelerate` (`Agent.cs:58-79`), `FORWARD_DELTA_THRESHOLD`/`THRUST_DELTA_THRESHOLD` (`:16-17`) | called by `MoveTo.cs:27`, `Combat.cs:127` | **Rewritten** in Cut 4 (planner). Signature kept |
|
||||
| `Agent.TopSpeed` (`Agent.cs:26`) | `MoveTo.cs:25`, `Combat.cs:127`. No live catalog item carries `VelocityLimit` or `VelocityConversion` (probe), so it is 100 everywhere | Survives |
|
||||
| `GameplaySettings.TorqueFloor` (`Settings.cs:205`) | `Ship.cs:115,118` only | **Dies** in Cut 3. The full-wrench solve has no threshold to apply it to, and nothing else reads it |
|
||||
| `TorqueMultiplier`, `AetherTorqueMultiplier` | `Thruster.cs:107`, `AetherDrive.cs:155` | Survive; also enter the yaw-rate row of each column |
|
||||
| `Entity.Direction` writers | `Thruster.cs:106`, `AetherDrive.cs:154`, `Ship.cs:79` (wormhole), `Ship.cs:283` (snap), `ActionGameManager.cs:848` (spawn), `EntitySerializer.cs:66` | `Ship.cs:283` **dies** (invariant 5); the others survive |
|
||||
| `Entity.Velocity` external writers | `HullCollider.cs:15` (collision impulse), `ShieldManager.cs:79` (bounce), `VelocityConversion.cs:41`, `VelocityLimit.cs:48` | Not control; these are external forces and constraints. Untouched |
|
||||
| Undock capability check (`ActionGameManager.cs:913`) | `GetBehavior<Thruster/AetherDrive>() == null` | Survives. It could later read the capability model; not this campaign |
|
||||
| Mining, Survey, HaulingTask, StationTowing (`Agents/Tasks/*.cs`) | data-only task classes; no movement code (grep) | Not consumers. `PatrolOrbitsState` drives `MoveToOrbitState`, which Cut 4 covers |
|
||||
| Player input path | `Input.Player.Look` → `_entityYawPitch` → `LookDirection` (`:1250-1254`); `Input.Player.Move` → `MovementDirection` (`:1261-1264`). No other action writes motion (grep of `Input.Player.*`: targeting, heat, shield, stance, tractor, ping, UI) | **Already on the shared surface**. The only bypasses are the ones `Ship.cs` itself holds (the snap, direct `Axis` writes), and both die in Cut 3 |
|
||||
|
||||
Out-of-scope note: the working tree has an uncommitted change to `Assets/Scripts/AetheriaInput.cs` (a "Cycle Target
|
||||
Item" action). That is fire-control work, and it does not touch motion.
|
||||
|
||||
---
|
||||
|
||||
# Part III: Cut map
|
||||
|
||||
## Status header
|
||||
|
||||
Status: cut map. Ends are owned by Part I above; this section owns the means.
|
||||
|
||||
Cut 1 landed and is merged into `codex/fire-control-12` at `e160bbe5`. Cuts 2 to 5 have not landed.
|
||||
|
||||
Rulings (operator, 2026-09-22): **Q1 A** ("The divergence is fine"), **Q2 B** ("that's absolutely viable and can
|
||||
be a better decision than turning around the long way, I wouldn't introduce a thruster exclusion for this"), **Q3**
|
||||
fixtures follow the data ("Good catch on the Longinus main thrusters, I was misremembering"), and Cut 1 exists
|
||||
because of "can we restore these layouts?". The Q2 text below is marked as history; the live design is in Cut 3.
|
||||
|
||||
Second-round rulings (operator, 2026-09-22): Cut 1 approved as inventoried, optional gear included ("Yes and
|
||||
yes"); the second hull behaviour is not `VelocityConversion` ("I don't think VelocityConversion was on either
|
||||
hull") and the decode names it `VelocityLimitData`; **Q5 is dissolved** by the full-wrench solve ("Yeah, that's
|
||||
better"), so the Q5 text below and every "sized demand" design it belonged to are history.
|
||||
|
||||
Open: **Q4** (heading versus aim) blocks only Cut 5. **Q6** (the one weight in Cut 3's solve) does not block
|
||||
Hands, who starts at the recommended default; the operator settles it by feel in the Cut 1 play check.
|
||||
|
||||
**Tutorial station (operator, 2026-09-25):** "What we're testing is going to be the tutorial level, right? Let's drop a station in there." The live catalog already has a station hull: Zenith, sold by Aeronautics Unlimited. The story-station path is dead because `StoryProcessor` has been commented out at `Galaxy.cs:242` since `ce1a0a46` (2021). Ruled: **faction station now**. The tutorial's entrance zone (`Galaxy.Entrance`) always gets a generated faction station with a docking bay. That is deterministic, not merely likely, and the test pins it on the real tutorial construction path. Reviving the Ink story stations belongs to a later narrative campaign, which must first find out why they were switched off.
|
||||
|
||||
Legacy hazard, recorded 2026-09-26 (Soul, Cut 1 fix batch 2): `VelocityLimit` is a hull behaviour gated by the hull's `Active` (`Entity.cs:1624`, `:1636`, `VelocityLimit.cs:45-49`). Thrusters are items with their own gating. Any path that takes the hull offline while the thrusters keep firing removes the cap. Under frozen fixture physics, with the player's override on the thrusters, speed reached 1237. On the shipped settings the hull did not go offline in 300 s. The behaviour dates from 2020-04 and 2021-03. Cut 3 and Cut 4 measure arrival times under this cap, so they must not assume it always holds.
|
||||
|
||||
Follow-ups outside this campaign:
|
||||
- `TurretController` has no `EntityTypeRestriction`, so equipping it on a ship would create a third
|
||||
`LookDirection` writer racing the player or agent. Restrict it to non-ship hulls when turret work next opens
|
||||
(`TurretController.cs:14`).
|
||||
- `Thruster.Execute` applies rotation per thruster inside the tick, which couples later thrusters' force to earlier
|
||||
thrusters' rotation. It is a small artefact, and it is `Thruster.cs`'s to fix, not the allocator's.
|
||||
- `AetherDrive.Execute` logs "FUCK FUCK FUCK FUCK" on NaN velocity (`AetherDrive.cs:157-158`), a leftover probe.
|
||||
|
||||
## Cut 1. Restore the legacy thruster ship hulls to the live catalog
|
||||
|
||||
A pure content cut, separable from every code cut, so Soul can falsify it on its own. Operator, 2026-09-22: "can
|
||||
we restore these layouts?", and on the inventory below, optional gear included: "Yes and yes". **The list is
|
||||
approved**; what is left for review is anything Hands finds that this map did not name.
|
||||
|
||||
- **Repo/branch:** Aetheria, implemented on `codex/locomotion-cut1` and merged into `codex/fire-control-12` at
|
||||
`e160bbe5`. The restored hulls are now the real fixtures for Cuts 3 and 4. The catalog mutation is complete.
|
||||
- **Standing rule** (memory: `aetheria-content-audits-pre-breach`): `GameData/Aetheria.cc` is the post-breach
|
||||
bare-minimum rebuild, so absence there is not evidence of absence, and **the operator's word is the authority**
|
||||
on what the pre-breach content was. The list below is therefore an **operator review item before Hands writes
|
||||
anything into the catalog**.
|
||||
|
||||
### What the legacy record actually holds (probe)
|
||||
|
||||
Sources, all decoded in the scratchpad: the git-LFS objects behind `GameData/Legacy/AetherDB.2021-04-14.msgpack`
|
||||
(`21ce7bd2…`, 76 KB) and `AetherDB.2021-03-05.msgpack` (`142998fd…`, 59 KB), and the last
|
||||
`GameData/AetherDB.msgpack` before the Cut 9 import (`8963a686…`, 46 KB, the commit's own parent at `70fbaca1^`).
|
||||
All three are present in `.git/lfs/objects`; nothing had to be fetched.
|
||||
|
||||
The comparison explains the loss. The 2021-04-14 record carries 5 ship-class hulls and 45 gear designs. The import
|
||||
source carries 3 hulls (LonginusX, Zenith, Turret) and 25 gear. **Longinus, Djinni and every thruster below the
|
||||
2×2 class were already gone from the file Cut 9 imported**, which is why the live catalog has no thruster ship.
|
||||
|
||||
**Recoverable in full from 2021-04-14** (name, shape, mass, price, hardpoint list with position, shape, rotation
|
||||
and armour, behaviours, temperature band, manufacturer, prefab and schematic paths):
|
||||
|
||||
| Record | Kind | Legacy detail | Notes |
|
||||
|---|---|---|---|
|
||||
| **Longinus** | ship hull | 6×17, mass 2500, drag 0.1, price 7,500,000, maker Alakrita | The shape is byte-identical to the live LonginusX's. 4 thruster hardpoints (`Th.L`/`Th.R` 2×2 aft, `Th.CW`/`Th.CCW` 1×2 in the nose) plus control module, 2 energy, 2 launcher, 2 radiator, reactor, sensors |
|
||||
| **Djinni** | ship hull | 14×17, mass 10000, drag 0.2, price 10,000,000, maker Rossum & Douglas | 8 thruster hardpoints (3 stern, 4 lateral, 1 bow) plus 4 launcher, 2 ballistic, reactor, control module, 4 radiator, sensors, and a shield hardpoint |
|
||||
| **Medium Drive** | thruster gear | 2×1, mass 100, thrust 100000..300000, price 50,000, no maker | **The one item both restored hulls need.** Fits the 2×1 stern/bow hardpoints and, rotated, the 1×2 lateral and nose ones |
|
||||
| **Small Drive** | thruster gear | 1×1, mass 50, thrust 75000, price 25,000, no maker | Optional; the cheap end of the line |
|
||||
| **Victoire** | thruster gear | 2×1, mass 25, thrust 200000..1500000, maker Alakrita | Optional; the racing thruster, and a natural Longinus fit |
|
||||
| **Talaria** | thruster gear | 2×1, mass 150, thrust 75000..250000, maker Aeronautics Unlimited | Optional |
|
||||
| **RevvITup 2.0** | thruster gear | 2×2, mass 150, thrust 250000..1000000, maker NiteLife Energy | Optional; a second 2×2 beside the two the catalog already ships |
|
||||
|
||||
Everything those records depend on is **already in the live catalog**: all 12 factions (Alakrita and Rossum &
|
||||
Douglas included), both existing 2×2 thrusters, and the Unity presentation. The prefabs still carry the hardpoint
|
||||
transforms by their legacy names — `Th.L`, `Th.R`, `Th.CW`, `Th.CCW` in `Assets/Content/Prefabs/Ships/
|
||||
Longinus.prefab` (GUID `4a3db609…`, already the hull the live LonginusX points at) and `Thruster Stern 1..3`,
|
||||
`Thruster Port/Starboard Fore/Aft` and `Thruster Bow` in `Djinni.prefab` (GUID `79024f63…`). The schematics exist
|
||||
too (`schema_Longinus.png` `51702555…`, already referenced; `djinni_schematic_transparent.png` `66f3acdd…`, unused
|
||||
today). So no art, no prefab work and no faction work is needed.
|
||||
|
||||
**Not recoverable, because it post-dates the breach and has to be authored:**
|
||||
|
||||
- `HardpointData.FiringArc` (Key 6) for the Djinni's weapon hardpoints. The legacy hardpoint record stops at
|
||||
armour. 0 means "use `GameplaySettings.FiringArc`"; the `firing-arc-migrate` command in `tools/AetherDb` is the
|
||||
precedent for deriving one from mount rotation.
|
||||
- `ItemRole` lists on the restored designs, and `ProductRole` qualities on their products.
|
||||
`RoleAuthoringTests` refuses a stat naming a role its design lacks, and `docs/content-batch-one.md` fixes the
|
||||
nomenclature (`injector`/`nozzle` for thrusters, `plating` for hulls). The live "deep space burnout" carries
|
||||
`injector, nozzle`; "Large Drive" carries none.
|
||||
- A `FactionProductData` per restored design. `LoadoutGenerator` picks products, not designs, so a design without
|
||||
one exists but is never generated or sold. The catalog holds 47 products today.
|
||||
- Any `PowerSupply` term on the restored thrusters' stats (the stats-and-power cut's brownout curve). The shipped
|
||||
thrusters request zero energy, so matching them is the safe default and is a content decision.
|
||||
- Provenance is runtime, not authored: `ItemManager` mints the `Lot` (`docs/item-provenance-target.md`).
|
||||
|
||||
**The second hull behaviour, identified** (probe; the operator was right that it is not `VelocityConversion`).
|
||||
Both legacy hulls carry a behaviour LonginusX does not, union tag 11 in the legacy record. The union table is in
|
||||
`Assets/Scripts/ServerShared/Behaviors/Behaviors.cs` at the legacy-project commit `7006a6b0` and unchanged at
|
||||
`b4c06b50`: **tag 11 is `VelocityLimitData`**; `VelocityConversionData` is tag 10, and it is on neither hull. The
|
||||
table cross-checks against the live catalog on every record that survived: tag 6 `ReflectorData` (live LonginusX
|
||||
has exactly that and nothing else), 8 `ThrusterData` and 9 `WearData` ("deep space burnout" carries both), 3
|
||||
`RadiatorData` (Arctica), 7 `ShieldData` (legacy "Shield"), 31 `CapacitorData` (legacy "Capacitor").
|
||||
|
||||
The payload is a single `PerformanceStat` in `Key(1)`, `VelocityLimitData.TopSpeed`, authored `50..50` with the
|
||||
legacy exponents `1, 0, 1.5` on both hulls. (Corrected 2026-09-26: the decode behind the restore gives Longinus
|
||||
`100..100` with exponents `1, 0, 0` and Djinni `50..50` with `1, 0, 1.5`. The catalog carries those values.) So **both restored hulls are capped**, where a hull
|
||||
without the behaviour leaves `Agent.TopSpeed` at its 100 default (`Agent.cs:26`) and leaves the player uncapped.
|
||||
`VelocityLimit.Execute` clamps `Entity.Velocity` (`VelocityLimit.cs:48`), so this is a real handling difference on
|
||||
the restored hulls and Cut 4's arrival times are measured with it.
|
||||
|
||||
**The legacy stat shape differs from today's.** A legacy `PerformanceStat` is
|
||||
`[Min, Max, HeatExponentMultiplier, DurabilityExponentMultiplier, QualityExponent]`; today it is `Min`, `Max` and
|
||||
a `Terms` list of `StatTerm` (`ItemData.cs:632-643`, keys 2 to 4 retired). Every restored stat has to be
|
||||
translated, not copied. `docs/stats-power-cut1-migration.md` is the precedent for that mapping and the authority
|
||||
on what each legacy exponent becomes.
|
||||
|
||||
### The cut
|
||||
|
||||
- **Deletes first:** nothing. This is content restoration.
|
||||
- **Adds:** the two hull records and all five thruster designs (`Medium Drive`, `Small Drive`, `Victoire`,
|
||||
`Talaria`, `RevvITup 2.0`), approved 2026-09-22; a `FactionProductData` for each; roles for each; firing arcs on
|
||||
the Djinni's weapon hardpoints; each hull's `VelocityLimit` behaviour with its translated stat.
|
||||
- **Mechanism:** a one-shot command in `tools/AetherDb` (`restore-hulls [apply]`), in the shape of the existing
|
||||
`*-migrate [apply]` commands: dry run by default, opens the catalog through `AetheriaStores.Open(catalogWritable:
|
||||
true)` only when applying, writes every record in one `Commit`, and refuses to run twice. The Cut 9 importer
|
||||
(`tools/AetherDb/Import.cs`, added in `70fbaca1` and deleted by Cut 10) is the precedent for reading the legacy
|
||||
`[tag, payload]` records and rewriting them by the target type's `[Key]` shape; read it out of git history rather
|
||||
than re-deriving the mapping. **Delete the command in the same campaign, as Cut 10 deleted the importer**, so the
|
||||
carrying cost of the restore is zero once it has run.
|
||||
- **Authority map:**
|
||||
- Owner: the catalog (`GameData/Aetheria.cc`) owns authored content; the operator owns what the content *is*.
|
||||
- Inputs: the legacy LFS records, the existing factions and assets, the operator's review of the list above.
|
||||
- Outputs: new `HullData`, `GearData` and `FactionProductData` records.
|
||||
- Derived state: none. Runtime `Lot`s and provenance are minted as for any other design.
|
||||
- Forbidden writers: nothing else may write the catalog while this cut is in flight; the one-shot command must
|
||||
refuse a second apply rather than upsert twice.
|
||||
- Deletion line: the command goes once the records are in.
|
||||
- **Verification:**
|
||||
- `FireControlCut7Tests.ShippedCatalogOpensAndGeneratesAnArmedHull` still passes unchanged: the real catalog
|
||||
opens, every `EquippableItemData` deserializes, and LonginusX still generates an armed loadout.
|
||||
- New `RestoredHullsTests` against the real catalog, read-only: each restored hull exists, has the expected
|
||||
thruster hardpoint count (Longinus 4, Djinni 8), every thruster hardpoint accepts a catalog thruster design
|
||||
through `TryEquip` at that hardpoint's own position, and the ship then moves and turns under
|
||||
`MovementDirection`/`LookDirection` for a few ticks. Before Cut 3 this runs on the old mixer, which is the
|
||||
point: it proves the content, not the controller.
|
||||
- `LoadoutGenerator` generates each restored hull when filtered to it, which is the check that the products and
|
||||
roles are authored correctly.
|
||||
- `dotnet run --project tools/AetherDb -- census` names the two hulls with their makers, and `dangling` reports
|
||||
no new dangling reference.
|
||||
- Operator: the Studio click-through, then a play check flying a restored hull. That play check is what
|
||||
unblocks the rest of this campaign, and it is where Q6's weight gets settled by feel.
|
||||
- **Operator questions:** none open. The list is approved and tag 11 is identified.
|
||||
- **Ledger estimate:** no source removed. About 3 to 7 catalog records added, plus their products, plus a one-shot
|
||||
command of roughly 150 lines that is deleted again in this campaign. Net carrying cost: the content, and nothing
|
||||
else.
|
||||
|
||||
## Cut 2. CultMath: bounded least squares (CultLib)
|
||||
|
||||
- **Repo/branch:** `F:\Projects\CultLib`, a branch from `45c2f40` (Aetheria's pinned `CultLibRevision`,
|
||||
`Directory.Build.props`). Depends on nothing.
|
||||
- **First:** run `dotnet test packages/cultmath/tests/CultMath.Tests` green at base and record the count.
|
||||
- **Deletes first:** none. This is a pure addition, and it is the ruled owner fill (R4).
|
||||
- **Adds:** one C# file in `packages/cultmath/src/CultMath/` with a static solver for
|
||||
`min ||A x − b||²` subject to `lo ≤ x ≤ hi`. It serves a dense, small problem (m ≤ ~24 rows, n ≤ ~24 columns).
|
||||
Rules:
|
||||
- The method is a primal active set (bounded-variable LS). Each iteration solves the free set by Cholesky on the
|
||||
normal equations, or by QR if Hands prefers conditioning. It terminates on KKT: at each bound the gradient sign
|
||||
must be consistent with that bound.
|
||||
- `float` in, `Span`/`ReadOnlySpan` arguments, caller-supplied workspace. No allocation per call.
|
||||
- `x` is both warm start and result. The solver clamps it to the box first.
|
||||
- It returns an iteration count or status, has a bounded iteration cap, is deterministic, and keeps its
|
||||
last feasible iterate on a cap hit. A rank-deficient free set is handled (the caller adds a small ridge row,
|
||||
and the solver must not throw on a singular pivot).
|
||||
- Naming stays boring and HLSL-adjacent per `docs/design.md` Rules, for example a
|
||||
`CultMath.BoundedLeastSquares` static class. It is C#-only like the intercept helpers (`math.cs`). No Rust or
|
||||
HLSL mirror, because it is not a batch kernel and no shader needs it.
|
||||
- **Tests** in `packages/cultmath/tests/CultMath.Tests`:
|
||||
- `InteriorOptimumEqualsNormalEquations`: a problem whose unconstrained optimum lies inside the box returns it.
|
||||
Pins the free-set solve.
|
||||
- `KktHoldsOnRandomBoxedProblems`: randomized problems up to 24×16 are checked against a projected-gradient
|
||||
reference to 1e-4 relative cost, and each active bound's gradient sign is checked. Pins optimality and the
|
||||
multiplier test.
|
||||
- `AllBoundsActive`, `ZeroColumn`, `DuplicateColumns`: degenerate columns return without throwing and are
|
||||
optimal. Pins rank handling.
|
||||
- `WarmStartMatchesColdStart`: a solution from a perturbed warm start equals the cold solution. Pins
|
||||
that the start does not bias the result.
|
||||
- `AsymmetricBounds`: `lo = −1, hi = 1` on some columns and `[0,1]` on others. Pins bidirectional actuators.
|
||||
- Fixtures must not be degenerate: non-square, non-identity A, and b not in A's range.
|
||||
- **Release:** build the Unity package (`packages/cultmath/scripts/build-unity-package.ps1`), bump
|
||||
`unity/org.gamecult.cultmath/package.json` to 0.2.4, and tag `cultmath-unity-v0.2.4` by CultLib's own release
|
||||
path. In Aetheria, bump `Packages/manifest.json`'s `org.gamecult.cultmath` tag and `Directory.Build.props`
|
||||
`CultLibRevision` in one commit.
|
||||
- **Authority map:** Owner: CultMath. Inputs: A, b, bounds, warm start. Outputs: x and status. Forbidden writers:
|
||||
no least-squares or linear-solve code in `Aetheria/Assets/Scripts/**` (negative grep in Cut 3).
|
||||
- **Verification:** `dotnet build packages/cultmath/src/CultMath/CultMath.csproj`; `dotnet test` of CultMath.Tests.
|
||||
Aetheria's `dotnet test tests/Aetheria.Shared.Tests` still passes 244 after the bump. Unity compiles the new
|
||||
package, and only the operator can check that.
|
||||
- **Ledger estimate:** +150..220 lines of source and +150 lines of test in CultLib; Aetheria gets a 2-line bump.
|
||||
|
||||
## Cut 3. `ShipControl`: shared controller and allocator replace the mixer
|
||||
|
||||
- **Repo/branch:** Aetheria, a branch from the Cut 2 bump commit. Depends on Cut 2. Cut 1 is not a
|
||||
prerequisite for the code, but its restored hulls are what the operator's play check needs.
|
||||
- **First:** before editing, commit the base flight numbers above as test constants, reproduced by the fixture spec
|
||||
in "Findings". They are computed at `cd846916`, never captured from new code. Also run a LonginusX-with-Traction
|
||||
pin at base: `AetherDrive.Axis` for each probe input is `(my, mx, sqrt(|sin e|)·sign)`, including e = 30°, which
|
||||
gives `Axis.z = 0.7071`.
|
||||
- **Deletes first** (separate commit, build and tests green, no behaviour change):
|
||||
- `Ship.cs:61-66` `TurnTime` (6 lines).
|
||||
- `Behaviors.cs:96-99` `IAnalogBehavior` (4 lines) and its mention in the `Thruster` declaration (`Thruster.cs:40`).
|
||||
- `Entity.cs:2007`, the commented `IAnalogBehavior` line.
|
||||
- **Deletes (behaviour commit):**
|
||||
- `Ship.cs:30-39` (bucket and item sets, 10 lines).
|
||||
- `:50-59` (capacity properties and strafe lists, 10 lines).
|
||||
- `:96-118` (bucket construction; `Activate` keeps `base.Activate()` and gathers actuators, about 20 lines).
|
||||
- `:123-124` (subscriptions) and `:127-143` (`RemoveAetherDrive`, `RemoveThruster`, 17 lines).
|
||||
- `:145-249` (the `ThrustCalculation` region, 105 lines).
|
||||
- `:255-291` (mixer and snap, 37 lines).
|
||||
- The public `Axis` setters: `Thruster.cs:45-49` and `AetherDrive.cs:81-85` become getters plus a command method
|
||||
only `ShipControl` calls.
|
||||
- Total is about 200 lines out of `Ship.cs`.
|
||||
- **Keeps:** `Ship.cs:253` gate (active, not in a wormhole); `:294-310` drag, position, gravity and rotation
|
||||
quaternion; wormhole code; `Thruster.Execute`/`AetherDrive.Execute` physics unchanged. The throttle is still
|
||||
`_input`/`_axis`, so power requests, audio and particles read what they read today.
|
||||
- **Adds:** `ShipControl` in `Assets/Scripts/ServerShared/ShipControl.cs`, owned by `Ship` and stepped from
|
||||
`Ship.Update` where the mixer was. It is one file and one owner. Types and rules:
|
||||
- **Actuator columns.** A narrow interface implemented by `Thruster` and `AetherDrive`. There are two
|
||||
implementers and one consumer; this replaces `IAnalogBehavior`.
|
||||
- Each actuator reports its columns every tick: body-frame (Fx, Fy) in m/s² and yaw rate in rad/s
|
||||
(clockwise positive) per unit throttle, plus bounds. It then accepts its throttles back.
|
||||
- **Thruster:** one column, [0,1]. F is the negative item facing (`Rotate` of (0,1) by mount rotation) times
|
||||
live `Evaluate(Thrust)/Mass`. Yaw is `Torque·Thrust·TorqueMultiplier/Mass`.
|
||||
- **Zeroing:** the column is zero when `!Item.Active.Value` or `Item.PowerSupply ≤ 1e-4`, which is the same
|
||||
predicate `Execute` gates on. `Thruster.Thrust` (stale, updated only in `Execute`) is not the source.
|
||||
- **AetherDrive:** three axes. Translation is split into ± columns, [0,1] each, because the drive's efficiency
|
||||
depends on sign and speed (`AetherDrive.cs:138`). Torque is one column, [−1,1].
|
||||
- **Drive authority is nominal.** Effectiveness is the drive's force at `MaximumRpm` from its own stats (rotor
|
||||
mass, λ, λ multiplier, coupling efficiency, `AetherTorqueMultiplier`), scaled by the same liveness and by its
|
||||
condition. It is not the instantaneous `Rpm`. Rotor spin-up is the drive's internal dynamics, not an
|
||||
allocation decision. This choice is what keeps LonginusX exact: for a lone drive, self-consistent capacity
|
||||
cancels the scale, so throttle equals input.
|
||||
- **One solve over the whole wrench.** There is no rotation stage and no translation stage. Each tick
|
||||
`ShipControl` builds a desired wrench `v = (Fx_d, Fy_d, ω_d)` and solves, once,
|
||||
|
||||
min over u in [lo, hi] of Σ_axis ( w_axis · (B_axis · u − v_axis) / cap_axis )² + ridge · |u|²
|
||||
|
||||
where `B` is the live column matrix, `cap_axis` is that axis's achievable extreme, and `ridge` is about 1e-3.
|
||||
The normalization is what lets a rotation error and a translation error be compared: each residual reads as a
|
||||
fraction of what this ship can do on that axis.
|
||||
- **Achievable extremes.** `cap` for an axis is the largest value that axis can take inside the throttle box,
|
||||
which for a box constraint is just the sum of the positive entries of that row (the negative ones for the
|
||||
other half-axis). Six numbers, no solve: `+x`, `−x`, `+y`, `−y`, clockwise, counter-clockwise. They are also
|
||||
what `MovementDirection` is a fraction of. Probe values: Longinus `+y` 172.41, `±x` 68.97, yaw 8.25 rad/s
|
||||
(472.9°/s); Djinni `+y` 55.56, `−y` 18.52, `±x` 37.04, yaw 3.25 rad/s (186.2°/s).
|
||||
- **Demand.** `F_d = (mx · cap(±x), my · cap(±y))` from `MovementDirection`. `ω_d = min(profile(e) · cap(dir),
|
||||
e / dt)` toward the `LookDirection` heading, `profile(e) = sqrt(sin e)` for e ≤ 90° (base's own curve) and 1
|
||||
beyond, with the `e/dt` term landing the heading without overshoot in place of the deleted snap. A zero
|
||||
`LookDirection` means hold heading: no demand, no NaN.
|
||||
- **Direction choice** stays a time comparison, `angle_in_that_direction / cap(dir)`, infinite where `cap` is
|
||||
zero, with the committed direction held unless the other is faster by a margin. It is not a branch on whether
|
||||
the ship "can" turn: under Q2 = B `cap(dir)` is almost always non-zero, and the comparison is what makes the
|
||||
long way round appear.
|
||||
- **Weights.** Translation rows weigh 1. The yaw row weighs `w`, the single knob (Q6), default **3**. There is
|
||||
no other tuning constant in the objective.
|
||||
- **The three regimes fall out of that solve; none of them is a rule** (closed-loop probe, below):
|
||||
- (a) *Turning while forward thrust is also wanted.* The mains are already firing for `F_d`, so their torque
|
||||
costs nothing extra, and the ship turns with them.
|
||||
- (b) *Turning in place.* `F_d` is zero, so every newton of main thrust is pure error, and the solver spends it
|
||||
only to the extent the remaining yaw residual is worth more. The intact Longinus is no longer forced into
|
||||
the 84 m/s² burn the earlier sized-demand design produced.
|
||||
- (c) *No attitude authority in that direction.* The only way to cut the yaw residual at all is the mains, so
|
||||
the solver takes the lurch, and the direction comparison decides whether that beats the long way round.
|
||||
- **`TorqueFloor` has no consumer left.** It was read only at `Ship.cs:115,118`. The field goes from
|
||||
`GameplaySettings` (`Settings.cs:205`) along with its authored value in `Assets/Resources/Settings.asset`;
|
||||
`TorqueMultiplier` and `AetherTorqueMultiplier` stay, because they are physics.
|
||||
- **Budget.** One solve per ship per tick, plus six sums. The earlier design's four extra capacity solves are
|
||||
gone. The fix for cost is solver efficiency, not a cache, because a cache would be a second truth for liveness
|
||||
(invariant 3).
|
||||
|
||||
### Closed-loop probe behind Cut 3
|
||||
|
||||
The single-tick table in Part II is measured against the real engine at `cd846916`. The numbers in this section
|
||||
come from a **separate scratch model**: the fixture columns above, kinematic rotation, `dt` 0.02, the objective as
|
||||
stated, and the base mixer re-implemented against the same integrator so the two are compared like for like. They
|
||||
are design evidence and test targets, not engine pins; Hands reproduces them against the real engine and reports
|
||||
the differences.
|
||||
|
||||
| Manoeuvre (Longinus fixture) | base mixer | solve at w = 3 |
|
||||
|---|---|---|
|
||||
| Turn 90° in place | 0.32 s, 13.9 m/s of drift | 0.30 s, 16.9 m/s of drift, main peaks at 0.73 throttle |
|
||||
| Turn 90° at full forward | 0.32 s | 0.30 s |
|
||||
| Strafe right, 1 s, look held | no strafe at all | 10.7 m/s gained, heading holds within 1.1° |
|
||||
| Djinni turn 90° in place | 0.68 s, no drift | 0.68 s, no drift, no stern throttle |
|
||||
|
||||
The drift in a turn is dominated by the nose thruster, which pushes sideways whatever the controller does: base
|
||||
pays 13.9 m/s for a 90° turn and the solve pays 16.9 m/s, in about the same time. That is the honest shape of
|
||||
regime (b): the main does contribute torque, but the turn does not become a forward burn.
|
||||
|
||||
The yaw weight trades heading-holding against how hard the mains are spent, and on this hull both come from the
|
||||
same pair of actuators:
|
||||
|
||||
| w | strafe gained in 1 s | heading deviation while strafing | 90° turn in place | main peak |
|
||||
|---|---|---|---|---|
|
||||
| 0.5 | 0.1 m/s | 179° (heading lost) | 1.62 s | 0.14 |
|
||||
| 1 | 46.4 m/s | 59° | 0.60 s | 0.37 |
|
||||
| 2 | 13.7 m/s | 3.8° | 0.36 s | 0.63 |
|
||||
| **3** | **10.7 m/s** | **1.1°** | **0.30 s** | **0.73** |
|
||||
| 5 | 9.9 m/s | 0.4° | 0.28 s | 0.79 |
|
||||
|
||||
Damaged cases at w = 3: a Longinus with `Th.CCW` destroyed reaches a heading 90° to port **the long way round**
|
||||
(0.74 s, sweeping +269°) and a heading 20° to port **the short way, on differential main thrust** (1.18 s, sweeping
|
||||
−18°, gaining 19.7 m/s). A hull whose single main sits on the centre line has no counter-clockwise authority at
|
||||
all and always takes the long way (0.86 s). A Longinus with both nose thrusters gone still turns 20° in 0.60 s on
|
||||
its mains alone, and does it while gaining 83 m/s if forward thrust was also asked for against 20 m/s if it was
|
||||
not — regime (a) against regime (b) on one fixture.
|
||||
|
||||
- **Per-file changes** (against `cd846916`):
|
||||
- `Ship.cs:251-292`: `Update` calls `ShipControl.Step(dt)` inside the existing `:253` gate. The drag and position
|
||||
code below stays.
|
||||
- `Ship.cs:92-119`: `Activate` collects actuators into `ShipControl` (all `Thruster` and `AetherDrive`
|
||||
behaviours). No classification.
|
||||
- `Ship.cs:121-125`: the constructor drops both `ItemDestroyed` subscriptions.
|
||||
- `Thruster.cs:40`: implement the actuator interface, drop `IAnalogBehavior`. `:45-49`: public getter, internal
|
||||
command. `:61-71`: `Torque` stays as the geometry factor.
|
||||
- `AetherDrive.cs:81-85`: same pattern. Add the nominal-authority read next to its stats.
|
||||
- `tests/Aetheria.Shared.Tests/BrownoutTests.cs:111-131` and `ConditionRatioTests.cs:94-95`: equip the consumer
|
||||
thruster on the hull's centre column, using `TryEquip(item, int2(2, y))` with a free y, so `Torque == 0`. These
|
||||
tests pin brownout and condition, not flight. Their asserted values (for example `.1f` at
|
||||
`BrownoutTests.cs:162`) must not change. Fix the fixture, never the assertion. `PowerCurveTests.cs:52-62`'s
|
||||
comment about the `Axis` being clobbered becomes true for a different reason; update the wording only.
|
||||
- **Authority map:**
|
||||
- Owner: `ShipControl` decides every actuator throttle and the feasible turn direction.
|
||||
- Inputs: `MovementDirection`, `LookDirection.xz`, current `Direction`, `Mass`, `dt`, each actuator's live
|
||||
column, `TorqueMultiplier`/`AetherTorqueMultiplier`.
|
||||
- Outputs: per-actuator throttle (`Thruster._input`, `AetherDrive._axis`); the achievable extremes, the
|
||||
movement-command mapping, `TurnTime(heading)`, and the step itself, which Cut 4 uses as its prediction model.
|
||||
- Derived state: columns, extremes and the demand are per-tick derived, never stored across ticks except the
|
||||
warm start and the committed turn direction, which are command state and not truth. `Thruster.Axis` and
|
||||
`AetherDrive.Axis` are display and command readbacks.
|
||||
- Forbidden writers: `Ship.Update`'s mixer (gone); any assignment to `Thruster.Axis`/`AetherDrive.Axis` outside
|
||||
`ShipControl`; `Ship.cs:283`'s direct `Direction` write; bucket pruning on `ItemDestroyed`; any Unity-side
|
||||
write of throttles. Also forbidden inside `ShipControl`: any test of whether an actuator is "for" rotation or
|
||||
translation, any per-direction special case, and any second solve that re-decides part of the wrench.
|
||||
- Shared paths: player writes (`ActionGameManager.cs:1254,1263`) and AI writes (`Agent`, `MoveTo`, `Combat`) both
|
||||
reach actuators only through `ShipControl.Step`. Wormhole exit leaves the gate closed until the animation
|
||||
ends, as today.
|
||||
- Deletion line: the delete commits above land before `ShipControl` gains behaviour.
|
||||
- **Verification:**
|
||||
- Builds: `dotnet build Aetheria.Shared`; `dotnet test tests/Aetheria.Shared.Tests -m:1 -p:CultLibRoot=…`.
|
||||
Unity batchmode compile (operator, or Self when the editor is closed).
|
||||
- Tests (new file `LocomotionControlTests.cs`, fixtures exactly as in "Findings": off-origin, off-axis nose with
|
||||
`|fx| > |fy|`, nonzero dt, asymmetric damage):
|
||||
- `IntactLonginusMatchesBase` and `IntactDjinniMatchesBase`: every row of the base table within tolerance
|
||||
(2% of that ship's full-scale acceleration or turn rate), except the four accepted divergences below, which
|
||||
are pinned at their own probed values. Pins the allocator against base.
|
||||
- **Accepted divergences** (operator, 2026-09-22, "The divergence is fine"). Soul reads these as pinned
|
||||
behaviour, not as regressions, and anything outside them is a regression:
|
||||
1. Longinus turning in place spends its mains for torque, peaking near 0.73 throttle at w = 3. The
|
||||
manoeuvre costs 16.9 m/s of drift against base's 13.9 and finishes in 0.30 s against base's 0.32.
|
||||
2. Longinus strafing gains a weak strafe it never had: about 10.7 m/s in a held second, heading holding
|
||||
within about 1°, where base produced exactly nothing.
|
||||
3. Djinni strafe reaches 37.0 m/s² against base's 34.0 (+9%), by balancing torque with Stern 3 and Bow.
|
||||
4. Djinni turning in place may run a stern thruster and the bow thruster against each other at low throttle;
|
||||
net force stays zero, but their exhaust is visible.
|
||||
Plus two intended fixes, which are not divergences to tolerate but behaviour this cut is buying: turns past
|
||||
90° run at full rate instead of decaying to zero at 180°, and `|Direction|` no longer shrinks when the look
|
||||
is directly aft.
|
||||
- `LonginusXDriveAxisEqualsBaseFormula`: a drive-only hull; for every probe input, `AetherDrive.Axis` equals
|
||||
`(my, mx, sqrt(|sin e|)·sign)` to 1e-3. Pins the live player ship's feel exactly.
|
||||
- `CentreMainHullTakesTheLongWayRound`: the long-way fixture, built so the long way is the *only* way. One
|
||||
centred main (torque 0, so no differential authority) and one clockwise attitude thruster, the
|
||||
counter-clockwise one destroyed through the real `ItemDamage` path. Write `LookDirection` directly, as the
|
||||
player would, to 90° left. Heading changes clockwise every tick (never counter-clockwise), and the ship
|
||||
arrives within 2° in under 1.2 s (model: 0.86 s). Base comparison: a ship of that shape never turns at all.
|
||||
Pins the shared feasible-direction choice.
|
||||
- `LonginusMissingCcwPrefersTheLongWayAtNinetyDegrees`: the two-main Longinus with `Th.CCW` destroyed, looking
|
||||
90° left. It sweeps clockwise through about +270° and arrives (model: 0.74 s). Pins that the comparison is by
|
||||
time, not by a rule about which actuators are "for" turning.
|
||||
- `LonginusMissingCcwLurchesRoundTheShortWayAtTwentyDegrees`: the same ship looking 20° left. It sweeps
|
||||
counter-clockwise through about −20° on differential main thrust, arrives within 2°, and its speed rises
|
||||
while it does (model: 1.18 s, 19.7 m/s). Pins that the lurching turn is available and is chosen when it is
|
||||
faster.
|
||||
- `IntactShipTurningInPlaceDoesNotBurnForward`: the intact Djinni, looking 90° right with
|
||||
`MovementDirection` zero. Its speed at the end of the turn is under 1 m/s and no stern or bow thruster
|
||||
exceeds a low throttle. Pins regime (b) on a hull that has the actuators to keep translation clean. The
|
||||
intact Longinus, which does not, is covered by accepted divergence 1 instead, with its own bound: drift no
|
||||
worse than 1.3× base's 13.9 m/s and turn time no worse than base's 0.32 s.
|
||||
- `NoAttitudeAuthorityStillTurns`: a Longinus with both nose thrusters destroyed, looking 20° right. It
|
||||
arrives, on differential main thrust, and it gains speed doing so (model: 0.60 s). Pins regime (c).
|
||||
- `TurningIsCheaperWhenForwardThrustIsAlsoWanted`: the same mains-only ship, 20° right, run twice with
|
||||
`MovementDirection` zero and at full forward. Both arrive in the same time; the second gains much more
|
||||
speed because the burn was wanted anyway (model: 20 m/s against 83 m/s). Pins regime (a) as a consequence of
|
||||
one solve rather than a special case.
|
||||
- `StrafeHoldsHeading`: the intact Longinus, full strafe held for 1 s with `LookDirection` fixed. Heading
|
||||
deviation stays under 2° (model at w = 3: 1.1°). Pins the weight's other half, which is what stops the nose
|
||||
swinging when a ship strafes with a thruster that also yaws.
|
||||
- `LonginusMissingCcwTurnsRightAsBefore`: looking 90° right reaches within 2° in 0.32 s ± one tick (base
|
||||
value). Pins that damage on one side leaves the other side alone.
|
||||
- `LookDirectlyBehindTurns`: intact, look exactly aft. The ship turns, `|Direction|` stays 1 ± 1e-4, and there
|
||||
is no NaN. Pins the snap's deletion and the >90° profile.
|
||||
- `ZeroLookHoldsHeading`: default `LookDirection` gives no NaN in `Direction` or any throttle.
|
||||
- `DestroyedThrusterNeverReceivesThrottle`: for each Djinni thruster in turn, destroy it, then drive 50
|
||||
ticks of mixed inputs (forward, strafe, turn both ways, diagonal). Its `Axis` is 0 on every tick. Repeat for
|
||||
`Enabled = false` and for a zero power grant. Pins invariant 7.
|
||||
- `RepairedThrusterRejoins`: destroy, restore durability, `UpdatePerformance`. The next tick's strafe uses it.
|
||||
Pins the live read (invariant 3) against the old permanent pruning.
|
||||
- `PlayerAndAiInputsGiveIdenticalThrottles`: two identical Djinni hulls with the same damage. One gets inputs
|
||||
the way `ActionGameManager` writes them (`LookDirection` with nonzero pitch from yaw/pitch Euler,
|
||||
`MovementDirection` from a stick value). The other gets them through an `Agent` state writing the same yaw,
|
||||
flat. After `Update`, every actuator throttle is identical. Pins R2.
|
||||
- `LonginusMissingMainHoldsHeadingUnderThrust`: `Th.L` destroyed, forward input. Heading drift stays under 1°
|
||||
over 2 s, and forward acceleration is at least 70 m/s² (probe: 78 with 12 lateral slip). Pins torque-coupling
|
||||
compensation in the shared layer.
|
||||
- Negative greps, verified against `cd846916` to hit only the lines this cut deletes:
|
||||
- `\.Axis\s*[-+]?=` in `Assets/Scripts` should match nothing outside `ShipControl.cs`. At base it matches
|
||||
exactly `Ship.cs:256,264,273,275,276,287,288,291`. `FieldDriver.cs`'s `RectTransform.Axis` does not match;
|
||||
checked.
|
||||
- `_forwardThrusters|_clockwiseThrusters|StrafeTorqueThrusters|RecalculateThrust|TurnTime\(` should match only
|
||||
`ShipControl.cs`'s new `TurnTime`.
|
||||
- `TorqueFloor` should match nothing in `Assets/Scripts`, and nothing in `Assets/Resources/Settings.asset`
|
||||
once Unity rewrites it.
|
||||
- `IAnalogBehavior` should match nothing.
|
||||
- `lerp\(Direction` in `Ship.cs` should match nothing.
|
||||
- No least-squares code outside CultMath: `Cholesky|pseudo.?inverse|ActiveSet` in `Assets/Scripts` should
|
||||
match nothing.
|
||||
- Stryker: `dotnet stryker --since:<Cut 3 base>` from `tests/Aetheria.Shared.Tests`. Every non-equivalent
|
||||
survivor in `ShipControl.cs`, `Thruster.cs` and `AetherDrive.cs` is killed or triaged by name. Float boundary
|
||||
flips are equivalent, per the fire-control Cut 11 ruling.
|
||||
- Operator: fly LonginusX and confirm it feels unchanged (strafe, turn, look behind now turns). Then fly a
|
||||
restored Longinus or Djinni from Cut 1, shoot a thruster off it, and confirm the damaged handling and the
|
||||
lurching turn. Without Cut 1 this half of the check cannot be done at all.
|
||||
- **Operator questions:** Q6, below, which does not block the cut. Q1, Q2, Q3 are ruled and Q5 is dissolved.
|
||||
- **Ledger estimate:** −200 lines in `Ship.cs`, −12 elsewhere (`IAnalogBehavior`, `TorqueFloor` and its authored
|
||||
value). `ShipControl.cs` adds about 250–350 lines, tests about 500. Net source roughly +100. That buys
|
||||
actuator-loss capability, which is the explicit ask, and removes seven parallel role sets, the snap, permanent
|
||||
pruning, one authored setting and four capacity solves a tick.
|
||||
|
||||
## Cut 4. Heading planner in the AI
|
||||
|
||||
- **Repo/branch:** Aetheria, after Cut 3.
|
||||
- **First:** pin base AI results as constants. On base, a Djinni with all stern thrusters destroyed never reaches
|
||||
the target (speed 0 at 120 s). Intact, it reaches it in 4.34 s. Both come from the probe (Agent plus MoveTo, dt
|
||||
0.02, target 300 m to port from (37,−12), nose `normalize(0.8,0.6)`).
|
||||
- **Deletes first:** `Agent.cs:16-17` (the two thresholds) and `Agent.cs:60-78` (the body of `Accelerate`, 19
|
||||
lines). `MoveTo.cs:26` (the duplicate `LookDirection` write). The signature `Accelerate(float2, bool noTurn)`
|
||||
stays, since `Combat.cs:127` and `MoveTo.cs:27` call it.
|
||||
- **Adds:** in `Agent` (above the inputs, AI only). **The planner chooses by predicted outcome, never by a
|
||||
rule.** It simulates each candidate and compares where the ship actually ends up.
|
||||
- **Candidate manoeuvre:** a pair (heading command, movement command) held for the horizon. The set is the
|
||||
headings the ship might fly with the translation that points the demand along Δv at each: 16 evenly spaced
|
||||
headings (Hands default; 8 to 32 is the sensible range), plus the Δv direction and the current heading.
|
||||
- **Prediction:** roll each candidate forward over a horizon of 1.0 s (Hands default; 0.5 to 2.0 s is the
|
||||
sensible range) in 5 substeps (3 to 10), stepping the *same* `ShipControl` solve and the same kinematics the
|
||||
ship will actually fly. There is no second physics model and no closed-form estimate: one owner for what the
|
||||
ship does, which is invariant 8 applied to prediction.
|
||||
- **Score:** the predicted outcome at the horizon — remaining distance to the objective, and the closing speed
|
||||
that ends the horizon (so a manoeuvre that arrives pointing the wrong way with no closing speed loses to one
|
||||
that is simply nearer and still closing). Infinite where the candidate ends further away than it started.
|
||||
- **This is what answers the operator's case.** A ship whose rotation has to be bought with main thrust turns in
|
||||
a great circle: the prediction shows the heading improving while the range opens, so a lateral burn that keeps
|
||||
the bearing and closes wins on its own numbers. Nothing in the planner tests whether the ship is a one-way
|
||||
turner, whether a thruster is missing, or which actuator would be used.
|
||||
- Pick the argmin with hysteresis: replan when a candidate beats the current plan by a margin, on a cadence
|
||||
(0.25 s default) or when the actuator set changes. The cadence exists for cost: 18 candidates × 5 substeps is
|
||||
about 90 solves per replan, roughly 1 ms per replan per ship at the scratch timings, so a 0.25 s cadence over
|
||||
20 AI ships is a few percent of a core. Hands measures and reports; if it is too slow the answer is fewer
|
||||
candidates or a shorter horizon, both of which are stated ranges, not a cache.
|
||||
- Write `LookDirection = θ*` unless `noTurn`. Write `MovementDirection` as the per-half-axis fractions that point
|
||||
the translation demand along Δv, inverting `ShipControl`'s own mapping (a `ShipControl` helper, so the AI never
|
||||
re-derives it), with a deadband near zero Δv.
|
||||
- `noTurn` (combat) skips the heading half of the candidate but still predicts the translation. A Djinni with no
|
||||
stern facing its target strafes or backs off on its own.
|
||||
- **Authority map:**
|
||||
- Owner: `Agent` decides what the AI writes to the two inputs.
|
||||
- Inputs: target velocity and objective position, the `ShipControl` step used as the prediction model, current
|
||||
velocity and heading.
|
||||
- Outputs: `LookDirection` (unless `noTurn`) and `MovementDirection`.
|
||||
- Derived: the plan (heading, time of last replan) is command state only.
|
||||
- Forbidden writers: `MoveToState` writing `LookDirection`; any AI code writing throttles or `Direction`; any
|
||||
second model of what the ship will do, whether a closed-form estimate, a capability table of its own, or a
|
||||
branch on which actuators are missing.
|
||||
- Shared paths: `MoveToOrbitState` (patrol) and `CombatState` both go through `Accelerate`.
|
||||
- **Verification:**
|
||||
- `DjinniWithoutSternReachesTargetByCrabbing`: stern cluster destroyed, target 300 m at a bearing 30° right of
|
||||
the nose, driven through `Agent` plus a fixed-target `MoveToState`. The ship arrives within 10 m in under 8 s.
|
||||
Base never arrives (speed 0 at 120 s). Pins R1(2) and the stuck-forever cheese.
|
||||
- `CrabBeatsTheBigCircle`: **the operator's case, and the reason Cut 4 predicts instead of deciding.** The
|
||||
fixture is a hull that can strafe cleanly but can only rotate by spending a main: two off-centre mains aft and
|
||||
one amidships lateral pair whose torque cancels, no attitude thrusters, with an objective abeam to port at
|
||||
300 m. A turn-to-face policy run in the same harness spends the manoeuvre sweeping a wide arc that barely
|
||||
improves the bearing and opens the range; the planner's choice closes it. Pinned as time to reach the
|
||||
objective, and as range at the horizon, never as "the planner chose to strafe".
|
||||
- `CrabBeatsPointAndBurnWhenMainIsWeak`: Djinni with Stern 1 and Stern 2 destroyed (asymmetric; Stern 3's torque
|
||||
is balanced by the laterals), target 300 m at 60° left. The planner arrives strictly sooner than a naive
|
||||
point-and-burn agent run in the same harness through the same Cut 3 controller. A relation, not a captured
|
||||
number.
|
||||
- `IntactShipsStillPointAndBurn`: an intact Djinni arrives no later than base's 4.34 s + 10%, with the restored
|
||||
hull's own `VelocityLimit` in force. Pins no regression.
|
||||
- `LonginusWithoutReverseFlipsToBrake`: target velocity opposite the current velocity; the predicted-outcome
|
||||
score puts the ship round, because a Longinus has no reverse thrust.
|
||||
- `PlannerTakesTheLurchWhenItPays`: the Longinus with `Th.CCW` destroyed and a Δv 20° to port, where the
|
||||
lurching turn is genuinely faster. The ship gets there sooner than a fixed-heading strafe would in the same
|
||||
harness. Pins that the planner inherits the controller's comparison rather than avoiding the lurch on
|
||||
principle.
|
||||
- `PlannerPredictionMatchesFlight`: run a candidate's prediction, then fly the same commands for the same
|
||||
horizon, and compare the end states. They agree within a small tolerance. Pins that the prediction uses the
|
||||
real controller and that nobody has grown a second model.
|
||||
- Negative grep: `LookDirection` in `Agents/States/MoveTo.cs` should match nothing.
|
||||
- Stryker `--since:<Cut 4 base>` over `Agent.cs`, `MoveTo.cs` and `ShipControl.cs` queries.
|
||||
- Operator: watch a patrol Djinni with a stern thruster shot out crab to its next orbit.
|
||||
- **Ledger estimate:** −22 lines, +140 lines of source (the prediction loop replaces the closed-form score),
|
||||
+300 lines of test. No new type beyond the plan and the candidate.
|
||||
|
||||
## Cut 5. Combat facing and tactics (target shape only)
|
||||
|
||||
This cut gets mapped after fire-control Cut 12 lands, because that cut decides what presenting a side is worth.
|
||||
|
||||
- **Owner:** `CombatState` (`Combat.cs:88-127`), above the inputs.
|
||||
- **Shape:** extend Cut 4's predicted-outcome scoring with what the weapons want — arcs, ranges and the aim the
|
||||
fire-control path will take — so the facing a ship holds is the one its predicted damage favours, not a rule
|
||||
about its turn asymmetry. A ship that turns one way fast and the other way slowly will, under that scoring, tend
|
||||
to keep its target drifting toward its fast side, because that is what predicts better. A ship with good turret arcs and poor rotation holds a heading and lets the
|
||||
turrets work. Weapons with fixed arcs pull the heading onto the target. It uses the Cut 4 planner for thrust.
|
||||
- **Fork:** Q4 (heading versus aim), which must be ruled before mapping.
|
||||
|
||||
## Operator questions
|
||||
|
||||
Each question gives options and a recommendation. Self paces these one at a time. Q1, Q2 and Q3 were ruled on
|
||||
2026-09-22; their text is kept as history, and the live design is in the cuts above.
|
||||
|
||||
- **Q6: the yaw weight in Cut 3's solve (does not block Hands).** The solve has exactly one knob, the weight on
|
||||
the yaw residual against the translation residuals, after each axis is normalized by that ship's achievable
|
||||
extreme. On a Longinus both the strafe and the turn come from the same nose thrusters, so the knob trades
|
||||
heading-holding against how hard the mains are spent for torque (closed-loop model, table in Cut 3):
|
||||
|
||||
| w | strafe gained in a held second | heading deviation while strafing | 90° turn in place | main peak |
|
||||
|---|---|---|---|---|
|
||||
| 1 | 46.4 m/s | 59° | 0.60 s | 0.37 |
|
||||
| 2 | 13.7 m/s | 3.8° | 0.36 s | 0.63 |
|
||||
| 3 | 10.7 m/s | 1.1° | 0.30 s | 0.73 |
|
||||
| 5 | 9.9 m/s | 0.4° | 0.28 s | 0.79 |
|
||||
|
||||
The Djinni is unaffected at every value: it has the actuators to do both cleanly. Base, for reference, does not
|
||||
strafe at all and turns 90° in 0.32 s.
|
||||
- **A: w = 3.** Heading holds while strafing, turns match base's speed, and the mains carry a real share of the
|
||||
torque in a turn.
|
||||
- **B: w ≈ 1.** The mains stay nearly out of turns, but a Longinus asked to strafe swings its nose most of the
|
||||
way round, because strafing and turning are the same thrusters.
|
||||
- **C: w = 5.** Heading holding is near-exact and the mains are spent hardest.
|
||||
|
||||
**Recommended: A.** Hands starts there and the Cut 3 pins are written against it. This is a feel question, so
|
||||
the honest place to settle it is the Cut 1 play check; changing it afterwards moves numbers in pins, not
|
||||
structure.
|
||||
- **Q4: heading versus aim (blocks Cut 5 only).** `LookDirection` is both the heading command and the aim, read by
|
||||
`LockWeapon.cs:94`'s lock cone, guided projectiles, reticle targeting and the tractor beam. Capability-aware
|
||||
facing wants the AI to hold a heading that is not its aim, and under R2 any split applies to the player too.
|
||||
- **A.** Add a heading input beside the aim on the shared surface. The player's heading follows the view unless a
|
||||
player control is added later.
|
||||
- **B.** Keep one input, and the AI accepts degraded lock cones and missile aim while it manoeuvres.
|
||||
|
||||
**Recommended: A**, decided when Cut 5 is mapped.
|
||||
|
||||
### Ruled or dissolved (history)
|
||||
|
||||
- **Q1: intact-ship divergence from base.** **Ruled A, 2026-09-22: "The divergence is fine."** The four accepted
|
||||
divergences and their magnitudes are listed in Cut 3's verification. The rejected option was to require exact
|
||||
base behaviour, which would have meant reintroducing per-thruster role rules into the objective.
|
||||
- **Q2: rotation from translation thrusters.** **Ruled B, 2026-09-22: "that's absolutely viable and can be a
|
||||
better decision than turning around the long way, I wouldn't introduce a thruster exclusion for this."** The
|
||||
option this map recommended (A: rotation authority only from thrusters above `TorqueFloor`, so a lost attitude
|
||||
thruster means that direction is gone) was rejected. Cut 3 and Cut 4 are written to B.
|
||||
- **Q3: Longinus fixture layout.** **Ruled, 2026-09-22: "Good catch on the Longinus main thrusters, I was
|
||||
misremembering."** Fixtures follow the data: two aft 2×2 mains.
|
||||
- **Q5: how the rotation demand is sized.** **Dissolved, 2026-09-22.** The question assumed a separate rotation
|
||||
demand that something had to size. The operator refused the premise — "it should only do that if the ship's
|
||||
controller also *wants* to accelerate forwards that much" — and the answer is one solve over the whole wrench
|
||||
with both residuals in the same currency, which makes the three regimes consequences rather than rules. Neither
|
||||
of the options this map offered (size from attitude authority with a fall-back; size from everything) survives,
|
||||
and `TorqueFloor` loses its last consumer. What is left of the question is Q6, the single weight.
|
||||
|
||||
## Subtraction ledger (estimates)
|
||||
|
||||
| Cut | Removed | Added | Dependencies / targets |
|
||||
|---|---|---|---|
|
||||
| 1 | 0 source; the one-shot command is deleted again in this campaign | 3–7 catalog records + products; ~150 lines of throwaway tool + ~120 test | No new package, target, asset or authored field. Existing prefabs, schematics and factions are reused |
|
||||
| 2 | 0 | ~200 src + ~150 test (CultLib) | CultMath gains one file; cultmath-unity 0.2.4; Aetheria pin bump |
|
||||
| 3 | ~212 (`Ship.cs` ~200, `Behaviors.cs` 4, `Entity.cs` 1, setters, `TorqueFloor` and its authored value) | ~300 src + ~500 test | `IAnalogBehavior` and one authored setting removed; four capacity solves a tick removed; no new package, target or authored field |
|
||||
| 4 | ~22 | ~140 src + ~300 test | none |
|
||||
| 5 | not mapped | not mapped | not mapped |
|
||||
172
docs/merge-to-master-checklist.md
Normal file
172
docs/merge-to-master-checklist.md
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
# Aetheria merge checklist: `codex/fire-control-12` into `master`
|
||||
|
||||
Compiled 2026-09-29 by Eyes from the maps on the branch. Pointers are `doc:line` in `docs/` at the branch tip. "Unrecorded" means the maps do not say the check was done.
|
||||
|
||||
**What merging does.** `origin/master..codex/fire-control-12` is 257 commits. It carries the item-provenance work after 2026-09-17, stats-and-power (resolver, power bus, input capacitors, priority tiers, power-supply term and brownout, nominal requests, condition ratio, shield reserve, authored roles), fire-control Cuts 1-12.4(b), locomotion Cut 1 (restored hulls), the shield-panel interceptor, and the Addressables cuts. Self performs the git merge after you sign off. Nothing here is for the merge itself; it is what only you can check first.
|
||||
|
||||
**Correction to the brief.** `codex/cultcache-cutover`, `codex/aetheria-state-rebuild` and `codex/item-provenance` are all ancestors of the branch tip, and the first two are already on `origin/master`. Master's merge commit `9b85211f` (2026-09-17) took cultcache-cutover and item-provenance at their 09-17 tips, after your play smoke passed (`cultcache-migration-cut.md:148`). Master has two commits the branch lacks (`9b85211f`, `263ac421`, which deletes dead narrative fixtures). `git merge-tree` of the two showed no conflicts. No `aetheria-state-rebuild` doc exists.
|
||||
|
||||
## 1. Before you start
|
||||
|
||||
- Open branch `codex/fire-control-12` at its tip, `4b594e116c4063ef5ee1dcb937bab0288008e63e` (2026-09-26, in sync with `origin/codex/fire-control-12`).
|
||||
- Unity `6000.3.24f1` (`ProjectSettings/ProjectVersion.txt`).
|
||||
- Batchmode: `tasklist` on 2026-09-29 showed Unity Hub and the licensing client but no `Unity.exe`, so none was running. Batchmode refuses an open editor and the maps say to close it and not kill anything (`item-provenance-cut.md:485,519`). Recheck when you start.
|
||||
- The Unity manifest pins `cultmath-unity-v0.2.4` (`Packages/manifest.json`); the tag exists in CultLib. Unity needs network access to resolve it on first open (`fire-control-cut.md:2205-2212`).
|
||||
- **Delete or move `GameData/run.cc` and `GameData/player.cc` before the first launch.** Both are git-ignored and stale (2026-09-22, 91,580 and 1,964 bytes). The maps' fresh-launch checks assume neither exists (`cultcache-migration-cut.md:2745`), and an old run store throws on the first lot lookup (`item-provenance-cut.md:595-596`). The persisted shape has changed since (power tier slot, fuse slot 32).
|
||||
|
||||
**Your uncommitted work.** The merge happens in a separate worktree and does not touch it. `git status` lists 22 modified tracked files and 3 untracked. `git diff --stat` shows content changes in only 9; I infer the other 13 (materials, render textures) differ by line endings, from the LF/CRLF warnings.
|
||||
- Content changes: `Asset Sources/Adrasteia1.blend`, `Car Paint White.mat`, `Steel.mat`, `Map Gravity Lines.mat`, `Minimap Gravity Lines.mat`, `LiberationSans SDF - Fallback.asset`, `Assets/Scenes/ARPG.unity` (+374), `Assets/Scenes/FieldShieldTest.unity` (+263), `Assets/Scripts/AetheriaInput.cs` (+40).
|
||||
- Line-ending-only (inferred): the other Map/Sector `.mat` files, 8 `.renderTexture` files, `Stardust.mat`.
|
||||
- Untracked: `Asset Sources/Adrasteia1_ContourRoute.blend`, `Ships.blend`, `adra1.png`.
|
||||
- **Decide about three that belong to merged campaigns (my reading of the diffs):**
|
||||
- `AetheriaInput.cs` (+40) adds the `Cycle Target Item` action (key J). The branch already has that action in `Assets/Resources/Aetheria.inputactions:72,326` and reads it in `ActionGameManager.cs:412`, but not in the generated wrapper. It is the wrapper catching up to committed data. Recommend including it.
|
||||
- `FieldShieldTest.unity` (+263) adds `ShieldInterceptor`, `ShieldEnvelope`, a `Panel` with `Prototype` and `ShieldPanel`. This is the shield-panel Cut 4 rig you clicked together (`shield-panel-cut.md:840-846`). It is not on the branch. Without it the interceptor code merges with no rig.
|
||||
- `ARPG.unity` (+374) adds "Debug Info Panel" and "Debug Info Text". `ActionGameManager.DebugInfoText` (`ActionGameManager.cs:151,1287,1333`) is the fire-control debug HUD and it returns early when null. Without the scene change the HUD "hull" factor in step 10 is invisible.
|
||||
|
||||
## 2. One play session, in order
|
||||
|
||||
### 2a. Fixtures to author first
|
||||
|
||||
1. **Scratch catalog for 12.4.** Copy the catalog; do not edit `GameData/Aetheria.cc`. Author one weapon with `Fuse = Proximity` and a `BlastRadius`, and one with `Fuse = Delayed`, a `BlastRadius` and a penetration of about 2 cells (`fire-control-cut.md:3094,2656-2658`). Shipped penetration is at most 0.25 and enclosed cockpits need about 2 cells, so a penetrator authored from shipped values cannot reach the interior (`:3224-3225`). Fields are `aetheria.weaponitemdata` slot 29 (`BlastRadius`) and slot 32 (`Fuse`). Unrecorded: how to point the game at the scratch catalog, and which tool you author with (the map says only "Studio or `AetherDb`", `:2665`).
|
||||
2. **Studio open, no game running.** You need it at 2c and 2d. Batchmode-based checks are the agent's, not yours.
|
||||
|
||||
### 2b. Fresh launch (no `run.cc`, no `player.cc`)
|
||||
|
||||
3. **Launch to main menu.** Expect no Addressables errors, and the Groups window shows `Assets/Content` under `Default Local Group` (`addressables-cut.md:301`). `player.cc` appears and Continue is disabled (`cultcache-migration-cut.md:2746`). Proves: Addressables Cut 1, CultCache cutover. The 09-17 smoke covered the last two on the old tree; this is a cheap recheck on the new schema.
|
||||
4. **New Game (tutorial).** Expect the galaxy generates and the start ship is LonginusX (`settings-globals-cut.md:498`, an expectation, not a recorded check for this stack). Expect a Zenith station with a docking bay in the entrance zone every time (`locomotion-cut.md:375`). Proves: locomotion Cut 1 station rule.
|
||||
5. **Addressables, "Use Asset Database".** Ships, turret and Zenith spawn; thruster and aether-drive particles show; fire an instant weapon (Autocannon) and a charged one (ChargeBlast SG); action bar icons show (`addressables-cut.md:362-366`). Proves: Addressables Cut 2.
|
||||
|
||||
### 2c. Flight, power and economy
|
||||
|
||||
6. **Provenance in play.** Starting-ship items show tier colour; the properties panel shows Manufacturer, product name and flavour for branded gear. Dock and buy: the brand still shows in cargo. `give Lamp` (any design name): no Manufacturer row. Kill an NPC and pick up loot: brand shown (`item-provenance-cut.md:528-539`). Proves: item-provenance Cut C.
|
||||
7. **Fly a restored hull (Longinus or Djinni).** Thrusters move and turn it (`locomotion-cut.md:501`). Watch the speed cap: `VelocityLimit` is gated by the hull's `Active`, and a hull taken offline with thrusters firing loses the cap (`:377`). It did not happen in 300 s on shipped settings; report if you see runaway speed. Unrecorded: how to spawn a restored hull in play (the map names no path).
|
||||
8. **Weak reactor (O2).** Fly with a reactor too small for the loadout. Expect visible, legible starvation rather than a cooked reactor (`stats-and-power-cut.md:705-706`). Proves: power bus (map Cut 3).
|
||||
9. **Brownout and refill (O6, O4).** Brownout reads as degradation, not breakage (`:774`, `:990`). A weapon refilling under brownout stutters instead of firing full rate and cooking the ship (`:729-730`). Proves: power-supply term, brownout, input capacitors.
|
||||
10. **Memory across zones (O1).** Play across several zones with kills, open the Profiler or Task Manager, and confirm memory does not climb (`:672-673`, `:980-982`). Proves: stat resolver, the entity-leak fix (map Cut 2). Combine with steps 11 and 12.
|
||||
|
||||
### 2d. Combat (against a LonginusX-class AI), then save and Studio
|
||||
|
||||
11. **Fire-control Cut 1 arcs.** Side-mounted weapons still fire at targets abeam; a turret tracks all the way round; nothing fires through the hull (`fire-control-cut.md:397-398`).
|
||||
12. **Fire-control Cut 3 and shots.** Shots show rolled impacts and misses; a miss reads as a near-miss, not a bug; damage matches the HUD; aiming at a revealed subsystem concentrates damage; kill time is in the same order as before (`:659-661`). Reveal and selection work, kills drop loot, pickup stores it, the tractor beam still pulls (`headless-playground-cut.md:789-794`). No crash or frozen hot ship when the target vanishes (the 2026-09-20 failure, `fire-control-cut.md:1464-1470`). Recheck after the fixes: unrecorded.
|
||||
13. **12.2, bow then beam.** The HUD `hull` factor reads higher from the beam. Turn your armoured face into a slow missile and watch where it lands (`:2380-2383`).
|
||||
14. **12.3, launcher into a bow, then a flank.** Use a GT 3K or pswarm launcher. The schematic display pulses the facing edge only (`:2519-2520`).
|
||||
15. **12.4, scratch catalog.** Watch a proximity airburst beside a LonginusX and a delayed penetrator into its nose. Damage must land where the model shows the blast; this confirms the centre-of-mass anchor. Bow is already confirmed +y (`:3095-3097`, `:2028-2031`). Proves: 12.4(b) `Detonate`.
|
||||
16. **Wormhole, save, Continue.** Take a wormhole, quit, Continue: same items, same tier and brand (`item-provenance-cut.md:536-537`).
|
||||
17. **Die.** Continue is disabled and `run.cc` holds no ledger (`:540-541`).
|
||||
18. **Shield panel, `FieldShieldTest`.** Follow the numbered look in `shield-panel-cut.md:683-700`. Nothing visible on load. Click the nose: a patch grows and the field ripple runs too. Click the flank: the panel lies flat, not tilted. Click the same spot twice: it strikes the same panel. Spam far-apart clicks: at most 12 panels, oldest replaced. Let them fade: none left. Then the Cut 5 payoff: strong hits dice the patch, and repeated hits on one spot break through on a later hit (`:737-739`). Proves: shield-panel Cuts 3, 4, 5.
|
||||
19. **Studio click-through.**
|
||||
- Open `Aetheria.cc`. The fire-control behaviour union renders (`fire-control-cut.md:503-506`).
|
||||
- `LonginusX` schematic still underlays the shape drawer (`addressables-cut.md:370-371`).
|
||||
- The restored hull records open (`locomotion-cut.md:501`; the map gives no checklist beyond "the Studio click-through").
|
||||
- The scratch catalog's new `Fuse` and `BlastRadius` fields edit (from 2a; no map line).
|
||||
- Open `GameData/run.cc` after step 16. `aetheria.provenanceledger` renders `Lots` with `Attributed` origins and per-role lists. If Studio cannot draw an int-keyed dictionary of unions, that is a Studio defect to raise, not a schema change (`item-provenance-cut.md:541-544`).
|
||||
20. **Addressables, "Use Existing Build".** Run *Build > New Build > Default Build Script*, then repeat step 5. This proves the player catalog carries GUID keys. Then *Analyze*, "Check Resources to Addressable Duplicate Dependencies", and record the result; 5 known leftovers are expected (`addressables-cut.md:367-370`).
|
||||
|
||||
### 2e. Desk review (not play)
|
||||
|
||||
21. **Role content (O7).** Review `docs/stats-power-cut7-roles.md`. Rows marked "generic, needs review" are arbitrary-seed, not brand identity, and no design yet has a second product with a raised role (`:156`, `:194-202`; `stats-and-power-cut.md:797-799`, `:991`).
|
||||
|
||||
## 3. Feel calls during the session
|
||||
|
||||
Only what the maps name.
|
||||
- **Balance numbers.** `CommitHorizon` (first value 0.3 s), `SchematicCellSize` (0.35) and the targeting stat ranges are first guesses; the smoke is the arbiter (`fire-control-cut.md:664-665`, `:855-859`). `UnaidedAccuracy` is ruled "really, really bad" (`:253-259`); judge whether it reads as a last resort.
|
||||
- **Arc rule (Q2).** Arcs apply to the player as well as the AI. The map says it is a real difficulty change to be felt in the smoke (`:836-841`).
|
||||
- **AI holds fire more** once `pOnHull` prices shots. The map calls that tuning, not broken AI (`:1396-1400`).
|
||||
- **Penetration retune (F12-2)** is a ruled follow-up, "Retuning penetration is a follow up" (`:3223-3229`). The map does not tie it to a smoke. The only link is 2a step 1: shipped penetrators cannot reach interiors, so step 15 needs the scratch value.
|
||||
- **Locomotion Q6, yaw weight (w = 3 recommended).** The map says settle it in the Cut 1 play check (`locomotion-cut.md:372-373`, `:903-904`), but the weight belongs to Cut 3's solver, which has not landed. There is nothing to feel today. Ambiguity, not a merge gate.
|
||||
|
||||
## 4. Already done: do not redo
|
||||
|
||||
- Play smoke for cultcache-cutover plus item-provenance, 2026-09-17: new game, combat, loot, save and Continue with brand and quality intact, death clears the run, stance toggle, `FieldShieldTest` (`cultcache-migration-cut.md:148-153`). It ran on the old tree, so steps 3, 6, 16 and 17 are rechecks, not repeats of a gap.
|
||||
- Studio click-through for the CultCache port, 2026-09-17: AmmoType refs repointed at `515859cf`, `dangling` at 0, schematic underlay restored and checked (`cultcache-migration-cut.md:161-165`).
|
||||
- Bow is +y on the schematic, confirmed 2026-09-22 from the schematic images (`fire-control-cut.md:2028-2029`). The blast-anchor half is still open (step 15).
|
||||
- Shield-panel play evidence, 2026-09-18, rigged scene: a panel spawns, is reused and spiderwebs; it shatters only near the rim (`shield-panel-cut.md:119-124`). Partial: the Cut 5 fixes landed after, so step 18 is still open.
|
||||
- A play smoke on 2026-09-20 found the frozen-ship, no-hits and `LockWeapon` crash (`fire-control-cut.md:1464-1470`). That was a failure report, not a pass. Cuts 8 and 9 answered it and no recheck is recorded.
|
||||
- Stats-and-power Cuts 0-1 landed with Soul verification and your re-author ruling (`stats-and-power-cut.md:79-99` onward). No operator check remains from them.
|
||||
|
||||
## 5. Not part of this merge
|
||||
|
||||
- Stats-and-power tier control in the schematic UI (O5) and the deletion of `IOrderedBehavior`/`SortPosition` (O3): no `PowerTier` under `Assets/Scripts/UI` at the tip, and `SortPosition`/`IOrderedBehavior` still exist in `Reactor.cs`, `Entity.cs` (my grep). `stats-and-power-cut.md:752-753`, `:985-989`.
|
||||
- Stats-and-power UI reconciliation (O8: properties panel, trade menu, schematic HUD, Studio over a stat with terms): the map's Cut 8 has not landed; the branch's "Cut 8" commits are the condition ratio (`:819`, `:991-992`).
|
||||
- Settings-into-globals: only Cut 0 (delete 5 dead assets, `ea8b420e`) landed. Its play smoke and Studio click-through wait for Cut 1 (`settings-globals-cut.md:498-511`). The map header still says nothing landed.
|
||||
- Build delivery: the two commits are the map and a ruling (`build-delivery-cut.md:5`, operator checks `:252,324,360,404`).
|
||||
- Locomotion Cuts 2-5, including Q6 and Q4 (`locomotion-cut.md:360,905`).
|
||||
- `content-batch-one.md` is a spec that writes no catalog data (`:5-8`).
|
||||
- Fire-control follow-ups F12-2 to F12-8 (`fire-control-cut.md:3223-3250`).
|
||||
|
||||
## 6. Open questions still yours
|
||||
|
||||
- **Q12-5 (not ruled):** should the HUD show which target items are exposed from the current bearing? Recommended as a follow-up after 12.3, on the target-item cycling UI (`fire-control-cut.md:1959`, `:3215-3218`).
|
||||
- **Locomotion Q4:** heading versus aim; blocks Cut 5 only (`locomotion-cut.md:905-913`, `:372`).
|
||||
- **Locomotion Q6:** the yaw weight; open, does not block (`:372-373`).
|
||||
- **Defaults Self took in 12.4, which you may overrule** (`fire-control-cut.md:3208-3213`): a blast ignores `DamageSpread` and P sits on the centre lane; `IncomingHit` fires for the host of a contact or delayed hit only; the delayed fuse point clamps to the last reached cell's exit; `Detonate` runs a flat armour, pool, hull pass.
|
||||
- **Stale headers, not open questions:** the fire-control 12.3 "pending ruling" at `:2581` was ruled at `:2588`; Q12-9 is ruled A (`:3171`); the shield-panel Q1-Q7 block (`shield-panel-cut.md:61`, `:800-`) was not updated after Cuts 1-5 landed, Q5 being ruled C (`:839-846`).
|
||||
|
||||
## 7. What happens after you sign off
|
||||
|
||||
- **Self merges `codex/fire-control-12` to `master` with `--no-ff`**, in a separate worktree. That single merge carries item-provenance, the stats-and-power work, fire control and locomotion Cut 1. The cultcache-cutover and item-provenance merge into master already happened on 2026-09-17 (`9b85211f`, `cultcache-migration-cut.md:148`), so the maps' "merge the two together" instruction (`item-provenance-cut.md:82`) is spent. The tree merges clean today.
|
||||
- Any of section 1's three uncommitted files you want included need to be committed to the branch first, or they stay out.
|
||||
- **Soul gates outstanding:**
|
||||
- Fire-control 12.4 Soul passes: running tonight. The 12.4 section carries no "closed" status yet (`fire-control-cut.md:2602`). 12.0-12.3 are closed (`:2168-2210`, `:2253`, `:2385`, `:2522`).
|
||||
- CultMath bounded least squares is locomotion Cut 2, not in this stack (`locomotion-cut.md:508`, `:360`). It gates nothing here.
|
||||
- Unrecorded: a Unity batchmode compile at the tip `4b594e11`. 12.2 and 12.3 record clean compiles at their own heads.
|
||||
- **Soul status at merge time: Self fills in.**
|
||||
|
||||
## 8. Results: play smoke, 2026-09-30 (operator plays, agent records)
|
||||
|
||||
Tree: `codex/fire-control-12` at `113164fa` plus the fixes listed below. `run.cc` and `player.cc` moved to
|
||||
`GameData/stale-2026-09-22/` before launch.
|
||||
|
||||
**Compile.** The Unity 6000.3.24f1 batchmode compile at `113164fa` was clean (exit 0, no `error CS`). The four
|
||||
never-compiled files needed no fix. One warning, `EntityInstance._destroyed` assigned but never read, is legacy
|
||||
(`729ab0e8`).
|
||||
|
||||
**Changes made during the smoke.**
|
||||
- `e0a80208`: `AetheriaInput.cs` regenerated; Cycle Target Item bound through `Input.Player.CycleTargetItem`,
|
||||
retiring the by-name `FindAction` stopgap. Batchmode recompile clean.
|
||||
- `97edf48c`: `ARPG.unity` Debug Info Panel and `FieldShieldTest.unity` shield-panel Cut 4 rig committed.
|
||||
- Console: control characters from text input are no longer appended, and Backspace deletes (see step 6 finding).
|
||||
- `give` (operator ruling 2026-09-30): an unknown name and a full cargo bay now say so instead of doing nothing. A
|
||||
ship hull is refused unless docked; when docked it goes through `ActionGameManager.CommissionShip`, the same
|
||||
primitive `TradeMenu.Buy` now uses, and moors a bare player ship at the docked entity with no docking bay
|
||||
("mothballed ships do not require docking bays"). Non-ship hulls are refused. This is the step 7 path to a
|
||||
restored hull.
|
||||
- Scratch weapons authored in place in `GameData/Aetheria.cc` (not committed; restore with
|
||||
`git checkout -- GameData/Aetheria.cc`): `Smoke Proximity` (Proximity, blast 8), `Smoke Delayed` (Delayed,
|
||||
blast 4, penetration 2 cells), `Smoke Refused` (Proximity, blast 30, range 20). Each is a Spectra clone, energy,
|
||||
1 column by 2 rows, to fit the test ship's only energy hardpoint.
|
||||
|
||||
| Step | Result | Evidence |
|
||||
|---|---|---|
|
||||
| 3 Launch to main menu | pass | Operator reached play through step 6 with no reported Addressables errors. |
|
||||
| 4 New Game | pass | As above. |
|
||||
| 5 Addressables, Use Asset Database | partial | Charged weapon (ChargeBlast SG) unprovable: the test ship's only energy hardpoint is 1x2 and ChargeBlast SG is 2x2. Instant weapon not separately reported. |
|
||||
| 6 Provenance in play | partial | Properties panel correct for starting gear and for a purchased item. **Tier colours missing everywhere**: known defect, `settings-globals-cut.md:150` (Unity-serialised `RarityTier.Color` loads as zero); fixed by settings-globals Cut 1, not part of this merge. `give Lamp` was first refused (console finding), then silently did nothing: `Lamp` is a test-fixture name, absent from the live catalog, and `give` reported no miss (now it does). No-Manufacturer check still open with a real unbranded design. Loot brand not yet reported. |
|
||||
|
||||
**Finding, console (not fire control).** Every console command was refused with "commands take only letters,
|
||||
digits, spaces and hyphens", and Backspace inserted a glyph. Cause: `Keyboard.onTextInput` delivers control
|
||||
characters (`\b`, `\r`), and `ConsoleView` appended them to the input line. Enter's `\r` rode into every command;
|
||||
`d503f076` (2026-09-14, on master) correctly changed the parser from stripping disallowed characters to refusing
|
||||
them, which exposed it. Backspace had never been handled (only Delete), which is legacy (`7006a6b0`).
|
||||
|
||||
**Feel notes.** Engaging an AI Djinni: the player was destroyed decisively. "Game is hard."
|
||||
|
||||
**Finding, ship purchase and docking bays (design gap, not a merge gate).** The intended UX is that a purchased
|
||||
ship is assigned its own docking bay. The code does not do that:
|
||||
- `TradeMenu.Buy` (`TradeMenu.cs:373-381`) creates a bare `Ship` parented to the docked station and assigns it no
|
||||
bay. It also charges `data.Price` rather than the lot's quality price that `GetPrice` computes for other items.
|
||||
- `LoadoutGenerator` equips exactly one docking bay per station (`LoadoutGenerator.cs:84-92`), so Zenith has one.
|
||||
- The inventory panel's Current button (`InventoryPanel.cs:110-120`) sets the new ship as current and overwrites
|
||||
the single bay's `DockedShip`; the previous ship stays a station child with no bay.
|
||||
|
||||
**Smoke stopped after step 6 (operator, 2026-09-30).** The operator rejected the script as a monolithic play order
|
||||
that does not respect how the game works: step 7 alone meant spawning and fitting a whole Djinni by catalog name.
|
||||
Direction: operator checks become a list of behaviours verified over time, each set up by an authored, retained
|
||||
scenario selectable from the main menu (a Eureka cut). Steps 7-20 and handoff checks A-F are unplayed. The operator
|
||||
prefers to merge now, with those as open entries to verify through scenarios; Self rules on the merge.
|
||||
|
||||
**Stale expectations found in this checklist.** Step 6 transcribes `item-provenance-cut.md:529-537` (written
|
||||
2026-09-17 03:38, `7425ff1b`). "Starting-ship items show tier colour" was falsified by that day's smoke and recorded
|
||||
at `settings-globals-cut.md:150` (`db420981`, 17:36); the provenance map was never corrected and this checklist
|
||||
copied it despite its own section 5. "`give Lamp`" names a test fixture (`LoadoutTests.cs:289-312`), never a live
|
||||
catalog design, and `give` could not have run at all between `d503f076` (09-14) and `f935c29b`.
|
||||
674
docs/scenarios-cut.md
Normal file
674
docs/scenarios-cut.md
Normal file
|
|
@ -0,0 +1,674 @@
|
|||
# Scenarios: Cut Map
|
||||
|
||||
Date: 2026-09-30, 02:10 CEST. Imagination pass.
|
||||
|
||||
Status: cut map. Nothing has landed. The target lives in section 0 until Self splits it out into
|
||||
`docs/scenarios-target.md`; this document owns the means.
|
||||
|
||||
Anchors are against Aetheria `origin/master` `dcd7bbc5` (the fire-control merge), read in the clone
|
||||
`C:\ws72-fuse5` with `git show`/`git grep`. The operator's tree `F:\Projects\Aetheria` was not touched. No
|
||||
build ran and no Yggdrasil job ran. **(read)** marks a claim read from source at the anchor. **(probe)** marks a
|
||||
claim measured against a real file.
|
||||
|
||||
---
|
||||
|
||||
## 0. Target
|
||||
|
||||
### 0.1 The request, in the operator's words (2026-09-30)
|
||||
|
||||
> "I feel like this would be much more manageable as a list of things to verify over time rather than a
|
||||
> monolithic smoke script that doesn't respect how the game works. Move gear onto Djinni? That's a lot of items
|
||||
> to spawn, and am I expected to have the catalog memorized to spawn them? If you want me to test a bunch of
|
||||
> behaviors under specific conditions, find a way to spawn me in an arena where those conditions are present. If
|
||||
> you want me to kill a guy and loot him, spawn me next to a ship with no armor or weapons, that sort of thing. I
|
||||
> wouldn't mind a scenario affordance in the main menu for this sort of job, that way the test fixtures can be
|
||||
> authored, retained and available. But that sounds like a Eureka cut."
|
||||
|
||||
What those words settle, so no question below re-asks them:
|
||||
- **A scenario is an arena whose conditions are present at spawn.** The player's ship and every other entity are
|
||||
already fitted and placed. The operator never spawns gear by catalog name and never fits a ship by hand.
|
||||
- **The fixtures are authored and retained,** and the main menu lists them.
|
||||
- **Verification is a list of behaviours checked over time,** not a play order.
|
||||
|
||||
### 0.2 Ends
|
||||
|
||||
- The main menu lists scenarios. Picking one starts a run in its arena.
|
||||
- A scenario is typed catalog data. It is authored once, kept in git, and replayed at any later revision.
|
||||
- Every operator check is a typed **check** record: what to do, what to observe, where the rule came from, and
|
||||
the scenario that sets it up. Results accumulate as typed records carrying the revision they were observed at.
|
||||
- Checks A-F and checklist steps 7-20 are the first consumers (section 5).
|
||||
|
||||
### 0.3 Invariants
|
||||
|
||||
- **One owner decides what a new run starts with.** A plain New Game and a scenario launch share the menu path,
|
||||
the galaxy build, `StartGame` and the staging owner. Scenario launch is New Game with a scenario as input; there
|
||||
is no second boot path. A plain New Game is the absent-scenario case.
|
||||
- **One primitive admits an entity into a zone.** Zone construction, staging, warp arrival and undock all admit
|
||||
through it, and agents are created there and nowhere else.
|
||||
- **A scenario sets conditions and nothing else.** Once staged, its entities are ordinary run state. The rules
|
||||
under test run through the same code whether or not a scenario started the run. No scenario-only branch exists
|
||||
in simulation code.
|
||||
- **Fixtures are typed state.** Scenario, loadout presets and test designs are CultCache catalog records. Checks and
|
||||
results are CultCache records. No load-bearing JSON, text scripts or prose checklists.
|
||||
- **A scenario that cannot stage is refused before anything is cleared,** with its failures listed.
|
||||
- **The catalog stays read-only at runtime** (`AetheriaStores.cs:13-21`).
|
||||
|
||||
### 0.4 Not in scope
|
||||
|
||||
- The full run lifecycle owner (`Run`) of `docs/headless-playground-cut.md` Cut 1 (warp, dock, save, death as one
|
||||
ServerShared owner) and its `AetherDb play` interpreter (Cut 3). This map takes over only the new-run staging
|
||||
half. The playground map is stale (anchors `1e647953`, fork S superseded by settings-globals) and must be
|
||||
re-anchored before Hands. When it lands, its `new` command stages a `Scenario` record instead of reading a
|
||||
`.play` text line.
|
||||
- Brokkr. It is not needed for any cut here: agents author scenarios headless through `AetherDb`, and the operator
|
||||
launches them from the menu. Brokkr's Unity actions (`setEditorPlayState`, `captureEditorView`, scene edits;
|
||||
`F:\Projects\Brokkr` `1357705`, read) have no way to pick a scenario in the menu. Agent-driven Unity play would
|
||||
need an Aetheria install cut plus a "launch scenario" intent. Recorded as a follow-up, not a fork.
|
||||
- The ship-purchase docking-bay gap (checklist section 8). It is a design gap in `TradeMenu.Buy` and
|
||||
`CommissionShip`, not a verification affordance. `CommissionShip` stays; `TradeMenu.Buy` is its consumer.
|
||||
- Tier colours (settings-globals Cut 1). The check is recorded as a known failure (section 5).
|
||||
- Balance and feel tuning. A check can record a feel call; it does not tune.
|
||||
|
||||
---
|
||||
|
||||
## 1. Body findings
|
||||
|
||||
### 1.1 The new-run path today (read)
|
||||
|
||||
| Concern | Anchor | Notes |
|
||||
|---|---|---|
|
||||
| Menu | `MainMenu.cs:92-184` | Continue `:103-108`; New Game `:110-176`; Settings; Quit. The same component runs in-game (`InGame`, `:96`), so the menu reappears on death (`ActionGameManager.cs:1171`). |
|
||||
| Clear the run | `MainMenu.cs:113` | `RunSave.Clear` at click time, before the galaxy is built. |
|
||||
| Galaxy | `MainMenu.cs:124-175` | `TutorialPassed` is never set anywhere, so New Game always takes the prelude branch `:146-175`. The background noise position comes from `UnityEngine.Random` (`:128,153`). The seed defaults to the clock (`Galaxy.cs:106,158`). |
|
||||
| Handoff | statics `ActionGameManager.CurrentGalaxy`, `IsTutorial` (`:96-97`) | read by `StartGame`, `SectorMap`, and nulled by `Die` (`:1173`). |
|
||||
| Start | `StartGame` `:796-834`, called from `Start` `:491` | New run `:803-815`: `PopulateLevel(Entrance)`, `LoadoutGenerator.GenerateShipLoadout` filtered by `GameSettings.StartingHullName` (`GameSettings.cs:13`, authored `LonginusX`), unpack, `Zone.Entities.Add`, `Activate`, `BindToEntity`. Continue `:817-833`. |
|
||||
| Zone entry | `PopulateLevel` `:710-744` | generates the pack lazily (`:714-722`), moves the pilot (`:731-737`). |
|
||||
|
||||
### 1.2 What a scenario can reuse (read, one probe)
|
||||
|
||||
- **Loadout presets already exist.** `aetheria.loadout` (`Loadout.cs:13-20`) holds a hull design, per-cell slot
|
||||
designs with rotation, and weapon groups. It is a catalog type (`AetheriaStores.cs:9`), authored in Studio or by
|
||||
the editor console command `capturepreset` (`ActionGameManager.cs:624-662`, `Loadouts.Commit` `Loadout.cs:70-87`).
|
||||
`Loadouts.Materialize` (`:96-159`) builds a live `Ship` all-or-nothing, listing every failure.
|
||||
- **No game path calls `Materialize`** (`LoadoutGenerator.cs:152-153` says so; only `LoadoutTests.cs:310,899`
|
||||
call it).
|
||||
- **(probe)** The live catalog holds no preset: the schema name `aetheria.loadout` does not occur in
|
||||
`GameData/Aetheria.cc` (12,698,108 bytes at `dcd7bbc5`), while every populated type's name does (for example
|
||||
`aetheria.hulldata`, `aetheria.weaponitemdata`). Method: `grep -a -o` over the file.
|
||||
- `Materialize` always builds a `Ship` (`:131`). A turret hull cannot be materialized.
|
||||
- It resolves every design through a product (`Resolve`, `:103-115`). A design with no product fails.
|
||||
- **Unbranded lots exist.** `ItemManager.CreateLot(design, maker, quality)` (`ItemManager.cs:161`) with no maker is
|
||||
how `give` made its items (`ActionGameManager.cs:538,542`). Provenance's "no Manufacturer row" check depends on
|
||||
them.
|
||||
- **Economy exclusion follows from products.** Generation iterates products and requires
|
||||
`product.Manufacturer.IsSet()` and `design.Price > 0` (`LoadoutGenerator.cs:126-133`). A design with no product
|
||||
is never generated, stocked or sold. Loot is what a killed entity carries (`EntityInstance.cs:302-321`), so it
|
||||
cannot leak through loot either unless a scenario fits it.
|
||||
- **Prelude galaxies offer every product.** `IsAvailable` returns true when `Galaxy.IsPrelude`
|
||||
(`LoadoutGenerator.cs:154-156`). A preset materialized in a prelude arena never fails on faction availability.
|
||||
- **Agents are made only at zone construction.** `Zone`'s constructor gives every packed non-player `Ship` a
|
||||
`Minion` (`Zone.cs:120-131`, `CreateAgent` `:135-142`). An entity added later gets none. A `Minion` targets the
|
||||
first visible enemy and fights (`Minion.cs`).
|
||||
- **An entity joins a zone in four other places,** each by hand: `spawnturret` (`ActionGameManager.cs:587`),
|
||||
`PopulateLevel` (`:735`), `StartGame` (`:813`) and `Entity.TryUndock` (`Entity.cs:1006`).
|
||||
- **IFF overrides are entity-local and unsaved.** `Entity.SetIff(other, bool?)` (`Entity.cs:529-533`) decides
|
||||
`IsHostileTo` ahead of faction rules (`:535-552`). A `Materialize`d ship has no faction, so it is neutral unless
|
||||
overridden.
|
||||
- **A target that dies and a target that leaves are the same case in fire control.**
|
||||
`targetGone = shot.Target != null && !zone.Entities.Contains(shot.Target)` (`FireControl.cs:610`), and death
|
||||
removes the entity from `Zone.Entities` (`Zone.cs:93`). Check A.3 ("the target warps away") is therefore set up by
|
||||
killing a fragile target while a fused round is in flight. No departure machinery is needed.
|
||||
- **An orbital entity with no orbit stays where it is put** (`OrbitalEntity.cs` `Update`: position follows the
|
||||
orbit only when one is set). That is how `spawnturret` placed turrets (`ActionGameManager.cs:583-588`).
|
||||
- **Headless tests already open the live catalog and the authored settings**
|
||||
(`RestoredHullsTests.cs`: `AuthoredSettings.Load`, `OpenReadOnlyRealCatalog`). A staging test can generate a
|
||||
prelude galaxy, build the arena zone and stage a scenario with no Unity.
|
||||
|
||||
### 1.3 Debug affordances a scenario replaces (read)
|
||||
|
||||
| Affordance | Anchor | Added for |
|
||||
|---|---|---|
|
||||
| `give <name>` | `ActionGameManager.cs:515-544` | ad hoc items; the hull route through `CommissionShip` was added tonight in `f935c29b` for step 7 |
|
||||
| `spawnturret` | `:564-589` | a hostile turret next to the player |
|
||||
| Neutral wanderers | `ZoneGenerator.cs:342-356`, `EligibleWandererFactions` `:361-365`, `ZoneGenerationSettings.NeutralWandererCount` (`Settings.cs:156`), tests `IffAndCombatTests.cs:329-350` | commit `f732cff9` (2026-09-17): "Spawn neutral wanderers so combat has something non-hostile to target". The code comment calls it a "Testing affordance". Every generated zone carries two. |
|
||||
|
||||
Staying, because no scenario replaces them: `iff` (flip a live target's stance mid-play), `trackmissile` (camera),
|
||||
`revealzones` (map), `tow` (a verb bound to the console), `capturepreset` (the in-play authoring tool for presets).
|
||||
|
||||
### 1.4 Collisions with open branches (read)
|
||||
|
||||
- `codex/mining` rewrites `Zone.cs` (+239/-). Cut 1 edits the constructor loop and adds the admission primitive.
|
||||
Land Cut 1 after mining merges, or re-anchor.
|
||||
- `codex/moddable-ships` edits `AetheriaStores.cs` (line 9, the catalog type list). Cuts 1 and 3 edit the same
|
||||
lines.
|
||||
- `codex/item-provenance` carries the narrative map, which edits `MainMenu.cs:132,160` and the `Galaxy`
|
||||
constructors. Cut 2 edits the same New Game block.
|
||||
|
||||
---
|
||||
|
||||
## 0b. Identity, lifecycle, authority
|
||||
|
||||
No cut is mapped against an empty cell.
|
||||
|
||||
| Kind | What names it | Lifecycle | Who decides |
|
||||
|---|---|---|---|
|
||||
| **Scenario** (`aetheria.scenario`, catalog) | `CultName` `Name`; key `scenario:<Name>`, derived like `Loadouts.KeyOf` | Authored, then edited in place. A rename is a new record; the old one is deleted, and the checks that pointed at it are repointed in the same commit. A result never points at a scenario (it points at a check), so history survives. A scenario whose presets stop materializing is caught by the staging test (Cut 4), not at play time. | Authored by agents through `AetherDb` or by the operator in Studio. The operator owns what an arena contains. |
|
||||
| **Loadout preset** (`aetheria.loadout`, existing) | key `loadout:<Name>` (`Loadout.cs:62`) | Unchanged: authored, replaced only explicitly (`Commit(..., replace)`). | Unchanged. |
|
||||
| **Test design** (catalog `ItemData`, no product) | name; key minted by `Upsert` | Authored with the scenario that needs it. Lives as long as a preset references it. Per Q3. | Operator (Q3) on whether they exist at all. |
|
||||
| **Check** (`aetheria.check`, ledger store) | `CultName` `Slug`; key `check:<Slug>` | Authored. Its statement is edited in place when a ruling changes (git keeps the history). It is retired, never deleted, once any result references it: `Retired` plus a reason. | The rule's owner (a ruling or a map) decides what it says. Agents transcribe it with a source pointer. |
|
||||
| **Check result** (`aetheria.checkresult`, ledger store) | key `checkresult:<Slug>:<At as UTC ticks>` | Append-only. Never edited or deleted. A correction is a new result whose note says what it corrects. The latest by `At` is the current status. Order is carried in the data (`At`), not in delivery. | The operator's observation. Who writes the record is Q2. |
|
||||
| **Pending scenario** (runtime) | `ActionGameManager.PendingScenario`, a static | Written once by the menu's launch, read and nulled once by `StartGame`'s new-run branch. Null for Continue. Never saved. | Command-only transport. It decides nothing. |
|
||||
| **Staged entities** (runtime, then run state) | ordinary entities | Born at staging. From then on they are run state and saved with the zone like any other entity. Two things are not saved: whether a ship was left unpiloted, and scenario IFF overrides. After Continue, an unpiloted scenario ship gets a `Minion` by the constructor rule and its stance reverts to faction rules (neutral, since presets carry no faction). A scenario run is meant to be played through in one sitting. | `RunStart` at birth; the zone afterwards. |
|
||||
|
||||
---
|
||||
|
||||
## 2. Target shape
|
||||
|
||||
### 2.1 Types (names and rules; bodies are Hands')
|
||||
|
||||
`Assets/Scripts/ServerShared/Scenario.cs`, catalog:
|
||||
|
||||
- `Scenario` (`aetheria.scenario` v1):
|
||||
- `Name` (`CultName`).
|
||||
- `Brief`: the conditions in one or two lines, shown in the menu.
|
||||
- `Seed` (`uint`): the arena galaxy and the background noise both derive from it, so the arena is the same layout
|
||||
every launch. Combat rolls are already zone-seeded (`Zone.cs:84`). Lot quality still comes from the
|
||||
clock-seeded `ItemManager.Random` (`ItemManager.cs:20`), so stats vary slightly per launch. Accepted.
|
||||
- `Ambient` (`bool`): true keeps the arena zone as generated. False keeps planets, orbits and stations but drops
|
||||
generated ships and turrets, so nothing wanders into the conditions.
|
||||
- `Player` (`ScenarioShip`).
|
||||
- `Entities` (`List<ScenarioEntity>`).
|
||||
- `ScenarioShip`: `Loadout` (`CultRecordRef<Loadout>`), `Position` (`float2`, zone xz), `Direction` (`float2`),
|
||||
`Cargo` (`List<CultRecordRef<EquippableItemData>>`, stored in the first cargo bay).
|
||||
- `ScenarioEntity : ScenarioShip`: `Stance` (`Neutral | Hostile`, applied both ways through `SetIff`) and `Piloted`
|
||||
(`bool`: a `Minion`, or no agent at all).
|
||||
- A preset's hull type picks the entity class: a ship hull gives a `Ship`; a turret hull gives an orbital entity
|
||||
with no orbit, stationary at its position. A station hull is refused as a staging failure.
|
||||
|
||||
`Assets/Scripts/ServerShared/Checks.cs`, ledger store (`GameData/Checks.cc`, committed, LFS by the existing
|
||||
`GameData/*.cc` rule):
|
||||
|
||||
- `Check` (`aetheria.check` v1): `Slug` (`CultName`), `Statement` (what to do and what must be observed),
|
||||
`Source` (the ruling or map pointer, `doc:line`), `Scenario` (`CultRecordRef<Scenario>`, optional), `Setup`
|
||||
(text, only when there is no scenario: "FieldShieldTest scene", "CultCache Studio", "Addressables play mode Use
|
||||
Existing Build"), `Retired` and `RetiredReason`.
|
||||
- `CheckResult` (`aetheria.checkresult` v1): `Check` (ref), `Result` (`Pass | Fail | Partial | Blocked`),
|
||||
`Revision` (the commit the operator played, plus `+dirty` when the tree had changes), `At` (UTC), `Note`,
|
||||
`Recorder`.
|
||||
|
||||
Naming: "check", not "behaviour". `Behavior` is already the gear-behaviour type family
|
||||
(`Assets/Scripts/ServerShared/Behaviors/`), and a document named `Behaviour` beside it reads as a typo.
|
||||
|
||||
Where they live, and why:
|
||||
- Scenarios, presets and test designs are design-side fixtures. They go in the catalog: presets are already
|
||||
catalog data, cross-type refs resolve inside one store, and Studio edits them side by side.
|
||||
- Checks and results are the verification ledger. They go in their own store. The shipped catalog carries no
|
||||
history, results never trigger a catalog write, and "one commit lands in one store" holds: recording a result
|
||||
touches the ledger only.
|
||||
|
||||
### 2.2 The staging owner
|
||||
|
||||
**Owner: `RunStart`, a static class in `Assets/Scripts/ServerShared/RunStart.cs`.** It decides what a new run
|
||||
starts with: how the arena zone is generated, the player ship, the other entities, their stance, pilot and cargo.
|
||||
It holds no Unity type.
|
||||
|
||||
- **Inputs:** `ItemManager` (and through it the catalog), the `Galaxy`, `ZoneGenerationSettings`, the optional
|
||||
`Scenario`, and, for the absent-scenario case, the default hull filter and faction `StartGame` uses today
|
||||
(`:805-809`).
|
||||
- **Outputs:**
|
||||
- the arena's `ZonePack`, with the `Ambient` rule applied inside generation (`ZoneGenerator.GenerateZone`
|
||||
gains the parameter), not generated and then pruned;
|
||||
- the admitted player `Ship`, flagged `IsPlayerShip`;
|
||||
- the admitted scenario entities;
|
||||
- a failure list. Staging is all-or-nothing, as `Materialize` is.
|
||||
- **A check entry** that validates a scenario without a zone (every preset materializes, every cargo design
|
||||
exists). The menu calls it before `RunSave.Clear`; the staging tests call it on every catalog scenario.
|
||||
- **Derived state:** `ActionGameManager.CurrentEntity` is bound to the returned player. `PendingScenario` is
|
||||
transport only.
|
||||
- **Forbidden writers:** `StartGame` may not generate, unpack or admit the player ship. `MainMenu` may not stage.
|
||||
No console command admits entities (`give` and `spawnturret` die, Q4).
|
||||
- **Shared paths:** New Game and scenario launch both run menu, galaxy, `StartGame`, `RunStart`. Continue does not
|
||||
stage.
|
||||
- **Deletion line:** `StartGame` `:805-814` (generator, unpack, add, activate). The only surviving line is the
|
||||
bind.
|
||||
|
||||
**Admission primitive: `Zone.Admit(Entity entity, bool piloted)`.** It adds the entity to `Entities`, activates it,
|
||||
and, when `piloted`, gives it the zone's `Minion` (the `CreateAgent` rule, `Zone.cs:135-142`). It is the only writer
|
||||
of `Entities.Add` and the only creator of agents.
|
||||
- The constructor loop (`:120-131`) calls it with `piloted: ship && !IsPlayerShip`. It keeps its own rule that
|
||||
moves a ship packed at the origin (`:129-130`); that is generation placement, not admission.
|
||||
- `PopulateLevel` (`ActionGameManager.cs:735`), `Entity.TryUndock` (`Entity.cs:1006-1007`) and `RunStart` call it.
|
||||
`spawnturret` (`:587`) is deleted.
|
||||
- The `Death` subscription (`Zone.cs:93`) stays on `ObserveAdd` and still covers every join.
|
||||
|
||||
**`Loadouts.Materialize` gains two rules** (`Loadout.cs:96-159`):
|
||||
- A design with **no product at all** is built unbranded, through `CreateLot(design, default, quality)` at one
|
||||
named quality constant (0.95, the quality `give` used). A design whose products are all unavailable still fails,
|
||||
as today. The rule turns "no manufacturer makes it" into "outside the economy", which generation already obeys.
|
||||
- The **hull type picks the entity class** (section 2.1).
|
||||
- The comment at `LoadoutGenerator.cs:150-153` ("No game path materializes a preset yet") is rewritten to name
|
||||
`RunStart`.
|
||||
|
||||
### 2.3 The Unity lowering
|
||||
|
||||
- `MainMenu.ShowMain` (`:92-184`) gains **Scenarios**, shown when `Debug.isDebugBuild` (editor and development
|
||||
builds). It opens a panel with one button per catalog scenario, ordered by name. Under each button is its brief
|
||||
and its checks, each with its latest result and revision, read from the ledger (display only). A scenario whose
|
||||
check entry fails shows the failures and is disabled.
|
||||
- **One launch body** is extracted from the New Game lambda (`:110-176`). New Game calls it with no scenario; a
|
||||
scenario button calls it with one. With a scenario, it runs the prelude branch (`:146-175`) with `Seed`, derives
|
||||
the noise position from `Seed` instead of `UnityEngine.Random`, sets `PendingScenario`, and loads `ARPG`. The
|
||||
check entry runs first; `RunSave.Clear` (`:113`) moves after it, so a refused scenario leaves the saved run intact.
|
||||
- `StartGame`'s new-run branch (`:803-815`) calls `RunStart`, binds the returned player and nulls
|
||||
`PendingScenario`. The Continue branch asserts it is null.
|
||||
- `AetheriaStores.Open` gains an optional ledger path. The game attaches `GameData/Checks.cc` read-only; `AetherDb`
|
||||
attaches it writable for the record commands (Cut 3).
|
||||
|
||||
### 2.4 Authoring
|
||||
|
||||
- **Agents author headless through `AetherDb`.** A seed command (Cut 4) declares the first set in C#. It writes a
|
||||
record only when the key is absent. When the key exists and differs from what it would write, it refuses and
|
||||
reports; that means Studio edited it, and Studio wins. When the key exists and matches, it does nothing. It
|
||||
validates every scenario through the `RunStart` check entry before committing. So the catalog is the authority,
|
||||
and the seed code never clobbers it.
|
||||
- **The operator authors in Studio and in play:** Studio for scenario fields; `capturepreset` for a ship fitted by
|
||||
hand in play.
|
||||
- Results are recorded per Q2.
|
||||
|
||||
---
|
||||
|
||||
## 3. Cuts
|
||||
|
||||
Build budget, every cut:
|
||||
- `Aetheria.Shared` (netstandard2.1, the Unity-independence check), `tests/Aetheria.Shared.Tests`, `tools/AetherDb`
|
||||
(net10.0), Debug.
|
||||
- CultLib is unchanged; the pins are those in `hands-fuse8/run.sh`.
|
||||
- No new project, target, package or daemon. One new store file (`GameData/Checks.cc`), three new schemas.
|
||||
- **Build host:** Yggdrasil builds the headless projects (`run.sh <rev>`). `Assembly-CSharp` is proven only by a
|
||||
Unity 6000.3.24f1 batchmode compile on Starfire, with the editor closed by the operator. Never kill Unity.
|
||||
- `run.sh` mounts a pinned `data/Aetheria.cc` over the tree's LFS file. Any cut that changes the catalog (Cut 4)
|
||||
must refresh that pin, or its content tests read the old catalog. Cut 4's tests that read the ledger mount it the
|
||||
same way. Yggdrasil's disk is saturated: one job per cut, `--artifacts-path` in the container.
|
||||
|
||||
Order: 0, 1, 2, 3, 4. Cut 0 is subtraction alone, so Soul can falsify it alone. Cuts 1 and 3 are headless. Cut 2
|
||||
is the only Unity-side cut. Cut 4 is content.
|
||||
|
||||
### Cut 0. Retire the ad hoc test affordances (Q4)
|
||||
|
||||
- **Repo/branch:** Aetheria, `codex/scenarios` from `master` `dcd7bbc5`.
|
||||
- **Deletes first** (per Q4 A; B keeps the item branch of `give` and the wanderers):
|
||||
- `ActionGameManager.cs:515-544`, `give` (30 lines).
|
||||
- `ActionGameManager.cs:564-589`, `spawnturret` (26 lines).
|
||||
- `ZoneGenerator.cs:342-356`, neutral wanderers (15 lines), and `EligibleWandererFactions` `:361-365` (5).
|
||||
- `Settings.cs:156`, `NeutralWandererCount` (1). It is absent from `Settings.asset` (settings-globals `:72`), so
|
||||
no asset edit is needed.
|
||||
- `IffAndCombatTests.cs:329-350`, the two wanderer tests (22).
|
||||
- **Keeps:** `CommissionShip` (`:898-903`) and its consumer `TradeMenu.Buy`; the console fixes in `f935c29b`.
|
||||
- **Docs:** `docs/merge-to-master-checklist.md` section 8, the `give` bullet: add "retired by the scenarios cut"
|
||||
with the commit. `docs/settings-globals-cut.md:72,348` get a one-line history note.
|
||||
- **Verification:**
|
||||
- builds: `Aetheria.Shared`, the test project. Batchmode compile (`ActionGameManager.cs` changed).
|
||||
- tests: the full suite is green. The locomotion "real enemy-count check" (`95394f78`) counts generated ships;
|
||||
if it counted wanderers, fix its expectation and say so.
|
||||
- negative: `rg -n '"give"|"spawnturret"' Assets/Scripts` is empty;
|
||||
`rg -n "NeutralWanderer|EligibleWandererFactions" Assets tests tools` is empty. Both patterns were checked to
|
||||
match only these sites today.
|
||||
- operator: none. There is nothing to see until Cut 2.
|
||||
- **Ledger:** about -99 lines; 0 added.
|
||||
|
||||
### Cut 1. `RunStart`, `Zone.Admit`, and the scenario type (headless)
|
||||
|
||||
- **Repo/branch:** Aetheria `codex/scenarios`, on Cut 0. Re-anchor `Zone.cs` if mining has merged.
|
||||
- **First:** with `AetherDb hardpoint-fit` and a scratch `Materialize` against the live catalog, confirm that
|
||||
`Djinni`, `LonginusX` and one turret hull each have a product and materialize bare. If one has no product, stop
|
||||
and report: the Q3 rule would make it unbranded, which may not be intended for a real hull.
|
||||
- **Deletes first:**
|
||||
- `ActionGameManager.cs:805-814`, the new-run spawn (it moves into `RunStart`; this cut leaves `StartGame`
|
||||
calling `RunStart` with no scenario, so behaviour is unchanged).
|
||||
- The four hand-written joins: `ActionGameManager.cs:735-736`, `Entity.cs:1006-1007`, `Zone.cs:124-125`, and the
|
||||
agent add at `Zone.cs:128`. Each becomes `Admit`.
|
||||
- **Adds:** `Scenario.cs`, `RunStart.cs`, `Zone.Admit`, the `ambient` parameter on `ZoneGenerator.GenerateZone`
|
||||
(`:38-43`; the ship loop `:334-340` and `PlaceTurrets` calls `:309,331` honour it), `Scenario` in
|
||||
`AetheriaStores.CatalogTypes` (`:9`), and the two `Materialize` rules (`Loadout.cs:103-115,131`).
|
||||
- **Authority map:** section 2.2. Owner `RunStart`; admission `Zone.Admit`; deletion line as above.
|
||||
- **Verification:**
|
||||
- builds: `Aetheria.Shared`, tests, `AetherDb`. Batchmode compile (`ActionGameManager.cs`, `Entity.cs` changed).
|
||||
- tests (new `RunStartTests`: live catalog, authored settings, a prelude galaxy at a fixed seed). Each rule
|
||||
must fail under its own mutation:
|
||||
- With no scenario, staging yields a player of the `StartingHullName` hull, `IsPlayerShip`, admitted, at the
|
||||
origin. This pins that New Game is unchanged.
|
||||
- With a scenario, the player is the preset's hull and fit at the authored position and direction, and its
|
||||
cargo holds the listed designs.
|
||||
- A piloted entity has exactly one agent in `Zone.Agents`; an unpiloted one has none and stays put over 5 s of
|
||||
`Zone.Update`.
|
||||
- `Hostile` makes both `IsHostileTo` directions true. `Neutral` makes both false.
|
||||
- `Ambient: false` leaves no ship or turret in the arena pack that the scenario did not place. Stations remain.
|
||||
- A turret preset stages as a stationary orbital entity. A station preset is a staging failure.
|
||||
- A scenario naming a missing design fails with that design named. The zone is unchanged, and no
|
||||
`RunSave` call was made (the check entry touches no store).
|
||||
- A product-less design materializes unbranded; a design whose only product is unavailable still fails.
|
||||
This is two tests, because the second case is the existing contract.
|
||||
- `Admit` is the only agent creator: after a warp (`PopulateLevel`'s join through `Admit(pilot, false)`) the
|
||||
pilot has no agent. The constructor's pack path still gives every non-player ship a `Minion`.
|
||||
- Stryker on `RunStart.cs`, `Zone.cs` (`Admit` and the constructor loop), `Loadout.cs` (`Materialize`), scoped
|
||||
to the diff. Triage survivors by name.
|
||||
- negative: `rg -n "Entities\.Add\(" Assets/Scripts --glob '!**/ZoneGenerator.cs'` matches only
|
||||
`Zone.cs` (once, inside `Admit`), `Sensor.cs:169` and `Entity.cs:242` (both are `VisibleEntities`/pings, not
|
||||
zones). `rg -n "new Minion\(" Assets/Scripts` matches only `Zone.cs`.
|
||||
- operator: none beyond the Cut 2 smoke.
|
||||
- **Ledger:** `Scenario.cs` +60; `RunStart.cs` +110; `Zone` +12 -8; `Loadout.cs` +20; `ZoneGenerator` +4;
|
||||
`ActionGameManager` -11 +4; `Entity` ±2; `AetheriaStores` ±1; tests +300.
|
||||
|
||||
### Cut 2. The main menu launches scenarios (Unity)
|
||||
|
||||
- **Repo/branch:** Aetheria `codex/scenarios`, on Cut 1.
|
||||
- **Deletes first:** the duplicated body of the two galaxy branches in the New Game lambda (`MainMenu.cs:124-175`)
|
||||
collapses into one launch body. The standard branch (`:124-145`) is live code only when `TutorialPassed` is
|
||||
true, and it is kept. Only the duplication goes.
|
||||
- **Adds:** the Scenarios panel, `PendingScenario`, the seed-derived noise, the check entry before
|
||||
`RunSave.Clear`. `StartGame` passes `PendingScenario` to `RunStart`.
|
||||
- **Authority map:**
|
||||
- Owner of what the run starts with: `RunStart` (unchanged).
|
||||
- `MainMenu` owns which scenario was picked and when the run is cleared. `PendingScenario` is a command-only
|
||||
transport, consumed once.
|
||||
- Forbidden: `MainMenu` stages nothing and admits nothing. `StartGame` reads `PendingScenario` only in the
|
||||
new-run branch.
|
||||
- Shared paths: both buttons run one launch body. In-game menu (after death) and title menu run the same one.
|
||||
- **Verification:**
|
||||
- builds: batchmode compile, editor closed.
|
||||
- negative: `rg -n "RunSave\.Clear" Assets/Scripts/UI/MainMenu.cs` appears once, after the check entry.
|
||||
`rg -n "PendingScenario\s*=" Assets/Scripts` matches the launch body and `StartGame`'s null only.
|
||||
- operator (Unity, Starfire):
|
||||
1. Title menu: Scenarios is listed. New Game still starts a LonginusX at the entrance with a Zenith station
|
||||
(the Cut 1 test pins the ship; this proves the lowering).
|
||||
2. Launch any scenario. The arena matches its brief; launch it again and the layout is the same.
|
||||
3. Die in a scenario. From the in-game menu, relaunch the same scenario.
|
||||
4. Quit mid-scenario, then Continue. The run continues (the 0b rule: unpiloted ships now patrol).
|
||||
5. Break a scenario on purpose in a scratch catalog (a missing design). It is shown disabled with the failure,
|
||||
and Continue still offers the previous run.
|
||||
- **Ledger:** `MainMenu` +45 -25; `ActionGameManager` +4; one static.
|
||||
|
||||
### Cut 3. The verification ledger (headless; Q2)
|
||||
|
||||
- **Repo/branch:** Aetheria `codex/scenarios`, on Cut 1 (independent of Cut 2).
|
||||
- **Adds:** `Checks.cs` (`Check`, `CheckResult`); `AetheriaStores.LedgerTypes` and the optional path;
|
||||
`GameData/Checks.cc` (empty, committed).
|
||||
- Under Q2 B, `AetherDb` gains two commands:
|
||||
- `checks [scenario]`: each check with its latest result, its revision, and "never" when there is none.
|
||||
- `record <slug> <pass|fail|partial|blocked> --revision <sha> [--note <text>]`. It refuses an unknown or
|
||||
retired slug. It opens the ledger writable and the catalog read-only.
|
||||
- Under Q2 A, the menu panel gains Pass/Fail/Partial and a note field per check. It writes through the same
|
||||
ledger primitive, and the game attaches the ledger writable.
|
||||
- **Authority map:**
|
||||
- Owner of results: the ledger store. The only writer is the Q2 writer, which calls one append primitive,
|
||||
`Ledger.Record`.
|
||||
- Derived, display only: the menu's latest-status line and `checks`' output.
|
||||
- Forbidden: nothing edits or deletes a `CheckResult`; nothing writes a result into the catalog.
|
||||
- **Verification:**
|
||||
- tests (new `LedgerTests`, temp stores):
|
||||
- Recording appends and never replaces: two results for one check both survive a reopen, and the latest is
|
||||
the one with the later `At`, even when written first.
|
||||
- A retired or unknown slug is refused with nothing written.
|
||||
- The catalog file is byte-identical after `record` (a catalog opened read-only cannot be written; this pins
|
||||
that the command opened it that way).
|
||||
- A result carries the revision it was given, and `record` without `--revision` is a usage error.
|
||||
- Stryker on `Checks.cs` and the `AetherDb` record path.
|
||||
- negative: `rg -n "CheckResult" Assets/Scripts --glob '!**/Checks.cs'` matches only the menu's read (and under
|
||||
Q2 A its record call).
|
||||
- **Ledger:** `Checks.cs` +50; `AetheriaStores` +4; `AetherDb` +90 (B) or `MainMenu` +50 (A); tests +120.
|
||||
|
||||
### Cut 4. The first scenarios, checks and history (content)
|
||||
|
||||
- **Repo/branch:** Aetheria `codex/scenarios`, on Cuts 2 and 3. Hands authors on the branch clone, never in
|
||||
`F:\Projects\Aetheria`.
|
||||
- **First:** tell the operator that the uncommitted smoke weapons in their tree's `GameData/Aetheria.cc` must be
|
||||
restored (`git checkout -- GameData/Aetheria.cc`, their own command) before they pull. This cut recreates them as
|
||||
committed designs.
|
||||
- **Adds:**
|
||||
- A transient `AetherDb scenario-seed [apply]` command, with the never-clobber rule of section 2.4.
|
||||
- It writes the test designs (section 5.3), the presets (5.4), the scenarios (5.2) and the checks (5.1).
|
||||
- It imports the 2026-09-30 smoke results (checklist section 8) as `CheckResult`s at revision `113164fa`,
|
||||
recorder "operator (play), recorded by agent".
|
||||
- It runs once, the data is committed, and the command is deleted in the same cut. The catalog is the authority
|
||||
from then on.
|
||||
- `ScenarioConditionTests` (live catalog; pinned catalog refreshed, see the build budget). Per scenario, stage it
|
||||
and assert the conditions its checks need, not the behaviour, which existing suites own. For example:
|
||||
- `Fused rounds`: the bare hull lies within the arc on the player's initial aim line and has no target
|
||||
selected; the close hull is nearer than `Smoke Proximity`'s `BlastRadius`; `Smoke Refused` has
|
||||
`Range < BlastRadius`; a direct-fire weapon can kill the fragile hull.
|
||||
- `Duel`: the AI is piloted, hostile both ways, and carries a slow missile weapon; the player can see it.
|
||||
- `Arcs`: the three bare hulls lie in the bow, beam and stern sectors of the player's mounts; the turret is
|
||||
hostile.
|
||||
- Every catalog scenario passes the check entry. This is the rot test.
|
||||
- Every non-retired check with a scenario points at an existing one. Every check without a scenario has a
|
||||
`Setup`.
|
||||
- Docs: `docs/merge-to-master-checklist.md` sections 2 and 8 get one line: steps 7-20 and handoff checks A-F are
|
||||
now checks in `GameData/Checks.cc`, listed by `AetherDb checks`. The prose steps stay as history.
|
||||
- **Verification:**
|
||||
- tests: `ScenarioConditionTests`, with mutation by editing a fixture. Moving the close hull outside the blast
|
||||
radius, dropping the AI's missile weapon, or flipping a stance must each fail its condition. This is a one-off
|
||||
Soul probe, not a committed suite.
|
||||
- `AetherDb checks` lists every check in section 5.1, with the imported results on 3, 4, 5, 6 and "never"
|
||||
elsewhere.
|
||||
- operator: play each scenario and report per check. That report is the first real use of the ledger.
|
||||
- **Ledger:** seed command +300 then -300; catalog +5 designs, +11 presets, +10 scenarios; ledger +44 checks, +7
|
||||
results; tests +250; docs ±4.
|
||||
|
||||
---
|
||||
|
||||
## 4. Authority map (whole campaign)
|
||||
|
||||
- **Owner of a new run's contents:** `RunStart`. It reads the scenario (or its absence) and writes the arena pack
|
||||
and the admitted entities.
|
||||
- **Owner of zone membership and agents:** `Zone.Admit`.
|
||||
- **Owner of fixtures:** the catalog (`Scenario`, `Loadout`, test designs), written by the seed, Studio or
|
||||
`capturepreset`, and read-only at runtime.
|
||||
- **Owner of verification history:** the ledger store. It is append-only and written by the Q2 writer.
|
||||
- **Derived:** menu status lines; `AetherDb checks`; `PendingScenario` (transport).
|
||||
- **Forbidden writers:** `StartGame` spawning ships; `MainMenu` staging; console commands admitting entities;
|
||||
anything editing a result; any catalog write at runtime.
|
||||
- **Shared paths:** New Game and every scenario launch: one launch body, `StartGame`, `RunStart`, `Admit`. Warp,
|
||||
undock, construction and staging: `Admit`.
|
||||
- **Deletion line:** Cut 0's affordances; `StartGame` `:805-814`; the four hand-written joins; the duplicated New
|
||||
Game branches; the transient seed command.
|
||||
|
||||
---
|
||||
|
||||
## 5. The first consumers
|
||||
|
||||
Sources: `docs/merge-to-master-checklist.md` section 2 (steps 7-20) and section 8; checks A-F from
|
||||
`F:\Projects\HANDOFF-aetheria-play-smoke-2026-09-29.md` section 3. That file sits outside the repo, so the checks
|
||||
below restate A-F and the ledger becomes their home. The rulings behind A-F are in `fire-control-cut.md`, in the
|
||||
block "Ruled (operator, 2026-09-30)" (`:2625-2690`).
|
||||
|
||||
### 5.1 Checks
|
||||
|
||||
| Slug | Statement (abridged; the record carries the full text) | Source | Setup |
|
||||
|---|---|---|---|
|
||||
| `restored-hull-flies` | Thrusters move and turn the Djinni. | step 7; `locomotion-cut.md:501` | Djinni shakedown |
|
||||
| `restored-hull-speed-cap` | Take the hull offline with thrusters firing; speed does not run away. | step 7; `:377` | Djinni shakedown |
|
||||
| `weak-reactor-starves-legibly` | A reactor too small for the loadout shows starvation, not a cooked reactor. | step 8; `stats-and-power-cut.md:705-706` | Starved reactor |
|
||||
| `brownout-degrades` | Brownout reads as degradation, not breakage. | step 9; `:774,990` | Starved reactor |
|
||||
| `brownout-refill-stutters` | A weapon refilling under brownout stutters rather than firing at full rate. | step 9; `:729-730` | Starved reactor |
|
||||
| `memory-flat-across-zones` | Several zones with kills; memory does not climb. | step 10; `:672-673,980-982` | Long haul |
|
||||
| `side-mounts-fire-abeam` | Side-mounted weapons fire at the beam target. | step 11; `fire-control-cut.md:397-398` | Arcs |
|
||||
| `turret-tracks-round` | The hostile turret tracks the player all the way round. | step 11 | Arcs |
|
||||
| `no-fire-through-hull` | Nothing fires at the stern target through the hull. | step 11 | Arcs |
|
||||
| `shots-roll` | Rolled impacts and misses; a miss reads as a near-miss; damage matches the HUD. | step 12; `:659-661` | Duel |
|
||||
| `subsystem-aim` | Reveal and selection work; aiming at a revealed subsystem concentrates damage. | step 12 | Duel |
|
||||
| `kill-drops-loot` | The kill drops its cargo; pickup stores it; the tractor beam pulls. | step 12; `headless-playground-cut.md:789-794` | Duel |
|
||||
| `loot-keeps-brand` | Picked-up loot shows its manufacturer. | step 6; `item-provenance-cut.md:528-539` | Duel |
|
||||
| `target-vanish-safe` | The target dies with shots in flight: no crash, no frozen ship. | step 12; `fire-control-cut.md:1464-1470` | Duel |
|
||||
| `beam-reads-higher` | The HUD `hull` factor reads higher from the beam than from the bow. | step 13; `:2380-2383` | Duel |
|
||||
| `armour-face-missile` | Turn the armoured face into the AI's slow missile; it lands there. | step 13 | Duel |
|
||||
| `ai-engages` | The AI still engages normally. | D; `:2658-2660` | Duel |
|
||||
| `launcher-edge-pulse` | Launcher into the bow, then a flank: the schematic pulses the facing edge only. | step 14; `:2519-2520` | Launcher angles |
|
||||
| `guided-explodes-on-detonation` | A guided round's explosion shows only when the simulation detonated. | E | Launcher angles |
|
||||
| `guided-target-left-fades` | Kill the target while a guided round flies: the round fades with no explosion. | E | Launcher angles |
|
||||
| `guided-hit-at-target` | A guided hit plays its effect at the target. | E | Launcher angles |
|
||||
| `fused-clear-line-max-range` | Nothing selected, clear line: the round bursts at max range along the arc-clamped aim. | A.1; `:2625,2636-2642` | Fused rounds |
|
||||
| `fused-first-hull-stop` | Nothing selected, aim at the bare hull: the round stops and detonates on it. | A.2; `:2632-2634` | Fused rounds |
|
||||
| `fused-target-left-no-burst` | Fire at the fragile target, kill it with the direct weapon before arrival: no burst. | A.3; `:2636-2642`, `FireControl.cs:610` | Fused rounds |
|
||||
| `fused-out-of-arc` | Select the stern target: the round fires and bursts at its range along the arc-clamped aim. | A.4; `:2643-2645` | Fused rounds |
|
||||
| `fused-arming-pushout` | Select the close hull: the burst is pushed out to `BlastRadius` from the ship's centre. | A.5; `:2646-2653` | Fused rounds |
|
||||
| `airburst-at-model` | A proximity airburst beside the LonginusX lands damage where the model shows the blast. | step 15; `:3094-3097` | Fused rounds |
|
||||
| `penetrator-reaches-interior` | A delayed penetrator into the LonginusX nose detonates inside. | step 15 | Fused rounds |
|
||||
| `hud-forecast-fused` | The HUD shows Direct, Burst at N m or Refused for fused weapons, and a percentage for direct weapons. | C; `:2661-2663` | Fused rounds |
|
||||
| `unbranded-no-manufacturer` | An unbranded smoke weapon shows no Manufacturer row. | step 6 | Fused rounds |
|
||||
| `refused-shot-free` | A refused shot costs no ammo, energy, heat, sound, visibility or cooldown. | B; `:2664-2666` | Refused rounds |
|
||||
| `refused-beam-no-flicker` | A refused beam never starts. | B | Refused rounds |
|
||||
| `refused-charge-never-charges` | A refused charged weapon never starts charging. | B | Refused rounds |
|
||||
| `instant-and-charged-fire` | Autocannon and ChargeBlast SG fire; effects, particles and action-bar icons show. | step 5; `addressables-cut.md:362-366` | Weapon feel |
|
||||
| `burst-cadence` | Burst cadence is unchanged. | F | Weapon feel |
|
||||
| `charge-release-press` | A fast release-and-press on a charged weapon starts no second charge. | F | Weapon feel |
|
||||
| `existing-build-play` | Under "Use Existing Build", the Weapon feel checks hold (GUID keys in the player catalog). | step 20; `addressables-cut.md:367-370` | Weapon feel, Setup: play mode Use Existing Build |
|
||||
| `ai-never-fires-refused` | The hostile AI whose only weapon is refused never fires it. | D | AI fused discipline |
|
||||
| `ai-never-bomb-fishes` | The neutral AI carrying a fused weapon never fires it. | D | AI fused discipline |
|
||||
| `continue-keeps-items` | Warp, quit, Continue: same items, same tier and brand. | step 16; `item-provenance-cut.md:536-537` | Long haul |
|
||||
| `death-ends-run` | Die: Continue is disabled and `run.cc` holds no ledger. | step 17; `:540-541` | Long haul |
|
||||
| `shield-panel-rig` | The numbered shield-panel look, including the Cut 5 dicing and break-through. | step 18; `shield-panel-cut.md:683-700,737-739` | Setup: FieldShieldTest scene |
|
||||
| `studio-*` (5 checks) | The fire-control union renders; the schematic underlay; restored hull records; the fuse fields edit; the provenance ledger renders from a real `run.cc`. | step 19 | Setup: CultCache Studio |
|
||||
| `addressables-duplicates` | Analyze the duplicate dependencies: 5 known leftovers. | step 20 | Setup: Addressables Analyze |
|
||||
| `new-game-start`, `purchase-keeps-brand`, `tier-colour` | New Game; buying keeps the brand; tier colours show. | steps 3, 4, 6 | Setup: New Game |
|
||||
|
||||
Imported results (checklist section 8, revision `113164fa`, 2026-09-30):
|
||||
- `new-game-start`: pass.
|
||||
- `purchase-keeps-brand`: pass.
|
||||
- `instant-and-charged-fire`: partial ("charged weapon unprovable: 1x2 hardpoint").
|
||||
- `tier-colour`: fail ("known defect, `settings-globals-cut.md:150`; fixed by settings-globals Cut 1").
|
||||
- `unbranded-no-manufacturer`: blocked ("`give Lamp` named a test fixture").
|
||||
- `loot-keeps-brand`: no result ("not yet reported").
|
||||
|
||||
### 5.2 Scenarios
|
||||
|
||||
All use `Ambient: false` except Long haul. Positions are authored in the seed and pinned by the condition tests.
|
||||
|
||||
| Scenario | Player | Entities | Checks |
|
||||
|---|---|---|---|
|
||||
| Djinni shakedown | Djinni, full fit | none | 2 |
|
||||
| Starved reactor | a combat hull with an undersized reactor, energy weapons and a shield | 1 unpiloted bare hull ahead, neutral | 3 |
|
||||
| Arcs | a hull with side mounts | 3 unpiloted bare hulls (bow, beam, stern), neutral; 1 turret preset, hostile | 3 |
|
||||
| Duel | combat fit | 1 piloted LonginusX, hostile, carrying a slow missile weapon, cargo holding a branded item | 8 |
|
||||
| Launcher angles | GT 3K or pswarm plus a direct weapon | 1 unpiloted LonginusX, hostile; 1 fragile bare hull | 4 |
|
||||
| Fused rounds | Smoke Proximity, Smoke Delayed, a direct weapon | unpiloted: LonginusX mid range, hostile; bare hull on the clear bearing; fragile bare hull; close bare hull inside `BlastRadius`; stern target | 9 |
|
||||
| Refused rounds | Smoke Refused (instant, beam, charged) plus one working weapon | 1 unpiloted bare hull | 3 |
|
||||
| Weapon feel | a hull with a 2x2 energy hardpoint: ChargeBlast SG, Autocannon, a burst weapon | 1 unpiloted bare hull | 4 |
|
||||
| AI fused discipline | a sturdy hull | 1 piloted neutral with a fused weapon; 1 piloted hostile whose only weapon is refused | 2 |
|
||||
| Long haul | standard combat fit, `Ambient: true` | none | 3 |
|
||||
|
||||
### 5.3 Test designs (Q3)
|
||||
|
||||
None has a product. They are unbranded and outside the economy.
|
||||
- `Smoke Proximity`: Proximity, blast 8.
|
||||
- `Smoke Delayed`: Delayed, blast 4, penetration 2 cells.
|
||||
- `Smoke Refused`: Proximity, blast 30, range 20.
|
||||
|
||||
These three are the operator's own designs from tonight, Spectra clones, energy, 1x2.
|
||||
- `Smoke Refused Beam` and `Smoke Refused Charge`: a constant weapon and a charged weapon with a fuse and
|
||||
`Range < BlastRadius`.
|
||||
- All must pass `CultRecordRefs.Validate` (R-heat, stat modifiers, roles).
|
||||
|
||||
### 5.4 Presets
|
||||
|
||||
About eleven, named after their scenarios. The seed author picks designs with `AetherDb hardpoint-fit`. The only
|
||||
hard constraints are those the condition tests pin.
|
||||
|
||||
---
|
||||
|
||||
## 6. Subtraction ledger
|
||||
|
||||
| Cut | Removed | Added | Targets, schemas, stores |
|
||||
|---|---|---|---|
|
||||
| 0 | `give` 30, `spawnturret` 26, wanderers 20, setting 1, tests 22 | 0 | no change |
|
||||
| 1 | `StartGame` spawn 10, joins 6 | `Scenario.cs` 60, `RunStart.cs` 110, `Admit` 12, `Materialize` 20, `GenerateZone` 4; tests 300 | +1 schema (`aetheria.scenario`) |
|
||||
| 2 | duplicated New Game body about 25 | menu panel and launch body about 45; 1 static | none |
|
||||
| 3 | none | `Checks.cs` 50, stores 4, `AetherDb` 90 (or the menu 50); tests 120 | +2 schemas, +1 store file |
|
||||
| 4 | the seed command, once spent (300) | seed 300; condition tests 250; catalog and ledger data | catalog content, ledger content |
|
||||
|
||||
Net production code is about +250. That buys:
|
||||
- the main-menu scenario affordance;
|
||||
- typed checks with history;
|
||||
- one staging owner and one admission primitive (from five hand-written joins);
|
||||
- the first game consumer of the presets that already existed.
|
||||
|
||||
It removes three ad hoc test affordances and the wanderers that ran in every zone.
|
||||
|
||||
---
|
||||
|
||||
## 7. Operator questions
|
||||
|
||||
Each question stands alone. The first is what the scenario request leaves open.
|
||||
|
||||
**Q1. Is a scenario arena part of a real run?**
|
||||
Your words settle what an arena holds. They leave open what surrounds it. Checks 16 and 17 (warp, save,
|
||||
Continue, death) need a real run. Every other check needs only the arena.
|
||||
- **A.** The arena is the entrance zone of a small prelude galaxy built from the scenario's seed. Stations,
|
||||
planets and wormholes are there, and the run saves on warp and quit, continues and ends at death like any run.
|
||||
Launching a scenario replaces your saved run, as New Game does. Scenario-only details (unpiloted ships, forced
|
||||
stances) do not survive a Continue.
|
||||
- **B.** A sealed arena: one zone, no galaxy, no saving. Launching never touches your saved run. Checks 16 and 17
|
||||
go back to plain New Game play. This is a second zone-entry path with no galaxy under it, which `PopulateLevel`
|
||||
and the sector map do not support today.
|
||||
- **Recommended: A.** It is the same New Game path with an input, so there is no second boot path. Every rule
|
||||
under test then runs exactly as it does in a real run. Replacing the saved run seems harmless for a dev
|
||||
affordance.
|
||||
- **Depends on it:** Cut 2's launch body; the 0b lifecycle row for staged entities; whether Long haul exists.
|
||||
|
||||
**Q2. Who records a check's result, and where?**
|
||||
You play and observe. Something has to write "pass at `abc123`, note ...".
|
||||
- **A.** In game. The Scenarios panel gets Pass/Fail/Partial and a note per check. The game writes the ledger file
|
||||
in your working tree, and you commit it with your other work.
|
||||
- **B.** The agent. You tell the session what you saw, and it records typed results with `AetherDb record` on a
|
||||
branch and pushes. The menu shows each check's latest result, read-only.
|
||||
- **C.** No typed results. Checks are typed, and results go in a prose ledger doc, as checklist section 8 does now.
|
||||
- **Recommended: B.** It matches how tonight's smoke already worked: you play, the agent records. Nothing in the
|
||||
game writes a file that git tracks, and no agent needs to touch your tree. The menu still shows what is stale.
|
||||
A can be added later on the same append primitive.
|
||||
- **Depends on it:** Cut 3's writer and whether the game attaches the ledger writable.
|
||||
|
||||
**Q3. Where do test-only item designs live?**
|
||||
Checks A-C need fused weapons the catalog does not ship. Tonight they were authored in place and left
|
||||
uncommitted.
|
||||
- **A.** Committed catalog designs with no product. With no product nothing makes them, so they are never
|
||||
generated, stocked, sold or looted. A preset builds them unbranded (a new `Materialize` rule). Studio lists them
|
||||
beside real content.
|
||||
- **B.** Committed designs with a product and price 0. Generation skips price 0 today, but only through a filter
|
||||
written for another reason, so the exclusion is a coincidence.
|
||||
- **C.** A scratch catalog swapped in per session, as checklist step 2a proposed. Scenarios would then depend on
|
||||
which catalog is loaded, and the fixtures would not be retained.
|
||||
- **Recommended: A.**
|
||||
- **Depends on it:** the `Materialize` rule in Cut 1; section 5.3.
|
||||
|
||||
**Q4. Which ad hoc test affordances do scenarios retire?**
|
||||
`give` got its hull route tonight (your ruling: "mothballed ships do not require docking bays"), and step 7 was its
|
||||
reason. `spawnturret` places a turret. Neutral wanderers spawn two non-hostile ships in every generated zone, "so
|
||||
combat has something non-hostile to target" (`f732cff9`).
|
||||
- **A.** Delete all three. Scenarios cover ships, cargo, turrets and neutral targets. `CommissionShip` stays for
|
||||
purchases.
|
||||
- **B.** Delete the hull route and `spawnturret`. Keep `give` for items (ad hoc poking outside scenarios) and keep
|
||||
the wanderers.
|
||||
- **C.** Keep everything.
|
||||
- **Recommended: A.** Each one is a second way to create what scenarios now author, and the wanderers change every
|
||||
zone of real play for a testing reason. `iff`, `trackmissile`, `revealzones`, `tow` and `capturepreset` stay.
|
||||
- **Depends on it:** Cut 0.
|
||||
|
||||
Defaults Self took, which you may overrule:
|
||||
- Scenarios show only in editor and development builds.
|
||||
- The ledger is its own committed store, `GameData/Checks.cc`, not the catalog.
|
||||
- "Check", not "behaviour", because `Behavior` is the gear type family.
|
||||
- Brokkr is not installed in this campaign (section 0.4).
|
||||
- The scenario record holds no "start docked" field. No first consumer needs one.
|
||||
|
||||
---
|
||||
|
||||
## 8. Follow-ups outside this campaign
|
||||
|
||||
- Re-anchor `docs/headless-playground-cut.md`. Its Cut 1 now builds on `RunStart` and `Zone.Admit`; its `new`
|
||||
command stages a `Scenario`.
|
||||
- Brokkr install plus a "launch scenario" intent, if agents should drive Unity play.
|
||||
- A durable agent authoring command for presets (fit by design name with validation), instead of transient seed
|
||||
commands.
|
||||
- `AetherDb` carries spent one-shot migration commands (`targeting-catalog-6c`, `-6d`, `firing-arc-migrate`, and
|
||||
others; `Program.cs` is 1,477 lines). This is a subtraction pass of its own.
|
||||
- `ItemManager`'s clock seed (`ItemManager.cs:20`) makes lot quality vary per scenario launch. It is recorded,
|
||||
not fixed here.
|
||||
83
docs/ship-collection-authoring.md
Normal file
83
docs/ship-collection-authoring.md
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
# Ship collection authoring
|
||||
|
||||
Status: authoring contract for new ships. Longinus and Djinni predate this contract and keep their current prefabs.
|
||||
|
||||
## Objective and ownership
|
||||
|
||||
One Blender collection exports one FBX model. Its hierarchy names the ship's presentation anchors. Unity builds
|
||||
`Assets/Content/Prefabs/Ships/<Name>.prefab` from that model and assigns the components and references that the
|
||||
runtime currently requires on a hand-built ship prefab. `GameData/Aetheria.cc` remains the owner of `HullData`,
|
||||
hardpoint cells and types, gameplay stats, products, and the prefab's Addressables key. The model never decides a
|
||||
hit, thruster force, weapon arc, or shield capacity.
|
||||
|
||||
Today `ShipInstance` reads manually filled arrays on each ship prefab. It matches their transform names against
|
||||
`HullData.Hardpoints[].Transform`. Its shared ping, invisible material, explosion, shield, and tractor references
|
||||
also live on each prefab. The builder derives the arrays from the FBX hierarchy and supplies the shared Unity
|
||||
assets once, from their existing project paths. The old prefabs are left alone.
|
||||
|
||||
## Blender collection and export
|
||||
|
||||
- Name the collection `Ship.<Name>` and configure its collection exporter as FBX. Export to
|
||||
`Assets/Models/Ships/<Name>.fbx`. The filename is the generated prefab name. Blender's collection exporter can
|
||||
export a collection directly and repeat that export after edits.
|
||||
- Export meshes and empties, with animation disabled. Use Blender's `-Z Forward`, `Y Up` axis conversion for Unity.
|
||||
Keep the collection origin at the ship's simulation centre, with the nose pointing toward the exported +Z axis.
|
||||
Apply object scales on visual and collision meshes; the `Shield` empty's scale is the deliberate exception.
|
||||
- The importer owns every prefab under `Assets/Content/Prefabs/Ships/` whose matching model is in
|
||||
`Assets/Models/Ships/`. Editing generated components by hand is temporary; the next export rebuilds them.
|
||||
Put appearance in the FBX and gameplay values in the catalog.
|
||||
|
||||
The exported hierarchy uses **exact, case-sensitive names**. Names beginning `HP.`, `Pivot.`, or `SHIP.` are
|
||||
reserved. IDs after a role prefix must be unique across the model. Other visual objects may have any names.
|
||||
|
||||
```text
|
||||
<Name> FBX root
|
||||
Body visible meshes, any nesting
|
||||
SHIP.MapIcon one mesh; assigned the shared map material and Minimap layer
|
||||
SHIP.HullCollider one low-poly closed convex mesh; rendered invisible, given a MeshCollider
|
||||
SHIP.Shield one empty; its position and scale set the shield envelope
|
||||
SHIP.TractorBeam one empty; its pose sets the tractor effect origin
|
||||
HP.Thruster.PortAft empty; exact name copied to HullData.Hardpoints[].Transform
|
||||
Emitter one mesh; thruster particle emission shape
|
||||
HP.Weapon.PortGun empty; exact name copied to the catalog
|
||||
Muzzle.0 empty; +Z is firing direction
|
||||
Muzzle.1 optional additional barrel
|
||||
HP.Radiator.Port empty; exact name copied to the catalog
|
||||
RadiatorMesh one mesh; temperature emission surface
|
||||
HP.Equipment.Reactor empty; exact name copied to the catalog
|
||||
Pivot.0.-90.90.-80.80.60 optional empty parent of articulated mounts
|
||||
```
|
||||
|
||||
`HP.Equipment` covers sensors, reactor, shield, cargo, and other mounts without a special visual component.
|
||||
`HP.Weapon` covers ballistic, energy, and launcher mounts; the catalog chooses which. Every `HP.*` becomes an
|
||||
`EquipmentHardpoints` entry. Thruster, weapon, and radiator roles also get their matching components and arrays.
|
||||
`Muzzle.<nonnegative integer>` children are sorted numerically; their transforms become `FiringPoint`. A weapon
|
||||
mount requires at least one. A `Pivot` name carries `Group.YawMin.YawMax.PitchMin.PitchMax.Speed` as signed
|
||||
integers in degrees and degrees per second. It gets `ArticulationPoint`; child mounts follow its transform. Pivots are
|
||||
presentation only: the simulation's catalog firing arc remains authoritative.
|
||||
|
||||
`SHIP.Shield` receives the existing Shield prefab as a child. That prefab's effective unscaled radius is one
|
||||
Unity unit; the marker's three scale components are the intended envelope radii in world units. The builder adds
|
||||
`ShieldEnvelope` to the Shield prefab root if absent. `SHIP.TractorBeam` receives the existing Tractor Beam
|
||||
prefab. The four `SHIP.*` markers are required exactly once. Ship-specific mesh materials remain authored in
|
||||
Blender/Unity's material import mapping; the builder only assigns the shared map-icon material.
|
||||
|
||||
## Build, validation, and failure
|
||||
|
||||
Re-exporting an FBX in `Assets/Models/Ships/` schedules a prefab rebuild after Unity finishes importing it.
|
||||
`Aetheria/Build Ship Prefab From Selected Model` performs the same build on demand. The builder validates all
|
||||
reserved names, required anchors, component meshes, muzzle numbering, and shared asset references **before**
|
||||
replacing a prefab. A bad export reports an error and leaves the last valid prefab in place. The output is a
|
||||
Prefab Variant of the FBX model, so mesh and transform identities remain tied to the source export.
|
||||
|
||||
After adding a ship, author its `HullData` and product in the catalog, set `HullData.Prefab` to the generated
|
||||
prefab's GUID, and set every `HardpointData.Transform` to an exact `HP.*` name. Run the catalog asset check and
|
||||
the Unity compile. A visual play check still owns size, materials, shield fit, barrel orientation, and thrust
|
||||
appearance. The builder cannot infer the 2D schematic from a 3D mesh.
|
||||
|
||||
## Cut and build budget
|
||||
|
||||
This adds an Editor-only builder, its focused smoke, and this contract. It adds no runtime component, persistent field, package,
|
||||
service, or build target. It replaces per-ship array and shared-reference authoring for newly exported ships.
|
||||
The focused verification target is Unity Editor script compilation plus a synthetic named-hierarchy check; a
|
||||
real Blender collection export is required before claiming end-to-end import fidelity.
|
||||
|
|
@ -8,6 +8,9 @@
|
|||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Aetheria.Shared\Aetheria.Shared.csproj" />
|
||||
<!-- AuthoredSettings (Unity Settings.asset YAML reader), so fixtures load the shipped gameplay settings
|
||||
instead of hand-copying them. -->
|
||||
<ProjectReference Include="..\..\tools\AetherDb\AetherDb.csproj" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.4.0" />
|
||||
<PackageReference Include="xunit" Version="2.9.3" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5" />
|
||||
|
|
|
|||
|
|
@ -331,7 +331,7 @@ public sealed class FireAuthorityTests : IDisposable
|
|||
e.Zone.Update(10f); // well past arrival
|
||||
|
||||
Assert.Equal(before, e.Target.Hull.Durability);
|
||||
Assert.Empty(e.Zone.PendingShots);
|
||||
SafeAssert.NoShots(e.Zone);
|
||||
}
|
||||
|
||||
// R4: ShotCommitted fires exactly CommitHorizon before ShotResolved, once per shot. Mutation: publish only
|
||||
|
|
@ -420,7 +420,7 @@ public sealed class FireAuthorityTests : IDisposable
|
|||
e.Zone.Update(.016f); // one ordinary tick
|
||||
|
||||
Assert.Equal(new[] { "committed", "resolved" }, order);
|
||||
Assert.Empty(e.Zone.PendingShots);
|
||||
SafeAssert.NoShots(e.Zone);
|
||||
}
|
||||
|
||||
// R10/Q6: a shot's parameters freeze when the trigger is pulled. Changing the weapon's authored Damage
|
||||
|
|
@ -488,64 +488,16 @@ public sealed class FireAuthorityTests : IDisposable
|
|||
Assert.True(aimedItem.EquippableItem.Durability < 1f);
|
||||
}
|
||||
|
||||
// The damage rule moved verbatim (Entity.DamageSchematic/ApplyHit): damage above armor plus item
|
||||
// durability zeroes the item and the remainder hits the hull. Mutation: skip subtracting armor, or skip
|
||||
// passing the remainder on to the hull.
|
||||
[Fact]
|
||||
public void HardpointHitDamagesItemThenHull()
|
||||
{
|
||||
var cell = new int2(1, 1);
|
||||
EquippableItem occupant = null;
|
||||
var e = Build(TestSettings(), armor: 2, hullDurability: 1000,
|
||||
beforeActivate: (items, shooter, target) =>
|
||||
{
|
||||
// No item occupies (1,1) in this fixture's hull -- occupy it before Activate() so the
|
||||
// item-then-hull chain has an item to pass through at a controlled cell.
|
||||
var occupantRef = items.ItemData.RefOf<ItemData>(items.ItemData.GetByName<GearData>("Targeting"));
|
||||
occupant = new EquippableItem { Data = occupantRef, Durability = 3, Lot = 6 };
|
||||
Assert.True(target.TryEquip(occupant, cell));
|
||||
});
|
||||
var occupantItem = e.Target.Equipment.Single(x => x.EquippableItem == occupant);
|
||||
|
||||
var beforeHull = e.Target.Hull.Durability;
|
||||
// Cut 12.2 (docs/fire-control-cut.md): ApplyHit's direction parameter is now an already-schematic
|
||||
// bearing (the caller's job, formerly ApplyHit's own internal ToSchematic call) -- unread here anyway,
|
||||
// since penetration 0 never enters the march.
|
||||
e.Target.ApplyHit(e.Shooter, cell, spread: 0, penetration: 0, damage: 10, bearing: float2(0, 1));
|
||||
|
||||
Assert.Equal(0f, e.Target.Armor[cell.x, cell.y]); // 2 armor consumed
|
||||
Assert.Equal(0f, occupantItem.EquippableItem.Durability); // 3 item durability consumed
|
||||
Assert.Equal(beforeHull - 5f, e.Target.Hull.Durability, 2); // remaining 5 hits the hull
|
||||
}
|
||||
|
||||
// R7: the penetration march is planar, in the target's own schematic frame. Firing straight into a
|
||||
// target's nose marches the hit shape toward the target's stern, along +Y in this hull's local grid
|
||||
// regardless of which way the entity happens to be facing in world space.
|
||||
// Cut 12.2 (docs/fire-control-cut.md): the world-to-schematic rotation this test pinned moved out of
|
||||
// ApplyHit and into its caller (FireControl.Commit computes `bearing = target.ToSchematic(travelDirection)`
|
||||
// once, at the commit tick, and passes the already-rotated bearing in) -- ApplyHit itself no longer reads
|
||||
// Direction at all. This test now performs that same rotation itself, at the call site, to keep pinning
|
||||
// the march's own planar behaviour once a schematic bearing is in hand; the end-to-end claim that
|
||||
// Direction feeds the rotation correctly is what FireControlCut12Tests.HitsLandOnTheFacingEdge and
|
||||
// TurningArmourIntoTheShotTakesItOnTheArmour now cover, through FireControl.Commit itself.
|
||||
[Fact]
|
||||
public void PenetrationMarchIsPlanar()
|
||||
{
|
||||
var e = Build(TestSettings(), armor: 5);
|
||||
e.Target.Direction = float2(1, 0); // facing world +X, not the default +Z
|
||||
|
||||
var cell = new int2(1, 0);
|
||||
var hitDirection = normalize(float2(1, 0)); // the shot arrived travelling along the target's own forward
|
||||
var bearing = e.Target.ToSchematic(hitDirection);
|
||||
e.Target.ApplyHit(e.Shooter, cell, spread: 0, penetration: 1.5f, damage: 30, bearing: bearing);
|
||||
|
||||
// Rotating hitDirection into this Direction's frame (forward=(1,0), right=(0,-1)) makes the local
|
||||
// penetration vector (0,1): the march should have advanced from (1,0) into (1,1), consuming that
|
||||
// cell's armor too. Mutation: skip the rotation and march along the raw world hitDirection (1,0)
|
||||
// instead, which would consume (2,0) rather than (1,1).
|
||||
Assert.True(e.Target.Armor[1, 1] < e.Target.MaxArmor[1, 1]);
|
||||
Assert.Equal(e.Target.MaxArmor[2, 0], e.Target.Armor[2, 0]); // untouched -- proves it wasn't a world-space march
|
||||
}
|
||||
// HardpointHitDamagesItemThenHull and PenetrationMarchIsPlanar (Entity.ApplyHit/DamageSchematic, deleted by
|
||||
// Cut 12.3 -- docs/fire-control-cut.md) pinned two rules that no longer have that function to call:
|
||||
// - "damage above armor plus item durability zeroes the item and the remainder hits the hull" is now
|
||||
// FireControlCut123Tests.DamageIsAbsorbedInOrderAlongTheRay, through the real Fire/Commit/Apply path
|
||||
// rather than a direct ApplyHit call.
|
||||
// - "the penetration march is planar, in the target's own schematic frame" is subsumed by 12.2's own
|
||||
// FireControlCut12Tests.HitsLandOnTheFacingEdge and TurningArmourIntoTheShotTakesItOnTheArmour (the
|
||||
// bearing FireControl.Apply's lane walk reads is already the committed, schematic-frame bearing Commit
|
||||
// computed, the same one those tests pin end-to-end) and by FireControlCut123Tests.ArmourFacesTheShot,
|
||||
// which pins that the lane's own facing cell is planar across several non-axis-aligned facings.
|
||||
|
||||
// The absorb rule now exists once, in FireControl: an active shield that CanTakeHit absorbs, and the
|
||||
// schematic is untouched. Mutation: remove the shield branch (the hit always reaches the hull).
|
||||
|
|
|
|||
|
|
@ -231,10 +231,14 @@ public sealed class FireControlCut11Tests : IDisposable
|
|||
Assert.Equal(hull, e.Target.Hull.Durability); // and every hit was absorbed
|
||||
}
|
||||
|
||||
// The same rule on Splash's path, whose absorb branch had no test coverage at all. Mutation: delete
|
||||
// TakeHit from Splash's absorb branch.
|
||||
// The same rule on a blast's path (12.4(b) rewrites this to Detonate, docs/fire-control-cut.md
|
||||
// "ShieldPaysForWhatReachesIt": "the reserve drops by the entity's covered share, not by the whole
|
||||
// blast"), whose absorb branch had no test coverage at all. The radius sits well inside the hull's own
|
||||
// solid interior (the 5x3 shape's centre of mass, at least 1 cell from every edge) so the disc never spills
|
||||
// off the hull -- the covered share equals the whole damage exactly, the same amount Splash always charged,
|
||||
// so this expectation is not loosened. Mutation: delete TakeHit from Detonate's absorb branch.
|
||||
[Fact]
|
||||
public void SplashShieldAbsorptionDrainsTheReserve()
|
||||
public void ABlastShieldAbsorptionDrainsTheReserve()
|
||||
{
|
||||
var e = Build(equipShield: true, shieldCapacity: 30);
|
||||
Charge(e);
|
||||
|
|
@ -244,7 +248,7 @@ public sealed class FireControlCut11Tests : IDisposable
|
|||
var blasts = 0;
|
||||
while (e.Target.Shield.CanTakeHit(DamageType.Kinetic, 5) && blasts < 200)
|
||||
{
|
||||
FireControl.Splash(e.Zone, e.Target.Position, radius: 20, damage: 5, damageType: DamageType.Kinetic);
|
||||
FireControl.Detonate(e.Zone, e.Target.Position.xz, radius: 1, damage: 5, damageType: DamageType.Kinetic);
|
||||
blasts++;
|
||||
}
|
||||
|
||||
|
|
@ -301,19 +305,19 @@ public sealed class FireControlCut11Tests : IDisposable
|
|||
|
||||
var shotId = FireControl.Fire(e.Weapon, e.WeaponItem, e.Shooter);
|
||||
e.Zone.Update(1f);
|
||||
Assert.Empty(committed);
|
||||
SafeAssert.Empty(committed);
|
||||
|
||||
e.Zone.Entities.Remove(e.Target);
|
||||
e.Zone.Update(1f);
|
||||
|
||||
foreach (var outcome in new[] { Assert.Single(committed), Assert.Single(resolved) })
|
||||
foreach (var outcome in new[] { SafeAssert.Only(committed), SafeAssert.Only(resolved) })
|
||||
{
|
||||
Assert.Equal(shotId, outcome.ShotId);
|
||||
Assert.False(outcome.Hit);
|
||||
Assert.False(outcome.Shielded, "a shot at nothing did not hit a shield");
|
||||
Assert.False(outcome.ShieldBroken, "a shot at nothing did not break a shield");
|
||||
}
|
||||
Assert.Empty(e.Zone.PendingShots);
|
||||
SafeAssert.NoShots(e.Zone);
|
||||
}
|
||||
|
||||
// ---- A targeting system's Tracking is what forgives a target that moves off its predicted line. ----
|
||||
|
|
@ -354,40 +358,11 @@ public sealed class FireControlCut11Tests : IDisposable
|
|||
}
|
||||
|
||||
// ---- Splash damages the side the blast came from. ----
|
||||
|
||||
// The operator's "damage on the wrong side of the ship" was a legacy Unity bug that Splash never shipped,
|
||||
// but nothing defended against it. Flipping the sign in Splash's
|
||||
// `right = float2(forward.y, -forward.x)` survived every earlier suite, and it survives this test too at
|
||||
// the default facing (0, 1): the flip only changes which side is hit when a ship faces more along world x
|
||||
// than z. So the target is spun through facings where the flip bites as well as ones where it does not,
|
||||
// and blasted from each side in turn. The blast side is computed here independently of FireControl --
|
||||
// starboard is the facing rotated clockwise -- so this is not the code checking itself.
|
||||
[Theory]
|
||||
[InlineData(0f, 1f)]
|
||||
[InlineData(1f, 0f)]
|
||||
[InlineData(.8f, .6f)]
|
||||
[InlineData(-.8f, -.6f)]
|
||||
[InlineData(-.6f, .8f)]
|
||||
public void SplashDamagesTheSideTheBlastCameFrom(float fx, float fy)
|
||||
{
|
||||
foreach (var fromStarboard in new[] { true, false })
|
||||
{
|
||||
var e = Build(markers: true);
|
||||
var facing = normalize(float2(fx, fy));
|
||||
e.Target.Direction = facing;
|
||||
var starboard = float2(facing.y, -facing.x);
|
||||
var side = fromStarboard ? starboard : -starboard;
|
||||
var blast = e.Target.Position + float3(side.x, 0, side.y) * 10f;
|
||||
|
||||
FireControl.Splash(e.Zone, blast, radius: 20, damage: 10, damageType: DamageType.Kinetic);
|
||||
|
||||
var nearMarker = fromStarboard ? e.StarboardMarker : e.PortMarker;
|
||||
var farMarker = fromStarboard ? e.PortMarker : e.StarboardMarker;
|
||||
var label = $"facing ({fx}, {fy}), blast from {(fromStarboard ? "starboard" : "port")}";
|
||||
Assert.True(nearMarker.EquippableItem.Durability < 100, $"{label}: the marker facing the blast took no damage");
|
||||
Assert.Equal(100f, farMarker.EquippableItem.Durability);
|
||||
}
|
||||
}
|
||||
//
|
||||
// Superseded (docs/fire-control-cut.md, "Symmetry and frame"): ABlastDamagesTheCellsNearestIt in
|
||||
// FireControlCut124Tests.cs succeeds this test and Cut4Tests.SplashIsDirectional -- a blast is now an area
|
||||
// (12.4(b)), not a directional half-hull split, so "the side the blast came from" is pinned by which cells
|
||||
// the disc actually covers, not by a facing-rotated half-shape.
|
||||
|
||||
// ---- pSpread is the share of the spread cone the target's silhouette covers. ----
|
||||
|
||||
|
|
|
|||
1935
tests/Aetheria.Shared.Tests/FireControlCut123Tests.cs
Normal file
1935
tests/Aetheria.Shared.Tests/FireControlCut123Tests.cs
Normal file
File diff suppressed because it is too large
Load diff
2661
tests/Aetheria.Shared.Tests/FireControlCut124Tests.cs
Normal file
2661
tests/Aetheria.Shared.Tests/FireControlCut124Tests.cs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -6,7 +6,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using CultMath;
|
||||
using GameCult.Caching;
|
||||
using UniRx;
|
||||
|
|
@ -63,6 +62,19 @@ public sealed class FireControlCut12Tests : IDisposable
|
|||
return shape;
|
||||
}
|
||||
|
||||
// S1 fix batch: a non-convex hull for the empty-lane sweep -- a solid square with its centre cell punched
|
||||
// out, the same "holed7" shape Soul's own EdgeSweep probe used.
|
||||
private static Shape HoledShape(int w, int h)
|
||||
{
|
||||
var shape = SolidShape(w, h);
|
||||
shape[new int2(w / 2, h / 2)] = false;
|
||||
return shape;
|
||||
}
|
||||
|
||||
// A unit direction at `d` degrees, matching Soul's own probe convention (SoulProbe122b.Deg) -- used here to
|
||||
// name an exact facing/bearing for a crash repro.
|
||||
private static float2 Deg(double d) => float2((float) Math.Sin(d * Math.PI / 180), (float) Math.Cos(d * Math.PI / 180));
|
||||
|
||||
private sealed class Engagement
|
||||
{
|
||||
public ItemManager Items;
|
||||
|
|
@ -75,6 +87,8 @@ public sealed class FireControlCut12Tests : IDisposable
|
|||
public EquippedItem[] Markers;
|
||||
public EquippedItem BigMarker;
|
||||
public int2[] BigMarkerCells;
|
||||
public EquippedItem LMarker;
|
||||
public int2[] LMarkerCells;
|
||||
}
|
||||
|
||||
// A shooter off the origin (Cut 11.3), a target over a caller-supplied hull shape, a full-strength
|
||||
|
|
@ -85,7 +99,19 @@ public sealed class FireControlCut12Tests : IDisposable
|
|||
GameplaySettings settings, Shape hullShape, float precision,
|
||||
float velocity = 0, float spread = 0, float2? targetFacing = null,
|
||||
bool equipShield = false, float shieldCapacity = 30,
|
||||
int2[] markerCells = null, float accuracy = 1f, float penetration = 0, bool equipBigMarker = false)
|
||||
int2[] markerCells = null, float accuracy = 1f, float penetration = 0, bool equipBigMarker = false,
|
||||
// S1 fix batch (Hands, 2026-09-25): a caller-chosen zone name -- Cut 6.1's own convention is one fixed
|
||||
// name so a fixture is replayable byte-for-byte, but Soul's own crash repros (Zone.CombatSeed is
|
||||
// StableHash(name)) each need their OWN exact name to reproduce a specific die roll.
|
||||
string zoneName = "Cut12",
|
||||
// S7 fix batch (Hands, 2026-09-25): Tracking authored through Build, like Precision and Accuracy already
|
||||
// are, instead of a caller patching PendingShot.Tracking after Fire (TheHudEstimateIsTheCommitPrice's own
|
||||
// former shape) -- one authoring path for every frozen shooter stat.
|
||||
float tracking = 100000f,
|
||||
// S8 fix batch (Hands, 2026-09-25): an L-shaped (3-cell, not 2x2) Tool item -- its true centroid differs
|
||||
// from both any single cell and the bounding-box centre a mutant could substitute (N11), which a
|
||||
// rectangular BigMarker cannot distinguish.
|
||||
bool equipLMarker = false)
|
||||
{
|
||||
var hullData = new HullData
|
||||
{
|
||||
|
|
@ -125,7 +151,7 @@ public sealed class FireControlCut12Tests : IDisposable
|
|||
MinimumTemperature = -1000, MaximumTemperature = 1000, OptimalTemperature = 0, PlateauWidth = 2000,
|
||||
Behaviors = { new TargetingSystemData
|
||||
{
|
||||
Accuracy = Constant(accuracy), Resolution = Constant(1000f), Precision = Constant(precision), Tracking = Constant(100000f)
|
||||
Accuracy = Constant(accuracy), Resolution = Constant(1000f), Precision = Constant(precision), Tracking = Constant(tracking)
|
||||
} }
|
||||
});
|
||||
cache.Upsert(new GearData
|
||||
|
|
@ -155,6 +181,15 @@ public sealed class FireControlCut12Tests : IDisposable
|
|||
Name = "BigMarker", Hardpoint = HardpointType.Tool, Shape = bigMarkerShape, Durability = 1000000,
|
||||
MinimumTemperature = -1000, MaximumTemperature = 1000, OptimalTemperature = 0, PlateauWidth = 2000
|
||||
});
|
||||
// S8 fix batch: an L-tromino (3 of a 2x2's 4 cells) -- its centroid ((0,0)+(1,0)+(0,1))/3 = (1/3,1/3) is
|
||||
// neither any one of its own cells nor the bounding box's centre (.5,.5), so a fixture built from it can
|
||||
// tell a true centroid apart from both.
|
||||
var lMarkerShape = new Shape(2, 2) { [new int2(0, 0)] = true, [new int2(1, 0)] = true, [new int2(0, 1)] = true };
|
||||
cache.Upsert(new GearData
|
||||
{
|
||||
Name = "LMarker", Hardpoint = HardpointType.Tool, Shape = lMarkerShape, Durability = 1000000,
|
||||
MinimumTemperature = -1000, MaximumTemperature = 1000, OptimalTemperature = 0, PlateauWidth = 2000
|
||||
});
|
||||
cache.FlushAsync().Wait();
|
||||
|
||||
var ledger = new ProvenanceLedger();
|
||||
|
|
@ -165,7 +200,7 @@ public sealed class FireControlCut12Tests : IDisposable
|
|||
// is replayable byte-for-byte across runs. A GUID-suffixed name here (this file's own earlier defect)
|
||||
// reseeded the die on every run, which is exactly what made TurningArmourIntoTheShotTakesItOnTheArmour
|
||||
// flaky (F2, Soul's fix batch, 2026-09-24).
|
||||
var zone = new Zone(items, new PlanetSettings(), new ZonePack(), new GalaxyZone { Name = "Cut12", Owner = null }, null);
|
||||
var zone = new Zone(items, new PlanetSettings(), new ZonePack(), new GalaxyZone { Name = zoneName, Owner = null }, null);
|
||||
|
||||
EquippableItem Make(string name, int lot, float durability) => new EquippableItem
|
||||
{
|
||||
|
|
@ -212,6 +247,18 @@ public sealed class FireControlCut12Tests : IDisposable
|
|||
Assert.Equal(4, bigMarkerCells.Length); // fixture precondition: the full 2x2 footprint landed
|
||||
}
|
||||
|
||||
EquippedItem lMarker = null;
|
||||
int2[] lMarkerCells = null;
|
||||
if (equipLMarker)
|
||||
{
|
||||
var lm = Make("LMarker", lot++, 1000000);
|
||||
Assert.True(target.TryFindSpace(lm, out var lmPos));
|
||||
Assert.True(target.TryEquip(lm, lmPos));
|
||||
lMarker = target.Equipment.Single(x => x.EquippableItem == lm);
|
||||
lMarkerCells = hullShape.Coordinates.Where(v => target.GearOccupancy[v.x, v.y] == lMarker).ToArray();
|
||||
Assert.Equal(3, lMarkerCells.Length); // fixture precondition: the full 3-cell L footprint landed
|
||||
}
|
||||
|
||||
if (equipShield)
|
||||
{
|
||||
var reactor = Make("Reactor", lot++, 10);
|
||||
|
|
@ -247,7 +294,8 @@ public sealed class FireControlCut12Tests : IDisposable
|
|||
return new Engagement
|
||||
{
|
||||
Items = items, Zone = zone, Shooter = shooter, Target = target, WeaponItem = weaponItem, Weapon = weapon,
|
||||
HullData = hullData, Markers = markers, BigMarker = bigMarker, BigMarkerCells = bigMarkerCells
|
||||
HullData = hullData, Markers = markers, BigMarker = bigMarker, BigMarkerCells = bigMarkerCells,
|
||||
LMarker = lMarker, LMarkerCells = lMarkerCells
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -397,6 +445,73 @@ public sealed class FireControlCut12Tests : IDisposable
|
|||
Assert.Equal(expected, p, 4);
|
||||
}
|
||||
|
||||
// :~483 fix batch (Hands, 2026-09-25): `if (p <= 0f) return 0f;` in CommitProbability is a guard against
|
||||
// building a silhouette for a shot that cannot hit -- Stryker's own `p < 0` boundary mutant (excluding only
|
||||
// the single value p == 0 exactly) survived because nothing exercised the guard at exactly 0.
|
||||
// 12.3 fix batch correction: the previous version of this test set `shot.PFire = 0f` on a pending shot by
|
||||
// hand, then asserted `sil.Intervals == null` -- a shape assertion on CommitProbability's own struct
|
||||
// default, not a behaviour a bug could actually violate (any caller reading `sil` after a real miss reads
|
||||
// the same default regardless of whether a Silhouette was built and discarded). Made behavioural per the
|
||||
// 12.2 postmortem: PFire == 0 is now produced through the real gate (closing the shooter's own
|
||||
// VisibleEntities, the same way S4's InvisibleTargetStillResolvesAtItsRealFlightTime does), and the claim
|
||||
// "no Silhouette was ever built" is checked the only way that is actually true of a function's own
|
||||
// behaviour: it allocates nothing. The `p < 0` mutant lets p == 0 fall through to build a real Silhouette
|
||||
// (Array.Sort, ResolveAimPoint, an owned Interval[]), which is not zero-allocation -- this test kills it
|
||||
// the same way S3's own zero-allocation pins do, not by re-reading a field the mutant never touches.
|
||||
[Fact]
|
||||
public void ZeroProbabilityShotCommitsAMissWithoutBuildingASilhouette()
|
||||
{
|
||||
var e = Build(TestSettings(), SolidShape(5, 5), precision: 1f);
|
||||
e.Shooter.VisibleEntities.Remove(e.Target); // closes the real gate -- PFire == 0 through the actual path
|
||||
|
||||
var shotId = FireControl.Fire(e.Weapon, e.WeaponItem, e.Shooter);
|
||||
var shot = e.Zone.PendingShots.Single(s => s.ShotId == shotId);
|
||||
Assert.Equal(0f, shot.PFire); // fixture precondition: the gate is actually closed
|
||||
|
||||
for (var i = 0; i < 50; i++) FireControl.CommitProbability(shot, e.Zone.Time, out _); // JIT warm-up
|
||||
|
||||
var before = GC.GetAllocatedBytesForCurrentThread();
|
||||
var p = FireControl.CommitProbability(shot, e.Zone.Time, out var sil);
|
||||
var allocated = GC.GetAllocatedBytesForCurrentThread() - before;
|
||||
|
||||
Assert.Equal(0f, p);
|
||||
Assert.Equal(0, sil.Count);
|
||||
Assert.Equal(0, allocated); // no Silhouette was built: Array.Sort/ResolveAimPoint never ran
|
||||
|
||||
ShotOutcome outcome = null;
|
||||
using var r = e.Zone.ShotResolved.Subscribe(o => outcome = o);
|
||||
e.Zone.Update(.01f);
|
||||
Assert.NotNull(outcome);
|
||||
Assert.False(outcome.Hit, "fixture: PFire 0 must commit as a clean miss");
|
||||
}
|
||||
|
||||
// S4 fix batch (Hands, 2026-09-25): F8 (Soul's earlier fix batch, 2026-09-24) moved range/flightTime
|
||||
// computation ahead of the visibility gate, so Fire's own flight time reflects the real distance even when
|
||||
// PFire prices the shot at 0 -- but nothing behavioural pinned that. N4 (Soul's mutation set: "range after
|
||||
// visibility gate", reverting F8) survived every existing test. A shot at a target the shooter cannot
|
||||
// currently see must still resolve, as a miss (PFire gates it to 0), at the arrival time the real
|
||||
// range/velocity imply -- not immediately (range 0) and not never (flight time 0 means instant resolve).
|
||||
[Fact]
|
||||
public void InvisibleTargetStillResolvesAtItsRealFlightTime()
|
||||
{
|
||||
var e = Build(TestSettings(), SolidShape(5, 5), precision: 1f, velocity: 20); // range 100 -> 5s flight
|
||||
e.Shooter.VisibleEntities.Remove(e.Target);
|
||||
|
||||
var shotId = FireControl.Fire(e.Weapon, e.WeaponItem, e.Shooter);
|
||||
var pending = e.Zone.PendingShots.Single(s => s.ShotId == shotId);
|
||||
Assert.Equal(0f, pending.PFire); // fixture precondition: the visibility gate is actually closed
|
||||
var expectedArrival = pending.FireTime + 100f / 20f; // the real range (100) over the real velocity (20)
|
||||
Assert.Equal(expectedArrival, pending.ArrivalTime, 3);
|
||||
|
||||
ShotOutcome outcome = null;
|
||||
using var r = e.Zone.ShotResolved.Subscribe(o => outcome = o);
|
||||
e.Zone.Update(4.9f);
|
||||
Assert.Null(outcome); // not yet: N4's bug (range 0) would have resolved this instantly
|
||||
e.Zone.Update(.2f); // past the real 5s arrival
|
||||
Assert.NotNull(outcome);
|
||||
Assert.False(outcome.Hit, "fixture: PFire 0 (not visible) must resolve as a miss");
|
||||
}
|
||||
|
||||
// Stryker survivors: ResolveAimPoint's fallback (aimed but currently occupying zero cells -> hull centre
|
||||
// of mass) and its multi-cell average were both untested -- every existing marker fixture uses the
|
||||
// catalog's 1x1 "Marker" stub, where sum/length and sum*length agree at length 1, and no fixture ever
|
||||
|
|
@ -457,6 +572,42 @@ public sealed class FireControlCut12Tests : IDisposable
|
|||
$"empirical mean lateral offset {empiricalMeanLateral:F3} does not track the centroid's own lane {expectedA:F3}");
|
||||
}
|
||||
|
||||
// S8 fix batch (Hands, 2026-09-25): the BigMarker test above only ever exercises a 2x2 (square) footprint,
|
||||
// whose true centroid and bounding-box centre are the same point -- N11 (aim point = bounding-box centre
|
||||
// instead of the cell average) survived because nothing could tell the two apart. An L-tromino (3 of a
|
||||
// 2x2's 4 cells) makes them different points: this fixture pins the aim point against the exact centroid
|
||||
// the test computes itself, and separately checks it against the wrong (bounding-box) candidate to prove
|
||||
// the fixture actually distinguishes them.
|
||||
[Fact]
|
||||
public void AimingAtAnLShapedItemCentresOnItsCentroidNotItsBoundingBox()
|
||||
{
|
||||
// A diagonal facing (not axis-aligned) puts the L-shape's actual asymmetry -- its centroid sits off
|
||||
// the bounding-box centre along the diagonal, not along either grid axis -- fully onto the lateral
|
||||
// axis, instead of losing most of it to the axis a purely axis-aligned facing would leave unmeasured.
|
||||
var e = Build(TestSettings(), SolidShape(9, 9), precision: 1f, targetFacing: normalize(float2(1, 1)), equipLMarker: true);
|
||||
Assert.True(e.Shooter.TrySelectTargetItem(e.LMarker));
|
||||
|
||||
var travelDirection = FireControl.TravelDirection(e.Weapon, e.Shooter, e.Target);
|
||||
var bearing = normalize(e.Target.ToSchematic(travelDirection));
|
||||
var ell = float2(-bearing.y, bearing.x);
|
||||
var centroid = e.LMarkerCells.Aggregate(float2.zero, (t, c) => t + (float2) c) / e.LMarkerCells.Length;
|
||||
var boundingBoxCentre = (float2(e.LMarkerCells.Min(c => c.x), e.LMarkerCells.Min(c => c.y))
|
||||
+ float2(e.LMarkerCells.Max(c => c.x), e.LMarkerCells.Max(c => c.y))) / 2f;
|
||||
Assert.True(lengthsq(centroid - boundingBoxCentre) > .01f, "fixture: the L-shape's centroid and bounding-box centre must actually differ");
|
||||
|
||||
var expectedA = dot(centroid, ell);
|
||||
var wrongA = dot(boundingBoxCentre, ell);
|
||||
Assert.True(Math.Abs(expectedA - wrongA) > .15f, "fixture: the two candidate aim points must project to distinguishably different lateral values");
|
||||
|
||||
var outcomes = FireMany(e, 3000);
|
||||
var hits = outcomes.Where(o => o.Hit).ToList();
|
||||
Assert.True(hits.Count > 300, $"expected a healthy number of hits, got {hits.Count}");
|
||||
|
||||
var empiricalMeanLateral = hits.Average(o => (double) o.Lateral);
|
||||
Assert.True(Math.Abs(empiricalMeanLateral - expectedA) < .1,
|
||||
$"empirical mean lateral offset {empiricalMeanLateral:F3} (bounding-box centre would predict {wrongA:F3}) does not track the true centroid's own lane {expectedA:F3}");
|
||||
}
|
||||
|
||||
// BroadsideIsEasierThanHeadOn: kills the bearing being ignored and the old max(W,H) bound. A 2x12 hull is
|
||||
// much easier to hit broadside (its long axis facing the shot) than head-on (its short axis facing it).
|
||||
[Fact]
|
||||
|
|
@ -527,74 +678,240 @@ public sealed class FireControlCut12Tests : IDisposable
|
|||
Assert.True(outcome.Cell.y >= 5.5f, $"expected every hit to land on the bow row (y>=5.5), got cell {outcome.Cell}");
|
||||
}
|
||||
|
||||
// F1 (Soul's fix batch, 2026-09-24): LateralDraw's clamp used to close the top of the shadow interval
|
||||
// ([Lo, Hi] instead of the spec's half-open [Lo, Hi)). Soul enumerated all 2^24 NextFloat outputs against
|
||||
// this exact geometry (TurningArmourIntoTheShotTakesItOnTheArmour's own 3x11 hull, bearing (0,-1),
|
||||
// Precision .4 -> interval [-0.5, 2.5]) and found 3 values of u that drew s == Hi == 2.5 exactly, at which
|
||||
// Lane's own half-open filter (`s >= centre + h` continues, :731) then found no candidate cell at all,
|
||||
// returning an empty lane for a shot that had already passed its roll (R3 violation) -- the reflection
|
||||
// call below reproduces that exact draw. u=0 is the analogous exact-Lo case (the first NextFloat output).
|
||||
// S1 (Soul's second pass, 2026-09-25): at a non-axis-aligned bearing, a lateral draw exactly at an
|
||||
// interval's Lo used to touch only a cell's corner -- Lane's own shadow prefilter admitted the cell but the
|
||||
// independent SlabAlongB slab test rejected it on float rounding, Lane returned zero cells, and Commit's
|
||||
// own guard threw InvalidOperationException out of Zone.Update (R3 violation: a hit that already passed
|
||||
// its roll must always land on metal). Soul reproduced this live, not through reflection into a private
|
||||
// method: zone name Cut12-edge-68442709 (StableHash seeds Zone.CombatSeed, so this exact name reproduces
|
||||
// the exact die roll), a 7x9 hull, Precision 2, target facing 1 degree, shot 1. Fixed by deleting the
|
||||
// second, disagreeing gate (this fix batch's FireControl.cs change) -- this pins the exact repro against a
|
||||
// real Commit, not a reflection call, and checks the placement lands where the roll priced it.
|
||||
[Fact]
|
||||
public void LateralDrawIsHalfOpenAtTheShadowsTopEdge()
|
||||
public void ShotAtBearingLoTouchingOnlyACellCornerHitsMetal()
|
||||
{
|
||||
var hull = new HullData { Name = "H", HullType = HullType.Ship, Shape = SolidShape(3, 11) };
|
||||
var bearing = float2(0, -1);
|
||||
const float precision = .4f;
|
||||
var sil = FireControl.Silhouette(null, hull, null, bearing, precision);
|
||||
Assert.Equal(1, sil.Count); // fixture precondition: one interval, matching Soul's own probe
|
||||
Assert.Equal(-0.5f, sil.Intervals[0].Lo, 3);
|
||||
Assert.Equal(2.5f, sil.Intervals[0].Hi, 3);
|
||||
var e = Build(TestSettings(), SolidShape(7, 9), precision: 2f, targetFacing: Deg(1), zoneName: "Cut12-edge-68442709");
|
||||
|
||||
var lateralDraw = (Func<Silhouette, float, float>) typeof(FireControl)
|
||||
.GetMethod("LateralDraw", BindingFlags.NonPublic | BindingFlags.Static)
|
||||
.CreateDelegate(typeof(Func<Silhouette, float, float>));
|
||||
ShotOutcome outcome = null;
|
||||
using var r = e.Zone.ShotResolved.Subscribe(o => outcome = o);
|
||||
FireControl.Fire(e.Weapon, e.WeaponItem, e.Shooter);
|
||||
e.Zone.Update(.01f);
|
||||
|
||||
void AssertLandsOnMetal(float u, string label)
|
||||
{
|
||||
var s = lateralDraw(sil, u);
|
||||
var buffer = new LaneCell[hull.Shape.Coordinates.Length];
|
||||
var count = FireControl.Lane(hull, bearing, s, buffer);
|
||||
Assert.True(count > 0, $"{label}: u={u:R} drew s={s:R} (interval [{sil.Intervals[0].Lo},{sil.Intervals[0].Hi}]) -- Lane found no occupied cell for a hit that already passed its roll");
|
||||
Assert.True(hull.Shape[buffer[0].Cell], $"{label}: Lane's own first cell {buffer[0].Cell} is not on the hull's schematic");
|
||||
}
|
||||
Assert.NotNull(outcome);
|
||||
Assert.True(outcome.Hit, "fixture: this exact seed must roll a hit (this is the repro, not a general property)");
|
||||
Assert.True(e.HullData.Shape[outcome.Cell], $"hit landed on {outcome.Cell}, not on the hull's own schematic");
|
||||
|
||||
AssertLandsOnMetal(0.9999998f, "at the top edge (u drives s to exactly Hi)");
|
||||
AssertLandsOnMetal(0f, "at the bottom edge (u drives s to exactly Lo)");
|
||||
var ell = float2(-outcome.Bearing.y, outcome.Bearing.x);
|
||||
var h = (Math.Abs(ell.x) + Math.Abs(ell.y)) / 2f;
|
||||
var centre = dot((float2) outcome.Cell, ell);
|
||||
Assert.True(outcome.Lateral >= centre - h && outcome.Lateral < centre + h,
|
||||
$"hit cell {outcome.Cell}'s own projected lateral interval [{centre - h},{centre + h}) does not contain the drawn Lateral {outcome.Lateral}");
|
||||
}
|
||||
|
||||
// Entity.ApplyHit's own penetration march, replicated independently (not by calling ApplyHit or reading
|
||||
// its source beyond the documented convention 12.2 explicitly leaves untouched: cell centres at
|
||||
// +.5, .5-unit steps, hullData.Shape[int2(point)] as the stop condition). Used to compute, from a frozen
|
||||
// Bearing, the full set of cells a march would consume -- independent of which bearing (committed or
|
||||
// live) the test feeds it.
|
||||
private static HashSet<int2> ExpectedMarchCells(HullData hull, int2 cell, float2 bearing, float penetration)
|
||||
// S1: the same class of empty-lane crash on the ruling's own TurningArmourIntoTheShotTakesItOnTheArmour
|
||||
// geometry (3x11 hull, velocity 20, Precision .4, the fire-then-turn sequence that fixture uses) --
|
||||
// Soul's search found a zone name (Cut12-edge-64078070) whose draw lands on an interval edge after the
|
||||
// target turns its bow into the shot.
|
||||
[Fact]
|
||||
public void ShotAtBearingLoOnTurningArmourHitsMetal()
|
||||
{
|
||||
var cells = new HashSet<int2> { cell };
|
||||
if (penetration <= .5f) return cells;
|
||||
var vector = normalize(bearing);
|
||||
var point = (float2) cell + float2(.5f);
|
||||
var distance = 0f;
|
||||
while (distance < penetration && hull.Shape[int2(point)])
|
||||
var e = Build(TestSettings(), SolidShape(3, 11), precision: .4f, velocity: 20, zoneName: "Cut12-edge-64078070");
|
||||
|
||||
var shotId = FireControl.Fire(e.Weapon, e.WeaponItem, e.Shooter);
|
||||
var pending = e.Zone.PendingShots.Single(s => s.ShotId == shotId);
|
||||
var travelDirection = pending.TravelDirection;
|
||||
|
||||
// At Fire: bow faces the same way the shot travels (stern exposed). Before commit: turn the bow to
|
||||
// face the incoming shot head-on, TurningArmourIntoTheShotTakesItOnTheArmour's own sequence.
|
||||
e.Target.Direction = travelDirection;
|
||||
e.Zone.Update(1f);
|
||||
e.Target.Direction = -travelDirection;
|
||||
|
||||
ShotOutcome outcome = null;
|
||||
using var r = e.Zone.ShotResolved.Subscribe(o => outcome = o);
|
||||
e.Zone.Update(4f); // past commit (4.5s), short of arrival (5s)
|
||||
e.Zone.Update(2f); // past arrival
|
||||
|
||||
Assert.NotNull(outcome);
|
||||
Assert.True(outcome.Hit, "fixture: this exact seed/sequence must roll a hit (this is the repro, not a general property)");
|
||||
Assert.True(e.HullData.Shape[outcome.Cell], $"hit landed on {outcome.Cell}, not on the hull's own schematic");
|
||||
Assert.True(outcome.Cell.y >= 5.5f, $"expected the hit to land on the bow row (y>=5.5), got cell {outcome.Cell}");
|
||||
|
||||
var ell = float2(-outcome.Bearing.y, outcome.Bearing.x);
|
||||
var h = (Math.Abs(ell.x) + Math.Abs(ell.y)) / 2f;
|
||||
var centre = dot((float2) outcome.Cell, ell);
|
||||
Assert.True(outcome.Lateral >= centre - h && outcome.Lateral < centre + h,
|
||||
$"hit cell {outcome.Cell}'s own projected lateral interval [{centre - h},{centre + h}) does not contain the drawn Lateral {outcome.Lateral}");
|
||||
}
|
||||
|
||||
// S1 sweep: across many bearings and precisions, on hulls including a non-convex (holed) one, Lane must
|
||||
// find at least one occupied cell for every lateral offset at an interval's own Lo, and just below its Hi
|
||||
// -- the exact edges LateralDraw's own half-open clamp can produce (u=0 draws Lo; u near 1 draws just
|
||||
// below Hi). An empty lane at either edge is precisely the class of crash S1 fixed; this is the general
|
||||
// property the two named-seed repros above are specific instances of.
|
||||
[Fact]
|
||||
public void LaneNeverEmptiesAtAnIntervalEdge()
|
||||
{
|
||||
var shapes = new[] { SolidShape(7, 9), SolidShape(3, 11), HoledShape(7, 7) };
|
||||
var precisions = new[] { .3f, .5f, 1f, 2f };
|
||||
var failures = new List<string>();
|
||||
|
||||
foreach (var shape in shapes)
|
||||
{
|
||||
distance += .5f;
|
||||
cells.Add(int2(point));
|
||||
point += vector * .5f;
|
||||
var hull = new HullData { Name = "Sweep", HullType = HullType.Ship, Shape = shape };
|
||||
var buffer = new LaneCell[shape.Coordinates.Length];
|
||||
for (var deg = 0; deg < 360; deg += 3)
|
||||
{
|
||||
var b = Deg(deg);
|
||||
foreach (var precision in precisions)
|
||||
{
|
||||
var sil = FireControl.Silhouette(null, hull, null, b, precision);
|
||||
for (var k = 0; k < sil.Count; k++)
|
||||
{
|
||||
var iv = sil.Intervals[k];
|
||||
if (FireControl.Lane(hull, b, iv.Lo, buffer) == 0)
|
||||
failures.Add($"{shape.Width}x{shape.Height} deg={deg} p={precision} k={k} at Lo={iv.Lo:R}");
|
||||
var justBelowHi = Math.Max(iv.Lo, iv.Hi - 1e-4f - 1e-5f);
|
||||
if (FireControl.Lane(hull, b, justBelowHi, buffer) == 0)
|
||||
failures.Add($"{shape.Width}x{shape.Height} deg={deg} p={precision} k={k} just below Hi={iv.Hi:R}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return cells;
|
||||
|
||||
Assert.True(failures.Count == 0, $"{failures.Count} empty lanes at an interval edge, e.g.: {string.Join("; ", failures.Take(5))}");
|
||||
}
|
||||
|
||||
// Carried into 12.3's brief (12.2 Soul pass 3): pins Lane's own seam contract directly, against a 2x1 hull
|
||||
// -- the smallest fixture where a seam actually falls between two occupied cells. At b=(0,1), ell=(-1,0),
|
||||
// so cell (0,0)'s shadow is [-.5,.5) and cell (1,0)'s is [.5,1.5): s=-0.5 must land only in (0,0)'s column,
|
||||
// and s=0.5 (the shared seam, exclusive on (0,0)'s side and where (1,0)'s own interval starts) must find
|
||||
// NOTHING here, because this fixture's hull is only 1 cell wide at y=0 -- there is no (1,0). Mutation: the
|
||||
// `s >= lateral.Hi` admission test at FireControl.cs:~817 flipped to `s > lateral.Hi` would let s=0.5
|
||||
// through as still touching (0,0) (0.5 is not > 0.5), which on a hull that DID have a second column would
|
||||
// interleave the two columns' lanes at the seam -- reproduced directly here as "an empty lane's cell count
|
||||
// is wrong", not by requiring the second column to exist.
|
||||
[Fact]
|
||||
public void LaneSeamIsHalfOpen()
|
||||
{
|
||||
var shape = new Shape(1, 1) { [new int2(0, 0)] = true };
|
||||
var hull = new HullData { Name = "Seam", HullType = HullType.Ship, Shape = shape };
|
||||
var b = float2(0, 1);
|
||||
var buffer = new LaneCell[shape.Coordinates.Length];
|
||||
|
||||
var atLo = FireControl.Lane(hull, b, -0.5f, buffer);
|
||||
Assert.Equal(1, atLo);
|
||||
Assert.Equal(new int2(0, 0), buffer[0].Cell);
|
||||
|
||||
var atHi = FireControl.Lane(hull, b, 0.5f, buffer);
|
||||
Assert.Equal(0, atHi); // the seam itself: half-open on the Hi side, so this cell's own shadow excludes it
|
||||
}
|
||||
|
||||
// Carried into 12.3's brief (12.2 Soul pass 3): AlongBearing/SlabAxis had no test of their own VALUES --
|
||||
// every mutant there survived in 12.2 because only buffer[0]'s Cell was ever read (S1's own shadow
|
||||
// prefilter, Extent, decided admission; AlongBearing's entry/exit were computed but unchecked). 12.3's own
|
||||
// walk (FireControl.Apply) reads Entry for penetration and ordering, so a wrong entry/exit here is now a
|
||||
// wrong damage cell, not dead arithmetic.
|
||||
// F10 fix batch (Soul, 2026-09-25): the previous, single-bearing version of this test wrote out SlabAxis's
|
||||
// OWN threshold (`1e-9f`) and clamp a second time, so a mutant that only moved that threshold (C7b, 1e-9 to
|
||||
// .2) agreed with both copies identically and survived. This version never special-cases a near-zero
|
||||
// bearing component at all: IEEE division by a signed zero already yields the correctly signed infinity, so
|
||||
// an axis with no motion is unconstrained without a hand-written epsilon to disagree with SlabAxis's own.
|
||||
// Checked at several bearings, including one within about 11 degrees of an axis -- inside SlabAxis's
|
||||
// mutated .2f threshold but nowhere near the real 1e-9f one, so C7b now has to answer for a visibly wrong
|
||||
// entry/exit instead of an unstressed one.
|
||||
[Fact]
|
||||
public void AlongBearingReturnsTheExactSlabIntersectionAtSeveralBearings()
|
||||
{
|
||||
var shape = SolidShape(5, 5);
|
||||
var hull = new HullData { Name = "Diagonal", HullType = HullType.Ship, Shape = shape };
|
||||
|
||||
(double Entry, double Exit) ExactSlabIndependent(int2 c, double bx, double by, double ellx, double elly, double s)
|
||||
{
|
||||
var valX = s * ellx; var valY = s * elly;
|
||||
var t1X = (c.x - .5 - valX) / bx; var t2X = (c.x + .5 - valX) / bx;
|
||||
var t1Y = (c.y - .5 - valY) / by; var t2Y = (c.y + .5 - valY) / by;
|
||||
var entry = Math.Max(Math.Min(t1X, t2X), Math.Min(t1Y, t2Y));
|
||||
var exit = Math.Min(Math.Max(t1X, t2X), Math.Max(t1Y, t2Y));
|
||||
return (entry, exit);
|
||||
}
|
||||
|
||||
void Check(float2 bRaw, float s)
|
||||
{
|
||||
var b = normalize(bRaw);
|
||||
var ell = float2(-b.y, b.x);
|
||||
var h = (Math.Abs(ell.x) + Math.Abs(ell.y)) / 2.0; // Extent's own half-width, written out independently
|
||||
var expectedCells = shape.Coordinates
|
||||
.Select(c => (Cell: c, Centre: (double) dot((float2) c, ell)))
|
||||
.Where(t => s >= t.Centre - h && s < t.Centre + h) // Extent's own half-open shadow
|
||||
.Select(t => t.Cell)
|
||||
.OrderBy(c => dot((float2) c, b))
|
||||
.ThenBy(c => c.x).ThenBy(c => c.y)
|
||||
.ToList();
|
||||
Assert.True(expectedCells.Count >= 3, $"fixture: b={b.x:R},{b.y:R} s={s} must cross several cells, got {expectedCells.Count}");
|
||||
|
||||
var buffer = new LaneCell[shape.Coordinates.Length];
|
||||
var count = FireControl.Lane(hull, b, s, buffer);
|
||||
var actualCells = Enumerable.Range(0, count).Select(i => buffer[i].Cell).ToList();
|
||||
|
||||
Assert.Equal(expectedCells, actualCells); // same cells, same order -- entry ordering and contiguity agree
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
var (expectedEntry, expectedExit) = ExactSlabIndependent(buffer[i].Cell, b.x, b.y, ell.x, ell.y, s);
|
||||
Assert.Equal(expectedEntry, buffer[i].Entry, 3);
|
||||
Assert.Equal(expectedExit, buffer[i].Exit, 3);
|
||||
}
|
||||
}
|
||||
|
||||
Check(float2(2, 1), 0.13f); // neither axis-aligned nor 45 degrees (the original fixture)
|
||||
Check(float2(1, .15f), .3f); // ~8.5 degrees off the x-axis -- by sits inside C7b's mutated .2f threshold
|
||||
Check(float2(.15f, 1), -.4f); // the same, off the y-axis -- bx sits inside C7b's mutated .2f threshold
|
||||
}
|
||||
|
||||
// Cut 12.3: replaces ExpectedMarchCells, which reproduced Entity.ApplyHit's own deleted 0.5-step march --
|
||||
// that rule is gone with the function. The rule this now pins is the NEW thing FireControl.Apply's lane
|
||||
// walk adds on top of Lane (Lane's own cell set/order/entry values are independently pinned elsewhere, by
|
||||
// AlongBearingReturnsTheExactSlabIntersectionAtSeveralBearings and the LaneNeverEmptiesAtAnIntervalEdge sweep): the
|
||||
// penetration cutoff. So this calls the real, already-verified FireControl.Lane for the walked cells and
|
||||
// their entry parameters, then applies the cutoff independently -- kept only while within `penetration`
|
||||
// cells of the first (impact) cell's own entry; the impact cell is always kept, matching the deleted
|
||||
// `> .5f` threshold's intent at zero cost.
|
||||
private static List<int2> ExpectedLaneCells(HullData hull, float2 bearing, float lateral, float penetration)
|
||||
{
|
||||
var buffer = new LaneCell[hull.Shape.Coordinates.Length];
|
||||
var walked = FireControl.Lane(hull, bearing, lateral, buffer);
|
||||
|
||||
var result = new List<int2>();
|
||||
if (walked == 0) return result;
|
||||
var impactEntry = buffer[0].Entry;
|
||||
for (var i = 0; i < walked; i++)
|
||||
{
|
||||
if (i > 0 && buffer[i].Entry - impactEntry >= penetration) break;
|
||||
result.Add(buffer[i].Cell);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// TurningAfterCommitChangesNothing (R4, closes L464/L465): after commit, turning the target and moving the
|
||||
// shooter must not change where the damage actually lands -- Apply reads no live position or facing.
|
||||
// F5 (Soul's fix batch, 2026-09-24): the original fixture fired with Penetration 0, so ApplyHit's march
|
||||
// (Entity.cs, gated at `penetration > .5f`) never ran and never actually read the bearing Apply passed it
|
||||
// -- a mutant that fed Apply a live (post-turn) bearing instead of the committed one survived (M2a) because
|
||||
// nothing downstream of Cell ever consumed Bearing. Penetration 3 marches several cells deep, so the full
|
||||
// damaged-cell set is asserted against the committed Bearing/Lateral, not the live one.
|
||||
// F5 (Soul's fix batch, 2026-09-24): the original fixture fired with Penetration 0, so the penetration march
|
||||
// never ran and never actually read the bearing Apply passed it -- a mutant that fed Apply a live
|
||||
// (post-turn) bearing instead of the committed one survived (M2a) because nothing downstream of Cell ever
|
||||
// consumed Bearing. Penetration 3 walks the lane several cells deep (Cut 12.3: FireControl.Apply's own lane
|
||||
// walk, replacing the deleted Entity.ApplyHit march), so the full damaged-cell set is asserted against the
|
||||
// committed Bearing/Lateral, not the live one.
|
||||
// Cut 12.3 fix: this fixture's hull carries the flat 1000 armour every Build() call authors, and the Gun's
|
||||
// own Damage is a fixed 5 -- fine for the old even-split model (every cell in the march took an
|
||||
// undetectable-but-nonzero 5/N share), fatal for the new sequential one, where the very first (impact) cell
|
||||
// alone would absorb the whole 5 and leave nothing for the rest of a several-cell-deep lane to show. Lowered
|
||||
// to 0.05 per cell here so 5 damage plainly carries the full penetration-3 span.
|
||||
[Fact]
|
||||
public void TurningAfterCommitChangesNothing()
|
||||
{
|
||||
var settings = TestSettings();
|
||||
var e = Build(settings, SolidShape(7, 7), precision: .5f, velocity: 20, penetration: 3); // 5s flight, commits at 4.5s
|
||||
foreach (var v in e.HullData.Shape.Coordinates) { e.Target.Armor[v.x, v.y] = 0.05f; e.Target.MaxArmor[v.x, v.y] = 0.05f; }
|
||||
|
||||
ShotOutcome committed = null;
|
||||
using var c = e.Zone.ShotCommitted.Subscribe(o => committed = o);
|
||||
|
|
@ -612,7 +929,7 @@ public sealed class FireControlCut12Tests : IDisposable
|
|||
var expectedCell = NearestOccupiedCellAtLateral(e.HullData, committed.Bearing, committed.Lateral);
|
||||
Assert.Equal(expectedCell, committed.Cell); // sanity: production's own Lane agrees with the independent recompute
|
||||
|
||||
var expectedFromCommitted = ExpectedMarchCells(e.HullData, committed.Cell, committed.Bearing, 3f);
|
||||
var expectedFromCommitted = ExpectedLaneCells(e.HullData, committed.Bearing, committed.Lateral, 3f).ToHashSet();
|
||||
|
||||
var before = (float[,]) e.Target.Armor.Clone();
|
||||
|
||||
|
|
@ -628,14 +945,14 @@ public sealed class FireControlCut12Tests : IDisposable
|
|||
// hand-rolled copy of the frame math.
|
||||
var liveTravelDirection = FireControl.TravelDirection(e.Weapon, e.Shooter, e.Target);
|
||||
var wrongBearing = normalize(e.Target.ToSchematic(liveTravelDirection));
|
||||
var expectedFromLive = ExpectedMarchCells(e.HullData, committed.Cell, wrongBearing, 3f);
|
||||
var expectedFromLive = ExpectedLaneCells(e.HullData, wrongBearing, committed.Lateral, 3f).ToHashSet();
|
||||
Assert.NotEqual(expectedFromCommitted, expectedFromLive);
|
||||
|
||||
e.Zone.Update(2f); // past arrival (5s)
|
||||
|
||||
foreach (var cell in expectedFromCommitted)
|
||||
Assert.True(e.Target.Armor[cell.x, cell.y] < before[cell.x, cell.y],
|
||||
$"cell {cell} is on the committed march and must have taken damage, regardless of the post-commit turn");
|
||||
$"cell {cell} is on the committed lane and must have taken damage, regardless of the post-commit turn");
|
||||
|
||||
foreach (var cell in expectedFromLive)
|
||||
if (!expectedFromCommitted.Contains(cell))
|
||||
|
|
@ -803,14 +1120,28 @@ public sealed class FireControlCut12Tests : IDisposable
|
|||
Assert.True(Math.Abs(empiricalShareA - expectedShareA) < .05,
|
||||
$"prong A's empirical share {empiricalShareA:F3} does not match its analytic share {expectedShareA:F3}");
|
||||
|
||||
// Within-prong shape, not just the aggregate share: prong A is x in {0,1}, projected lateral centres
|
||||
// 0 and -1 respectively (ell=(-1,0)); a=-3 sits closer to x=1's centre (-1) than x=0's (0), so a real
|
||||
// Gaussian shape (not a coin flip within the prong, and not "first cell only") puts strictly more mass
|
||||
// on x=1 than x=0.
|
||||
// S2 fix batch (Hands, 2026-09-25): within-prong SHAPE, pinned by ratio, not just direction. Prong A is
|
||||
// x in {0,1}, projected lateral centres 0 and -1 respectively (ell=(-1,0)), a=-3. The old
|
||||
// "atNearColumn > atFarColumn" check survived M12/M12b (an entire second silhouette built at sigma
|
||||
// floor .5 or at sigma*sqrt(2)) and the sigma/sqrt(2) Stryker mutants at :~753/:~750, because every one
|
||||
// of those wrong sigmas still puts more mass on the nearer column -- direction alone can't tell a
|
||||
// sigma of 1.5 from a sigma of 1.5*sqrt(2). The RATIO can: Soul's own figures are ~2.9 at the true
|
||||
// sigma against ~1.73 at sigma*sqrt(2), well separated at 8000 shots. The near and far columns' own raw
|
||||
// (unmerged) intervals are exactly the two ends of `raw` for prong A, reused here rather than
|
||||
// recomputed.
|
||||
var nearInterval = raw.First(iv => Math.Abs(iv.Lo - (-1.5f)) < 1e-3f); // x=1: [-1.5,-0.5)
|
||||
var farInterval = raw.First(iv => Math.Abs(iv.Lo - (-0.5f)) < 1e-3f); // x=0: [-0.5,0.5)
|
||||
var nearMass = Mass(nearInterval);
|
||||
var farMass = Mass(farInterval);
|
||||
var analyticRatio = nearMass / farMass;
|
||||
Assert.True(analyticRatio > 2.3, $"fixture: analytic near/far ratio ({analyticRatio:F3}) must be well clear of the wrong-sigma ratio (~1.73) to actually distinguish the two");
|
||||
|
||||
var atNearColumn = hits.Count(o => o.Cell.x == 1);
|
||||
var atFarColumn = hits.Count(o => o.Cell.x == 0);
|
||||
Assert.True(atNearColumn > atFarColumn,
|
||||
$"expected the column nearer the aim point (x=1, {atNearColumn} hits) to outweigh the far one (x=0, {atFarColumn} hits)");
|
||||
Assert.True(atNearColumn > 0 && atFarColumn > 0, $"expected hits on both columns, got near={atNearColumn} far={atFarColumn}");
|
||||
var empiricalRatio = atNearColumn / (double) atFarColumn;
|
||||
Assert.True(Math.Abs(empiricalRatio - analyticRatio) < .6,
|
||||
$"empirical near/far ratio {empiricalRatio:F3} ({atNearColumn}/{atFarColumn}) does not track the analytic ratio {analyticRatio:F3} -- a sigma perturbed by sqrt(2) would give ~1.73 instead");
|
||||
}
|
||||
|
||||
// HitsLandOnTheFacingEdge supersedes EveryHitLandsOnMetal: on a concave (holed) hull, every hit's Cell is
|
||||
|
|
@ -893,10 +1224,15 @@ public sealed class FireControlCut12Tests : IDisposable
|
|||
// a target jinked off its fire-time projection so pDeviation is strictly less than 1) and checks the
|
||||
// EMPIRICAL hit fraction over the real Commit path against the HUD's own forecast, with a tolerance sized
|
||||
// from the sample (3 sigma of a Bernoulli(p, n)).
|
||||
// S7 fix batch (Hands, 2026-09-25): Tracking is now authored through Build's own `tracking` parameter (one
|
||||
// authoring path for every frozen shooter stat, matching Precision/Accuracy) instead of patching
|
||||
// PendingShot.Tracking after every Fire -- the operator's own rule (2026-09-22) is that a fixture should
|
||||
// author its state up front, not reach into a frozen field post hoc. An authored Tracking of 6 against this
|
||||
// 5x7 hull and jink gives pDeviation ~= .33, strictly between 0 and 1, with no patching.
|
||||
[Fact]
|
||||
public void TheHudEstimateIsTheCommitPrice()
|
||||
{
|
||||
var e = Build(TestSettings(), SolidShape(5, 7), precision: .5f, velocity: 40, spread: 6f); // 2.5s flight, commits at 2.0s
|
||||
var e = Build(TestSettings(), SolidShape(5, 7), precision: .5f, velocity: 40, spread: 6f, tracking: 6f); // 2.5s flight, commits at 2.0s
|
||||
var origin = e.Target.Position;
|
||||
const int shots = 800;
|
||||
|
||||
|
|
@ -906,16 +1242,8 @@ public sealed class FireControlCut12Tests : IDisposable
|
|||
e.Target.Position = origin; // reset before each Fire so every shot freezes the same FireTargetPosition
|
||||
var shotId = FireControl.Fire(e.Weapon, e.WeaponItem, e.Shooter);
|
||||
e.Zone.Update(.001f);
|
||||
// The fixture's own Targeting system freezes Tracking = 100000 (full-strength isolation, Build's
|
||||
// own convention) -- against that, a jink small enough to keep the target on this 5x7 hull barely
|
||||
// registers (pDeviation ~= .99996). Lower the frozen Tracking after the fact, the same way
|
||||
// CommitProbabilityIsTheExactProductOfItsFourFactors overrides a frozen field, so the jink below
|
||||
// produces a pDeviation strictly between 0 and 1.
|
||||
var index = e.Zone.PendingShots.FindIndex(s => s.ShotId == shotId);
|
||||
var shot = e.Zone.PendingShots[index];
|
||||
shot.Tracking = 6f;
|
||||
e.Zone.PendingShots[index] = shot;
|
||||
pendingSnapshots.Add(shot);
|
||||
pendingSnapshots.Add(e.Zone.PendingShots[index]);
|
||||
}
|
||||
|
||||
// One jink, after every shot is queued, before any of them commit -- pDeviation < 1 for all of them,
|
||||
|
|
@ -994,4 +1322,69 @@ public sealed class FireControlCut12Tests : IDisposable
|
|||
Assert.True(AbsorbsFrom(float2(0, -1))); // stern toward the shot
|
||||
Assert.True(AbsorbsFrom(float2(1, 0))); // beam
|
||||
}
|
||||
|
||||
// S3 fix batch (Hands, 2026-09-25): Lane's own comment ("never allocates on its own") and Silhouette's
|
||||
// pooled path are pinned directly, instead of trusting the comment. Measured (Release, LonginusX-shaped
|
||||
// fixture unavailable to this test file -- a 7x9 solid hull is used instead): Lane and Silhouette (given a
|
||||
// caller-supplied buffer) allocate exactly 0 bytes over 1000 calls, confirming the S3 change itself
|
||||
// (Array.Sort(T[], int, int) resolving Interval/LaneCell's own IComparable<T> at JIT time, not the
|
||||
// (T[], int, int, IComparer<T>) overload that wrapped even a cached singleton comparer in a fresh delegate
|
||||
// per call). A full gated-in HitProbability call is NOT zero-allocation (measured ~120 B/call, Release) --
|
||||
// 12.3 fix batch correction: that cost is exactly three GetBehavior<TargetingSystem> calls (Accuracy,
|
||||
// Resolution, Precision, ~40 B each), each walking Entity.Equipment (a ReactiveCollection<T>, heap-allocated
|
||||
// enumerator per foreach) -- NOT `Behaviors` (a plain array, the earlier wording here was wrong; see the
|
||||
// corrected comment on Forecast). It predates this cut and is out of its scope. The loose `< 500_000` bound
|
||||
// below is a regression trip-wire, not a proof: a reintroduced per-call IComparer<T> wrapper (~184 B/call)
|
||||
// would pass it easily. The two zero-allocation asserts just above are what actually catch that regression
|
||||
// -- Lane and Silhouette are exactly where such a wrapper would reappear -- so the bound here only needs to
|
||||
// catch something far larger, such as a reintroduced unpooled Interval[]/LaneCell[] on this path.
|
||||
[Fact]
|
||||
public void LaneAndSilhouetteAllocateNothingGivenAPooledBuffer()
|
||||
{
|
||||
var e = Build(TestSettings(), SolidShape(7, 9), precision: .5f);
|
||||
var hull = e.HullData;
|
||||
var travelDirection = FireControl.TravelDirection(e.Weapon, e.Shooter, e.Target);
|
||||
var bearing = normalize(e.Target.ToSchematic(travelDirection));
|
||||
var sil = FireControl.Silhouette(e.Target, hull, null, bearing, .5f);
|
||||
var laneBuffer = new LaneCell[hull.Shape.Coordinates.Length];
|
||||
var intervalBuffer = new Interval[hull.Shape.Coordinates.Length];
|
||||
|
||||
for (var i = 0; i < 100; i++) FireControl.Lane(hull, bearing, sil.A, laneBuffer); // JIT warm-up
|
||||
for (var i = 0; i < 100; i++) FireControl.Silhouette(e.Target, hull, null, bearing, .5f, intervalBuffer);
|
||||
|
||||
// Steady state, not first-use: under a whole-suite run the runtime's background tier-up is delayed by the
|
||||
// other tests' JIT activity, so a one-off allocation (measured: 1232 bytes over 1000 calls, in 1 of 12
|
||||
// full-suite runs and 0 of 100 isolated runs) can land inside a single window. That is a cost paid once.
|
||||
// A per-call allocation, the regression this test guards, lands in EVERY round, so the smallest round
|
||||
// over a bounded number of rounds is the steady-state allocation.
|
||||
long SmallestRoundAllocation(Action round)
|
||||
{
|
||||
var smallest = long.MaxValue;
|
||||
for (var r = 0; r < 20 && smallest != 0; r++)
|
||||
{
|
||||
var start = GC.GetAllocatedBytesForCurrentThread();
|
||||
round();
|
||||
smallest = Math.Min(smallest, GC.GetAllocatedBytesForCurrentThread() - start);
|
||||
}
|
||||
return smallest;
|
||||
}
|
||||
|
||||
var laneAllocated = SmallestRoundAllocation(() => { for (var i = 0; i < 1000; i++) FireControl.Lane(hull, bearing, sil.A, laneBuffer); });
|
||||
Assert.True(laneAllocated == 0, $"1000 Lane calls allocated {laneAllocated} bytes in every round; \"never allocates\" is not true");
|
||||
|
||||
var silhouetteAllocated = SmallestRoundAllocation(() => { for (var i = 0; i < 1000; i++) FireControl.Silhouette(e.Target, hull, null, bearing, .5f, intervalBuffer); });
|
||||
Assert.True(silhouetteAllocated == 0, $"1000 buffered Silhouette calls allocated {silhouetteAllocated} bytes in every round");
|
||||
|
||||
// Recorded, not asserted zero: the full gated-in HitProbability call still allocates, from Entity's own
|
||||
// collection enumeration (GetBehavior<T> over ReactiveCollection<T>), not from anything this fix batch
|
||||
// touches. A loose upper bound catches a real regression (e.g. a reintroduced comparer wrapper) without
|
||||
// pretending Entity's own cost is Lane's or Silhouette's to fix here.
|
||||
for (var i = 0; i < 100; i++) FireControl.HitProbability(e.Weapon, e.Shooter, e.Target);
|
||||
var before = GC.GetAllocatedBytesForCurrentThread();
|
||||
var sum = 0f;
|
||||
for (var i = 0; i < 1000; i++) sum += FireControl.HitProbability(e.Weapon, e.Shooter, e.Target);
|
||||
var hitProbabilityAllocated = GC.GetAllocatedBytesForCurrentThread() - before;
|
||||
Assert.True(sum > 0f, "fixture: this must be a real, gated-in call, not a gated-out one");
|
||||
Assert.True(hitProbabilityAllocated < 500_000, $"1000 gated-in HitProbability calls allocated {hitProbabilityAllocated} bytes -- well above Entity's own ~120 B/call baseline; likely a reintroduced Lane/Silhouette allocation");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -247,9 +247,10 @@ public sealed class FireControlCut4Tests : IDisposable
|
|||
Assert.Equal(1, resolvedCount);
|
||||
}
|
||||
|
||||
// ---- Cut 4's splash rule: FireControl.Splash is an unconditional area effect (no roll), directional per
|
||||
// target's own hull facing. Tested directly against the function, no weapon/gear catalog needed -- Entity.
|
||||
// MapEntity (called from the Entity constructor) is enough to give a Ship its Armor/GearOccupancy/Hull. ----
|
||||
// ---- Cut 4's blast rule (12.4(b) renames FireControl.Splash to Detonate, and areas replace the
|
||||
// directional half-hull split): FireControl.Detonate is an unconditional area effect, no roll. Tested
|
||||
// directly against the function, no weapon/gear catalog needed -- Entity.MapEntity (called from the Entity
|
||||
// constructor) is enough to give a Ship its Armor/GearOccupancy/Hull. ----
|
||||
|
||||
private ProvenanceLedger _splashLedger;
|
||||
|
||||
|
|
@ -279,10 +280,10 @@ public sealed class FireControlCut4Tests : IDisposable
|
|||
return ship;
|
||||
}
|
||||
|
||||
// Splash is one rule, not per-effect: every entity within radius takes damage, one outside radius takes
|
||||
// A blast is one rule, not per-effect: every entity within radius takes damage, one outside radius takes
|
||||
// none. Mutation: damage only the nearest entity in range instead of every one.
|
||||
[Fact]
|
||||
public void SplashHitsEveryEntityInRadius()
|
||||
public void ABlastHitsEveryEntityItCovers()
|
||||
{
|
||||
var (items, zone) = BuildSplashZone(TestSettings());
|
||||
var near = AddShip(items, zone, float3(10, 0, 0), float2(0, 1), 1);
|
||||
|
|
@ -293,39 +294,15 @@ public sealed class FireControlCut4Tests : IDisposable
|
|||
var farBefore = far.Hull.Durability;
|
||||
var outBefore = outOfRange.Hull.Durability;
|
||||
|
||||
FireControl.Splash(zone, float3.zero, radius: 30, damage: 50, damageType: DamageType.Kinetic);
|
||||
FireControl.Detonate(zone, float2.zero, radius: 30, damage: 50, damageType: DamageType.Kinetic);
|
||||
|
||||
Assert.True(near.Hull.Durability < nearBefore);
|
||||
Assert.True(far.Hull.Durability < farBefore);
|
||||
Assert.Equal(outBefore, outOfRange.Hull.Durability);
|
||||
}
|
||||
|
||||
// Splash is directional over each target's own hull: cells facing the blast take it, cells facing away do
|
||||
// not. Mutation: damage the whole shape regardless of direction.
|
||||
[Fact]
|
||||
public void SplashIsDirectional()
|
||||
{
|
||||
// Nonzero armor so an undamaged cell is distinguishable from a damaged one -- with armor 0 every cell
|
||||
// starts and stays at 0 regardless of which half took the schematic hit.
|
||||
var (items, zone) = BuildSplashZone(TestSettings(), armor: 10);
|
||||
// Facing +Z (the default); the blast sits behind the ship along -Z, so the near half of the hull
|
||||
// (negative-Z cells, closest to the blast) should take damage and the far half (positive-Z) should not.
|
||||
var ship = AddShip(items, zone, float3(0, 0, 10), float2(0, 1), 1);
|
||||
|
||||
FireControl.Splash(zone, float3(0, 0, 0), radius: 50, damage: 1000, damageType: DamageType.Kinetic);
|
||||
|
||||
var hullData = (HullData) items.GetData(ship.Hull);
|
||||
var center = hullData.Shape.CenterOfMass;
|
||||
var nearCellDamaged = false;
|
||||
var farCellUntouched = false;
|
||||
foreach (var v in hullData.Shape.Coordinates)
|
||||
{
|
||||
var offset = (float2) v - center;
|
||||
if (offset.y < -.5f && ship.Armor[v.x, v.y] < ship.MaxArmor[v.x, v.y]) nearCellDamaged = true;
|
||||
if (offset.y > .5f && ship.Armor[v.x, v.y] >= ship.MaxArmor[v.x, v.y]) farCellUntouched = true;
|
||||
}
|
||||
|
||||
Assert.True(nearCellDamaged);
|
||||
Assert.True(farCellUntouched);
|
||||
}
|
||||
// Superseded (docs/fire-control-cut.md, "Symmetry and frame"): ABlastDamagesTheCellsNearestIt in
|
||||
// FireControlCut124Tests.cs succeeds this test (SplashIsDirectional) and Cut11Tests'
|
||||
// SplashDamagesTheSideTheBlastCameFrom -- a blast is now an area (12.4(b)), not a directional half-hull
|
||||
// split, so "which cells take it" is pinned by the disc's own coverage, not a facing-rotated half-shape.
|
||||
}
|
||||
|
|
|
|||
|
|
@ -499,12 +499,16 @@ public sealed class FireControlCut5Tests : IDisposable
|
|||
Assert.Equal(0, resolvedCount);
|
||||
}
|
||||
|
||||
// A named Soul-pass survivor (docs/fire-control-cut.md Cut 5 Verification): FireControl.Splash's shield
|
||||
// branch must actually break an unabsorbed shield, not merely route the remainder to the hull. Mutation:
|
||||
// delete `shield.Break()` from Splash -- the target's hull still takes the blast (SplashHitsEveryEntityInRadius
|
||||
// stays green), but the shield itself never registers the overwhelming hit and keeps absorbing on schedule.
|
||||
// A named Soul-pass survivor (docs/fire-control-cut.md Cut 5 Verification), rewritten to Detonate (12.4(b),
|
||||
// "Retargeted, because Absorb is deleted" / Q12-9 = A): the blast's shield branch must actually break an
|
||||
// unabsorbed shield, not merely route the remainder to the hull. A radius this much larger than the hull
|
||||
// covers essentially the whole disc's damage on the target's own cells, overwhelming a 5-capacity reserve
|
||||
// however the exact per-cell shares fall -- the expected amount is not loosened, it was never asserted
|
||||
// precisely here (only that the shield breaks). Mutation: delete `shield.Break()` from Detonate -- the
|
||||
// target's hull still takes the blast (ABlastHitsEveryEntityItCovers stays green), but the shield itself
|
||||
// never registers the overwhelming hit and keeps absorbing on schedule.
|
||||
[Fact]
|
||||
public void SplashBreaksUnabsorbedShield()
|
||||
public void ABlastBreaksUnabsorbedShield()
|
||||
{
|
||||
var e = Build(TestSettings(), damage: 10, velocity: 0, accuracy: 1, resolution: 1, spread: 0, armor: 0,
|
||||
equipShield: true, shieldCapacity: 5);
|
||||
|
|
@ -512,7 +516,10 @@ public sealed class FireControlCut5Tests : IDisposable
|
|||
Assert.False(e.Target.Shield.Broken);
|
||||
Assert.False(e.Target.Shield.CanTakeHit(DamageType.Kinetic, 500));
|
||||
|
||||
FireControl.Splash(e.Zone, e.Target.Position, radius: 50, damage: 500, damageType: DamageType.Kinetic);
|
||||
// radius 1, centred on the target's own position (its hull's centre of mass): well inside the 5x5
|
||||
// solid hull's interior, so the disc never spills off the hull and the covered share equals the whole
|
||||
// damage exactly, the same amount Splash always charged.
|
||||
FireControl.Detonate(e.Zone, e.Target.Position.xz, radius: 1, damage: 500, damageType: DamageType.Kinetic);
|
||||
|
||||
Assert.True(e.Target.Shield.Broken);
|
||||
}
|
||||
|
|
@ -614,12 +621,12 @@ public sealed class FireControlCut5Tests : IDisposable
|
|||
var e = Build(TestSettings(), damage: 10000, velocity: 0, accuracy: 1, resolution: 1, spread: 0,
|
||||
hullDurability: 5, armor: 0); // one hit is lethal
|
||||
|
||||
Assert.Contains(e.Target, e.Zone.Entities);
|
||||
SafeAssert.In(e.Zone, e.Target);
|
||||
FireControl.Fire(e.Weapon, e.WeaponItem, e.Shooter);
|
||||
e.Zone.Update(.1f);
|
||||
|
||||
Assert.True(e.Target.Hull.Durability < .01f);
|
||||
Assert.DoesNotContain(e.Target, e.Zone.Entities);
|
||||
SafeAssert.NotIn(e.Zone, e.Target);
|
||||
}
|
||||
|
||||
// ---- 5.7: delete the two carried-and-unread fields (Soul finding 12). ----
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ public sealed class FireControlCut6Tests : IDisposable
|
|||
GameplaySettings settings,
|
||||
float damage = 10, float range = 1000, float velocity = 0, float spread = 0,
|
||||
float accuracy = 1, float resolution = 1, float tracking = 100000,
|
||||
float targetRange = 100, bool airburst = false, float airburstRange = 0)
|
||||
float targetRange = 100, WeaponFuse? fuse = null, float blastRadius = 0)
|
||||
{
|
||||
var hullShape = SolidShape(5, 5);
|
||||
var hullData = new HullData
|
||||
|
|
@ -91,14 +91,15 @@ public sealed class FireControlCut6Tests : IDisposable
|
|||
_openCaches.Add(cache);
|
||||
cache.Upsert(new TestCatalogGlobal { Name = "Temperament" });
|
||||
cache.Upsert(hullData);
|
||||
// Cut 6b, 6.2: a real WeaponItemData (not the bare GearData earlier cuts' fixtures use) -- it is the
|
||||
// one catalog type carrying WeaponModifiers (the Airburst flag) and, since this cut, AirburstRange.
|
||||
// Cut 6b, 6.2 (renamed 12.4(a)): a real WeaponItemData (not the bare GearData earlier cuts' fixtures
|
||||
// use) -- it is the one catalog type carrying Fuse and BlastRadius. WeaponModifiers no longer decides
|
||||
// behaviour (Q12-6), so the fixture does not bother setting it.
|
||||
cache.Upsert(new WeaponItemData
|
||||
{
|
||||
Name = "Gun", Hardpoint = HardpointType.Sensors, Shape = new Shape(), Durability = 1,
|
||||
MinimumTemperature = -1000, MaximumTemperature = 1000, OptimalTemperature = 0, PlateauWidth = 2000,
|
||||
WeaponModifiers = airburst ? WeaponModifiers.Airburst : WeaponModifiers.None,
|
||||
AirburstRange = airburstRange,
|
||||
Fuse = fuse,
|
||||
BlastRadius = blastRadius,
|
||||
Behaviors = { new InstantWeaponData
|
||||
{
|
||||
Damage = Constant(damage), Range = Constant(range), MinRange = Constant(0),
|
||||
|
|
@ -234,19 +235,20 @@ public sealed class FireControlCut6Tests : IDisposable
|
|||
|
||||
// ---- 6.2: airburst resolves in the simulation (Soul finding 5). ----
|
||||
|
||||
// An airburst shot resolves via Splash, and Splash does not gate on the discrete hit roll at all -- it
|
||||
// damages everything in radius unconditionally (Cut 4's rule). Accuracy 0 pins PBase (and so Commit's hit)
|
||||
// to false with no dependence on the random draw, so a normal discrete shot would apply no damage
|
||||
// whatsoever (Apply's own `if (!shot.Outcome.Hit) return;`). An airburst shot must still deal its area
|
||||
// damage. Mutation: call Apply as well as Splash -- harmless here (Apply still no-ops on a miss), so this
|
||||
// test alone does not catch that mutation; AirburstAndDiscreteNeverDoubleUp below does, with a guaranteed
|
||||
// hit where an extra Apply call is not a no-op.
|
||||
// A proximity-fuse shot detonates unconditionally, at arrival, with no roll (12.4(b)'s "Which model a shot
|
||||
// uses") -- it damages everything in radius regardless of the discrete hit roll (Cut 4's rule, kept).
|
||||
// Accuracy 0 pins PBase (and so Commit's hit) to false with no dependence on the random draw, so a direct
|
||||
// hit would apply no damage whatsoever (Apply's own gate on shot.Outcome.Hit). A proximity shot must still
|
||||
// deal its area damage. Mutation: route a proximity fuse through the direct-hit branch instead -- harmless
|
||||
// here (that branch still no-ops on a miss), so this test alone does not catch that mutation;
|
||||
// AirburstAndDiscreteNeverDoubleUp below does, with a guaranteed hit where an extra direct-hit application
|
||||
// is not a no-op.
|
||||
[Fact]
|
||||
public void AirburstSplashesEvenOnAGuaranteedMiss()
|
||||
public void ProximityDetonatesEvenOnAGuaranteedMiss()
|
||||
{
|
||||
var settings = TestSettings();
|
||||
var e = Build(settings, damage: 500, velocity: 0, accuracy: 0, resolution: 1, tracking: 100000,
|
||||
targetRange: 50, airburst: true, airburstRange: 100);
|
||||
targetRange: 50, fuse: WeaponFuse.Proximity, blastRadius: 100);
|
||||
|
||||
var before = e.Target.Hull.Durability;
|
||||
FireControl.Fire(e.Weapon, e.WeaponItem, e.Shooter);
|
||||
|
|
@ -255,49 +257,52 @@ public sealed class FireControlCut6Tests : IDisposable
|
|||
Assert.True(e.Target.Hull.Durability < before, "An airburst shot must splash regardless of the discrete hit roll.");
|
||||
}
|
||||
|
||||
// The double-application Soul was told to hunt for: with a guaranteed hit (accuracy 1), an airburst shot's
|
||||
// total damage must equal a bare Splash call's own damage -- not more. Mutation: call Apply as well as
|
||||
// Splash at arrival -- Apply's own discrete cell hit would land on top of Splash's area damage, so the
|
||||
// airburst shot's total damage exceeds a lone Splash call's.
|
||||
// The double-application Soul was told to hunt for: with a guaranteed hit (accuracy 1), a proximity shot's
|
||||
// total damage must equal a bare Detonate call's own damage -- not more. Mutation: route the shot through
|
||||
// the direct-hit branch as well as Detonate at arrival -- the direct-hit cell would land on top of
|
||||
// Detonate's area damage, so the shot's total damage exceeds a lone Detonate call's.
|
||||
[Fact]
|
||||
public void AirburstAndDiscreteNeverDoubleUp()
|
||||
{
|
||||
var settings = TestSettings();
|
||||
|
||||
var e = Build(settings, damage: 10, velocity: 0, accuracy: 1, resolution: 1, tracking: 100000,
|
||||
targetRange: 50, airburst: true, airburstRange: 100);
|
||||
// 12.4(b)'s area model spreads damage over pi*r^2, so a radius this much larger than the 5x5 target
|
||||
// needs enough damage that the covered share still clears DamageHull's .1f threshold (matching
|
||||
// ProximityDetonatesEvenOnAGuaranteedMiss's own damage, above).
|
||||
var e = Build(settings, damage: 500, velocity: 0, accuracy: 1, resolution: 1, tracking: 100000,
|
||||
targetRange: 50, fuse: WeaponFuse.Proximity, blastRadius: 100);
|
||||
var before = e.Target.Hull.Durability;
|
||||
FireControl.Fire(e.Weapon, e.WeaponItem, e.Shooter);
|
||||
e.Zone.Update(.01f);
|
||||
var actualDelta = before - e.Target.Hull.Durability;
|
||||
|
||||
// A fresh, identically-shaped target, damaged by one bare Splash call with the same parameters
|
||||
// A fresh, identically-shaped target, damaged by one bare Detonate call with the same parameters
|
||||
// FireControl.Fire freezes for this weapon (BurstPosition, for a stationary velocity-0 target, is
|
||||
// exactly its own position -- PredictedIntercept falls back to target.Position below weapon.Velocity's
|
||||
// .01f floor).
|
||||
var e2 = Build(settings, damage: 10, velocity: 0, accuracy: 1, resolution: 1, tracking: 100000,
|
||||
targetRange: 50, airburst: true, airburstRange: 100);
|
||||
var e2 = Build(settings, damage: 500, velocity: 0, accuracy: 1, resolution: 1, tracking: 100000,
|
||||
targetRange: 50, fuse: WeaponFuse.Proximity, blastRadius: 100);
|
||||
var before2 = e2.Target.Hull.Durability;
|
||||
FireControl.Splash(e2.Zone, e2.Target.Position, 100, 10, DamageType.Kinetic);
|
||||
FireControl.Detonate(e2.Zone, e2.Target.Position.xz, 100, 500, DamageType.Kinetic);
|
||||
var expectedDelta = before2 - e2.Target.Hull.Durability;
|
||||
|
||||
Assert.True(expectedDelta > 0);
|
||||
Assert.Equal(expectedDelta, actualDelta, 3);
|
||||
}
|
||||
|
||||
// The other side: a non-airburst shot must never splash, even one that lands exactly on its own frozen
|
||||
// burst position at zero range (a stationary target, so BurstPosition == the target's own position at
|
||||
// arrival) -- the zero-radius edge case a careless "splash unconditionally" mutant would still pass
|
||||
// through, since distance 0 is never greater than radius 0. Accuracy 0 pins the discrete roll to a
|
||||
// guaranteed miss, so the correct path (Apply, gated on Outcome.Hit) deals no damage at all. Mutation:
|
||||
// splash unconditionally at arrival instead of gating on BurstRadius -- Splash does not check Hit, so it
|
||||
// would still deal damage even though this shot never carried the Airburst flag.
|
||||
// The other side: a shot with no fuse must never detonate, even one whose frozen burst position (unread,
|
||||
// for a null-fuse shot) would land exactly at zero range on a stationary target -- the zero-radius edge
|
||||
// case a careless "detonate unconditionally" mutant would still pass through, since distance 0 is never
|
||||
// greater than radius 0. Accuracy 0 pins the discrete roll to a guaranteed miss, so the correct path
|
||||
// (Apply's null-fuse branch, gated on Outcome.Hit) deals no damage at all. Mutation: detonate unconditionally
|
||||
// at arrival instead of switching on the frozen Fuse -- Detonate does not check Hit, so it would still deal
|
||||
// damage even though this shot never froze a fuse.
|
||||
[Fact]
|
||||
public void NonAirburstNeverSplashes()
|
||||
public void NoFuseNeverDetonates()
|
||||
{
|
||||
var settings = TestSettings();
|
||||
var e = Build(settings, damage: 1000, velocity: 0, accuracy: 0, resolution: 1, tracking: 100000,
|
||||
targetRange: 50, airburst: false);
|
||||
targetRange: 50);
|
||||
|
||||
var before = e.Target.Hull.Durability;
|
||||
FireControl.Fire(e.Weapon, e.WeaponItem, e.Shooter);
|
||||
|
|
@ -306,6 +311,31 @@ public sealed class FireControlCut6Tests : IDisposable
|
|||
Assert.Equal(before, e.Target.Hull.Durability);
|
||||
}
|
||||
|
||||
// ---- Cut 12.4(a): Fire decides "detonates" once, from the weapon's own data fields, never from a label
|
||||
// (Q12-6, "WeaponModifiers are labels, not behaviour"). A fuse without a radius is inert: it freezes null,
|
||||
// not the weapon's Fuse. ----
|
||||
|
||||
// Mutation: freeze `weaponItemData.Fuse` unconditionally instead of gating it on `blastRadius > 0f` -- a
|
||||
// weapon that carries a fuse but no radius would then freeze a fuse it should not, and Apply's future
|
||||
// fuse switch (12.4(b)) would try to detonate a shot with nothing to detonate with.
|
||||
[Fact]
|
||||
public void FireFreezesFuseOnlyWhenBlastRadiusIsPositive()
|
||||
{
|
||||
var settings = TestSettings();
|
||||
|
||||
var withRadius = Build(settings, fuse: WeaponFuse.Delayed, blastRadius: 40);
|
||||
FireControl.Fire(withRadius.Weapon, withRadius.WeaponItem, withRadius.Shooter);
|
||||
var shotWithRadius = withRadius.Zone.PendingShots[0];
|
||||
Assert.Equal(WeaponFuse.Delayed, shotWithRadius.Fuse);
|
||||
Assert.Equal(40f, shotWithRadius.BlastRadius);
|
||||
|
||||
var withoutRadius = Build(settings, fuse: WeaponFuse.Delayed, blastRadius: 0);
|
||||
FireControl.Fire(withoutRadius.Weapon, withoutRadius.WeaponItem, withoutRadius.Shooter);
|
||||
var shotWithoutRadius = withoutRadius.Zone.PendingShots[0];
|
||||
Assert.Null(shotWithoutRadius.Fuse);
|
||||
Assert.Equal(0f, shotWithoutRadius.BlastRadius);
|
||||
}
|
||||
|
||||
// ---- negative: ItemManager.Random no longer appears in FireControl.cs; Airburst no longer appears
|
||||
// anywhere under Assets/Scripts/Gameplay (Projectile.cs's fields and ProjectileManager.cs's write-back are
|
||||
// deleted, not merely unused). Enforced by tests/mutation_tests_fire_control_cut6.sh's negative-grep step,
|
||||
|
|
|
|||
|
|
@ -293,10 +293,10 @@ public sealed class FireControlCut8Tests : IDisposable
|
|||
e.Zone.Update(.1f);
|
||||
|
||||
Assert.True(e.Target.Hull.Durability < .01f);
|
||||
Assert.DoesNotContain(e.Target, e.Zone.Entities);
|
||||
SafeAssert.NotIn(e.Zone, e.Target);
|
||||
Assert.False(e.Target.Active);
|
||||
Assert.Empty(e.Target.EntityInfoGathered);
|
||||
Assert.Empty(e.Target.VisibleEntities);
|
||||
Assert.True(e.Target.VisibleEntities.Count == 0, "the target's visible set must be empty");
|
||||
}
|
||||
|
||||
// ---- Ordering risk (8.1's own callout): EntityInstance's loot-drop subscription (EntityInstance.cs:292-325)
|
||||
|
|
|
|||
|
|
@ -428,7 +428,7 @@ public sealed class FireControlCut9Tests : IDisposable
|
|||
e.Shooter.EntityInfoGathered[e.Target] = info;
|
||||
var hud = FireControl.Inspect(e.Weapon, e.Shooter, e.Target);
|
||||
var hot = FireControl.HitProbability(e.Weapon, e.Shooter, e.Target);
|
||||
Assert.True(hud.Visible && hud.InRange && hud.Locked && hud.InArc, $"info {info}: precondition, every gate open");
|
||||
Assert.True(hud.Designated && hud.InArc, $"info {info}: precondition, every gate open");
|
||||
Assert.True(hot > 0f, $"info {info}, Precision {precision}: precondition, a shot that can land");
|
||||
Assert.Equal(hot, hud.Accuracy * hud.PSensor * hud.PSpread * hud.POnHull, 5);
|
||||
sawPartialSpread |= hud.PSpread < .99f;
|
||||
|
|
@ -445,7 +445,7 @@ public sealed class FireControlCut9Tests : IDisposable
|
|||
}
|
||||
|
||||
e.Target.Position = origin + float3(0, 0, 5000);
|
||||
Closed("out of range", d => d.InRange);
|
||||
Closed("out of range", d => d.Designated);
|
||||
e.Target.Position = origin + float3(0, 0, -100);
|
||||
Closed("behind the mount", d => d.InArc);
|
||||
|
||||
|
|
@ -455,13 +455,13 @@ public sealed class FireControlCut9Tests : IDisposable
|
|||
e.Target.Position = float3(600, 0, 500);
|
||||
var far = FireControl.Inspect(e.Weapon, e.Shooter, e.Target);
|
||||
Assert.Equal(500f, far.Range, 3);
|
||||
Assert.True(far.InRange && FireControl.HitProbability(e.Weapon, e.Shooter, e.Target) > 0f, "shooter far from the origin");
|
||||
Assert.True(far.Designated && FireControl.HitProbability(e.Weapon, e.Shooter, e.Target) > 0f, "shooter far from the origin");
|
||||
checkedConfigurations++;
|
||||
e.Shooter.Position = origin;
|
||||
e.Target.Position = origin + float3(0, 0, 100);
|
||||
|
||||
e.Shooter.VisibleEntities.Remove(e.Target);
|
||||
Closed("not visible", d => d.Visible);
|
||||
Closed("not visible", d => d.Designated);
|
||||
|
||||
Assert.False(FireControl.Inspect(e.Weapon, e.Shooter, null).HasTarget);
|
||||
Assert.Equal(0f, FireControl.HitProbability(e.Weapon, e.Shooter, null));
|
||||
|
|
|
|||
789
tests/Aetheria.Shared.Tests/FireControlPerWeaponTests.cs
Normal file
789
tests/Aetheria.Shared.Tests/FireControlPerWeaponTests.cs
Normal file
|
|
@ -0,0 +1,789 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using CultMath;
|
||||
using GameCult.Caching;
|
||||
using UniRx;
|
||||
using Xunit;
|
||||
using static CultMath.math;
|
||||
using float2 = CultMath.float2;
|
||||
using float3 = CultMath.float3;
|
||||
using int2 = CultMath.int2;
|
||||
|
||||
// Operator rulings 2026-09-30 (fuse batch 5): AI and turrets decide per weapon and a fused weapon needs a
|
||||
// designated target; the HUD forecast shows a fused weapon's outcome and reads the same decision Fire flies; a
|
||||
// refused round is free, for a discrete weapon and for a beam. Builds its own fixture, the convention every
|
||||
// fire-control test file follows: its shooter carries several mounts and can hold either kind of weapon.
|
||||
public sealed class FireControlPerWeaponTests : IDisposable
|
||||
{
|
||||
private readonly string _root = Path.Combine(Path.GetTempPath(), "aetheria-firecontrolperweapon-" + Guid.NewGuid().ToString("N"));
|
||||
private string Catalog => Path.Combine(_root, "Aetheria.cc");
|
||||
|
||||
public FireControlPerWeaponTests() => Directory.CreateDirectory(_root);
|
||||
|
||||
private readonly List<CultCache> _openCaches = new List<CultCache>();
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var c in _openCaches) c.Dispose();
|
||||
Directory.Delete(_root, true);
|
||||
}
|
||||
|
||||
private static GameplaySettings TestSettings(float minHit) => new GameplaySettings
|
||||
{
|
||||
DefaultEntitySettings = new EntitySettings(),
|
||||
Tiers = new[] { new RarityTier { Name = "Common", Quality = .5f, Rarity = 0, Color = new float3(1, 1, 1) } },
|
||||
QualityPriceModifier = new ExponentialLerp(),
|
||||
TargetDetectionInfoThreshold = .1f,
|
||||
TargetArmorInfoThreshold = .2f,
|
||||
TargetGearInfoThreshold = .8f,
|
||||
FiringArc = 170,
|
||||
CommitHorizon = .5f,
|
||||
SchematicCellSize = 2f,
|
||||
UnaidedAccuracy = .05f,
|
||||
UnaidedTracking = 10f,
|
||||
UnaidedPrecision = 1000f,
|
||||
AgentMinHitProbability = minHit,
|
||||
BeamResolveInterval = .1f
|
||||
};
|
||||
|
||||
private static PerformanceStat Constant(float v) => new PerformanceStat { Min = v, Max = v };
|
||||
|
||||
private static Shape SolidShape(int w, int h)
|
||||
{
|
||||
var shape = new Shape(w, h);
|
||||
foreach (var cell in shape.AllCoordinates) shape[cell] = true;
|
||||
return shape;
|
||||
}
|
||||
|
||||
private sealed class Gun
|
||||
{
|
||||
public EquippedItem Item;
|
||||
public Weapon Weapon;
|
||||
}
|
||||
|
||||
private sealed class Rig
|
||||
{
|
||||
public Zone Zone;
|
||||
public Ship Shooter;
|
||||
public Ship Target;
|
||||
public List<Gun> Guns = new List<Gun>();
|
||||
public Gun Gun => Guns[0];
|
||||
public Gun Decoy;
|
||||
}
|
||||
|
||||
// Mount 0 (None, arc 0) bears on a target dead ahead; (Clockwise, arc 0) is a side mount the default 170
|
||||
// degree arc cannot bring to bear on it. Fused: Proximity with `blast`, which is also its arming distance: blast 30
|
||||
// arms at 30, so a Range of 29.5 refuses and 40 fires.
|
||||
private Rig Build(
|
||||
(ItemRotation Rotation, float Arc)[] mounts = null, bool beam = false, WeaponFuse? fuse = null, float blast = 0f,
|
||||
float range = 100f, float targetRange = 60f, float accuracy = 1f, float minHit = .2f, bool lockWeapon = false,
|
||||
bool turret = false, float energy = 0f, float heat = 0f, float visibility = 0f, int magazine = 0, bool singleAmmoBurst = false, bool decoy = false, bool charged = false, bool auto = false)
|
||||
{
|
||||
mounts ??= new[] { (ItemRotation.None, 0f) };
|
||||
var hullData = new HullData
|
||||
{
|
||||
Name = "Hull", HullType = HullType.Ship, Shape = SolidShape(5, 4), Durability = 1000000, Mass = 1000, Armor = 0,
|
||||
Hardpoints = { new HardpointData { Type = HardpointType.Sensors, Position = new int2(0, 0), Shape = new Shape() } }
|
||||
};
|
||||
var shooterHullData = new HullData
|
||||
{
|
||||
Name = "ShooterHull", HullType = HullType.Ship, Shape = SolidShape(5, 5), Durability = 1000000, Mass = 1000
|
||||
};
|
||||
for (var i = 0; i < mounts.Length; i++)
|
||||
shooterHullData.Hardpoints.Add(new HardpointData
|
||||
{
|
||||
Type = HardpointType.Sensors, Position = new int2(i, 0), Shape = new Shape(),
|
||||
Rotation = mounts[i].Rotation, FiringArc = mounts[i].Arc
|
||||
});
|
||||
// A second weapon type on its own mount (a group of its own, since groups are per item type), dead ahead
|
||||
// and unfused, weaker than the gun: what a group pick falls back to when the gun's group is refused.
|
||||
if (decoy)
|
||||
shooterHullData.Hardpoints.Add(new HardpointData
|
||||
{
|
||||
Type = HardpointType.Sensors, Position = new int2(mounts.Length, 0), Shape = new Shape(),
|
||||
Rotation = ItemRotation.None, FiringArc = 0f
|
||||
});
|
||||
|
||||
WeaponData behavior;
|
||||
if (beam)
|
||||
behavior = new ConstantWeaponData();
|
||||
else if (lockWeapon)
|
||||
behavior = new LockWeaponData
|
||||
{
|
||||
LockSpeed = Constant(1000), SensorImpact = Constant(1), LockAngle = Constant(0), DirectionImpact = Constant(1), Decay = Constant(1),
|
||||
Count = Constant(1), BurstTime = Constant(0), Cooldown = Constant(1)
|
||||
};
|
||||
else if (charged)
|
||||
behavior = new ChargedWeaponData
|
||||
{
|
||||
Count = Constant(1), BurstTime = Constant(0), Cooldown = Constant(1), SingleAmmoBurst = singleAmmoBurst,
|
||||
ChargeTime = Constant(1), ChargeEnergy = Constant(0), ChargeHeat = Constant(5000), CanFireEarly = true
|
||||
};
|
||||
else if (auto)
|
||||
behavior = new AutoWeaponData { Count = Constant(1), BurstTime = Constant(0), Cooldown = Constant(1), SingleAmmoBurst = singleAmmoBurst };
|
||||
else
|
||||
behavior = new InstantWeaponData { Count = Constant(1), BurstTime = Constant(0), Cooldown = Constant(1), SingleAmmoBurst = singleAmmoBurst };
|
||||
behavior.Damage = Constant(100);
|
||||
behavior.Range = Constant(range);
|
||||
behavior.MinRange = Constant(0);
|
||||
behavior.Velocity = Constant(0);
|
||||
behavior.Spread = Constant(0);
|
||||
behavior.DamageSpread = Constant(0);
|
||||
behavior.Penetration = Constant(0);
|
||||
behavior.Energy = Constant(energy);
|
||||
behavior.Heat = Constant(heat);
|
||||
behavior.Visibility = Constant(visibility);
|
||||
behavior.MagazineSize = magazine;
|
||||
behavior.DamageCurve = new BezierCurve { Keys = new[] { float4(0, 1, 0, 0), float4(1, 1, 0, 0) } };
|
||||
|
||||
var cache = AetheriaStores.Open(Catalog + Guid.NewGuid().ToString("N"), catalogWritable: true);
|
||||
_openCaches.Add(cache);
|
||||
cache.Upsert(new TestCatalogGlobal { Name = "Temperament" });
|
||||
cache.Upsert(hullData);
|
||||
cache.Upsert(shooterHullData);
|
||||
cache.Upsert(new WeaponItemData
|
||||
{
|
||||
Name = "Gun", Hardpoint = HardpointType.Sensors, Shape = new Shape(), Durability = 1,
|
||||
MinimumTemperature = -1000, MaximumTemperature = 1000, OptimalTemperature = 0, PlateauWidth = 2000,
|
||||
Fuse = fuse, BlastRadius = blast,
|
||||
Behaviors = { behavior }
|
||||
});
|
||||
cache.Upsert(new WeaponItemData
|
||||
{
|
||||
Name = "Decoy", Hardpoint = HardpointType.Sensors, Shape = new Shape(), Durability = 1,
|
||||
MinimumTemperature = -1000, MaximumTemperature = 1000, OptimalTemperature = 0, PlateauWidth = 2000,
|
||||
Behaviors =
|
||||
{
|
||||
new InstantWeaponData
|
||||
{
|
||||
Count = Constant(1), BurstTime = Constant(0), Cooldown = Constant(1), Damage = Constant(50), Range = Constant(100),
|
||||
MinRange = Constant(0), Velocity = Constant(0), Spread = Constant(0), DamageSpread = Constant(0), Penetration = Constant(0),
|
||||
Energy = Constant(0), Heat = Constant(0), Visibility = Constant(0),
|
||||
DamageCurve = new BezierCurve { Keys = new[] { float4(0, 1, 0, 0), float4(1, 1, 0, 0) } }
|
||||
}
|
||||
}
|
||||
});
|
||||
cache.Upsert(new GearData
|
||||
{
|
||||
Name = "Targeting", Hardpoint = HardpointType.Tool, Shape = new Shape(), Durability = 1,
|
||||
MinimumTemperature = -1000, MaximumTemperature = 1000, OptimalTemperature = 0, PlateauWidth = 2000,
|
||||
Behaviors = { new TargetingSystemData { Accuracy = Constant(accuracy), Resolution = Constant(1000f), Precision = Constant(1000f), Tracking = Constant(1000000f) } }
|
||||
});
|
||||
cache.Upsert(new GearData
|
||||
{
|
||||
Name = "Reactor", Hardpoint = HardpointType.Tool, Shape = new Shape(), Durability = 10,
|
||||
MinimumTemperature = -1000, MaximumTemperature = 1000, OptimalTemperature = 0, PlateauWidth = 2000,
|
||||
Behaviors = { new ReactorData { Charge = Constant(1000), Efficiency = Constant(1), OverloadEfficiency = Constant(1), ThrottlingFactor = Constant(2) } }
|
||||
});
|
||||
cache.Upsert(new GearData
|
||||
{
|
||||
Name = "Turret", Hardpoint = HardpointType.Tool, Shape = new Shape(), Durability = 1,
|
||||
MinimumTemperature = -1000, MaximumTemperature = 1000, OptimalTemperature = 0, PlateauWidth = 2000,
|
||||
Behaviors = { new TurretControllerData() }
|
||||
});
|
||||
cache.FlushAsync().Wait();
|
||||
|
||||
var ledger = new ProvenanceLedger();
|
||||
for (var i = 1; i <= 100; i++) ledger.Lots[i] = new Lot { Origin = new Attributed(), Quality = 1 };
|
||||
var items = new ItemManager(cache, ledger, TestSettings(minHit), _ => { });
|
||||
var zone = new Zone(items, new PlanetSettings(), new ZonePack(), new GalaxyZone { Name = "PerWeapon", Owner = null }, null);
|
||||
|
||||
EquippableItem Make(string name, int lot, float durability) => new EquippableItem
|
||||
{
|
||||
Data = items.ItemData.RefOf<ItemData>(items.ItemData.GetByName<ItemData>(name)), Durability = durability, Lot = lot
|
||||
};
|
||||
|
||||
var lot = 1;
|
||||
var shooterHullRef = items.ItemData.RefOf<ItemData>(items.ItemData.GetByName<HullData>("ShooterHull"));
|
||||
var hullRef = items.ItemData.RefOf<ItemData>(items.ItemData.GetByName<HullData>("Hull"));
|
||||
var shooter = new Ship(items, zone, new EquippableItem { Data = shooterHullRef, Durability = 1000000, Lot = lot++ }, new EntitySettings());
|
||||
var rig = new Rig();
|
||||
for (var i = 0; i < mounts.Length; i++)
|
||||
{
|
||||
var gun = Make("Gun", lot++, 1);
|
||||
Assert.True(shooter.TryEquip(gun, new int2(i, 0)));
|
||||
var item = shooter.Equipment.Single(x => x.EquippableItem == gun);
|
||||
rig.Guns.Add(new Gun { Item = item, Weapon = (Weapon) item.Behaviors.Single(b => b is Weapon) });
|
||||
}
|
||||
if (decoy)
|
||||
{
|
||||
var d = Make("Decoy", lot++, 1);
|
||||
Assert.True(shooter.TryEquip(d, new int2(mounts.Length, 0)));
|
||||
var item = shooter.Equipment.Single(x => x.EquippableItem == d);
|
||||
rig.Decoy = new Gun { Item = item, Weapon = (Weapon) item.Behaviors.Single(b => b is Weapon) };
|
||||
}
|
||||
var targeting = Make("Targeting", lot++, 1);
|
||||
Assert.True(shooter.TryFindSpace(targeting, out var tpos));
|
||||
Assert.True(shooter.TryEquip(targeting, tpos));
|
||||
if (true)
|
||||
{
|
||||
var reactor = Make("Reactor", lot++, 10);
|
||||
Assert.True(shooter.TryFindSpace(reactor, out var rpos));
|
||||
Assert.True(shooter.TryEquip(reactor, rpos));
|
||||
}
|
||||
if (turret)
|
||||
{
|
||||
var t = Make("Turret", lot++, 1);
|
||||
Assert.True(shooter.TryFindSpace(t, out var upos));
|
||||
Assert.True(shooter.TryEquip(t, upos));
|
||||
}
|
||||
|
||||
var target = new Ship(items, zone, new EquippableItem { Data = hullRef, Durability = 1000000, Lot = lot++ }, new EntitySettings());
|
||||
Assert.True(target.TryEquip(Make("Gun", lot++, 1), new int2(0, 0)));
|
||||
|
||||
zone.Entities.Add(shooter);
|
||||
zone.Entities.Add(target);
|
||||
shooter.Activate();
|
||||
target.Activate();
|
||||
|
||||
shooter.Position = float3(-53, 0, -101);
|
||||
target.Position = shooter.Position + float3(0, 0, targetRange);
|
||||
shooter.Target.Value = target;
|
||||
shooter.EntityInfoGathered[target] = 1f;
|
||||
shooter.SetIff(target, true);
|
||||
|
||||
zone.Update(1f);
|
||||
|
||||
rig.Zone = zone;
|
||||
rig.Shooter = shooter;
|
||||
rig.Target = target;
|
||||
return rig;
|
||||
}
|
||||
|
||||
private static void Aim(Rig r, float2 direction) => r.Shooter.LookDirection = float3(direction.x, 0, direction.y);
|
||||
|
||||
private static readonly (ItemRotation, float)[] SideThenForward = { (ItemRotation.Clockwise, 0f), (ItemRotation.None, 0f) };
|
||||
private static readonly (ItemRotation, float)[] SideMount = { (ItemRotation.Clockwise, 0f) };
|
||||
|
||||
// ==== Ruling 1: per weapon, and a fused weapon needs a designated target ====
|
||||
|
||||
// A weapon group shares a trigger, not a verdict: two guns of one type, the first on a side mount that cannot
|
||||
// bear on the target and the second dead ahead. Only the second fires. Kills: the group's verdict read off its
|
||||
// first weapon (Combat's old `testWeapon`), which silences the group.
|
||||
[Fact]
|
||||
public void CombatDecidesEachWeaponOfAGroupForItself()
|
||||
{
|
||||
var r = Build(SideThenForward);
|
||||
var group = r.Shooter.WeaponGroups.Single(g => g.weapons.Count == 2).weapons;
|
||||
Assert.True(ReferenceEquals(group[0], r.Guns[0].Weapon), "fixture: the side mount leads the group");
|
||||
r.Zone.Agents.Add(new Minion(r.Shooter));
|
||||
|
||||
r.Zone.Update(1f);
|
||||
r.Zone.Update(1f);
|
||||
|
||||
Assert.False(r.Guns[0].Weapon.Firing, "the side-mounted gun cannot bear");
|
||||
Assert.True(r.Guns[1].Weapon.Firing, "the forward gun bears and is worth firing");
|
||||
}
|
||||
|
||||
// A fused weapon fires whenever its target is designated, whatever the arc: the same group, now fused, fires
|
||||
// both guns, the side mount included. Kills: Combat reading HitProbability (zero out of arc) for a fused weapon.
|
||||
[Fact]
|
||||
public void CombatFiresAFusedWeaponAtADesignatedTargetOutOfArc()
|
||||
{
|
||||
var r = Build(SideThenForward, fuse: WeaponFuse.Proximity, blast: 4f);
|
||||
r.Zone.Agents.Add(new Minion(r.Shooter));
|
||||
|
||||
r.Zone.Update(1f);
|
||||
r.Zone.Update(1f);
|
||||
|
||||
Assert.True(r.Guns[0].Weapon.Firing, "a designated target is enough, arc or no");
|
||||
Assert.True(r.Guns[1].Weapon.Firing);
|
||||
}
|
||||
|
||||
// The turret makes the same per-weapon decision. Kills: TurretController reading HitProbability, or its own
|
||||
// range test, for a fused weapon.
|
||||
[Fact]
|
||||
public void ATurretFiresAFusedWeaponAtADesignatedTargetOutOfArc()
|
||||
{
|
||||
var r = Build(SideMount, fuse: WeaponFuse.Proximity, blast: 4f, turret: true);
|
||||
|
||||
r.Zone.Update(1f);
|
||||
r.Zone.Update(1f);
|
||||
|
||||
Assert.True(r.Gun.Weapon.Firing, "the turret must fire a fused weapon at a designated target out of arc");
|
||||
}
|
||||
|
||||
public enum Withheld { NoTarget, OutOfRange, NotVisible, Unlocked }
|
||||
|
||||
// The AI never fires a fused weapon at nothing: a missing target, one out of range, one not visible and one
|
||||
// an unlocked LockWeapon holds no lock on are each no reason to fish. The direct-hit control fires (true) on
|
||||
// the same rig once the target is valid. Kills: `designated` dropped from the fused branch (null included).
|
||||
[Theory]
|
||||
[InlineData(Withheld.NoTarget)]
|
||||
[InlineData(Withheld.OutOfRange)]
|
||||
[InlineData(Withheld.NotVisible)]
|
||||
[InlineData(Withheld.Unlocked)]
|
||||
public void AnAgentNeverFiresAFusedWeaponAtNothing(Withheld reason)
|
||||
{
|
||||
var r = Build(fuse: WeaponFuse.Proximity, blast: 4f, range: 100f,
|
||||
targetRange: reason == Withheld.OutOfRange ? 150f : 60f, lockWeapon: reason == Withheld.Unlocked);
|
||||
var target = r.Target;
|
||||
if (reason == Withheld.NoTarget) target = null;
|
||||
if (reason == Withheld.NotVisible) r.Shooter.VisibleEntities.Remove(r.Target);
|
||||
|
||||
Assert.False(FireControl.AgentFires(r.Gun.Weapon, r.Shooter, target));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void AnAgentFiresAFusedWeaponAtAValidTargetWhateverItsHitChance()
|
||||
{
|
||||
// Accuracy 0 prices every direct hit at zero; the fused weapon is unmoved.
|
||||
var r = Build(SideMount, fuse: WeaponFuse.Proximity, blast: 4f, accuracy: 0f);
|
||||
|
||||
Assert.True(FireControl.AgentFires(r.Gun.Weapon, r.Shooter, r.Target));
|
||||
}
|
||||
|
||||
// A weapon that fires at what it hits keeps the AgentMinHitProbability threshold, per weapon.
|
||||
// Kills: the threshold dropped for a direct-hit weapon, or applied to a fused one.
|
||||
[Theory]
|
||||
[InlineData(.5f, .2f, true)]
|
||||
[InlineData(.5f, .9f, false)]
|
||||
public void AnAgentKeepsTheHitProbabilityThresholdForADirectHitWeapon(float accuracy, float minHit, bool fires)
|
||||
{
|
||||
var r = Build(accuracy: accuracy, minHit: minHit);
|
||||
var p = FireControl.HitProbability(r.Gun.Weapon, r.Shooter, r.Target);
|
||||
Assert.True(p > .3f && p < .7f, $"fixture: the shot must price near the accuracy, priced {p}");
|
||||
|
||||
Assert.Equal(fires, FireControl.AgentFires(r.Gun.Weapon, r.Shooter, r.Target));
|
||||
}
|
||||
|
||||
// ==== Ruling 2: the HUD forecast is Fire's own decision ====
|
||||
|
||||
// Inspect's Outcome and BurstReach against what Fire then does with the same rig: Refused iff Fire returns 0,
|
||||
// and a Burst's reach is the planar distance to the burst point Fire froze. Rows: a target beyond the arming
|
||||
// distance (burst at its range), one inside it (pushed out to 30), no target (max range), out of arc, a
|
||||
// Range that cannot reach the arming distance, and a weapon without a fuse.
|
||||
// Kills: an Inspect that computes its own reach (ignoring the arming push or the Range clamp).
|
||||
[Theory]
|
||||
[InlineData(60f, 100f, false, false, FireOutcome.Burst, 60f)]
|
||||
[InlineData(20f, 100f, false, false, FireOutcome.Burst, 30f)]
|
||||
[InlineData(60f, 40f, true, false, FireOutcome.Burst, 40f)]
|
||||
[InlineData(60f, 100f, false, true, FireOutcome.Burst, 60f)]
|
||||
[InlineData(60f, 29.5f, false, false, FireOutcome.Refused, 0f)]
|
||||
[InlineData(60f, 29.5f, true, false, FireOutcome.Refused, 0f)]
|
||||
public void TheForecastIsTheOutcomeFireDelivers(float targetRange, float range, bool noTarget, bool outOfArc, FireOutcome outcome, float reach)
|
||||
{
|
||||
var r = Build(outOfArc ? SideMount : null, fuse: WeaponFuse.Proximity, blast: 30f, range: range, targetRange: targetRange);
|
||||
if (noTarget) r.Shooter.Target.Value = null;
|
||||
Aim(r, float2(0, 1));
|
||||
|
||||
var d = FireControl.Inspect(r.Gun.Weapon, r.Shooter, r.Shooter.Target.Value);
|
||||
var shotId = FireControl.Fire(r.Gun.Weapon, r.Gun.Item, r.Shooter);
|
||||
|
||||
Assert.Equal(outcome, d.Outcome);
|
||||
Assert.Equal(outcome != FireOutcome.Refused, shotId != 0);
|
||||
if (outcome == FireOutcome.Refused) return;
|
||||
Assert.Equal(reach, d.BurstReach, 2);
|
||||
var shot = SafeAssert.OnlyShot(r.Zone);
|
||||
Assert.Equal(d.BurstReach, length((shot.BurstPosition - shot.FireOrigin).xz), 2);
|
||||
}
|
||||
|
||||
// A weapon without a fuse forecasts a direct hit and keeps its percentages. Kills: Solve calling everything a burst.
|
||||
[Fact]
|
||||
public void AWeaponWithoutAFuseForecastsADirectHit()
|
||||
{
|
||||
var r = Build();
|
||||
|
||||
var d = FireControl.Inspect(r.Gun.Weapon, r.Shooter, r.Target);
|
||||
|
||||
Assert.Equal(FireOutcome.Direct, d.Outcome);
|
||||
Assert.True(d.PBase > 0f);
|
||||
}
|
||||
|
||||
// ==== Ruling 3: a refused round is free ====
|
||||
|
||||
private sealed class Costs
|
||||
{
|
||||
public int Ammo;
|
||||
public float ChargeSpent;
|
||||
public int Sounds;
|
||||
public int Wears;
|
||||
public float Heat;
|
||||
public bool Visible;
|
||||
public int Announced;
|
||||
public int Shots;
|
||||
public bool CanFire;
|
||||
}
|
||||
|
||||
// One discrete weapon, triggered once at no target, with every cost observable: a magazine, an energy charge,
|
||||
// a sound bank, wear events, heat and visibility. Range 29.5 refuses (arming 30); Range 40 fires.
|
||||
private Costs Pull(float range, bool single, bool viaTrigger, bool staleRange = false, bool auto = false)
|
||||
{
|
||||
var r = Build(fuse: WeaponFuse.Proximity, blast: 30f, range: range, energy: 50f, heat: 5000f, visibility: 100f, magazine: 5, singleAmmoBurst: single, auto: auto);
|
||||
r.Shooter.Target.Value = null;
|
||||
Aim(r, float2(0, 1));
|
||||
var weapon = (InstantWeapon) r.Gun.Weapon;
|
||||
var capacitor = (InputCapacitor) typeof(InstantWeapon).GetField("_capacitor", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(weapon);
|
||||
r.Gun.Item.SoundBank = new WwiseMetaSoundBank { IncludedEvents = new[] { new WwiseMetaObject { Id = 7, Name = "gun_fire" } } };
|
||||
var costs = new Costs();
|
||||
r.Gun.Item.AudioEvents.Subscribe(_ => costs.Sounds++);
|
||||
r.Zone.ShotCommitted.Subscribe(_ => costs.Shots++); // a fused round with no flight commits and resolves in its own tick
|
||||
r.Shooter.ItemDamage.Subscribe(t => { if (t.Item1 == r.Gun.Item) costs.Wears++; });
|
||||
weapon.OnFire += _ => costs.Announced++;
|
||||
capacitor.AddCharge(1000f); // a full buffer, so the first round can be paid for
|
||||
var chargeBefore = capacitor.Charge;
|
||||
var heatBefore = r.Gun.Item.Temperature;
|
||||
var ammoBefore = weapon.Ammo;
|
||||
Assert.True(chargeBefore > 0f && ammoBefore == 5, "fixture: a full buffer and magazine");
|
||||
|
||||
// The Range the previous tick's Execute left, before this tick refreshes it: a power-dependent Range that
|
||||
// has since fallen. Set through the property's own setter, so the trigger sees a Range the round will not.
|
||||
if (staleRange) typeof(Weapon).GetProperty("Range").GetSetMethod(true).Invoke(weapon, new object[] { 100f });
|
||||
if (auto)
|
||||
{
|
||||
// AutoWeapon's own trigger: a held weapon whose cooldown has run out retriggers inside Execute.
|
||||
typeof(Weapon).GetField("_firing", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(weapon, true);
|
||||
typeof(InstantWeapon).GetField("_cooldown", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(weapon, -1f);
|
||||
}
|
||||
else if (viaTrigger) weapon.Activate();
|
||||
else typeof(InstantWeapon).GetField("_burstRemaining", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(weapon, 1);
|
||||
r.Zone.Update(.01f);
|
||||
|
||||
costs.Ammo = ammoBefore - weapon.Ammo;
|
||||
costs.ChargeSpent = chargeBefore - capacitor.Charge;
|
||||
costs.Heat = r.Gun.Item.Temperature - heatBefore;
|
||||
costs.Visible = r.Shooter.VisibilitySources.TryGetValue(weapon, out var v) && v > 1f;
|
||||
costs.CanFire = weapon.CanFire;
|
||||
return costs;
|
||||
}
|
||||
|
||||
// Control: the same weapon with Range to spare pays every cost, so a free refusal below is not a fixture that
|
||||
// never spends. Then the refusal costs nothing: no ammo, no energy, no sound, no wear, no heat, no
|
||||
// visibility, no shot. `single` is a weapon that pays once per burst, at its first unrefused round rather than at each;
|
||||
// `viaTrigger` false authorises the burst directly (the way a trigger that passed leaves it) on a weapon whose
|
||||
// Range is short, so the Trigger check cannot be what stops the round and Execute must refuse it itself.
|
||||
// Kills, one per row of the assertions: a spend that precedes the refusal (Execute or Trigger), an
|
||||
// announcement, a sound, wear, heat or visibility left ahead of the `continue`.
|
||||
[Theory]
|
||||
[InlineData(false, true)]
|
||||
[InlineData(true, true)]
|
||||
[InlineData(false, false)]
|
||||
public void ARefusedDiscreteRoundCostsNothing(bool single, bool viaTrigger)
|
||||
{
|
||||
var fired = Pull(40f, single, viaTrigger);
|
||||
Assert.True(fired.Shots == 1, $"shots {fired.Shots}");
|
||||
Assert.True(fired.Ammo == 1, $"ammo spent {fired.Ammo}");
|
||||
Assert.True(fired.ChargeSpent > 1f, "a fired round spends its energy");
|
||||
Assert.Equal(1, fired.Sounds);
|
||||
Assert.True(fired.Wears > 0);
|
||||
Assert.True(fired.Heat > 0f);
|
||||
Assert.True(fired.Visible);
|
||||
Assert.Equal(1, fired.Announced);
|
||||
|
||||
var refused = Pull(29.5f, single, viaTrigger);
|
||||
Assert.Equal(0, refused.Shots);
|
||||
Assert.Equal(0, refused.Ammo);
|
||||
Assert.Equal(0f, refused.ChargeSpent);
|
||||
Assert.Equal(0, refused.Sounds);
|
||||
Assert.Equal(0, refused.Wears);
|
||||
Assert.True(fired.Heat - refused.Heat > 5f, $"a refused round adds no heat ({refused.Heat} vs {fired.Heat})");
|
||||
Assert.False(refused.Visible);
|
||||
Assert.Equal(0, refused.Announced);
|
||||
}
|
||||
|
||||
// The same rule for a beam: a fused beam whose arming distance exceeds Range fires nothing and draws
|
||||
// nothing. The control (Range 40) rolls shots, wears, draws power and shows; the refused beam does none of
|
||||
// that, asks the bus for nothing, and never starts (ARefusedBeamNeverStarts).
|
||||
// Kills: ConstantWeapon spending (power request, wear, heat, visibility) before the refusal, or not
|
||||
// consulting FireControl at all.
|
||||
private (int Shots, int Wears, float Request, bool Visible, float Heat, int Stops, bool Firing) Burn(float range)
|
||||
{
|
||||
var r = Build(beam: true, fuse: WeaponFuse.Proximity, blast: 30f, range: range, energy: 50f, heat: 5000f, visibility: 100f);
|
||||
r.Shooter.Target.Value = null;
|
||||
Aim(r, float2(0, 1));
|
||||
var weapon = (ConstantWeapon) r.Gun.Weapon;
|
||||
var wears = 0;
|
||||
var stops = 0;
|
||||
var shots = 0;
|
||||
r.Zone.ShotResolved.Subscribe(_ => shots++);
|
||||
r.Shooter.ItemDamage.Subscribe(t => { if (t.Item1 == r.Gun.Item) wears++; });
|
||||
weapon.OnStopFiring += () => stops++;
|
||||
var heatBefore = r.Gun.Item.Temperature;
|
||||
|
||||
weapon.Activate();
|
||||
var request = weapon.PowerRequest(.1f);
|
||||
for (var i = 0; i < 5; i++) r.Zone.Update(.1f);
|
||||
|
||||
var visible = r.Shooter.VisibilitySources.TryGetValue(weapon, out var v) && v > 1f;
|
||||
return (shots, wears, request, visible, r.Gun.Item.Temperature - heatBefore, stops, weapon.Firing);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ARefusedBeamCostsNothing()
|
||||
{
|
||||
var fired = Burn(40f);
|
||||
Assert.True(fired.Shots > 0, "control: the beam rolls shots");
|
||||
Assert.True(fired.Wears > 0);
|
||||
Assert.True(fired.Request > 0f);
|
||||
Assert.True(fired.Visible);
|
||||
Assert.True(fired.Heat > 0f);
|
||||
|
||||
var refused = Burn(29.5f);
|
||||
Assert.Equal(0, refused.Shots);
|
||||
Assert.Equal(0, refused.Wears);
|
||||
Assert.Equal(0f, refused.Request);
|
||||
Assert.False(refused.Visible);
|
||||
Assert.True(fired.Heat - refused.Heat > 5f, $"a refused beam adds no heat ({refused.Heat} vs {fired.Heat})");
|
||||
Assert.True(refused.Stops == 0 && !refused.Firing, "a refused beam never starts, so it never has to stop");
|
||||
}
|
||||
|
||||
// A beam is a stream of rounds, so a refused beam never starts: OnStartFiring drives the beam's visuals and
|
||||
// audio, and starting it for Execute to stop a tick later would flash a beam that fires nothing. The control
|
||||
// (Range 40) starts once and keeps firing. Kills: Activate that starts a beam without asking FireControl.
|
||||
[Theory]
|
||||
[InlineData(40f, 1)]
|
||||
[InlineData(29.5f, 0)]
|
||||
public void ARefusedBeamNeverStarts(float range, int starts)
|
||||
{
|
||||
var r = Build(beam: true, fuse: WeaponFuse.Proximity, blast: 30f, range: range);
|
||||
r.Shooter.Target.Value = null;
|
||||
Aim(r, float2(0, 1));
|
||||
var weapon = (ConstantWeapon) r.Gun.Weapon;
|
||||
var started = 0;
|
||||
weapon.OnStartFiring += () => started++;
|
||||
|
||||
weapon.Activate();
|
||||
for (var i = 0; i < 5; i++) r.Zone.Update(.1f);
|
||||
|
||||
Assert.Equal(starts, started);
|
||||
Assert.Equal(starts == 1, weapon.Firing);
|
||||
}
|
||||
|
||||
// A refused weapon is not one an agent can use: a fused weapon whose arming distance (30) exceeds its Range
|
||||
// (29.5) is not fired at a target inside that Range, where the same weapon with Range to spare is.
|
||||
// Kills: AgentFires answering "designated" without asking whether Solve refuses.
|
||||
[Theory]
|
||||
[InlineData(29.5f, false)]
|
||||
[InlineData(40f, true)]
|
||||
public void AnAgentNeverFiresARefusedFusedWeapon(float range, bool fires)
|
||||
{
|
||||
var r = Build(fuse: WeaponFuse.Proximity, blast: 30f, range: range, targetRange: 20f);
|
||||
|
||||
Assert.Equal(fires, FireControl.AgentFires(r.Gun.Weapon, r.Shooter, r.Target));
|
||||
}
|
||||
|
||||
// Combat's group pick counts only weapons that can fire: the refused gun's group out-damages the decoy's, so a
|
||||
// pick that counted it would select a group whose weapons are then never fired, and the decoy would stay silent.
|
||||
// Kills: Combat counting a refused weapon's damage toward its group.
|
||||
[Fact]
|
||||
public void CombatDoesNotPickAGroupWhoseWeaponIsRefused()
|
||||
{
|
||||
var r = Build(fuse: WeaponFuse.Proximity, blast: 30f, range: 29.5f, targetRange: 20f, decoy: true);
|
||||
Assert.True(r.Gun.Weapon.RangeDamagePerSecond(20f) > r.Decoy.Weapon.RangeDamagePerSecond(20f), "fixture: the refused gun is the stronger group");
|
||||
r.Zone.Agents.Add(new Minion(r.Shooter));
|
||||
|
||||
r.Zone.Update(1f);
|
||||
r.Zone.Update(1f);
|
||||
|
||||
Assert.False(r.Gun.Weapon.Firing, "a refused weapon is never activated");
|
||||
Assert.True(r.Decoy.Weapon.Firing, "the group that can fire is the one picked");
|
||||
}
|
||||
|
||||
// Combat's group pick counts only weapons whose target is designated: the stronger gun's Range (10) does not reach the
|
||||
// target (20), so its group is not picked and the decoy's, which does reach, is. Kills: Combat asking
|
||||
// Designated nothing (a group of weapons that cannot reach the target selected).
|
||||
[Fact]
|
||||
public void CombatDoesNotPickAGroupWhoseWeaponCannotReachTheTarget()
|
||||
{
|
||||
var r = Build(range: 10f, targetRange: 20f, decoy: true);
|
||||
Assert.True(r.Gun.Weapon.RangeDamagePerSecond(20f) > r.Decoy.Weapon.RangeDamagePerSecond(20f), "fixture: the short gun is the stronger group");
|
||||
r.Zone.Agents.Add(new Minion(r.Shooter));
|
||||
|
||||
r.Zone.Update(1f);
|
||||
r.Zone.Update(1f);
|
||||
|
||||
Assert.False(r.Gun.Weapon.Firing, "a weapon that cannot reach the target is never activated");
|
||||
Assert.True(r.Decoy.Weapon.Firing, "the group that reaches is the one picked");
|
||||
}
|
||||
|
||||
// Combat's range test is Designated's, not a second one: a target exactly at max range is in reach (the old
|
||||
// private test was strict). Kills: a range comparison of Combat's own.
|
||||
[Fact]
|
||||
public void CombatCountsATargetExactlyAtMaxRangeAsInReach()
|
||||
{
|
||||
var r = Build(range: 60f, targetRange: 60f);
|
||||
// The agent is driven directly, not through the zone, so the shooter stays exactly at max range: the first
|
||||
// update leaves the root state for combat, the second is combat deciding.
|
||||
var agent = new Minion(r.Shooter);
|
||||
agent.Update(.01f);
|
||||
agent.Update(.01f);
|
||||
|
||||
Assert.True(r.Gun.Weapon.Firing);
|
||||
}
|
||||
|
||||
// The trigger's threshold is inclusive: a shot priced exactly at AgentMinHitProbability is worth taking, and
|
||||
// one priced a hair under it is not. Kills: `>` for `>=`.
|
||||
[Fact]
|
||||
public void AnAgentFiresAtExactlyTheHitProbabilityThreshold()
|
||||
{
|
||||
var probe = Build(accuracy: .5f);
|
||||
var price = FireControl.HitProbability(probe.Gun.Weapon, probe.Shooter, probe.Target);
|
||||
Assert.True(price > 0f);
|
||||
|
||||
var atThreshold = Build(accuracy: .5f, minHit: price);
|
||||
var overThreshold = Build(accuracy: .5f, minHit: MathF.BitIncrement(price));
|
||||
|
||||
Assert.True(FireControl.AgentFires(atThreshold.Gun.Weapon, atThreshold.Shooter, atThreshold.Target));
|
||||
Assert.False(FireControl.AgentFires(overThreshold.Gun.Weapon, overThreshold.Shooter, overThreshold.Target));
|
||||
}
|
||||
|
||||
// A round refused on a Range that fell between the trigger and the round is still free: the burst is paid
|
||||
// (SingleAmmoBurst) at its first round that is not refused, judged with the Range that round flies with.
|
||||
// The trigger saw a stale Range of 100; the round's Range is 29.5, under the arming distance. The refusal
|
||||
// starts no cooldown either (operator ruling 2026-09-30): the weapon can fire again at once, while the
|
||||
// control (Range 40) fired and is cooling down. Covers the player's trigger and AutoWeapon's own.
|
||||
// Kills: paying for the burst at the trigger; starting the cooldown at the trigger (Trigger or AutoWeapon).
|
||||
[Theory]
|
||||
[InlineData(true, false)]
|
||||
[InlineData(false, false)]
|
||||
[InlineData(true, true)]
|
||||
[InlineData(false, true)]
|
||||
public void ARefusedBurstThatPassedTheTriggerOnAStaleRangeCostsNothing(bool single, bool auto)
|
||||
{
|
||||
var fired = Pull(40f, single, viaTrigger: true, staleRange: true, auto: auto);
|
||||
Assert.Equal(1, fired.Shots);
|
||||
Assert.False(fired.CanFire, "control: a fired burst starts the cooldown");
|
||||
|
||||
var refused = Pull(29.5f, single, viaTrigger: true, staleRange: true, auto: auto);
|
||||
|
||||
Assert.Equal(0, refused.Shots);
|
||||
Assert.Equal(0, refused.Ammo);
|
||||
Assert.Equal(0f, refused.ChargeSpent);
|
||||
Assert.Equal(0, refused.Announced);
|
||||
Assert.True(refused.CanFire, "a burst that fired nothing leaves no cooldown");
|
||||
}
|
||||
|
||||
// A refused charged weapon never starts charging: no charge heat, no audio, no start event, and it can be
|
||||
// triggered again at once. The control (Range 40) charges, sounds and heats.
|
||||
// Kills: ChargedWeapon.Activate that does not ask FireControl.
|
||||
private (int Starts, int Sounds, float Heat, bool Charging) Charge(float range)
|
||||
{
|
||||
var r = Build(charged: true, fuse: WeaponFuse.Proximity, blast: 30f, range: range);
|
||||
r.Shooter.Target.Value = null;
|
||||
Aim(r, float2(0, 1));
|
||||
var weapon = (ChargedWeapon) r.Gun.Weapon;
|
||||
r.Gun.Item.SoundBank = new WwiseMetaSoundBank { IncludedEvents = new[] { new WwiseMetaObject { Id = 7, Name = "gun_charge_play" } } };
|
||||
var starts = 0;
|
||||
var sounds = 0;
|
||||
weapon.OnStartCharging += () => starts++;
|
||||
r.Gun.Item.AudioEvents.Subscribe(_ => sounds++);
|
||||
var heatBefore = r.Gun.Item.Temperature;
|
||||
|
||||
weapon.Activate();
|
||||
for (var i = 0; i < 3; i++) r.Zone.Update(.1f);
|
||||
|
||||
return (starts, sounds, r.Gun.Item.Temperature - heatBefore, weapon.Progress > 0f);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ARefusedChargedWeaponNeverStartsCharging()
|
||||
{
|
||||
var fired = Charge(40f);
|
||||
Assert.Equal(1, fired.Starts);
|
||||
Assert.True(fired.Sounds > 0, "control: charging sounds");
|
||||
Assert.True(fired.Heat > 0f, "control: charging heats");
|
||||
|
||||
var refused = Charge(29.5f);
|
||||
Assert.Equal(0, refused.Starts);
|
||||
Assert.Equal(0, refused.Sounds);
|
||||
Assert.True(fired.Heat - refused.Heat > 5f, $"a refused weapon adds no charge heat ({refused.Heat} vs {fired.Heat})");
|
||||
}
|
||||
// A triggered burst has not started its cooldown, but it is not ready either: pulled again before its first round
|
||||
// flies it would restart the burst. Kills: CanFire that reads the cooldown alone.
|
||||
[Fact]
|
||||
public void ATriggeredBurstIsNotReadyBeforeItsFirstRound()
|
||||
{
|
||||
var r = Build(range: 100f);
|
||||
r.Shooter.Target.Value = null;
|
||||
Aim(r, float2(0, 1));
|
||||
var weapon = (InstantWeapon) r.Gun.Weapon;
|
||||
r.Zone.Update(.01f); // resolves the gun's stats, which size the burst
|
||||
Assert.True(weapon.CanFire);
|
||||
|
||||
weapon.Activate();
|
||||
|
||||
Assert.False(weapon.CanFire);
|
||||
}
|
||||
|
||||
// A charge released with a burst pending has not started its cooldown, but it is not ready either: pressed
|
||||
// again before that burst's first round it would start a second charge over it. Kills: ChargedWeapon.Activate
|
||||
// that reads the cooldown alone instead of CanFire.
|
||||
[Fact]
|
||||
public void AChargedWeaponPressedAgainBeforeItsReleasedRoundFliesStartsNoSecondCharge()
|
||||
{
|
||||
var r = Build(charged: true, range: 100f);
|
||||
r.Shooter.Target.Value = null;
|
||||
Aim(r, float2(0, 1));
|
||||
var weapon = (ChargedWeapon) r.Gun.Weapon;
|
||||
var starts = 0;
|
||||
weapon.OnStartCharging += () => starts++;
|
||||
r.Zone.Update(.01f); // resolves the stats
|
||||
weapon.Activate();
|
||||
for (var i = 0; i < 15; i++) r.Zone.Update(.1f);
|
||||
Assert.Equal(1, starts);
|
||||
|
||||
weapon.Deactivate();
|
||||
weapon.Activate();
|
||||
r.Zone.Update(.1f);
|
||||
|
||||
Assert.Equal(1, starts);
|
||||
Assert.False((bool) typeof(ChargedWeapon).GetField("_charging", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(weapon));
|
||||
}
|
||||
|
||||
// Holding the trigger fires once per Cooldown: the round that starts the cooldown pays for the tick it flew in.
|
||||
// Cooldown 1 at .25 s ticks is a shot every 5 ticks, 12 in 15 s. And a burst whose every round is refused
|
||||
// leaves no cooldown: the same held trigger is ready every tick. Kills: a first round that starts the cooldown
|
||||
// at 1 after the tick's decrement (a shot every 6 ticks, 10 in 15 s); a cooldown left by a refused burst.
|
||||
[Theory]
|
||||
[InlineData(100f, 12)]
|
||||
[InlineData(29.5f, 0)]
|
||||
public void AHeldTriggerFiresOncePerCooldownAndARefusedBurstLeavesNone(float range, int shots)
|
||||
{
|
||||
var r = Build(fuse: WeaponFuse.Proximity, blast: 30f, range: range);
|
||||
r.Shooter.Target.Value = null;
|
||||
Aim(r, float2(0, 1));
|
||||
var weapon = (InstantWeapon) r.Gun.Weapon;
|
||||
var fired = 0;
|
||||
weapon.OnFire += _ => fired++;
|
||||
r.Zone.Update(.25f); // resolves the stats
|
||||
var readyTicks = 0;
|
||||
|
||||
for (var i = 0; i < 60; i++)
|
||||
{
|
||||
weapon.Activate();
|
||||
r.Zone.Update(.25f);
|
||||
if (weapon.CanFire) readyTicks++;
|
||||
}
|
||||
|
||||
Assert.Equal(shots, fired);
|
||||
if (shots == 0) Assert.Equal(60, readyTicks);
|
||||
}
|
||||
|
||||
// Kills: Trigger that leaves _burstStarted true from the previous burst, so the next burst reads as started
|
||||
// (and ready) before its first round has flown.
|
||||
[Fact]
|
||||
public void ABurstTriggeredAfterAFiredOneIsNotReadyBeforeItsFirstRound()
|
||||
{
|
||||
var r = Build(range: 100f);
|
||||
r.Shooter.Target.Value = null;
|
||||
Aim(r, float2(0, 1));
|
||||
var weapon = (InstantWeapon) r.Gun.Weapon;
|
||||
r.Zone.Update(.25f);
|
||||
weapon.Activate();
|
||||
r.Zone.Update(.25f);
|
||||
Assert.False(weapon.CanFire, "control: the first burst fired and is cooling");
|
||||
for (var i = 0; i < 10 && !weapon.CanFire; i++) r.Zone.Update(.25f);
|
||||
Assert.True(weapon.CanFire, "fixture: the cooldown expired");
|
||||
|
||||
weapon.Activate();
|
||||
|
||||
Assert.False(weapon.CanFire);
|
||||
}
|
||||
}
|
||||
|
|
@ -32,7 +32,7 @@ public sealed class IffAndCombatTests : IDisposable
|
|||
cache.Upsert(new GearData
|
||||
{
|
||||
Name = "Gun", Hardpoint = HardpointType.Sensors, Shape = new Shape(), Durability = 1,
|
||||
Behaviors = { new InstantWeaponData() }
|
||||
Behaviors = { new InstantWeaponData { Count = new PerformanceStat { Min = 1, Max = 1 }, Cooldown = new PerformanceStat { Min = 1, Max = 1 } } }
|
||||
});
|
||||
cache.FlushAsync().Wait();
|
||||
}
|
||||
|
|
@ -248,9 +248,11 @@ public sealed class IffAndCombatTests : IDisposable
|
|||
shooter.Target.Value = target;
|
||||
shooter.SetIff(target, false); // explicitly neutral
|
||||
|
||||
weapon.Execute(.01f); // resolves the gun's stats: a burst has no rounds before the first tick
|
||||
weapon.Activate();
|
||||
weapon.Execute(.01f);
|
||||
|
||||
Assert.Equal(0f, weapon.Progress); // Trigger() was safed: no cooldown/burst was started
|
||||
Assert.True(weapon.CanFire); // Trigger() was safed: no burst fired, so no cooldown
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -264,9 +266,11 @@ public sealed class IffAndCombatTests : IDisposable
|
|||
shooter.Target.Value = target;
|
||||
shooter.SetIff(target, true);
|
||||
|
||||
weapon.Execute(.01f); // resolves the gun's stats: a burst has no rounds before the first tick
|
||||
weapon.Activate();
|
||||
weapon.Execute(.01f);
|
||||
|
||||
Assert.Equal(1f, weapon.Progress); // Trigger() ran: cooldown/burst started
|
||||
Assert.False(weapon.CanFire); // Trigger() ran: the burst fired and the cooldown runs
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -277,9 +281,11 @@ public sealed class IffAndCombatTests : IDisposable
|
|||
var shooter = NewShip(items, zone, new Faction { Name = "Shooter" }, equipGun: true);
|
||||
var weapon = (InstantWeapon) shooter.Equipment.Single(e => e.Behaviors.Any(b => b is Weapon)).Behaviors.Single(b => b is Weapon);
|
||||
|
||||
weapon.Execute(.01f); // resolves the gun's stats: a burst has no rounds before the first tick
|
||||
weapon.Activate();
|
||||
weapon.Execute(.01f);
|
||||
|
||||
Assert.Equal(1f, weapon.Progress);
|
||||
Assert.False(weapon.CanFire); // Trigger() ran: the burst fired and the cooldown runs
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
902
tests/Aetheria.Shared.Tests/RestoredHullsTests.cs
Normal file
902
tests/Aetheria.Shared.Tests/RestoredHullsTests.cs
Normal file
|
|
@ -0,0 +1,902 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using CultMath;
|
||||
using GameCult.Caching;
|
||||
using GameCult.Caching.MessagePack;
|
||||
using Xunit;
|
||||
using static CultMath.math;
|
||||
using float3 = CultMath.float3;
|
||||
using Random = CultMath.Random;
|
||||
|
||||
// Cut 1 (docs/locomotion-cut.md, "Restore the legacy thruster ship hulls to the live catalog"). Verifies the
|
||||
// content restore-hulls landed, against the real shipped catalog, read-only: the hulls exist with the expected
|
||||
// thruster hardpoint counts, every thruster hardpoint accepts a catalog thruster design through TryEquip at its
|
||||
// own position, and the ship then moves and turns for a few ticks under MovementDirection/LookDirection on the
|
||||
// pre-Cut-3 mixer -- proof of the restored content, not of a controller this cut does not touch.
|
||||
public sealed class RestoredHullsTests
|
||||
{
|
||||
// Soul's finding #1 (this cut's fix batch 3): a hand-set GameplaySettings fixture left thermal radiation and
|
||||
// conduction at their bare-class defaults (1/1/1) against the shipped 3 / 1e-8 / 0.01
|
||||
// (Assets/Resources/Settings.asset), so equipped parts froze toward 0 K, performance collapsed to 0 from
|
||||
// cold, and TorqueMultiplier defaulting to 0 on top of that made every thruster's yaw contribution silently
|
||||
// zero (Ship.cs's mixer applies Torque*Thrust*TorqueMultiplier/Mass) -- velocity moved but Direction never
|
||||
// turned, which looks exactly like a content defect instead of a fixture gap. AuthoredSettings
|
||||
// (tools/AetherDb/AuthoredSettings.cs) is the same headless YAML reader tools/AetherDb already uses to
|
||||
// inspect Settings.asset outside Unity; this loads the real GameplaySettings the same way instead of
|
||||
// hand-copying its fields a second time.
|
||||
private static GameplaySettings Settings() => AuthoredSettings.Load(FindRepoRoot()).Read<GameplaySettings>("GameplaySettings");
|
||||
|
||||
// Same composition FireControlCut7Tests.OpenReadOnlyRealCatalog uses: a registry scoped to the shipped
|
||||
// assembly's own [CultDocument] types, so this test's own process-wide type registration never pollutes the
|
||||
// real catalog's validation the way the shared, AppDomain-scanning CultCache() default would.
|
||||
private static CultCache OpenReadOnlyRealCatalog(string catalogPath)
|
||||
{
|
||||
var registry = CultDocumentRegistry.ForTypes(typeof(ItemData).Assembly.GetTypes()
|
||||
.Where(t => t is { IsAbstract: false, IsInterface: false })
|
||||
.Where(t => t.GetCustomAttribute<CultDocumentAttribute>() != null));
|
||||
var cache = new CultCache(registry);
|
||||
cache.AddBackingStore(new SingleFileMessagePackBackingStore(catalogPath, true), AetheriaStores.CatalogTypes);
|
||||
return cache;
|
||||
}
|
||||
|
||||
private static string FindRepoRoot()
|
||||
{
|
||||
for (var dir = new DirectoryInfo(AppContext.BaseDirectory); dir != null; dir = dir.Parent)
|
||||
if (File.Exists(Path.Combine(dir.FullName, "Aetheria.Shared", "Aetheria.Shared.csproj")))
|
||||
return dir.FullName;
|
||||
throw new DirectoryNotFoundException("Run from inside the Aetheria repository.");
|
||||
}
|
||||
|
||||
private static CultCache OpenCatalog() => OpenReadOnlyRealCatalog(Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc"));
|
||||
|
||||
// Shared tutorial-galaxy construction settings (Assets/Resources/Settings.asset's own values), factored out
|
||||
// so every test that needs a real tutorial Galaxy -- not just EntranceZoneAlwaysGetsADockedStationAcrossSeeds
|
||||
// -- builds it the same way instead of re-inlining the same ~20 fields.
|
||||
private static ZoneGenerationSettings TutorialZoneSettings() => new ZoneGenerationSettings
|
||||
{
|
||||
PlanetSafetyRadius = new ExponentialCurve { Exponent = .25f, Multiplier = 2.5f, Constant = 0 },
|
||||
MassFloor = 1, SunMass = 5000, GasGiantMass = 1000, PlanetMass = 100,
|
||||
SatellitePasses = 5, SatelliteCreationMassFloor = 100, SatelliteCreationProbability = .25f,
|
||||
BinaryCreationProbability = .1f, RosetteProbability = .1f,
|
||||
ZoneRadius = new ExponentialLerp { Exponent = 1.5f, Minimum = 1000, Maximum = 10000 },
|
||||
ZoneMass = new ExponentialLerp { Exponent = 1.5f, Minimum = 10000, Maximum = 500000 },
|
||||
SubZoneCount = new ExponentialLerp { Exponent = 1.5f, Minimum = 0, Maximum = 8 },
|
||||
ZoneBoundaryRadius = .9f, BeltProbability = .25f, BeltMassCeiling = 500,
|
||||
AsteroidBeltWidth = new ExponentialCurve { Exponent = .666f, Multiplier = 5, Constant = 50 },
|
||||
AsteroidCount = new ExponentialCurve { Exponent = .5f, Multiplier = 1, Constant = 11 },
|
||||
AsteroidRotationSpeed = new ExponentialLerp { Exponent = 2, Minimum = .1f, Maximum = .5f },
|
||||
SunColorSaturation = .85f, SunSecondaryColorDistance = .33f, SunLightSaturation = .5f, SunFogTintSaturation = .55f,
|
||||
GasGiantBandCount = new ExponentialLerp { Exponent = 2, Minimum = 5, Maximum = 8 },
|
||||
GasGiantBandColorSeparation = .25f, GasGiantBandAltColorChance = .25f,
|
||||
GasGiantBandSaturation = new ExponentialLerp { Exponent = .5f, Minimum = 0, Maximum = .8f },
|
||||
GasGiantBandBrightness = new ExponentialLerp { Exponent = .25f, Minimum = .25f, Maximum = 1 },
|
||||
NameData = new string[0],
|
||||
};
|
||||
|
||||
private static TutorialGenerationSettings TutorialGalaxySettings() => new TutorialGenerationSettings
|
||||
{
|
||||
ProtagonistFaction = "Miss", AntagonistFaction = "Zhe", BufferFaction = "Luc",
|
||||
NeutralFactions = new[] { "Aero", "Finch" }, QuestFaction = "Adras", LinkDensity = .5f, ZoneCount = 64,
|
||||
};
|
||||
|
||||
private static SectorBackgroundSettings TutorialBackgroundSettings() => new SectorBackgroundSettings
|
||||
{
|
||||
NoiseAmplitude = 1, NoiseOffset = .3f, NoiseGain = .7f, NoiseLacunarity = 2, NoiseFrequency = .1f,
|
||||
NoisePosition = 536.5106f, CloudExponent = 10, CloudAmplitude = .01f,
|
||||
};
|
||||
|
||||
private static NameGeneratorSettings TutorialNameSettings() =>
|
||||
new NameGeneratorSettings { NameGeneratorMinLength = 5, NameGeneratorMaxLength = 10, NameGeneratorOrder = 3 };
|
||||
|
||||
// A station's orbit is a copy of its source planet's own (Parent, Distance) (ZoneGenerator.CreateLagrangeOrbit),
|
||||
// so it always matches that one planet. It matches MORE than one planet only when the source planet shares its
|
||||
// distance with a sibling under the same parent -- exactly what ZoneGenerator's potentialLagrangePoints filter
|
||||
// excludes. An entrance station whose orbit matches more than one planet orbit this way could therefore only
|
||||
// have come from the widened candidate set, never from the ordinary (non-rosette) Lagrange selection.
|
||||
//
|
||||
// Soul's finding (this cut's fix batch 3): counting planet orbits as pack.Orbits.Count minus the
|
||||
// OrbitalEntityPack count (the previous version of this method) over-counts whenever a station or turret
|
||||
// loadout generator returns null -- CreateLagrangeOrbit already appended that orbit to pack.Orbits before the
|
||||
// null check (ZoneGenerator.cs) skips adding the entity, so the subtraction no longer matches. Deriving the
|
||||
// set from pack.Planets' own Orbit refs instead (Census.cs's own approach) sidesteps that entirely: every
|
||||
// real planet, including an ordinary rosette member, names its own orbit directly. Only a rosette ROOT is
|
||||
// excluded this way (it gets no BodyData/PlanetData entry at all), which is fine here -- a root never shares
|
||||
// its own Parent's distance with itself, so it was never a sibling candidate for `orbit` in the first place.
|
||||
private static bool IsRosetteMember(CultCache cache, ZonePack pack, OrbitData orbit)
|
||||
{
|
||||
if (!orbit.Parent.IsSet()) return false;
|
||||
var planetOrbits = pack.Planets.Select(p => cache.Get(cache.Get(p).Orbit)).ToArray();
|
||||
return planetOrbits.Count(o => o.Parent.IsSet() && o.Parent.Key.Equals(orbit.Parent.Key) && abs(o.Distance - orbit.Distance) < .1f) > 1;
|
||||
}
|
||||
|
||||
// ZoneGenerator.GenerateZone writes OrbitData/BodyData (run-store types, AetheriaStores.RunTypes), so a
|
||||
// catalog-only cache has no home for them. A scratch run file, deleted after the seed that used it.
|
||||
private static CultCache OpenReadOnlyRealCatalogWithScratchRun(string catalogPath, string runPath)
|
||||
{
|
||||
var registry = CultDocumentRegistry.ForTypes(typeof(ItemData).Assembly.GetTypes()
|
||||
.Where(t => t is { IsAbstract: false, IsInterface: false })
|
||||
.Where(t => t.GetCustomAttribute<CultDocumentAttribute>() != null));
|
||||
var cache = new CultCache(registry);
|
||||
cache.AddBackingStore(new SingleFileMessagePackBackingStore(catalogPath, true), AetheriaStores.CatalogTypes);
|
||||
cache.AddBackingStore(new SingleFileMessagePackBackingStore(runPath), AetheriaStores.RunTypes);
|
||||
return cache;
|
||||
}
|
||||
|
||||
// Headless asset-reference rule: every hull's Prefab, every ThrusterData.ParticlesPrefab, and every
|
||||
// non-empty Schematic names a GUID that actually exists under Assets/ (a .meta file carries it). Unity's
|
||||
// EngineAssetCheck enforces this too, but only in-editor; this is the same check run headless against the
|
||||
// shipped catalog, so a fabricated or dropped GUID fails a build that never opens Unity. Soul's own probe
|
||||
// (commit message, this cut's fix batch) found Djinni.Prefab fabricated and all five restored thrusters'
|
||||
// ParticlesPrefab null; this test is that probe, committed so it can be rerun and mutated.
|
||||
[Fact]
|
||||
public void EveryAssetReferenceResolvesToAMetaGuid()
|
||||
{
|
||||
var assetGuids = new HashSet<string>(Directory.EnumerateFiles(Path.Combine(FindRepoRoot(), "Assets"), "*.meta", SearchOption.AllDirectories)
|
||||
.Select(f => File.ReadLines(f).FirstOrDefault(l => l.StartsWith("guid: "))?.Substring("guid: ".Length).Trim())
|
||||
.Where(g => g != null));
|
||||
|
||||
using var cache = OpenCatalog();
|
||||
var missing = new List<string>();
|
||||
foreach (var hull in cache.GetAll<HullData>())
|
||||
if (!assetGuids.Contains(hull.Prefab ?? ""))
|
||||
missing.Add($"{hull.Name}.Prefab = {hull.Prefab ?? "null"}");
|
||||
foreach (var design in cache.GetAll<EquippableItemData>())
|
||||
{
|
||||
foreach (var thruster in design.Behaviors.OfType<ThrusterData>())
|
||||
if (!assetGuids.Contains(thruster.ParticlesPrefab ?? ""))
|
||||
missing.Add($"{design.Name}.ParticlesPrefab = {thruster.ParticlesPrefab ?? "null"}");
|
||||
if (!string.IsNullOrEmpty(design.Schematic) && !assetGuids.Contains(design.Schematic))
|
||||
missing.Add($"{design.Name}.Schematic = {design.Schematic}");
|
||||
}
|
||||
|
||||
Assert.True(missing.Count == 0, "Dangling asset references:\n" + string.Join("\n", missing));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Longinus", 4)]
|
||||
[InlineData("Djinni", 8)]
|
||||
public void RestoredHullExistsWithExpectedThrusterHardpointCount(string name, int expectedThrusterHardpoints)
|
||||
{
|
||||
using var cache = OpenCatalog();
|
||||
var hull = cache.GetByName<HullData>(name);
|
||||
Assert.NotNull(hull);
|
||||
Assert.Equal(HullType.Ship, hull.HullType);
|
||||
Assert.Equal(expectedThrusterHardpoints, hull.Hardpoints.Count(h => h.Type == HardpointType.Thruster));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Longinus")]
|
||||
[InlineData("Djinni")]
|
||||
public void EveryThrusterHardpointAcceptsACatalogThrusterAtItsOwnPosition(string name)
|
||||
{
|
||||
using var cache = OpenCatalog();
|
||||
var hull = cache.GetByName<HullData>(name);
|
||||
var thrusterDesigns = cache.GetAll<GearData>().Where(g => g.Hardpoint == HardpointType.Thruster).ToArray();
|
||||
Assert.NotEmpty(thrusterDesigns);
|
||||
|
||||
var settings = Settings();
|
||||
var ledger = new ProvenanceLedger();
|
||||
for (var i = 1; i <= hull.Hardpoints.Count + 1; i++) ledger.Lots[i] = new Lot { Origin = new Attributed(), Quality = .5f };
|
||||
var items = new ItemManager(cache, ledger, settings, _ => { });
|
||||
var zone = new Zone(items, new PlanetSettings(), new ZonePack(), new GalaxyZone { Name = "Test", Owner = null }, null);
|
||||
var hullItem = new EquippableItem { Data = cache.RefOf<ItemData>(hull), Durability = hull.Durability, Lot = 1 };
|
||||
var ship = new Ship(items, zone, hullItem, settings.DefaultEntitySettings);
|
||||
|
||||
var lot = 2;
|
||||
foreach (var hardpoint in hull.Hardpoints.Where(h => h.Type == HardpointType.Thruster))
|
||||
{
|
||||
var cells = hardpoint.Shape.Coordinates.Length;
|
||||
var design = thrusterDesigns.FirstOrDefault(d => d.Shape.FitsWithin(hardpoint.Shape, hardpoint.Rotation, out _) && d.Shape.Coordinates.Length == cells);
|
||||
Assert.True(design != null, $"{name}'s {hardpoint.Transform ?? hardpoint.Type.ToString()} hardpoint at {hardpoint.Position} has no fitting catalog thruster design (needs {cells} cells).");
|
||||
var gearItem = new EquippableItem { Data = cache.RefOf<ItemData>(design), Durability = design.Durability, Lot = lot++ };
|
||||
Assert.True(ship.TryEquip(gearItem, hardpoint.Position),
|
||||
$"{name}'s {hardpoint.Transform ?? hardpoint.Type.ToString()} hardpoint at {hardpoint.Position} refused {design.Name} via TryEquip.");
|
||||
}
|
||||
}
|
||||
|
||||
// "The ship then moves and turns... for a few ticks" (docs/locomotion-cut.md verification list). Equips
|
||||
// every thruster hardpoint with a fitting design, then drives MovementDirection/LookDirection the same way
|
||||
// ActionGameManager's player-input path does (docs' own consumer audit) and checks Entity.Velocity and
|
||||
// Entity.Direction both move over a few ticks on the current (pre-Cut-3) mixer.
|
||||
[Theory]
|
||||
[InlineData("Longinus")]
|
||||
[InlineData("Djinni")]
|
||||
public void RestoredHullMovesAndTurnsUnderMovementAndLookDirection(string name)
|
||||
{
|
||||
using var cache = OpenCatalog();
|
||||
var hull = cache.GetByName<HullData>(name);
|
||||
var thrusterDesigns = cache.GetAll<GearData>().Where(g => g.Hardpoint == HardpointType.Thruster).ToArray();
|
||||
|
||||
var settings = Settings();
|
||||
var ledger = new ProvenanceLedger();
|
||||
for (var i = 1; i <= hull.Hardpoints.Count + 1; i++) ledger.Lots[i] = new Lot { Origin = new Attributed(), Quality = .5f };
|
||||
var items = new ItemManager(cache, ledger, settings, _ => { });
|
||||
var zone = new Zone(items, new PlanetSettings(), new ZonePack(), new GalaxyZone { Name = "Test", Owner = null }, null);
|
||||
var hullItem = new EquippableItem { Data = cache.RefOf<ItemData>(hull), Durability = hull.Durability, Lot = 1 };
|
||||
var ship = new Ship(items, zone, hullItem, settings.DefaultEntitySettings);
|
||||
|
||||
var lot = 2;
|
||||
foreach (var hardpoint in hull.Hardpoints.Where(h => h.Type == HardpointType.Thruster))
|
||||
{
|
||||
var cells = hardpoint.Shape.Coordinates.Length;
|
||||
var design = thrusterDesigns.First(d => d.Shape.FitsWithin(hardpoint.Shape, hardpoint.Rotation, out _) && d.Shape.Coordinates.Length == cells);
|
||||
var gearItem = new EquippableItem { Data = cache.RefOf<ItemData>(design), Durability = design.Durability, Lot = lot++ };
|
||||
Assert.True(ship.TryEquip(gearItem, hardpoint.Position));
|
||||
}
|
||||
|
||||
// A reactor: Victoire (one of Cut 1's own restored thrusters, docs/locomotion-cut.md's own note on it)
|
||||
// carries a real EnergyUsage draw unlike its four siblings, so an unpowered ship reads as though only
|
||||
// some fitting thrusters produce thrust -- an artifact of which design TryEquip's own hardpoint search
|
||||
// happens to land on, not of the restored content. Every hull here also has a Reactor hardpoint; a real
|
||||
// ship always carries one, so this fixture should too.
|
||||
var reactorHardpoint = hull.Hardpoints.FirstOrDefault(h => h.Type == HardpointType.Reactor);
|
||||
if (reactorHardpoint != null)
|
||||
{
|
||||
var reactorDesign = cache.GetAll<GearData>().First(g => g.Hardpoint == HardpointType.Reactor &&
|
||||
g.Shape.FitsWithin(reactorHardpoint.Shape, reactorHardpoint.Rotation, out _) && g.Shape.Coordinates.Length == reactorHardpoint.Shape.Coordinates.Length);
|
||||
var reactorItem = new EquippableItem { Data = cache.RefOf<ItemData>(reactorDesign), Durability = reactorDesign.Durability, Lot = lot++ };
|
||||
Assert.True(ship.TryEquip(reactorItem, reactorHardpoint.Position));
|
||||
}
|
||||
|
||||
zone.Entities.Add(ship);
|
||||
ship.Position = float3.zero;
|
||||
ship.Activate();
|
||||
zone.Update(0f); // warm-up: resolves equipment stats before the driven ticks read them
|
||||
|
||||
var startVelocity = ship.Velocity;
|
||||
var startDirection = ship.Direction;
|
||||
|
||||
ship.MovementDirection = float2(0, 1); // full forward, same axis ActionGameManager.Input.Player.Move drives
|
||||
ship.LookDirection = float3(1, 0, 0); // off-axis target heading, so the mixer's yaw thrusters have work to do
|
||||
for (var i = 0; i < 10; i++) zone.Update(1f / 60f);
|
||||
|
||||
Assert.NotEqual(startVelocity, ship.Velocity);
|
||||
Assert.NotEqual(startDirection, ship.Direction);
|
||||
}
|
||||
|
||||
// Operator ruling, 2026-09-25 (docs/locomotion-cut.md, "Tutorial station"): "What we're testing is going to
|
||||
// be the tutorial level, right? Let's drop a station in there." The tutorial's entrance zone always gets a
|
||||
// generated faction station with a docking bay, deterministically -- not merely likely. This REPLACES
|
||||
// TutorialZoneGenerationCanProduceADockedStation, which never used the tutorial construction path at all: it
|
||||
// built an ad hoc single-zone SavedGame/Galaxy and asserted a docking bay showed up in at least one of 25
|
||||
// zone-name variants, which is a claim about the BACKGROUND station path in general, not about the entrance
|
||||
// zone Galaxy.cs actually picks (lowest-influence, unowned -- the one case ZoneGenerator.cs's own stationCount
|
||||
// roll produces 0 on essentially every seed, docs' own probe: 30 of 30). This test builds the real tutorial
|
||||
// Galaxy exactly as Assets/Resources/Settings.asset configures it and ActionGameManager.StartGame ->
|
||||
// PopulateLevel(CurrentGalaxy.Entrance) generates it, across seeds, and requires a docked station in every
|
||||
// run. It must fail without ZoneGenerator's tutorial-entrance override.
|
||||
//
|
||||
// Also requires that the NORMAL case (a zone with a real Lagrange candidate, the common case across 25 seeds)
|
||||
// seats its station on a genuine, non-rosette Lagrange orbit rather than the widened fallback -- the widened
|
||||
// candidate set is for the rare zone with none, not a replacement for ordinary placement.
|
||||
[Fact]
|
||||
public void EntranceZoneAlwaysGetsADockedStationAcrossSeeds()
|
||||
{
|
||||
var zoneSettings = TutorialZoneSettings();
|
||||
var tutorialSettings = TutorialGalaxySettings();
|
||||
var background = TutorialBackgroundSettings();
|
||||
var names = TutorialNameSettings();
|
||||
var gameData = Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc");
|
||||
|
||||
// Galaxy zone-graph generation has a pre-existing, seed-dependent flakiness of its own (a disconnected
|
||||
// zone graph throws inside the Galaxy constructor on roughly 1 seed in 15, confirmed unrelated to this
|
||||
// cut: it reproduces identically against the pre-fix-batch catalog). That failure belongs to Galaxy.cs,
|
||||
// not to ZoneGenerator's entrance-station override this test is pinning, so it is skipped rather than
|
||||
// asserted on; every seed whose Galaxy actually builds must still get a docked entrance station.
|
||||
var succeeded = 0;
|
||||
var sawGenuineLagrangeOrbit = false;
|
||||
for (uint seed = 1; seed <= 25; seed++)
|
||||
{
|
||||
var scratchRun = Path.Combine(Path.GetTempPath(), $"aetheria-entrance-station-{Guid.NewGuid():N}.cc");
|
||||
try
|
||||
{
|
||||
// Galaxy mutates Faction.InfluenceDistance in place; a fresh catalog open per seed keeps runs independent.
|
||||
using var cache = OpenReadOnlyRealCatalogWithScratchRun(gameData, scratchRun);
|
||||
Galaxy galaxy;
|
||||
try { galaxy = new Galaxy(tutorialSettings, background, names, cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed); }
|
||||
catch (Exception) { continue; }
|
||||
succeeded++;
|
||||
|
||||
var items = new ItemManager(cache, new ProvenanceLedger(), Settings(), _ => { });
|
||||
var pack = ZoneGenerator.GenerateZone(items, zoneSettings, galaxy, galaxy.Entrance, isTutorial: true);
|
||||
|
||||
var dockedStation = pack.Entities.OfType<OrbitalEntityPack>()
|
||||
.FirstOrDefault(e => (cache.Get(e.Hull.Data) as HullData)?.HullType == HullType.Station && e.DockingBays.Length > 0);
|
||||
Assert.True(dockedStation != null, $"seed {seed}: the tutorial entrance zone generated no station with a docking bay.");
|
||||
|
||||
if (!IsRosetteMember(cache, pack, cache.Get(dockedStation.Orbit)))
|
||||
sawGenuineLagrangeOrbit = true;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (File.Exists(scratchRun)) File.Delete(scratchRun);
|
||||
}
|
||||
}
|
||||
|
||||
Assert.True(succeeded >= 15, $"only {succeeded} of 25 seeds produced a Galaxy at all; too few runs to trust this result.");
|
||||
Assert.True(sawGenuineLagrangeOrbit, "none of the 25 seeds seated the entrance station on a genuine (non-rosette) Lagrange orbit.");
|
||||
}
|
||||
|
||||
// Cut 1 fix batch 3 (F6, N1): a per-seed strengthening of the "across seeds" test above. That test only
|
||||
// requires a genuine Lagrange orbit at least once in 25 seeds; it says nothing about a seed where a genuine
|
||||
// candidate DID exist but the station landed on the widened fallback anyway (which the widening condition's
|
||||
// own isTutorialEntrance-and-empty-candidates guard should make impossible). This pins the normal case
|
||||
// directly, seed by seed: whenever the entrance zone actually has a genuine (non-rosette) Lagrange candidate,
|
||||
// its station must be seated on one.
|
||||
[Fact]
|
||||
public void EntranceStationSitsOnAGenuineLagrangeOrbitWheneverOneExists()
|
||||
{
|
||||
var zoneSettings = TutorialZoneSettings();
|
||||
var tutorialSettings = TutorialGalaxySettings();
|
||||
var background = TutorialBackgroundSettings();
|
||||
var names = TutorialNameSettings();
|
||||
var gameData = Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc");
|
||||
|
||||
var succeeded = 0;
|
||||
var sawGenuineCandidate = false;
|
||||
for (uint seed = 1; seed <= 25; seed++)
|
||||
{
|
||||
var scratchRun = Path.Combine(Path.GetTempPath(), $"aetheria-entrance-normalcase-{Guid.NewGuid():N}.cc");
|
||||
try
|
||||
{
|
||||
using var cache = OpenReadOnlyRealCatalogWithScratchRun(gameData, scratchRun);
|
||||
Galaxy galaxy;
|
||||
try { galaxy = new Galaxy(tutorialSettings, background, names, cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed); }
|
||||
catch (Exception) { continue; }
|
||||
succeeded++;
|
||||
|
||||
var items = new ItemManager(cache, new ProvenanceLedger(), Settings(), _ => { });
|
||||
var pack = ZoneGenerator.GenerateZone(items, zoneSettings, galaxy, galaxy.Entrance, isTutorial: true);
|
||||
|
||||
var planetOrbits = pack.Planets.Select(p => cache.Get(cache.Get(p).Orbit)).Where(o => o.Parent.IsSet()).ToArray();
|
||||
var hasGenuineCandidate = planetOrbits.Any(o => planetOrbits.Count(c => c.Parent.Key.Equals(o.Parent.Key) && abs(c.Distance - o.Distance) < .1f) == 1);
|
||||
if (!hasGenuineCandidate) continue;
|
||||
sawGenuineCandidate = true;
|
||||
|
||||
var dockedStation = pack.Entities.OfType<OrbitalEntityPack>()
|
||||
.FirstOrDefault(e => (cache.Get(e.Hull.Data) as HullData)?.HullType == HullType.Station && e.DockingBays.Length > 0);
|
||||
Assert.True(dockedStation != null, $"seed {seed}: the tutorial entrance zone generated no station with a docking bay.");
|
||||
Assert.False(IsRosetteMember(cache, pack, cache.Get(dockedStation.Orbit)),
|
||||
$"seed {seed}: a genuine Lagrange candidate existed, but the station sat on the widened (rosette) fallback anyway.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (File.Exists(scratchRun)) File.Delete(scratchRun);
|
||||
}
|
||||
}
|
||||
|
||||
Assert.True(succeeded >= 15, $"only {succeeded} of 25 seeds produced a Galaxy at all; too few runs to trust this result.");
|
||||
Assert.True(sawGenuineCandidate, "none of the 25 seeds had a genuine Lagrange candidate at all; too few runs to trust this result.");
|
||||
}
|
||||
|
||||
// Cut 1 fix batch 3 (F5): the throw ZoneGenerator.cs's own entrance-station override raises
|
||||
// (ZoneGenerator.cs's "every planet in the zone is a parentless root" case, fixed in this same batch, F3) is
|
||||
// reachable through authored settings, not just a hypothetical: a real seed-1 tutorial entrance with
|
||||
// RosetteProbability 0 (no rosettes to widen into) and MassFloor far above every possible child mass (no
|
||||
// satellite ever clears the floor, so every planet stays a parentless root) leaves the entrance with no
|
||||
// candidate orbit at all, even after widening.
|
||||
[Fact]
|
||||
public void ThrowReachableWithAuthoredSettings()
|
||||
{
|
||||
var gameData = Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc");
|
||||
var scratchRun = Path.Combine(Path.GetTempPath(), $"aetheria-entrance-throw-{Guid.NewGuid():N}.cc");
|
||||
try
|
||||
{
|
||||
using var cache = OpenReadOnlyRealCatalogWithScratchRun(gameData, scratchRun);
|
||||
var galaxy = new Galaxy(TutorialGalaxySettings(), TutorialBackgroundSettings(), TutorialNameSettings(),
|
||||
cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed: 1u);
|
||||
var items = new ItemManager(cache, new ProvenanceLedger(), Settings(), _ => { });
|
||||
|
||||
var zoneSettings = TutorialZoneSettings();
|
||||
zoneSettings.RosetteProbability = 0;
|
||||
zoneSettings.MassFloor = 1e9f;
|
||||
|
||||
Assert.Throws<InvalidOperationException>(() =>
|
||||
ZoneGenerator.GenerateZone(items, zoneSettings, galaxy, galaxy.Entrance, isTutorial: true));
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (File.Exists(scratchRun)) File.Delete(scratchRun);
|
||||
}
|
||||
}
|
||||
|
||||
// Cut 1 fix batch 3 (F6, N3): a multi-root, heavily-widened entrance via authored settings -- RosetteProbability
|
||||
// 1 (every subzone becomes a rosette) and a fixed SubZoneCount of 8 (several independent rosette systems, each
|
||||
// its own root, never each other's sibling) with satellite/binary creation turned off so as few non-rosette
|
||||
// orbits form as this generator's own unconditional "captured planet" step (ZoneGenerator.cs's ExpandRosette
|
||||
// caller always adds at least one) allows. Verified directly against seed 1's real entrance: this leaves 14
|
||||
// distinct parents among its planets, not the single root a boring system would have. Whatever candidate
|
||||
// selection actually runs on a topology this fragmented -- ordinary or widened -- every resulting station
|
||||
// orbit must still be a real, positioned orbit: a set Parent and a positive Distance, never the zero-distance,
|
||||
// parentless orbit the pre-F4 fallback used to synthesize.
|
||||
[Fact]
|
||||
public void MultiRootEntranceStationOrbitsAreAlwaysParentedWithPositiveDistance()
|
||||
{
|
||||
var gameData = Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc");
|
||||
var scratchRun = Path.Combine(Path.GetTempPath(), $"aetheria-entrance-multiroot-{Guid.NewGuid():N}.cc");
|
||||
try
|
||||
{
|
||||
using var cache = OpenReadOnlyRealCatalogWithScratchRun(gameData, scratchRun);
|
||||
var galaxy = new Galaxy(TutorialGalaxySettings(), TutorialBackgroundSettings(), TutorialNameSettings(),
|
||||
cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed: 1u);
|
||||
var items = new ItemManager(cache, new ProvenanceLedger(), Settings(), _ => { });
|
||||
|
||||
var zoneSettings = TutorialZoneSettings();
|
||||
zoneSettings.RosetteProbability = 1;
|
||||
zoneSettings.SubZoneCount = new ExponentialLerp { Exponent = 1, Minimum = 8, Maximum = 8 };
|
||||
zoneSettings.SatelliteCreationProbability = 0;
|
||||
zoneSettings.BinaryCreationProbability = 0;
|
||||
|
||||
var pack = ZoneGenerator.GenerateZone(items, zoneSettings, galaxy, galaxy.Entrance, isTutorial: true);
|
||||
|
||||
var roots = pack.Planets.Select(p => cache.Get(p).Orbit)
|
||||
.Select(cache.Get)
|
||||
.Select(o => o.Parent.IsSet() ? o.Parent.Key.Value : "(root)")
|
||||
.Distinct().Count();
|
||||
Assert.True(roots > 1, $"this fixture no longer produces a multi-root entrance (only {roots} distinct parent); it no longer tests the fragmented-topology case.");
|
||||
|
||||
var stations = pack.Entities.OfType<OrbitalEntityPack>()
|
||||
.Where(e => (cache.Get(e.Hull.Data) as HullData)?.HullType == HullType.Station).ToArray();
|
||||
Assert.NotEmpty(stations);
|
||||
foreach (var station in stations)
|
||||
{
|
||||
var orbit = cache.Get(station.Orbit);
|
||||
Assert.True(orbit.Parent.IsSet(), "a station's orbit has no Parent.");
|
||||
Assert.True(orbit.Distance > 0, $"a station's orbit Distance is not positive: {orbit.Distance}.");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (File.Exists(scratchRun)) File.Delete(scratchRun);
|
||||
}
|
||||
}
|
||||
|
||||
// Cut 1 fix batch 3 (F6, N9): a station-offset pin. CreateLagrangeOrbit (ZoneGenerator.cs) builds the
|
||||
// station's orbit as a COPY of its source planet's (Parent, Distance) but offsets Phase by
|
||||
// PI/3 * sign(random...) -- a real angular displacement, not the same orbital slot. Must fail if that offset
|
||||
// is ever dropped (a mutant that seats the station directly on the planet's own orbit object): the station's
|
||||
// Phase must differ from every planet's Phase among those sharing its own (Parent, Distance), across seeds.
|
||||
[Fact]
|
||||
public void EntranceStationPhaseDiffersFromEveryPlanetAtItsOwnDistanceAcrossSeeds()
|
||||
{
|
||||
var zoneSettings = TutorialZoneSettings();
|
||||
var tutorialSettings = TutorialGalaxySettings();
|
||||
var background = TutorialBackgroundSettings();
|
||||
var names = TutorialNameSettings();
|
||||
var gameData = Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc");
|
||||
|
||||
var checkedAny = false;
|
||||
for (uint seed = 1; seed <= 25; seed++)
|
||||
{
|
||||
var scratchRun = Path.Combine(Path.GetTempPath(), $"aetheria-entrance-offset-{Guid.NewGuid():N}.cc");
|
||||
try
|
||||
{
|
||||
using var cache = OpenReadOnlyRealCatalogWithScratchRun(gameData, scratchRun);
|
||||
Galaxy galaxy;
|
||||
try { galaxy = new Galaxy(tutorialSettings, background, names, cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed); }
|
||||
catch (Exception) { continue; }
|
||||
|
||||
var items = new ItemManager(cache, new ProvenanceLedger(), Settings(), _ => { });
|
||||
var pack = ZoneGenerator.GenerateZone(items, zoneSettings, galaxy, galaxy.Entrance, isTutorial: true);
|
||||
|
||||
var dockedStation = pack.Entities.OfType<OrbitalEntityPack>()
|
||||
.FirstOrDefault(e => (cache.Get(e.Hull.Data) as HullData)?.HullType == HullType.Station && e.DockingBays.Length > 0);
|
||||
if (dockedStation == null) continue;
|
||||
var stationOrbit = cache.Get(dockedStation.Orbit);
|
||||
if (!stationOrbit.Parent.IsSet()) continue;
|
||||
|
||||
var siblingPlanets = pack.Planets.Select(p => cache.Get(cache.Get(p).Orbit))
|
||||
.Where(o => o.Parent.IsSet() && o.Parent.Key.Equals(stationOrbit.Parent.Key) && abs(o.Distance - stationOrbit.Distance) < .1f)
|
||||
.ToArray();
|
||||
if (siblingPlanets.Length == 0) continue;
|
||||
checkedAny = true;
|
||||
|
||||
foreach (var planetOrbit in siblingPlanets)
|
||||
Assert.True(abs(planetOrbit.Phase - stationOrbit.Phase) > 1e-3f,
|
||||
$"seed {seed}: the docked station's Phase ({stationOrbit.Phase}) matches a planet's own Phase at the same (Parent, Distance) -- it is sitting on the planet's own orbital slot instead of an offset one.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (File.Exists(scratchRun)) File.Delete(scratchRun);
|
||||
}
|
||||
}
|
||||
|
||||
Assert.True(checkedAny, "no seed produced a docked entrance station with an identifiable source planet at its own (Parent, Distance); too few runs to trust this result.");
|
||||
}
|
||||
|
||||
// Speed cap (docs/locomotion-cut.md Cut 1 verification): Longinus's restored VelocityLimitData caps it at
|
||||
// the legacy TopSpeed, 100 (100..100) -- asserted as the literal from the legacy record rather than read
|
||||
// back out of the same catalog value being tested, so a mutated TopSpeed (e.g. 1000) can't also move the
|
||||
// bound this test checks against.
|
||||
//
|
||||
// Cut 1 fix batch 3 (Soul's finding #1): the comment this replaces claimed the run went "long enough to
|
||||
// approach its drag/thrust balance well past 100" while forcing OverrideShutdown on the hull and both
|
||||
// firing thrusters for the whole scenario -- a fixture compensating for RestoredHullsTests.Settings() (then
|
||||
// hand-set, thermal radiation/conduction frozen at 1/1/1 against the shipped 3 / 1e-8 / 0.01) making every
|
||||
// part freeze toward 0 K and shut down within about a second on real physics. Settings() now loads the real
|
||||
// GameplaySettings (AuthoredSettings, above), so OverrideShutdown is no longer needed to keep the ship
|
||||
// flying: a real, unforced Longinus holds thrust (and the hull's own VelocityLimit) running well past the
|
||||
// window this test drives.
|
||||
//
|
||||
// Real settings also retired the old +-10 tolerance's premise. On real physics the mixer's own tick order
|
||||
// (Ship.cs: a tick's thrust-driven velocity is checked against VelocityLimit's cap on the FOLLOWING tick)
|
||||
// settles into a steady state at the cap plus one tick's own forward acceleration, not at the literal cap --
|
||||
// measured here at ~103.3 for this seed's generated loadout, not the ~110 an unconstrained +-10 tolerance
|
||||
// would also accept. +4 keeps that real headroom on the ceiling side. The floor is tighter (-3): a
|
||||
// materially nerfed cap (Soul's own catalog mutant, TopSpeed 100 -> 92) still produces the same kind of
|
||||
// steady state, just a lower one (~95), which -3 catches but +-10 or a +4 ceiling would not.
|
||||
//
|
||||
// Must fail when VelocityLimitData is removed (docs' own probe: Longinus reaches 122 without it), when
|
||||
// TopSpeed is mutated away from 100, and when VelocityLimit's own trigger check is loosened (a "+6 slack"
|
||||
// mutant pushes this same steady state to ~109, over the +4 ceiling).
|
||||
[Fact]
|
||||
public void LonginusNeverExceedsItsRestoredTopSpeedUnderFullThrust()
|
||||
{
|
||||
const float LegacyTopSpeed = 100f; // Longinus's legacy-record TopSpeed (100..100)
|
||||
|
||||
using var cache = OpenCatalog();
|
||||
var hull = cache.GetByName<HullData>("Longinus");
|
||||
var settings = Settings();
|
||||
var items = new ItemManager(cache, new ProvenanceLedger(), settings, _ => { });
|
||||
// ItemManager.Random defaults to a DateTime.Now-seeded instance; without pinning it here, the item
|
||||
// qualities LoadoutGenerator/EntitySerializer roll through it (not through the `random` below, which
|
||||
// only drives which designs get picked) would make this test's own measured speed non-deterministic.
|
||||
items.Random = new Random(1u);
|
||||
var random = new Random(1);
|
||||
var generator = new LoadoutGenerator(ref random, items, null, null, null, .5f);
|
||||
var pack = generator.GenerateShipLoadout(candidate => candidate == hull);
|
||||
Assert.NotNull(pack);
|
||||
var zone = new Zone(items, new PlanetSettings(), new ZonePack(), new GalaxyZone { Name = "Test", Owner = null }, null);
|
||||
var ship = (Ship) EntitySerializer.Unpack(items, zone, pack);
|
||||
|
||||
zone.Entities.Add(ship);
|
||||
ship.Position = float3.zero;
|
||||
ship.Activate();
|
||||
zone.Update(0f);
|
||||
|
||||
ship.MovementDirection = float2(0, 1); // full forward
|
||||
ship.LookDirection = float3(ship.Direction.x, 0, ship.Direction.y); // straight line: hold the ship's own heading
|
||||
|
||||
// Soul measured this loadout's forward thrusters crossing 386 K (thermal shutdown) around 7.3 s under
|
||||
// real settings; 5 s keeps every tick inside the window where thrust runs continuously and unforced, so
|
||||
// the cap -- not a coasting or shut-down ship -- is what the assertions below are pinning.
|
||||
const int ticks = 60 * 5;
|
||||
var lastSpeed = 0f;
|
||||
for (var i = 0; i < ticks; i++)
|
||||
{
|
||||
zone.Update(1f / 60f);
|
||||
var speed = length(ship.Velocity);
|
||||
lastSpeed = speed;
|
||||
Assert.True(speed <= LegacyTopSpeed + 4f, $"tick {i}: speed {speed} exceeded the legacy top speed {LegacyTopSpeed} by more than the real tick-order headroom.");
|
||||
}
|
||||
|
||||
Assert.True(lastSpeed >= LegacyTopSpeed - 3f, $"final speed {lastSpeed} fell too far below the legacy top speed {LegacyTopSpeed}; the cap looks nerfed.");
|
||||
}
|
||||
|
||||
// Loadout generation (docs/locomotion-cut.md Cut 1 verification): LoadoutGenerator, filtered to each
|
||||
// restored hull, must fill every one of its thruster hardpoints -- the check that the restored designs and
|
||||
// their FactionProductData/roles are authored correctly, not just present.
|
||||
[Theory]
|
||||
[InlineData("Longinus")]
|
||||
[InlineData("Djinni")]
|
||||
public void LoadoutGeneratorFillsEveryThrusterHardpointAcrossSeeds(string name)
|
||||
{
|
||||
using var cache = OpenCatalog();
|
||||
var hull = cache.GetByName<HullData>(name);
|
||||
var thrusterHardpoints = hull.Hardpoints.Where(h => h.Type == HardpointType.Thruster).ToArray();
|
||||
var settings = Settings();
|
||||
|
||||
for (uint seed = 1; seed <= 10; seed++)
|
||||
{
|
||||
var items = new ItemManager(cache, new ProvenanceLedger(), settings, _ => { });
|
||||
var random = new Random(seed);
|
||||
var generator = new LoadoutGenerator(ref random, items, null, null, null, .5f);
|
||||
var pack = generator.GenerateShipLoadout(candidate => candidate == hull);
|
||||
Assert.True(pack != null, $"{name}: seed {seed} produced no loadout.");
|
||||
|
||||
foreach (var hardpoint in thrusterHardpoints)
|
||||
{
|
||||
var filled = pack.Equipment.Any(e => e.position.Equals(hardpoint.Position) &&
|
||||
(cache.Get(e.item.Data) as GearData)?.Hardpoint == HardpointType.Thruster);
|
||||
Assert.True(filled, $"{name}: seed {seed}'s {hardpoint.Transform ?? hardpoint.Type.ToString()} hardpoint at {hardpoint.Position} got no thruster.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Builds the real tutorial galaxy for `seed`, then re-targets its Entrance to `entranceZoneName` via the
|
||||
// public SavedGame/SavedZone round trip (RunSave's own shape: Galaxy -> SavedZone[] -> Galaxy(cache,
|
||||
// SavedGame, log)), without touching Galaxy's private Entrance backing field by reflection. Zone content
|
||||
// (planets) is keyed off each zone's own Name/Position, not off which zone happens to be Entrance, so the
|
||||
// re-targeted galaxy's chosen zone generates identically to the original -- letting a test pick, by name, any
|
||||
// real zone from a real galaxy (e.g. one already known to have no Lagrange candidate) and make it the Entrance.
|
||||
private static Galaxy BuildGalaxyWithForcedEntrance(CultCache cache, uint seed, string entranceZoneName)
|
||||
{
|
||||
var galaxy = new Galaxy(TutorialGalaxySettings(), TutorialBackgroundSettings(), TutorialNameSettings(),
|
||||
cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed);
|
||||
var target = galaxy.Zones.Single(z => z.Name == entranceZoneName);
|
||||
|
||||
var factions = galaxy.Factions;
|
||||
var savedZones = galaxy.Zones.Select(zone => new SavedZone
|
||||
{
|
||||
Name = zone.Name,
|
||||
Position = zone.Position,
|
||||
AdjacentZones = zone.AdjacentZones.Select(az => Array.IndexOf(galaxy.Zones, az)).ToArray(),
|
||||
Factions = zone.Factions.Select(f => Array.IndexOf(factions, f)).ToArray(),
|
||||
Contents = zone.PackedContents,
|
||||
Owner = zone.Owner == null ? -1 : Array.IndexOf(factions, zone.Owner),
|
||||
}).ToArray();
|
||||
var keys = savedZones.Select((_, i) => new CultRecordKey($"restoredhullstests-forced-entrance-zone-{i}")).ToArray();
|
||||
cache.Commit(batch => { for (var i = 0; i < keys.Length; i++) batch.Upsert(typeof(SavedZone), savedZones[i], keys[i]); });
|
||||
|
||||
var game = new SavedGame
|
||||
{
|
||||
Zones = keys.Select(k => new CultRecordRef<SavedZone>(k)).ToArray(),
|
||||
Factions = factions.Select(f => cache.RefOf(f)).ToArray(),
|
||||
HomeZones = galaxy.HomeZones.ToDictionary(x => Array.IndexOf(factions, x.Key), x => Array.IndexOf(galaxy.Zones, x.Value)),
|
||||
BossZones = galaxy.BossZones.ToDictionary(x => Array.IndexOf(factions, x.Key), x => Array.IndexOf(galaxy.Zones, x.Value)),
|
||||
Entrance = Array.IndexOf(galaxy.Zones, target),
|
||||
Exit = -1,
|
||||
Relationships = factions.Select(f => galaxy.FactionRelationships[f]).ToArray(),
|
||||
DiscoveredZones = Array.Empty<int>(),
|
||||
Background = galaxy.Background,
|
||||
IsTutorial = true,
|
||||
};
|
||||
return new Galaxy(cache, game, _ => { });
|
||||
}
|
||||
|
||||
// Cut 1 fix batch 2 (Soul's finding #2): the tutorial entrance's widened candidate set. Seed 3's real tutorial
|
||||
// galaxy has a zone, "EAC-7089", whose planets are entirely one rosette with no captured satellites at all: 4
|
||||
// planets sharing one Distance under one Parent, and nothing else -- potentialLagrangePoints is empty for it
|
||||
// (verified directly against this exact fixture, not carried over from Soul's own forced-fallback probe, whose
|
||||
// own candidate check undercounted planet orbits by using pack.Planets.Count -- which excludes Empty rosette
|
||||
// roots -- and so misidentified some zones, including its originally-reported "EAC-3208", as candidate-less
|
||||
// when they were not). Re-targeted here to be the Entrance through BuildGalaxyWithForcedEntrance above. Its
|
||||
// docked station can therefore only have come from the widened candidate set (every parented planet orbit,
|
||||
// not just non-rosette ones), never from a synthesized, unparented fallback orbit. Pins: still docked, and
|
||||
// turrets sit on a real orbit (a real Parent, a finite Phase).
|
||||
//
|
||||
// Cut 1 fix batch 3 (F7): the Distance check this comment used to describe as "near their station" was
|
||||
// vacuous -- PlaceTurret (ZoneGenerator.cs) sets a turret orbit's Distance from `orbit.Distance` directly,
|
||||
// unconditionally, the same as CreateLagrangeOrbit does for the station itself, so every turret's Distance
|
||||
// equals the station's by construction regardless of placement; the check could never fail. What actually
|
||||
// makes a turret "near" its station is Phase: PlaceTurrets' own `dist = t/2` gives each turret a small
|
||||
// angular nudge (`20 * dist / orbit.Distance`) off the station's own Phase, not a placement anywhere else on
|
||||
// the orbit. Replaced with a bound on that real offset, generous over PlaceTurrets' own formula.
|
||||
[Fact]
|
||||
public void TutorialEntranceWithNoLagrangeCandidateStillSeatsAStationWithFiniteNearbyTurrets()
|
||||
{
|
||||
var gameData = Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc");
|
||||
var scratchRun = Path.Combine(Path.GetTempPath(), $"aetheria-entrance-widened-{Guid.NewGuid():N}.cc");
|
||||
try
|
||||
{
|
||||
using var cache = OpenReadOnlyRealCatalogWithScratchRun(gameData, scratchRun);
|
||||
var galaxy = BuildGalaxyWithForcedEntrance(cache, seed: 3u, "EAC-7089");
|
||||
|
||||
var items = new ItemManager(cache, new ProvenanceLedger(), Settings(), _ => { });
|
||||
var pack = ZoneGenerator.GenerateZone(items, TutorialZoneSettings(), galaxy, galaxy.Entrance, isTutorial: true);
|
||||
|
||||
var station = pack.Entities.OfType<OrbitalEntityPack>()
|
||||
.FirstOrDefault(e => (cache.Get(e.Hull.Data) as HullData)?.HullType == HullType.Station && e.DockingBays.Length > 0);
|
||||
Assert.True(station != null, "the known no-Lagrange-candidate entrance zone generated no docked station.");
|
||||
var stationOrbit = cache.Get(station.Orbit);
|
||||
|
||||
// Confirms this fixture still exercises the widened path (a regression here would mean the fixture no
|
||||
// longer probes what this test claims to probe).
|
||||
Assert.True(IsRosetteMember(cache, pack, stationOrbit), "the entrance station no longer sits on a rosette-only orbit -- this fixture no longer tests the widened candidate path.");
|
||||
|
||||
var turrets = pack.Entities.OfType<OrbitalEntityPack>()
|
||||
.Where(e => (cache.Get(e.Hull.Data) as HullData)?.HullType != HullType.Station).ToArray();
|
||||
Assert.NotEmpty(turrets);
|
||||
// Generous over PlaceTurrets' own max |distanceMultiplier| ((turrets.Length - 1) / 2): a real bound,
|
||||
// not the vacuous Distance-always-matches check this replaces.
|
||||
var maxPhaseOffset = 20f * turrets.Length / stationOrbit.Distance;
|
||||
foreach (var turret in turrets)
|
||||
{
|
||||
var turretOrbit = cache.Get(turret.Orbit);
|
||||
Assert.True(turretOrbit.Parent.IsSet(), "a turret's orbit has no Parent.");
|
||||
Assert.False(float.IsNaN(turretOrbit.Phase) || float.IsInfinity(turretOrbit.Phase), $"a turret's orbit Phase is not finite: {turretOrbit.Phase}.");
|
||||
var phaseDelta = abs(turretOrbit.Phase - stationOrbit.Phase);
|
||||
Assert.True(phaseDelta <= maxPhaseOffset,
|
||||
$"a turret's Phase ({turretOrbit.Phase}) is not near the station's own Phase ({stationOrbit.Phase}): delta {phaseDelta} > {maxPhaseOffset}.");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (File.Exists(scratchRun)) File.Delete(scratchRun);
|
||||
}
|
||||
}
|
||||
|
||||
// Cut 1 fix batch 2 (Soul's finding #2, leak check): the entrance override must not leak to (a) other
|
||||
// tutorial zones or (b) a non-tutorial game's own entrance zone. Both are pinned against a seed-1 galaxy --
|
||||
// the widened-candidate test above uses a different fixture, seed 3's "EAC-7089" -- so this test and the one
|
||||
// below it stand or fall on this one known fixture, not that one.
|
||||
[Fact]
|
||||
public void EntranceOverrideDoesNotLeakToOtherTutorialZonesOrNonTutorialGames()
|
||||
{
|
||||
var gameData = Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc");
|
||||
var scratchRun = Path.Combine(Path.GetTempPath(), $"aetheria-entrance-leak-{Guid.NewGuid():N}.cc");
|
||||
try
|
||||
{
|
||||
using var cache = OpenReadOnlyRealCatalogWithScratchRun(gameData, scratchRun);
|
||||
var galaxy = new Galaxy(TutorialGalaxySettings(), TutorialBackgroundSettings(), TutorialNameSettings(),
|
||||
cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed: 1u);
|
||||
var items = new ItemManager(cache, new ProvenanceLedger(), Settings(), _ => { });
|
||||
|
||||
int StationCount(GalaxyZone zone, bool isTutorial) =>
|
||||
ZoneGenerator.GenerateZone(items, TutorialZoneSettings(), galaxy, zone, isTutorial)
|
||||
.Entities.OfType<OrbitalEntityPack>()
|
||||
.Count(e => (cache.Get(e.Hull.Data) as HullData)?.HullType == HullType.Station);
|
||||
|
||||
// (a) A non-entrance tutorial zone that naturally rolls zero stations keeps that roll under
|
||||
// isTutorial: true -- the floor must not leak past the galaxy.Entrance reference check.
|
||||
var otherZone = galaxy.Zones.Single(z => z.Name == "EAC-2733");
|
||||
Assert.NotSame(galaxy.Entrance, otherZone);
|
||||
Assert.Equal(0, StationCount(otherZone, isTutorial: true));
|
||||
|
||||
// (b) The entrance zone itself, generated for a non-tutorial game (isTutorial: false), keeps its
|
||||
// natural roll too -- the floor must not leak past the isTutorial flag either.
|
||||
Assert.Equal(0, StationCount(galaxy.Entrance, isTutorial: false));
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (File.Exists(scratchRun)) File.Delete(scratchRun);
|
||||
}
|
||||
}
|
||||
|
||||
// Cut 1 fix batch 2 (Soul's finding #2, baseStationCount): the entrance override raises stationCount (the
|
||||
// orbit-selection floor) but must not also raise the enemyCount roll, which is keyed to baseStationCount
|
||||
// (the pre-override value) precisely so the forced station doesn't buy the zone an extra enemy. Seed 1's
|
||||
// entrance zone rolls baseStationCount 0 (confirmed via the isTutorial: false StationCount == 0 above) and
|
||||
// the override raises stationCount to 1; this pins the resulting ship count at the value baseStationCount
|
||||
// produces. It must fail if the enemy-count formula is changed to add stationCount instead (it would add a
|
||||
// ship instead of zero).
|
||||
[Fact]
|
||||
public void ForcedTutorialEntranceStationDoesNotInflateEnemyCount()
|
||||
{
|
||||
var gameData = Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc");
|
||||
var scratchRun = Path.Combine(Path.GetTempPath(), $"aetheria-entrance-enemycount-{Guid.NewGuid():N}.cc");
|
||||
try
|
||||
{
|
||||
using var cache = OpenReadOnlyRealCatalogWithScratchRun(gameData, scratchRun);
|
||||
var galaxy = new Galaxy(TutorialGalaxySettings(), TutorialBackgroundSettings(), TutorialNameSettings(),
|
||||
cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed: 1u);
|
||||
var items = new ItemManager(cache, new ProvenanceLedger(), Settings(), _ => { });
|
||||
|
||||
var pack = ZoneGenerator.GenerateZone(items, TutorialZoneSettings(), galaxy, galaxy.Entrance, isTutorial: true);
|
||||
var stationCount = pack.Entities.OfType<OrbitalEntityPack>().Count(e => (cache.Get(e.Hull.Data) as HullData)?.HullType == HullType.Station);
|
||||
// Soul's finding (this cut's fix batch 3): pack.Entities.OfType<ShipPack>().Count() also counts the
|
||||
// zone's neutral wanderers (ZoneGenerator.cs's own EligibleWandererFactions spawn, keyed to
|
||||
// ZoneGenerationSettings.NeutralWandererCount -- 2 by TutorialZoneSettings' own default, unrelated to
|
||||
// this fixture's own enemy roll), so the old assertion of exactly 2 was pinning the wanderer count,
|
||||
// not the enemy count baseStationCount is supposed to gate. The nearest faction here is the same one
|
||||
// ZoneGenerator computes internally (galaxy.HomeZones' own distance-to-zone ordering); every ShipPack
|
||||
// names its faction directly (EntityPack.Faction), so filtering on it separates the two spawns.
|
||||
var nearestFaction = galaxy.Factions.MinBy(f => galaxy.HomeZones[f].Distance[galaxy.Entrance]);
|
||||
var enemyShipCount = pack.Entities.OfType<ShipPack>().Count(s => cache.Get(s.Faction) == nearestFaction);
|
||||
|
||||
Assert.Equal(1, stationCount); // the override did raise the station count (from a natural roll of 0)
|
||||
Assert.Equal(0, enemyShipCount); // the enemy roll stayed keyed to the pre-override baseStationCount of 0
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (File.Exists(scratchRun)) File.Delete(scratchRun);
|
||||
}
|
||||
}
|
||||
|
||||
// Cut 1 fix batch 3 (F6, N2): the entrance-only widening must not leak to a non-entrance zone that would
|
||||
// otherwise get zero stations. Seed 3's "EAC-7089" (the same no-Lagrange fixture the widened-candidate test
|
||||
// above uses, this time NOT retargeted as Entrance) rolls a real, nonzero station count on its own -- forced
|
||||
// here by boosting one faction's presence there (HomeZone distance 0, InfluenceDistance 50, so the roll's
|
||||
// floor(rand * (factionPresence+1)) is overwhelmingly likely nonzero) via the same public SavedGame round
|
||||
// trip BuildGalaxyWithForcedEntrance uses, not by touching ZoneGenerator's private roll. Verified directly:
|
||||
// temporarily widening every zone (dropping ZoneGenerator's isTutorialEntrance guard) turns this fixture's
|
||||
// station count from 0 into 2, so a natural nonzero roll really is hiding behind the empty candidate set.
|
||||
// Must fail if that guard is dropped for real.
|
||||
private static Galaxy BuildGalaxyWithBoostedPresence(CultCache cache, uint seed, string zoneName)
|
||||
{
|
||||
var galaxy = new Galaxy(TutorialGalaxySettings(), TutorialBackgroundSettings(), TutorialNameSettings(),
|
||||
cache, new PlayerSettings(), new DirectoryInfo(Path.GetTempPath()), _ => { }, null, seed);
|
||||
var target = galaxy.Zones.Single(z => z.Name == zoneName);
|
||||
|
||||
var factions = galaxy.Factions;
|
||||
var savedZones = galaxy.Zones.Select(zone => new SavedZone
|
||||
{
|
||||
Name = zone.Name,
|
||||
Position = zone.Position,
|
||||
AdjacentZones = zone.AdjacentZones.Select(az => Array.IndexOf(galaxy.Zones, az)).ToArray(),
|
||||
Factions = zone.Factions.Select(f => Array.IndexOf(factions, f)).ToArray(),
|
||||
Contents = zone.PackedContents,
|
||||
Owner = zone.Owner == null ? -1 : Array.IndexOf(factions, zone.Owner),
|
||||
}).ToArray();
|
||||
var keys = savedZones.Select((_, i) => new CultRecordKey($"restoredhullstests-boosted-presence-zone-{i}")).ToArray();
|
||||
cache.Commit(batch => { for (var i = 0; i < keys.Length; i++) batch.Upsert(typeof(SavedZone), savedZones[i], keys[i]); });
|
||||
|
||||
var homeZones = galaxy.HomeZones.ToDictionary(x => Array.IndexOf(factions, x.Key), x => Array.IndexOf(galaxy.Zones, x.Value));
|
||||
var boosted = Enumerable.Range(0, factions.Length).OrderByDescending(i => factions[i].InfluenceDistance).First();
|
||||
homeZones[boosted] = Array.IndexOf(galaxy.Zones, target);
|
||||
factions[boosted].InfluenceDistance = 50;
|
||||
|
||||
var game = new SavedGame
|
||||
{
|
||||
Zones = keys.Select(k => new CultRecordRef<SavedZone>(k)).ToArray(),
|
||||
Factions = factions.Select(f => cache.RefOf(f)).ToArray(),
|
||||
HomeZones = homeZones,
|
||||
BossZones = galaxy.BossZones.ToDictionary(x => Array.IndexOf(factions, x.Key), x => Array.IndexOf(galaxy.Zones, x.Value)),
|
||||
Entrance = Array.IndexOf(galaxy.Zones, galaxy.Entrance),
|
||||
Exit = -1,
|
||||
Relationships = factions.Select(f => galaxy.FactionRelationships[f]).ToArray(),
|
||||
DiscoveredZones = Array.Empty<int>(),
|
||||
Background = galaxy.Background,
|
||||
IsTutorial = true,
|
||||
};
|
||||
return new Galaxy(cache, game, _ => { });
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WideningDoesNotLeakToANonEntranceNoLagrangeZoneThatRollsAStation()
|
||||
{
|
||||
var gameData = Path.Combine(FindRepoRoot(), "GameData", "Aetheria.cc");
|
||||
var scratchRun = Path.Combine(Path.GetTempPath(), $"aetheria-widen-leak-{Guid.NewGuid():N}.cc");
|
||||
try
|
||||
{
|
||||
using var cache = OpenReadOnlyRealCatalogWithScratchRun(gameData, scratchRun);
|
||||
var galaxy = BuildGalaxyWithBoostedPresence(cache, seed: 3u, "EAC-7089");
|
||||
var zone = galaxy.Zones.Single(z => z.Name == "EAC-7089");
|
||||
Assert.NotSame(galaxy.Entrance, zone);
|
||||
|
||||
var items = new ItemManager(cache, new ProvenanceLedger(), Settings(), _ => { });
|
||||
var pack = ZoneGenerator.GenerateZone(items, TutorialZoneSettings(), galaxy, zone, isTutorial: true);
|
||||
|
||||
// Confirms this fixture still has no genuine (non-rosette) Lagrange candidate -- a regression here
|
||||
// would mean the fixture no longer probes what this test claims to probe.
|
||||
var planetOrbits = pack.Planets.Select(p => cache.Get(cache.Get(p).Orbit)).Where(o => o.Parent.IsSet()).ToArray();
|
||||
var hasGenuineCandidate = planetOrbits.Any(o => planetOrbits.Count(c => c.Parent.Key.Equals(o.Parent.Key) && abs(c.Distance - o.Distance) < .1f) == 1);
|
||||
Assert.False(hasGenuineCandidate, "the entrance-adjacent fixture zone now has a genuine Lagrange candidate; it no longer tests the no-Lagrange leak path.");
|
||||
|
||||
var stationCount = pack.Entities.OfType<OrbitalEntityPack>().Count(e => (cache.Get(e.Hull.Data) as HullData)?.HullType == HullType.Station);
|
||||
Assert.Equal(0, stationCount);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (File.Exists(scratchRun)) File.Delete(scratchRun);
|
||||
}
|
||||
}
|
||||
|
||||
// Soul's finding #3 (asset identity): the existence-only check (EveryAssetReferenceResolvesToAMetaGuid) passes
|
||||
// even when Djinni.Prefab is swapped for Longinus's -- both are real GUIDs somewhere under Assets/. This pins
|
||||
// the actual identity: each restored reference names the specific legacy-record file it is supposed to, not
|
||||
// merely some meta file that happens to exist. Must fail under Soul's own "djprefab" mutation (Djinni.Prefab
|
||||
// set to Longinus's GUID).
|
||||
[Fact]
|
||||
public void RestoredAssetReferencesNameTheirOwnLegacyFileNotJustAnyExistingGuid()
|
||||
{
|
||||
string GuidOf(string assetPathUnderRepoRoot)
|
||||
{
|
||||
var meta = Path.Combine(FindRepoRoot(), assetPathUnderRepoRoot + ".meta");
|
||||
return File.ReadLines(meta).First(l => l.StartsWith("guid: ")).Substring("guid: ".Length).Trim();
|
||||
}
|
||||
|
||||
using var cache = OpenCatalog();
|
||||
|
||||
var djinniPrefabGuid = GuidOf("Assets/Content/Prefabs/Ships/Djinni.prefab");
|
||||
var djinni = cache.GetByName<HullData>("Djinni");
|
||||
Assert.Equal(djinniPrefabGuid, djinni.Prefab);
|
||||
|
||||
// Every restored thruster's particle effect is Thruster 1.prefab, by the legacy record (soul-dump.txt).
|
||||
var thruster1Guid = GuidOf("Assets/Content/Prefabs/Thrusters/Thruster 1.prefab");
|
||||
var restoredThrusterNames = new[] { "deep space burnout", "Large Drive", "Victoire", "Small Drive", "Talaria", "RevvITup 2.0", "Medium Drive" };
|
||||
foreach (var name in restoredThrusterNames)
|
||||
{
|
||||
var design = cache.GetAll<GearData>().First(g => g.Name == name);
|
||||
var thrusterBehavior = design.Behaviors.OfType<ThrusterData>().Single();
|
||||
Assert.Equal(thruster1Guid, thrusterBehavior.ParticlesPrefab);
|
||||
}
|
||||
}
|
||||
}
|
||||
37
tests/Aetheria.Shared.Tests/SafeAssert.cs
Normal file
37
tests/Aetheria.Shared.Tests/SafeAssert.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Xunit;
|
||||
|
||||
// Assertions over collections of entities and shots. xunit formats a collection's contents into its failure
|
||||
// message, and an Entity, a PendingShot or a ShotOutcome drags the whole zone graph in with it: the formatter
|
||||
// recurses until the test host dies of a stack overflow, which a mutation tool scores as a kill of every test
|
||||
// that was running. A failure here must be an ordinary red naming the test, so these compare counts and
|
||||
// identities and never hand xunit an entity.
|
||||
internal static class SafeAssert
|
||||
{
|
||||
public static void NoShots(Zone zone) =>
|
||||
Assert.True(zone.PendingShots.Count == 0, $"{zone.PendingShots.Count} shot(s) still pending");
|
||||
|
||||
public static PendingShot OnlyShot(Zone zone)
|
||||
{
|
||||
Assert.True(zone.PendingShots.Count == 1, $"expected exactly one pending shot, found {zone.PendingShots.Count}");
|
||||
return zone.PendingShots[0];
|
||||
}
|
||||
|
||||
public static T Only<T>(List<T> list)
|
||||
{
|
||||
Assert.True(list.Count == 1, $"expected exactly one {typeof(T).Name}, found {list.Count}");
|
||||
return list[0];
|
||||
}
|
||||
|
||||
public static void Empty<T>(List<T> list) => Assert.True(list.Count == 0, $"expected no {typeof(T).Name}, found {list.Count}");
|
||||
|
||||
public static void In(Zone zone, Entity entity, string why = "entity should be in the zone") =>
|
||||
Assert.True(zone.Entities.Contains(entity), why);
|
||||
|
||||
public static void NotIn(Zone zone, Entity entity, string why = "entity should have left the zone") =>
|
||||
Assert.False(zone.Entities.Contains(entity), why);
|
||||
}
|
||||
Loading…
Reference in a new issue