2020-12-22 03:13:43 +00:00
|
|
|
/* 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/. */
|
|
|
|
|
|
Move the ServerShared data model onto CultLib's CultCache
Cut 8b. Aetheria.Shared builds headless against GameCult.Caching and
GameCult.Caching.MessagePack at the pinned CultLib; the pin guard also
checks the Caching project exists.
Documents: [CultDocument("aetheria.<type>", "1")] with [MessagePackObject]
and integer [Key]s on the Q7 concrete types (the eight ItemData leaves,
Faction, FactionProductData, PersonalityAttribute, NameFile, OrbitData, the
four BodyData leaves, SavedZone, SavedGame, PlayerSettings, InputLayout).
SavedGame and PlayerSettings are [CultGlobal]; Name members are [CultName].
ItemData, CraftedItemData, EquippableItemData, BodyData and AgentTask lose
[MessagePackObject]; BodyData and AgentTask lose their [Union]s. InputLayout
moves into ServerShared so AetheriaStores can route it.
References: Guid and DatabaseLink<T> members become CultRecordRef<T>;
Guid-keyed maps become ref-keyed with [CultReference(..., many: true)];
ZonePack holds refs to orbit and body records. Runtime maps (Zone orbits,
bodies and belts, cargo ItemsOfType, agent targets) key by CultRecordKey.
Identity is the record key: ID comparisons become reference or key
comparisons. StatModifierData.RequireBehavior is a simple type name.
AetheriaStores.Open composes the catalog (read-only unless writable), run
and player stores, one home per type. CultRecordRefs carries IsSet, a
null-safe Get(ref), RefOf (key from TryGetHandle) and Upsert.
ItemManager.GetData is the one item resolution path. MathResolver is
declared by [assembly: CultCacheFormatterResolver].
Inspector attributes: text, range and asset path map onto CultLib's
CultInspector attributes (asset path only on string members); every
replaced Aetheria attribute keeps [Inspectable] for the runtime panel.
Builds: Aetheria.Shared. Does not build: AetherDb and the Unity project,
which follow.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 19:00:42 +02:00
|
|
|
using GameCult.Caching;
|
2026-08-10 14:57:50 +01:00
|
|
|
using MessagePack;
|
|
|
|
|
using Newtonsoft.Json;
|
2026-09-14 17:39:12 +02:00
|
|
|
using CultMath;
|
|
|
|
|
using static CultMath.math;
|
2026-08-10 14:57:50 +01:00
|
|
|
|
|
|
|
|
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), EntityTypeRestriction(HullType.Ship), RuntimeInspectable]
|
|
|
|
|
public class ThrusterData : BehaviorData
|
|
|
|
|
{
|
|
|
|
|
[Inspectable, JsonProperty("thrust"), Key(1), RuntimeInspectable]
|
|
|
|
|
public PerformanceStat Thrust = new PerformanceStat();
|
|
|
|
|
|
|
|
|
|
[Inspectable, JsonProperty("visibility"), Key(2), RuntimeInspectable]
|
|
|
|
|
public PerformanceStat Visibility = new PerformanceStat();
|
|
|
|
|
|
|
|
|
|
[Inspectable, JsonProperty("heat"), Key(3), RuntimeInspectable]
|
|
|
|
|
public PerformanceStat Heat = new PerformanceStat();
|
|
|
|
|
|
|
|
|
|
[Inspectable, JsonProperty("energy"), Key(4), RuntimeInspectable]
|
|
|
|
|
public PerformanceStat EnergyUsage = new PerformanceStat();
|
|
|
|
|
|
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
|
|
|
[Inspectable, CultInspectorAssetGuid, JsonProperty("Particles"), Key(5)]
|
2026-08-10 14:57:50 +01:00
|
|
|
public string ParticlesPrefab;
|
|
|
|
|
|
|
|
|
|
public override Behavior CreateInstance(EquippedItem item)
|
|
|
|
|
{
|
|
|
|
|
return new Thruster(this, item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Behavior CreateInstance(ConsumableItemEffect item)
|
|
|
|
|
{
|
|
|
|
|
return new Thruster(this, item);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-09 07:48:45 +01:00
|
|
|
|
2021-04-18 05:13:20 +01:00
|
|
|
public class Thruster : Behavior, IAnalogBehavior
|
2020-04-09 07:48:45 +01:00
|
|
|
{
|
2020-05-07 03:53:54 +01:00
|
|
|
public float Thrust { get; private set; }
|
2020-12-22 03:13:43 +00:00
|
|
|
public float Torque { get; }
|
2020-04-09 07:48:45 +01:00
|
|
|
|
2020-06-05 04:16:33 +01:00
|
|
|
public float Axis
|
|
|
|
|
{
|
|
|
|
|
get => _input;
|
|
|
|
|
set => _input = saturate(value);
|
|
|
|
|
}
|
|
|
|
|
|
2026-08-10 14:57:50 +01:00
|
|
|
private ThrusterData _data;
|
|
|
|
|
|
2020-05-07 03:53:54 +01:00
|
|
|
private float _input;
|
2020-04-09 07:48:45 +01:00
|
|
|
|
2026-08-10 14:57:50 +01:00
|
|
|
public Thruster(ThrusterData data, EquippedItem item) : base(data, item)
|
2020-04-09 07:48:45 +01:00
|
|
|
{
|
2026-08-10 14:57:50 +01:00
|
|
|
_data = data;
|
|
|
|
|
var hullData = ItemManager.GetData(Entity.Hull) as HullData;
|
|
|
|
|
var hullCenter = hullData.Shape.CenterOfMass;
|
|
|
|
|
var itemData = ItemManager.GetData(item.EquippableItem);
|
|
|
|
|
var itemCenter = hullData.Shape.Inset(itemData.Shape, item.Position, item.EquippableItem.Rotation).CenterOfMass;
|
2020-12-22 03:13:43 +00:00
|
|
|
var toCenter = hullCenter - itemCenter;
|
2026-08-10 14:57:50 +01:00
|
|
|
Torque = -dot(normalize(toCenter), float2(1, 0).Rotate(item.EquippableItem.Rotation));
|
|
|
|
|
Thrust = Evaluate(_data.Thrust);
|
2021-04-18 05:13:20 +01:00
|
|
|
}
|
|
|
|
|
|
2026-08-10 14:57:50 +01:00
|
|
|
public Thruster(ThrusterData data, ConsumableItemEffect item) : base(data, item)
|
2021-04-18 05:13:20 +01:00
|
|
|
{
|
2026-08-10 14:57:50 +01:00
|
|
|
_data = data;
|
2021-04-18 05:13:20 +01:00
|
|
|
Torque = 0;
|
2026-08-10 14:57:50 +01:00
|
|
|
Thrust = Evaluate(_data.Thrust);
|
2020-04-09 07:48:45 +01:00
|
|
|
}
|
|
|
|
|
|
2021-04-18 05:13:20 +01:00
|
|
|
public override bool Execute(float dt)
|
2020-04-09 07:48:45 +01:00
|
|
|
{
|
2021-04-30 06:39:57 +01:00
|
|
|
Item.SetAudioParameter(SpecialAudioParameter.Intensity, _input);
|
2026-08-10 14:57:50 +01:00
|
|
|
if(_input > .01f && Entity.TryConsumeEnergy(_input * Evaluate(_data.EnergyUsage)))
|
2021-03-22 05:22:31 +00:00
|
|
|
{
|
2026-08-10 14:57:50 +01:00
|
|
|
Thrust = Evaluate(_data.Thrust);
|
|
|
|
|
Entity.Velocity -= Direction.xz * _input * Thrust / Entity.Mass * dt;
|
|
|
|
|
Entity.Direction = mul(Entity.Direction,
|
2026-09-14 17:39:12 +02:00
|
|
|
CultMath.float2x2.Rotate(_input * Torque * Thrust * ItemManager.GameplaySettings.TorqueMultiplier / Entity.Mass * dt));
|
2026-08-10 14:57:50 +01:00
|
|
|
AddHeat(_input * Evaluate(_data.Heat) * dt);
|
|
|
|
|
var vis = _input * Evaluate(_data.Visibility);
|
|
|
|
|
if (!Entity.VisibilitySources.ContainsKey(this) || vis > Entity.VisibilitySources[this])
|
2021-04-18 05:13:20 +01:00
|
|
|
Entity.VisibilitySources[this] = vis;
|
2021-03-22 05:22:31 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
2020-05-11 01:17:10 +01:00
|
|
|
}
|
2026-08-10 14:57:50 +01:00
|
|
|
}
|