Replace runtime union metadata

This commit is contained in:
Meta Vens 2026-06-13 14:51:01 +01:00
commit d2c062c94d
10 changed files with 59 additions and 93 deletions

View file

@ -16,9 +16,40 @@ public interface IRuntimeItemCatalogReader
public sealed class AetheriaRuntimeItemCatalog : IRuntimeItemCatalogReader
{
private readonly Dictionary<Guid, ItemData> _items;
private static readonly IReadOnlyDictionary<int, Type> BehaviorTypesByUnionKey = typeof(BehaviorData)
.GetCustomAttributes<UnionAttribute>()
.ToDictionary(attribute => attribute.Key, attribute => attribute.SubType);
private static readonly IReadOnlyDictionary<int, Type> BehaviorTypesByUnionKey = new Dictionary<int, Type>
{
{ 0, typeof(GuidedWeaponData) },
{ 1, typeof(LauncherData) },
{ 2, typeof(ReactorData) },
{ 3, typeof(RadiatorData) },
{ 4, typeof(StatModifierData) },
{ 5, typeof(SensorData) },
{ 6, typeof(ReflectorData) },
{ 7, typeof(ShieldData) },
{ 8, typeof(ThrusterData) },
{ 9, typeof(WearData) },
{ 10, typeof(VelocityConversionData) },
{ 11, typeof(VelocityLimitData) },
{ 12, typeof(AetherDriveData) },
{ 15, typeof(CooldownData) },
{ 16, typeof(HeatData) },
{ 18, typeof(ItemUsageData) },
{ 20, typeof(SwitchData) },
{ 21, typeof(TriggerData) },
{ 22, typeof(VisibilityData) },
{ 23, typeof(ThermotoggleData) },
{ 24, typeof(EnergyDrawData) },
{ 26, typeof(MiningToolData) },
{ 28, typeof(ResourceScannerData) },
{ 31, typeof(CapacitorData) },
{ 32, typeof(CockpitData) },
{ 33, typeof(HeatStorageData) },
{ 34, typeof(TurretControllerData) },
{ 35, typeof(InstantWeaponData) },
{ 36, typeof(ConstantWeaponData) },
{ 37, typeof(ChargedWeaponData) },
{ 38, typeof(AutoWeaponData) }
};
public AetheriaRuntimeItemCatalog(AetheriaRuntimeCatalogSnapshot catalog)
{

View file

@ -3,26 +3,16 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
[MessagePackObject,
Union(0, typeof(StationTowing)),
Union(1, typeof(Mining)),
Union(2, typeof(Survey)),
Union(3, typeof(HaulingTask))]
public abstract class AgentTask : DatabaseEntry
{
[Key(1)]
public int Priority;
[Key(2)]
public Guid Zone;
[Key(3)]
public bool Reserved;
[IgnoreMember] public abstract TaskType Type { get; }
public abstract TaskType Type { get; }
}
public enum TaskType

View file

@ -3,22 +3,16 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
public class HaulingTask : AgentTask
{
public override TaskType Type => TaskType.Haul;
[Key(4)]
public Entity Origin;
[Key(5)]
public Entity Target;
[Key(6)]
public Guid ItemType;
[Key(7)]
public int Quantity;
}

View file

@ -3,14 +3,10 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
[MessagePackObject]
public class Mining : AgentTask
{
[IgnoreMember] public override TaskType Type => TaskType.Mine;
public override TaskType Type => TaskType.Mine;
[Key(4)]
public Guid Asteroids;
}
}

View file

@ -3,20 +3,14 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
[MessagePackObject]
public class StationTowing : AgentTask
{
[IgnoreMember] public override TaskType Type => TaskType.Tow;
public override TaskType Type => TaskType.Tow;
[Key(4)]
public OrbitalEntity Station;
[Key(5)]
public Guid OrbitParent;
[Key(6)]
public float OrbitDistance;
}

View file

@ -3,14 +3,11 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
[MessagePackObject]
public class Survey : AgentTask
{
[IgnoreMember] public override TaskType Type => TaskType.Explore;
public override TaskType Type => TaskType.Explore;
[Key(4)]
public List<Guid> Planets;
}
}

View file

@ -145,45 +145,7 @@ public abstract class PersistentBehaviorData
{
}
[Inspectable,
Union(0, typeof(GuidedWeaponData)),
Union(1, typeof(LauncherData)),
Union(2, typeof(ReactorData)),
Union(3, typeof(RadiatorData)),
Union(4, typeof(StatModifierData)),
Union(5, typeof(SensorData)),
Union(6, typeof(ReflectorData)),
Union(7, typeof(ShieldData)),
Union(8, typeof(ThrusterData)),
Union(9, typeof(WearData)),
Union(10, typeof(VelocityConversionData)),
Union(11, typeof(VelocityLimitData)),
Union(12, typeof(AetherDriveData)),
// Union(14, typeof(TowingControllerData)),
Union(15, typeof(CooldownData)),
Union(16, typeof(HeatData)),
// Union(17, typeof(HitscanData)),
Union(18, typeof(ItemUsageData)),
//Union(19, typeof(RadianceData)),
Union(20, typeof(SwitchData)),
Union(21, typeof(TriggerData)),
Union(22, typeof(VisibilityData)),
Union(23, typeof(ThermotoggleData)),
Union(24, typeof(EnergyDrawData)),
// Union(25, typeof(MiningControllerData)),
Union(26, typeof(MiningToolData)),
// Union(27, typeof(SurveyControllerData)),
Union(28, typeof(ResourceScannerData)),
// Union(29, typeof(WanderControllerData)),
// Union(30, typeof(HaulingControllerData)),
Union(31, typeof(CapacitorData)),
Union(32, typeof(CockpitData)),
Union(33, typeof(HeatStorageData)),
Union(34, typeof(TurretControllerData)),
Union(35, typeof(InstantWeaponData)),
Union(36, typeof(ConstantWeaponData)),
Union(37, typeof(ChargedWeaponData)),
Union(38, typeof(AutoWeaponData))]
[Inspectable]
public abstract class BehaviorData
{
[Inspectable, Key(0)]
@ -196,4 +158,4 @@ public abstract class BehaviorData
{
return base.ToString().FormatTypeName();
}
}
}

View file

@ -9,12 +9,7 @@ using MessagePack;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable,
Union(0, typeof(InstantWeaponData)),
Union(1, typeof(LauncherData)),
Union(2, typeof(ConstantWeaponData)),
Union(3, typeof(ChargedWeaponData)),
RuntimeInspectable]
[Inspectable, RuntimeInspectable]
public abstract class WeaponData : BehaviorData
{
[Inspectable, Key(1), RuntimeInspectable]