2021-04-15 04:25:22 +01:00
|
|
|
using System;
|
2026-08-10 14:57:50 +01:00
|
|
|
using System.Collections;
|
2021-02-26 19:01:47 +00:00
|
|
|
using System.Linq;
|
|
|
|
|
using UnityEngine;
|
2026-09-14 17:39:12 +02:00
|
|
|
using CultMath;
|
Convert engine types through CultMath.UnityBridge
CultMath has no implicit conversions to or from Vector*, Quaternion or
Color, so Assembly-CSharp converts explicitly with ToCultMath/ToUnity at
each engine boundary: FieldDriver, GuidedProjectile(Manager),
EntityInstance, ActionGameManager, HullCollider, GridObject, ShipInstance,
ShieldManager, ItemPickup, FieldTester, PlaceUIElementWorldspace,
MapMenuInput, MapRenderer, SectorRenderer and ZoneRenderer. CultMath math
calls that were handed Unity vectors now take converted values;
Vector3.Scale in FieldDriver becomes a float3 product, and ItemPickup's
Vector3.Dot on float3s becomes dot. packages-lock.json records the
cultmath git package at f0605367 and demotes com.unity.mathematics to a
transitive dependency.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 17:47:33 +02:00
|
|
|
using CultMath.UnityBridge;
|
2026-09-14 17:39:12 +02:00
|
|
|
using static CultMath.math;
|
2021-02-26 19:01:47 +00:00
|
|
|
|
|
|
|
|
public class ShipInstance : EntityInstance
|
|
|
|
|
{
|
2021-04-15 04:25:22 +01:00
|
|
|
private static int _shipIndex;
|
|
|
|
|
public TractorBeam TractorBeam;
|
2021-03-16 16:35:23 +00:00
|
|
|
private class ThrusterInstance
|
|
|
|
|
{
|
|
|
|
|
public Thruster Thruster;
|
|
|
|
|
public ParticleSystem System;
|
|
|
|
|
public float BaseEmission;
|
|
|
|
|
public int MaxParticleCount;
|
|
|
|
|
}
|
2021-04-30 15:37:39 +01:00
|
|
|
|
2021-03-16 16:35:23 +00:00
|
|
|
private ThrusterInstance[] _thrusters;
|
2021-02-26 19:01:47 +00:00
|
|
|
|
|
|
|
|
public Ship Ship { get; private set; }
|
|
|
|
|
|
2021-04-15 04:25:22 +01:00
|
|
|
private void Start()
|
|
|
|
|
{
|
|
|
|
|
var tractorBeamMain = TractorBeam.ParticleSystem.main;
|
|
|
|
|
tractorBeamMain.customSimulationSpace = LocalSpace;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-15 11:40:46 +00:00
|
|
|
public override void SetEntity(ZoneRenderer zoneRenderer, Entity entity)
|
2021-02-26 19:01:47 +00:00
|
|
|
{
|
2021-03-15 11:40:46 +00:00
|
|
|
base.SetEntity(zoneRenderer, entity);
|
2021-02-26 19:01:47 +00:00
|
|
|
var ship = entity as Ship;
|
|
|
|
|
if (ship == null)
|
|
|
|
|
{
|
|
|
|
|
Debug.LogError($"Attempted to assign non-ship entity to {gameObject.name} ship instance prefab!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Ship = ship;
|
2021-03-16 16:35:23 +00:00
|
|
|
_thrusters = ship.GetBehaviors<Thruster>().Select(thruster =>
|
2021-02-26 19:01:47 +00:00
|
|
|
{
|
2026-08-10 14:57:50 +01:00
|
|
|
var effectData = (ThrusterData) thruster.Data;
|
Switch engine asset references from Resources paths to Addressables GUIDs
Cut 2 of docs/addressables-cut.md. The asset move (git mv
Resources/{Prefabs,Schematics,Sprites/Icons} -> Content/...) and the
UnityHelpers.cs deletion already landed in 1fdf8151, picked up by a
concurrent session sharing this working tree; this commit is the rest
of Cut 2 landing on top of that shared state, atomically:
- Bump CultLib to cultlib-unity-v1.0.60 / caching-unity-v1.4.0 (both
45c2f40) in Packages/manifest.json, packages-lock.json and
Directory.Build.props, together with the 8 ServerShared
[CultInspectorAssetPath] usages becoming [CultInspectorAssetGuid] -
the .NET and Unity sides move together or nothing compiles.
- Assets/Scripts/EngineAssets.cs replaces UnityHelpers: loads an
Addressables key (bare GUID or guid[subAsset]) synchronously,
loading the GameObject and taking the component for the four sites
that load a component. ActionBarSlot, EntityInstance, ShipInstance
and ZoneRenderer call it instead of Resources.Load/UnityHelpers; the
inline "Assets/Resources/" prefix strips are gone with them.
CultCacheDrawers' schematic preview goes through
AssetDatabase.GUIDToAssetPath first.
- Assets/Scripts/Editor/EngineAssetCheck.cs validates every stored
[CultInspectorAssetGuid] value: 32 lowercase hex, resolves to a file,
is addressable, and satisfies its member's consumer-type contract
(Texture2D for icons/logos/schematics, a GameObject with the right
component for prefabs) - table-driven, so an attributed member with
no row fails loudly instead of being skipped.
- GameData/Aetheria.cc: the scratch migration (Aetheria.Shared + the
pinned CultLib revision, a throwaway console app, never landed)
walked all 138 attributed field slots across 180 documents,
rewriting the 30 non-empty Resources paths to their .meta GUIDs -
108 stayed empty, 0 unresolved, matching the map's census exactly.
Verification: dotnet test tests/Aetheria.Shared.Tests 61/61 green
against CultLib 45c2f40; Unity 6000.3.24f1 batchmode compiles clean;
EngineAssetCheck.Run passes all 30 stored references; the map's
negative greps are clean; tests/mutation_tests.py's 5 mutations (wrong
type, non-addressable, random guid, an old path, and an untabled
attributed member) are all caught and named, the control case and the
post-revert recompile stay clean, and the catalog/source are restored
byte-identical afterward.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-18 05:04:50 +02:00
|
|
|
var particles = Instantiate(EngineAssets.Load<ParticleSystem>(effectData.ParticlesPrefab), transform, false);
|
2021-03-16 16:35:23 +00:00
|
|
|
var thrusterHardpoint = ThrusterHardpoints
|
2026-10-03 14:57:27 +02:00
|
|
|
.FirstOrDefault(t => t.name == thruster.Item.Hardpoint.Transform);
|
2026-10-03 15:39:14 +02:00
|
|
|
ThrusterHardpoint.WireExhaust(particles, thrusterHardpoint);
|
2026-08-10 14:57:50 +01:00
|
|
|
// if (!string.IsNullOrEmpty(thruster.Item.Data.SoundEffectTrigger) && thrusterHardpoint != null)
|
|
|
|
|
// {
|
|
|
|
|
// AkSoundEngine.RegisterGameObj(thrusterHardpoint.gameObject);
|
|
|
|
|
// AkSoundEngine.PostEvent(thruster.Item.Data.SoundEffectTrigger, thrusterHardpoint.gameObject);
|
|
|
|
|
// }
|
2021-03-16 16:35:23 +00:00
|
|
|
|
|
|
|
|
return new ThrusterInstance
|
|
|
|
|
{
|
|
|
|
|
Thruster = thruster,
|
|
|
|
|
System = particles,
|
|
|
|
|
BaseEmission = particles.emission.rateOverTimeMultiplier,
|
|
|
|
|
MaxParticleCount = 0
|
|
|
|
|
};
|
2021-02-26 19:01:47 +00:00
|
|
|
})
|
|
|
|
|
.ToArray();
|
|
|
|
|
|
2021-03-16 16:35:23 +00:00
|
|
|
foreach (var particle in _thrusters)
|
2021-02-26 19:01:47 +00:00
|
|
|
{
|
2021-03-16 16:35:23 +00:00
|
|
|
particle.System.gameObject.SetActive(false);
|
2021-02-26 19:01:47 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void ShowUnfadedElements()
|
|
|
|
|
{
|
|
|
|
|
base.ShowUnfadedElements();
|
2021-03-16 16:35:23 +00:00
|
|
|
foreach (var particle in _thrusters)
|
2021-02-26 19:01:47 +00:00
|
|
|
{
|
2021-03-16 16:35:23 +00:00
|
|
|
particle.System.gameObject.SetActive(true);
|
2021-02-26 19:01:47 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void HideUnfadedElements()
|
|
|
|
|
{
|
|
|
|
|
base.HideUnfadedElements();
|
2021-03-16 16:35:23 +00:00
|
|
|
foreach (var particle in _thrusters)
|
2021-02-26 19:01:47 +00:00
|
|
|
{
|
2021-03-16 16:35:23 +00:00
|
|
|
particle.System.gameObject.SetActive(false);
|
2021-02-26 19:01:47 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
2021-04-15 04:25:22 +01:00
|
|
|
|
|
|
|
|
TractorBeam.Power = Entity.TractorPower;
|
2026-10-07 12:33:20 +02:00
|
|
|
TractorBeam.Direction = Entity.Aim.ToUnity();
|
2021-04-30 15:37:39 +01:00
|
|
|
|
2021-03-16 16:35:23 +00:00
|
|
|
foreach (var thrusterInstance in _thrusters)
|
2021-02-26 19:01:47 +00:00
|
|
|
{
|
2021-03-16 16:35:23 +00:00
|
|
|
var emissionModule = thrusterInstance.System.emission;
|
|
|
|
|
thrusterInstance.MaxParticleCount = thrusterInstance.System.particleCount;
|
2026-09-19 04:41:23 +02:00
|
|
|
// Cut 8 (operator ask 2026-09-19): intent (Axis) times condition (Thruster.Condition, the item's
|
|
|
|
|
// resolved Thrust against its own perfect-conditions Thrust) -- no durability/heat/power arithmetic
|
|
|
|
|
// recomputed here, only the same emission math that already existed.
|
|
|
|
|
emissionModule.rateOverTimeMultiplier = thrusterInstance.BaseEmission * thrusterInstance.Thruster.Axis * thrusterInstance.Thruster.Condition;
|
2021-02-26 19:01:47 +00:00
|
|
|
}
|
|
|
|
|
|
2026-10-08 18:26:02 +02:00
|
|
|
transform.rotation = DrawAhead.Rotation(Ship, ActionGameManager.Clock.Lead).ToUnity();
|
2021-02-26 19:01:47 +00:00
|
|
|
}
|
2026-08-10 14:57:50 +01:00
|
|
|
}
|