Modular Database Tools

Extracted all inspector code for database inspector into a single class per supported field type and wrote reflection code to invoke them automatically
Removed all Aetheria-specific code from database tools
Database View editor is now abstract and supports arbitrary grouping of entry types; specific users must implement their own database view
This commit is contained in:
Reinier Vens 2021-03-31 04:07:11 +01:00
commit 526a737a4d
72 changed files with 1674 additions and 1624 deletions

View file

@ -6,7 +6,7 @@ using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class AutoWeaponData : InstantWeaponData
{
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -83,7 +83,7 @@ public abstract class PersistentBehaviorData
{
}
[InspectableField,
[Inspectable,
Union(0, typeof(GuidedWeaponData)),
Union(1, typeof(LauncherData)),
Union(2, typeof(ReactorData)),
@ -125,7 +125,7 @@ public abstract class PersistentBehaviorData
JsonConverter(typeof(JsonKnownTypesConverter<BehaviorData>)), JsonObject(MemberSerialization.OptIn)]
public abstract class BehaviorData
{
[InspectableField, JsonProperty("group"), Key(0)]
[Inspectable, JsonProperty("group"), Key(0)]
public int Group;
public abstract IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item);

View file

@ -11,10 +11,10 @@ using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class CapacitorData : BehaviorData
{
[InspectableField, JsonProperty("capacity"), Key(1), RuntimeInspectable]
[Inspectable, JsonProperty("capacity"), Key(1), RuntimeInspectable]
public PerformanceStat Capacity = new PerformanceStat();
[InspectableField, JsonProperty("efficiency"), Key(2), RuntimeInspectable]
[Inspectable, JsonProperty("efficiency"), Key(2), RuntimeInspectable]
public PerformanceStat Efficiency = new PerformanceStat();
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -6,43 +6,43 @@ using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class ChargedWeaponData : InstantWeaponData
{
[InspectableField, JsonProperty("chargeTime"), Key(21), RuntimeInspectable]
[Inspectable, JsonProperty("chargeTime"), Key(21), RuntimeInspectable]
public PerformanceStat ChargeTime = new PerformanceStat();
[InspectableField, JsonProperty("chargeEnergy"), Key(22), RuntimeInspectable]
[Inspectable, JsonProperty("chargeEnergy"), Key(22), RuntimeInspectable]
public PerformanceStat ChargeEnergy = new PerformanceStat();
[InspectableField, JsonProperty("chargeHeat"), Key(23), RuntimeInspectable]
[Inspectable, JsonProperty("chargeHeat"), Key(23), RuntimeInspectable]
public PerformanceStat ChargeHeat = new PerformanceStat();
[InspectableField, JsonProperty("canFireEarly"), Key(24)]
[Inspectable, JsonProperty("canFireEarly"), Key(24)]
public bool CanFireEarly;
[InspectableField, JsonProperty("failureCharge"), Key(25)]
[Inspectable, JsonProperty("failureCharge"), Key(25)]
public float FailureCharge;
[InspectableField, JsonProperty("failureDamage"), Key(26)]
[Inspectable, JsonProperty("failureDamage"), Key(26)]
public float FailureDamage = 1;
[InspectableField, JsonProperty("chargeDamage"), Key(27)]
[Inspectable, JsonProperty("chargeDamage"), Key(27)]
public float ChargeFiringDamageMultiplier = 1;
[InspectableField, JsonProperty("chargeSpread"), Key(28)]
[Inspectable, JsonProperty("chargeSpread"), Key(28)]
public float ChargeFiringSpreadMultiplier = 1;
[InspectableField, JsonProperty("chargeBurstCount"), Key(29)]
[Inspectable, JsonProperty("chargeBurstCount"), Key(29)]
public float ChargeFiringBurstCountMultiplier = 1;
[InspectableField, JsonProperty("chargeVisibility"), Key(30)]
[Inspectable, JsonProperty("chargeVisibility"), Key(30)]
public float ChargeFiringVisibilityMultiplier = 1;
[InspectableField, JsonProperty("chargeVelocity"), Key(31)]
[Inspectable, JsonProperty("chargeVelocity"), Key(31)]
public float ChargeFiringVelocityMultiplier = 1;
[InspectableField, JsonProperty("chargeHeatMul"), Key(32)]
[Inspectable, JsonProperty("chargeHeatMul"), Key(32)]
public float ChargeFiringHeatMultiplier = 1;
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -8,7 +8,7 @@ using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class ConstantWeaponData : WeaponData
{
[InspectablePrefab, JsonProperty("ammoInterval"), Key(17)]

View file

@ -9,10 +9,10 @@ using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-10), RuntimeInspectable]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-10), RuntimeInspectable]
public class CooldownData : BehaviorData
{
[InspectableField, JsonProperty("cooldown"), Key(1), RuntimeInspectable]
[Inspectable, JsonProperty("cooldown"), Key(1), RuntimeInspectable]
public PerformanceStat Cooldown = new PerformanceStat();
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -7,13 +7,13 @@ using System.Linq;
using MessagePack;
using Newtonsoft.Json;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-20), RuntimeInspectable]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-20), RuntimeInspectable]
public class EnergyDrawData : BehaviorData
{
[InspectableField, JsonProperty("draw"), Key(1), RuntimeInspectable]
[Inspectable, JsonProperty("draw"), Key(1), RuntimeInspectable]
public PerformanceStat EnergyDraw = new PerformanceStat();
[InspectableField, JsonProperty("perSecond"), Key(2)]
[Inspectable, JsonProperty("perSecond"), Key(2)]
public bool PerSecond;
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -7,13 +7,13 @@ using System.Linq;
using MessagePack;
using Newtonsoft.Json;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(10), Inspectable]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(10)]
public class HeatData : BehaviorData
{
[InspectableField, JsonProperty("heat"), Key(1), RuntimeInspectable]
[Inspectable, JsonProperty("heat"), Key(1), RuntimeInspectable]
public PerformanceStat Heat = new PerformanceStat();
[InspectableField, JsonProperty("perSecond"), Key(2)]
[Inspectable, JsonProperty("perSecond"), Key(2)]
public bool PerSecond;
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -6,16 +6,16 @@ using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class InstantWeaponData : WeaponData
{
[InspectableField, JsonProperty("count"), Key(17)]
[Inspectable, JsonProperty("count"), Key(17)]
public PerformanceStat Count = new PerformanceStat();
[InspectableField, JsonProperty("burstTime"), Key(18)]
[Inspectable, JsonProperty("burstTime"), Key(18)]
public PerformanceStat BurstTime = new PerformanceStat();
[InspectableField, JsonProperty("cooldown"), Key(19), RuntimeInspectable]
[Inspectable, JsonProperty("cooldown"), Key(19), RuntimeInspectable]
public PerformanceStat Cooldown = new PerformanceStat();
[InspectablePrefab, JsonProperty("ammoInterval"), Key(20)]

View file

@ -7,7 +7,7 @@ using System.Linq;
using MessagePack;
using Newtonsoft.Json;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-5), RuntimeInspectable]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-5), RuntimeInspectable]
public class ItemUsageData : BehaviorData
{
[InspectableDatabaseLink(typeof(SimpleCommodityData)), JsonProperty("item"), Key(1), RuntimeInspectable]

View file

@ -6,7 +6,7 @@ using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class LauncherData : LockWeaponData
{
[InspectableAnimationCurve, JsonProperty("guidance"), Key(26)]
@ -18,13 +18,13 @@ public class LauncherData : LockWeaponData
[InspectableAnimationCurve, JsonProperty("liftCurve"), Key(28)]
public float4[] LiftCurve;
[InspectableField, JsonProperty("thrust"), Key(29)]
[Inspectable, JsonProperty("thrust"), Key(29)]
public PerformanceStat Thrust = new PerformanceStat();
[InspectableField, JsonProperty("frequency"), Key(30)]
[Inspectable, JsonProperty("frequency"), Key(30)]
public float DodgeFrequency;
[InspectableField, JsonProperty("missileSpeed"), Key(31), RuntimeInspectable]
[Inspectable, JsonProperty("missileSpeed"), Key(31), RuntimeInspectable]
public PerformanceStat MissileVelocity = new PerformanceStat();
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)
@ -33,7 +33,7 @@ public class LauncherData : LockWeaponData
}
}
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class GuidedWeaponData : InstantWeaponData
{
[InspectableAnimationCurve, JsonProperty("guidance"), Key(21)]
@ -45,13 +45,13 @@ public class GuidedWeaponData : InstantWeaponData
[InspectableAnimationCurve, JsonProperty("liftCurve"), Key(23)]
public float4[] LiftCurve;
[InspectableField, JsonProperty("thrust"), Key(24)]
[Inspectable, JsonProperty("thrust"), Key(24)]
public PerformanceStat Thrust = new PerformanceStat();
[InspectableField, JsonProperty("frequency"), Key(25)]
[Inspectable, JsonProperty("frequency"), Key(25)]
public float DodgeFrequency;
[InspectableField, JsonProperty("missileSpeed"), Key(26), RuntimeInspectable]
[Inspectable, JsonProperty("missileSpeed"), Key(26), RuntimeInspectable]
public PerformanceStat MissileVelocity = new PerformanceStat();
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -6,22 +6,22 @@ using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class LockWeaponData : InstantWeaponData
{
[InspectableField, JsonProperty("speed"), Key(21), RuntimeInspectable]
[Inspectable, JsonProperty("speed"), Key(21), RuntimeInspectable]
public PerformanceStat LockSpeed = new PerformanceStat();
[InspectableField, JsonProperty("sensorImpact"), Key(22)]
[Inspectable, JsonProperty("sensorImpact"), Key(22)]
public PerformanceStat SensorImpact = new PerformanceStat();
[InspectableField, JsonProperty("threshold"), Key(23), RuntimeInspectable]
[Inspectable, JsonProperty("threshold"), Key(23), RuntimeInspectable]
public PerformanceStat LockAngle = new PerformanceStat();
[InspectableField, JsonProperty("directionImpact"), Key(24)]
[Inspectable, JsonProperty("directionImpact"), Key(24)]
public PerformanceStat DirectionImpact = new PerformanceStat();
[InspectableField, JsonProperty("decay"), Key(25)]
[Inspectable, JsonProperty("decay"), Key(25)]
public PerformanceStat Decay = new PerformanceStat();
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -9,19 +9,19 @@ using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(10)]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(10)]
public class MiningToolData : BehaviorData
{
[InspectableField, JsonProperty("dps"), Key(1)]
[Inspectable, JsonProperty("dps"), Key(1)]
public PerformanceStat DamagePerSecond = new PerformanceStat();
[InspectableField, JsonProperty("efficiency"), Key(2)]
[Inspectable, JsonProperty("efficiency"), Key(2)]
public PerformanceStat Efficiency = new PerformanceStat();
[InspectableField, JsonProperty("penetration"), Key(3)]
[Inspectable, JsonProperty("penetration"), Key(3)]
public PerformanceStat Penetration = new PerformanceStat();
[InspectableField, JsonProperty("range"), Key(4)]
[Inspectable, JsonProperty("range"), Key(4)]
public PerformanceStat Range = new PerformanceStat();
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -7,10 +7,10 @@ using System.Linq;
using MessagePack;
using Newtonsoft.Json;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class RadianceData : BehaviorData
{
[InspectableField, JsonProperty("radiance"), Key(1), RuntimeInspectable]
[Inspectable, JsonProperty("radiance"), Key(1), RuntimeInspectable]
public PerformanceStat Radiance = new PerformanceStat();
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -10,19 +10,19 @@ using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class RadiatorData : BehaviorData
{
[InspectableField, JsonProperty("emissivity"), Key(1), RuntimeInspectable]
[Inspectable, JsonProperty("emissivity"), Key(1), RuntimeInspectable]
public PerformanceStat Emissivity = new PerformanceStat();
[InspectableField, JsonProperty("pumpedHeat"), Key(2), RuntimeInspectable]
[Inspectable, JsonProperty("pumpedHeat"), Key(2), RuntimeInspectable]
public PerformanceStat PumpedHeat = new PerformanceStat();
[InspectableTemperature, JsonProperty("temperatureFloor"), Key(3), RuntimeInspectable]
public float TemperatureFloor;
[InspectableField, JsonProperty("wasteHeat"), Key(4), RuntimeInspectable]
[Inspectable, JsonProperty("wasteHeat"), Key(4), RuntimeInspectable]
public PerformanceStat WasteHeat = new PerformanceStat();
[InspectableField, JsonProperty("energyUsage"), Key(5), RuntimeInspectable]
[Inspectable, JsonProperty("energyUsage"), Key(5), RuntimeInspectable]
public PerformanceStat EnergyUsage = new PerformanceStat();
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -13,16 +13,16 @@ using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class ReactorData : BehaviorData
{
[InspectableField, JsonProperty("charge"), Key(1), RuntimeInspectable]
[Inspectable, JsonProperty("charge"), Key(1), RuntimeInspectable]
public PerformanceStat Charge = new PerformanceStat();
[InspectableField, JsonProperty("efficiency"), Key(2), RuntimeInspectable]
[Inspectable, JsonProperty("efficiency"), Key(2), RuntimeInspectable]
public PerformanceStat Efficiency = new PerformanceStat();
[InspectableField, JsonProperty("overload"), Key(3), RuntimeInspectable]
[Inspectable, JsonProperty("overload"), Key(3), RuntimeInspectable]
public PerformanceStat OverloadEfficiency = new PerformanceStat();
[InspectableField, JsonProperty("underload"), Key(4), RuntimeInspectable]
[Inspectable, JsonProperty("underload"), Key(4), RuntimeInspectable]
public PerformanceStat ThrottlingFactor = new PerformanceStat();
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -10,7 +10,7 @@ using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class ReflectorData : BehaviorData
{
[InspectableField, JsonProperty("crossSection"), Key(1), RuntimeInspectable]
[Inspectable, JsonProperty("crossSection"), Key(1), RuntimeInspectable]
public PerformanceStat CrossSection = new PerformanceStat();
// [InspectableAnimationCurve, JsonProperty("visibility"), Key(1)]

View file

@ -9,16 +9,16 @@ using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class ResourceScannerData : BehaviorData
{
[InspectableField, JsonProperty("range"), Key(1), RuntimeInspectable]
[Inspectable, JsonProperty("range"), Key(1), RuntimeInspectable]
public PerformanceStat Range = new PerformanceStat();
[InspectableField, JsonProperty("minDensity"), Key(2), RuntimeInspectable]
[Inspectable, JsonProperty("minDensity"), Key(2), RuntimeInspectable]
public PerformanceStat MinimumDensity = new PerformanceStat();
[InspectableField, JsonProperty("scanDuration"), Key(3), RuntimeInspectable]
[Inspectable, JsonProperty("scanDuration"), Key(3), RuntimeInspectable]
public PerformanceStat ScanDuration = new PerformanceStat();
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -9,34 +9,34 @@ using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class SensorData : BehaviorData
{
[InspectableField, JsonProperty("sensitivity"), Key(3), RuntimeInspectable]
[Inspectable, JsonProperty("sensitivity"), Key(3), RuntimeInspectable]
public PerformanceStat Sensitivity = new PerformanceStat();
[InspectableAnimationCurve, JsonProperty("sensitivityCurve"), Key(4), RuntimeInspectable]
public float4[] SensitivityCurve;
[InspectableField, JsonProperty("pingBoost"), Key(5), RuntimeInspectable]
[Inspectable, JsonProperty("pingBoost"), Key(5), RuntimeInspectable]
public PerformanceStat PingBoost;
[InspectableField, JsonProperty("pingEnergy"), Key(6), RuntimeInspectable]
[Inspectable, JsonProperty("pingEnergy"), Key(6), RuntimeInspectable]
public PerformanceStat PingEnergy;
[InspectableField, JsonProperty("pingVisibility"), Key(7), RuntimeInspectable]
[Inspectable, JsonProperty("pingVisibility"), Key(7), RuntimeInspectable]
public PerformanceStat PingVisibility;
[InspectableField, JsonProperty("pingRange"), Key(8), RuntimeInspectable]
[Inspectable, JsonProperty("pingRange"), Key(8), RuntimeInspectable]
public PerformanceStat PingRange;
[InspectableField, JsonProperty("pingCooldown"), Key(9), RuntimeInspectable]
[Inspectable, JsonProperty("pingCooldown"), Key(9), RuntimeInspectable]
public PerformanceStat PingCooldown;
[InspectableField, JsonProperty("pingDuration"), Key(10)]
[Inspectable, JsonProperty("pingDuration"), Key(10)]
public float PingDuration = 2;
[InspectableField, JsonProperty("pingRadiusExponent"), Key(11)]
[Inspectable, JsonProperty("pingRadiusExponent"), Key(11)]
public float PingRadiusExponent = .5f;
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -10,10 +10,10 @@ using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class ShieldData : BehaviorData
{
[InspectableField, JsonProperty("efficiency"), Key(1), RuntimeInspectable]
[Inspectable, JsonProperty("efficiency"), Key(1), RuntimeInspectable]
public PerformanceStat Efficiency = new PerformanceStat();
[InspectableField, JsonProperty("energy"), Key(2), RuntimeInspectable]
[Inspectable, JsonProperty("energy"), Key(2), RuntimeInspectable]
public PerformanceStat EnergyUsage = new PerformanceStat();
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -7,16 +7,16 @@ using System.Linq;
using MessagePack;
using Newtonsoft.Json;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class StatModifierData : BehaviorData
{
[InspectableField, JsonProperty("stat"), Key(1)]
[Inspectable, JsonProperty("stat"), Key(1)]
public StatReference Stat = new StatReference();
[InspectableField, JsonProperty("modifier"), Key(2)]
[Inspectable, JsonProperty("modifier"), Key(2)]
public PerformanceStat Modifier = new PerformanceStat();
[InspectableField, JsonProperty("type"), Key(3)]
[Inspectable, JsonProperty("type"), Key(3)]
public StatModifierType Type;
[InspectableType(typeof(BehaviorData)), JsonProperty("requireBehavior"), Key(4)]
@ -103,12 +103,12 @@ public enum StatModifierType
Multiplier
}
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class StatReference
{
[InspectableType(typeof(BehaviorData)), JsonProperty("behavior"), Key(1)]
public string Target;
[InspectableField, JsonProperty("stat"), Key(2)]
[Inspectable, JsonProperty("stat"), Key(2)]
public string Stat;
}

View file

@ -7,7 +7,7 @@ using System.Linq;
using MessagePack;
using Newtonsoft.Json;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-25)]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-25)]
public class SwitchData : BehaviorData
{
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -7,13 +7,13 @@ using System.Linq;
using MessagePack;
using Newtonsoft.Json;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-22)]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-22)]
public class ThermotoggleData : BehaviorData
{
[InspectableTemperature, JsonProperty("targetTemp"), Key(1)]
public float TargetTemperature;
[InspectableField, JsonProperty("highPass"), Key(2)]
[Inspectable, JsonProperty("highPass"), Key(2)]
public bool HighPass;
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -10,16 +10,16 @@ using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), EntityTypeRestriction(HullType.Ship), RuntimeInspectable]
public class ThrusterData : BehaviorData
{
[InspectableField, JsonProperty("thrust"), Key(1), RuntimeInspectable]
[Inspectable, JsonProperty("thrust"), Key(1), RuntimeInspectable]
public PerformanceStat Thrust = new PerformanceStat();
[InspectableField, JsonProperty("visibility"), Key(2), RuntimeInspectable]
[Inspectable, JsonProperty("visibility"), Key(2), RuntimeInspectable]
public PerformanceStat Visibility = new PerformanceStat();
[InspectableField, JsonProperty("heat"), Key(3), RuntimeInspectable]
[Inspectable, JsonProperty("heat"), Key(3), RuntimeInspectable]
public PerformanceStat Heat = new PerformanceStat();
[InspectableField, JsonProperty("energy"), Key(4), RuntimeInspectable]
[Inspectable, JsonProperty("energy"), Key(4), RuntimeInspectable]
public PerformanceStat EnergyUsage = new PerformanceStat();
[InspectablePrefab, JsonProperty("Particles"), Key(5)]

View file

@ -7,7 +7,7 @@ using System.Linq;
using MessagePack;
using Newtonsoft.Json;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-20)]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-20)]
public class TriggerData : BehaviorData
{
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -10,7 +10,7 @@ using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class VelocityConversionData : BehaviorData
{
[InspectableField, JsonProperty("traction"), Key(1), RuntimeInspectable]
[Inspectable, JsonProperty("traction"), Key(1), RuntimeInspectable]
public PerformanceStat Traction = new PerformanceStat();
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -10,7 +10,7 @@ using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class VelocityLimitData : BehaviorData
{
[InspectableField, JsonProperty("topSpeed"), Key(1), RuntimeInspectable]
[Inspectable, JsonProperty("topSpeed"), Key(1), RuntimeInspectable]
public PerformanceStat TopSpeed = new PerformanceStat();
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -7,13 +7,13 @@ using System.Linq;
using MessagePack;
using Newtonsoft.Json;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
public class VisibilityData : BehaviorData
{
[InspectableField, JsonProperty("visibility"), Key(1), RuntimeInspectable]
[Inspectable, JsonProperty("visibility"), Key(1), RuntimeInspectable]
public PerformanceStat Visibility = new PerformanceStat();
[InspectableField, JsonProperty("visibilityDecay"), Key(2)]
[Inspectable, JsonProperty("visibilityDecay"), Key(2)]
public PerformanceStat VisibilityDecay = new PerformanceStat();
public override IBehavior CreateInstance(ItemManager context, Entity entity, EquippedItem item)

View file

@ -17,10 +17,10 @@ using static Unity.Mathematics.math;
RuntimeInspectable]
public abstract class WeaponData : BehaviorData
{
[InspectableField, JsonProperty("damageType"), Key(1), RuntimeInspectable]
[Inspectable, JsonProperty("damageType"), Key(1), RuntimeInspectable]
public DamageType DamageType;
[InspectableField, JsonProperty("damage"), Key(2), RuntimeInspectable]
[Inspectable, JsonProperty("damage"), Key(2), RuntimeInspectable]
public PerformanceStat Damage = new PerformanceStat();
[RangedFloatInspectable(0,1), JsonProperty("penetration"), Key(3), RuntimeInspectable]
@ -29,10 +29,10 @@ public abstract class WeaponData : BehaviorData
[RangedFloatInspectable(0,1), JsonProperty("damageSpread"), Key(4)]
public PerformanceStat DamageSpread = new PerformanceStat();
[InspectableField, JsonProperty("minRange"), Key(5), RuntimeInspectable]
[Inspectable, JsonProperty("minRange"), Key(5), RuntimeInspectable]
public PerformanceStat MinRange = new PerformanceStat();
[InspectableField, JsonProperty("range"), Key(6), RuntimeInspectable]
[Inspectable, JsonProperty("range"), Key(6), RuntimeInspectable]
public PerformanceStat Range = new PerformanceStat();
[InspectableAnimationCurve, JsonProperty("damageRange"), Key(7), RuntimeInspectable]
@ -62,7 +62,7 @@ public abstract class WeaponData : BehaviorData
[InspectablePrefab, JsonProperty("spread"), Key(15)]
public PerformanceStat Spread = new PerformanceStat();
[InspectableField, JsonProperty("velocity"), Key(16)]
[Inspectable, JsonProperty("velocity"), Key(16)]
public PerformanceStat Velocity = new PerformanceStat();
}

View file

@ -9,39 +9,13 @@ using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
[RethinkTable("Galaxy"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class Corporation : DatabaseEntry, INamedEntry
{
[JsonProperty("name"), Key(1)]
public string Name;
[JsonProperty("parent"), Key(2)]
public Guid Parent;
[JsonProperty("tasks"), Key(3)]
public List<Guid> Tasks = new List<Guid>();
[JsonProperty("planetSurveyFloor"), Key(4)]
public Dictionary<Guid, float> PlanetSurveyFloor = new Dictionary<Guid, float>();
[JsonProperty("unlockedBlueprints"), Key(5)]
public List<Guid> UnlockedBlueprints = new List<Guid>();
[IgnoreMember] public string EntryName
{
get => Name;
set => Name = value;
}
}
[RethinkTable("Galaxy"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class Faction : DatabaseEntry, INamedEntry
{
[InspectableField, JsonProperty("name"), Key(1)]
[Inspectable, JsonProperty("name"), Key(1)]
public string Name;
[InspectableField, JsonProperty("shortName"), Key(2)]
[Inspectable, JsonProperty("shortName"), Key(2)]
public string ShortName;
[InspectableText, JsonProperty("description"), Key(3)]
@ -53,7 +27,7 @@ public class Faction : DatabaseEntry, INamedEntry
[InspectableDatabaseLink(typeof(PersonalityAttribute)), JsonProperty("personality"), Key(5)]
public Dictionary<Guid, float> Personality = new Dictionary<Guid, float>();
[InspectableField, JsonProperty("hostile"), Key(6)]
[Inspectable, JsonProperty("hostile"), Key(6)]
public bool PlayerHostile;
[InspectableColor, JsonProperty("primaryColor"), Key(7)]
@ -68,7 +42,7 @@ public class Faction : DatabaseEntry, INamedEntry
[InspectableDatabaseLink(typeof(HullData)), JsonProperty("bossHull"), Key(10)]
public Guid BossHull;
[InspectableField, JsonProperty("influence"), Key(11)]
[Inspectable, JsonProperty("influence"), Key(11)]
public int InfluenceDistance = 4;
[InspectableDatabaseLink(typeof(Faction)), RangedFloat(0, 1), JsonProperty("allegiance"), Key(12)]

View file

@ -1,28 +1,14 @@
using System;
[AttributeUsage(AttributeTargets.Class)]
public class InspectableAttribute : Attribute { }
public abstract class PreferredInspectorAttribute : InspectableAttribute
{
public Type TargetType;
public PreferredInspectorAttribute(Type targetType)
{
TargetType = targetType;
}
}
[AttributeUsage(AttributeTargets.Class)]
public class ExternalEntryAttribute : Attribute { }
public class InspectableFieldAttribute : Attribute { }
public class InspectableAttribute : Attribute { }
[AttributeUsage(AttributeTargets.Field)]
public class InspectableTextAttribute : InspectableFieldAttribute { }
public abstract class PreferredInspectorAttribute : InspectableAttribute { }
[AttributeUsage(AttributeTargets.Field)]
public class InspectableUnityObjectAttribute : InspectableFieldAttribute
public class InspectableUnityObjectAttribute : PreferredInspectorAttribute
{
public Type ObjectType;
@ -31,27 +17,15 @@ public class InspectableUnityObjectAttribute : InspectableFieldAttribute
ObjectType = type;
}
}
public class InspectableTextAttribute : PreferredInspectorAttribute { }
public class InspectablePrefabAttribute : PreferredInspectorAttribute { }
public class InspectableTextureAttribute : PreferredInspectorAttribute { }
public class InspectableTextAssetAttribute : PreferredInspectorAttribute { }
public class InspectableTemperatureAttribute : PreferredInspectorAttribute { }
public class InspectableAnimationCurveAttribute : PreferredInspectorAttribute { }
public class InspectableColorAttribute : PreferredInspectorAttribute { }
[AttributeUsage(AttributeTargets.Field)]
public class InspectablePrefabAttribute : InspectableFieldAttribute { }
[AttributeUsage(AttributeTargets.Field)]
public class InspectableTextureAttribute : InspectableFieldAttribute { }
[AttributeUsage(AttributeTargets.Field)]
public class InspectableTextAssetAttribute : InspectableFieldAttribute { }
[AttributeUsage(AttributeTargets.Field)]
public class InspectableTemperatureAttribute : InspectableFieldAttribute { }
[AttributeUsage(AttributeTargets.Field)]
public class InspectableAnimationCurveAttribute : InspectableFieldAttribute { }
[AttributeUsage(AttributeTargets.Field)]
public class InspectableColorAttribute : InspectableFieldAttribute { }
[AttributeUsage(AttributeTargets.Field)]
public class InspectableDatabaseLinkAttribute : InspectableFieldAttribute
public class InspectableDatabaseLinkAttribute : PreferredInspectorAttribute
{
public readonly Type EntryType;
@ -61,8 +35,7 @@ public class InspectableDatabaseLinkAttribute : InspectableFieldAttribute
}
}
[AttributeUsage(AttributeTargets.Field)]
public class RangedFloatInspectableAttribute : InspectableFieldAttribute
public class RangedFloatInspectableAttribute : PreferredInspectorAttribute
{
public readonly float Min, Max;
@ -73,6 +46,27 @@ public class RangedFloatInspectableAttribute : InspectableFieldAttribute
}
}
public class RangedIntInspectableAttribute : PreferredInspectorAttribute
{
public readonly int Min, Max;
public RangedIntInspectableAttribute(int min, int max)
{
Min = min;
Max = max;
}
}
public class InspectableTypeAttribute : PreferredInspectorAttribute
{
public readonly Type Type;
public InspectableTypeAttribute(Type type)
{
Type = type;
}
}
[AttributeUsage(AttributeTargets.Field)]
public class RangedFloatAttribute : Attribute
{
@ -85,30 +79,6 @@ public class RangedFloatAttribute : Attribute
}
}
[AttributeUsage(AttributeTargets.Field)]
public class RangedIntInspectableAttribute : InspectableFieldAttribute
{
public readonly int Min, Max;
public RangedIntInspectableAttribute(int min, int max)
{
Min = min;
Max = max;
}
}
public class InspectableTypeAttribute : InspectableFieldAttribute
{
public readonly Type Type;
public InspectableTypeAttribute(Type type)
{
Type = type;
}
}
[AttributeUsage(AttributeTargets.Field)]
public class SimplePerformanceStatAttribute : Attribute { }
/// <summary>
/// <para>Specify a tooltip for a field in the Inspector window.</para>

View file

@ -10,7 +10,7 @@ using System.Linq;
using System.Reflection;
using MessagePack;
public class DatabaseCache
public class CultCache
{
public event Action<DatabaseEntry> OnDataInsertLocal;
public event Action<DatabaseEntry> OnDataUpdateLocal;
@ -42,10 +42,11 @@ public class DatabaseCache
}
}
private readonly Dictionary<Guid, ExternalEntry> _externalEntries = new Dictionary<Guid, ExternalEntry>();
private readonly Dictionary<Type, FieldInfo[]> _linkFields = new Dictionary<Type, FieldInfo[]>();
public IEnumerable<DatabaseEntry> AllEntries => _entries.Values;
public DatabaseCache(string filePath)
public CultCache(string filePath)
{
RegisterResolver.Register();
_filePath = filePath;
@ -57,6 +58,9 @@ public class DatabaseCache
// This is mainly to accomodate large files like datasets
foreach (var type in typeof(DatabaseEntry).GetAllChildClasses())
{
var linkFields = type.GetFields().Where(f => f.FieldType.IsAssignableToGenericType(typeof(DatabaseLink<>))).ToArray();
if(linkFields.Length > 0)
_linkFields[type] = linkFields;
if (type.GetCustomAttribute<ExternalEntryAttribute>() != null)
{
var typeDirectory = dataDirectory.CreateSubdirectory(type.Name);
@ -88,6 +92,17 @@ public class DatabaseCache
// If an external entry is added, store it separately
var type = entry.GetType();
if (_linkFields.ContainsKey(type))
{
foreach (var linkField in _linkFields[type])
{
var link = (DatabaseLinkBase) linkField.GetValue(entry);
if (link != null)
{
link.Cache = this;
}
}
}
if (_externalTypes.ContainsKey(type))
{
if (_externalEntries.ContainsKey(entry.ID))

View file

@ -17,9 +17,7 @@ public interface INamedEntry
string EntryName { get; set; }
}
[InspectableField,
MessagePackObject,
//MessagePackFormatter(typeof(TypelessFormatter)),
[MessagePackObject,
JsonObject(MemberSerialization.OptIn),
JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>)),
Union(0, typeof(SimpleCommodityData)),
@ -33,7 +31,7 @@ public interface INamedEntry
Union(9, typeof(NameFile)),
//Union(10, typeof(ZoneData)),
Union(11, typeof(PlayerData)),
Union(12, typeof(Corporation)),
// Union(12, typeof(Corporation)),
Union(13, typeof(Faction)),
Union(14, typeof(OrbitalEntity)),
Union(15, typeof(OrbitData)),
@ -41,8 +39,8 @@ public interface INamedEntry
Union(17, typeof(PersonalityAttribute)),
Union(18, typeof(AgentTask)),
// Union(19, typeof(LoadoutData)),
Union(20, typeof(Ship)),
Union(21, typeof(Mining)),
Union(20, typeof(Ship)),
Union(21, typeof(Mining)),
Union(22, typeof(StationTowing)),
Union(23, typeof(Survey)),
Union(24, typeof(HaulingTask)),
@ -57,6 +55,21 @@ public abstract class DatabaseEntry
{
[JsonProperty("id"), Key(0)]
public Guid ID = Guid.NewGuid();
}
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class DatabaseLink<T> : DatabaseLinkBase where T : DatabaseEntry
{
[IgnoreMember]
public T Value => Cache.Get<T>(LinkID);
}
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class DatabaseLinkBase
{
[Key(0), JsonProperty("linkID")]
public Guid LinkID;
public DatabaseEntry(){}
[IgnoreMember]
public CultCache Cache;
}

View file

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
public static class CultCacheExtensions
@ -56,7 +57,35 @@ public static class CultCacheExtensions
return ChildClasses[type] = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(ass => ass.GetTypes()).Where(type.IsAssignableFrom).ToArray();
}
private static Dictionary<Type,Type[]> GenericChildClasses = new Dictionary<Type, Type[]>();
public static Type[] GetAllGenericChildClasses(this Type genericType)
{
if (GenericChildClasses.ContainsKey(genericType))
return ChildClasses[genericType];
return ChildClasses[genericType] = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(ass => ass.GetTypes()).Where(type=>type.IsAssignableToGenericType(genericType)).ToArray();
}
public static bool IsAssignableToGenericType(this Type givenType, Type genericType)
{
var interfaceTypes = givenType.GetInterfaces();
foreach (var it in interfaceTypes)
{
if (it.IsGenericType && it.GetGenericTypeDefinition() == genericType)
return true;
}
if (givenType.IsGenericType && givenType.GetGenericTypeDefinition() == genericType)
return true;
Type baseType = givenType.BaseType;
if (baseType == null) return false;
return IsAssignableToGenericType(baseType, genericType);
}
public static async void WrapAwait(this Task task)
{
await task;

View file

@ -15,46 +15,46 @@ using static NoiseFbm;
[Inspectable, Serializable, RethinkTable("Galaxy"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class GalaxyMapLayerData : DatabaseEntry, INamedEntry
{
[InspectableField, JsonProperty("coreBoost"), Key(1)]
[Inspectable, JsonProperty("coreBoost"), Key(1)]
public float CoreBoost = 1.05f;
[InspectableField, JsonProperty("coreBoostOffset"), Key(2)]
[Inspectable, JsonProperty("coreBoostOffset"), Key(2)]
public float CoreBoostOffset = .1f;
[InspectableField, JsonProperty("coreBoostPower"), Key(3)]
[Inspectable, JsonProperty("coreBoostPower"), Key(3)]
public float CoreBoostPower = 2.25f;
[InspectableField, JsonProperty("spokeScale"), Key(4)]
[Inspectable, JsonProperty("spokeScale"), Key(4)]
public float SpokeScale = 1;
[InspectableField, JsonProperty("spokeOffset"), Key(5)]
[Inspectable, JsonProperty("spokeOffset"), Key(5)]
public float SpokeOffset = 0;
[InspectableField, JsonProperty("edgeReduction"), Key(6)]
[Inspectable, JsonProperty("edgeReduction"), Key(6)]
public float EdgeReduction = 3;
[InspectableField, JsonProperty("noiseOffset"), Key(7)]
[Inspectable, JsonProperty("noiseOffset"), Key(7)]
public float NoiseOffset = 0;
[InspectableField, JsonProperty("noiseAmplitude"), Key(8)]
[Inspectable, JsonProperty("noiseAmplitude"), Key(8)]
public float NoiseAmplitude = 1.5f;
[InspectableField, JsonProperty("noiseGain"), Key(9)]
[Inspectable, JsonProperty("noiseGain"), Key(9)]
public float NoiseGain = .7f;
[InspectableField, JsonProperty("noiseLacunarity"), Key(10)]
[Inspectable, JsonProperty("noiseLacunarity"), Key(10)]
public float NoiseLacunarity = 2;
[InspectableField, JsonProperty("noiseOctaves"), Key(11)]
[Inspectable, JsonProperty("noiseOctaves"), Key(11)]
public int NoiseOctaves = 7;
[InspectableField, JsonProperty("noiseFrequency"), Key(12)]
[Inspectable, JsonProperty("noiseFrequency"), Key(12)]
public float NoiseFrequency = 1;
[InspectableField, JsonProperty("noisePosition"), Key(13)]
[Inspectable, JsonProperty("noisePosition"), Key(13)]
public float NoisePosition = 1337;
[InspectableField, JsonProperty("name"), Key(14)]
[Inspectable, JsonProperty("name"), Key(14)]
public string Name;
public float Evaluate(float2 uv, GalaxyShapeSettings settings)

View file

@ -14,7 +14,7 @@ using static Unity.Mathematics.math;
using float2 = Unity.Mathematics.float2;
using int2 = Unity.Mathematics.int2;
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class Shape
{
[JsonProperty("name"), Key(0)] public bool[,] Cells;
@ -222,7 +222,7 @@ public class Shape
[MessagePackObject, JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<ItemData>))]
public abstract class ItemData : DatabaseEntry, INamedEntry
{
[InspectableField, JsonProperty("name"), Key(1)]
[Inspectable, JsonProperty("name"), Key(1)]
public string Name;
[InspectableText, JsonProperty("description"), Key(2)]
@ -231,20 +231,20 @@ public abstract class ItemData : DatabaseEntry, INamedEntry
[InspectableDatabaseLink(typeof(Faction)), JsonProperty("creator"), Key(3)]
public Guid Manufacturer;
[InspectableField, JsonProperty("mass"), Key(4)]
[Inspectable, JsonProperty("mass"), Key(4)]
public float Mass;
[InspectableField, JsonProperty("shape"), Key(5)]
[Inspectable, JsonProperty("shape"), Key(5)]
public Shape Shape;
// Heat needed to change temperature of 1 gram by 1 degree
[InspectableField, JsonProperty("specificHeat"), Key(6)]
[Inspectable, JsonProperty("specificHeat"), Key(6)]
public float SpecificHeat = 1;
[InspectableField, JsonProperty("conductivity"), Key(7)]
[Inspectable, JsonProperty("conductivity"), Key(7)]
public float Conductivity = 1;
[InspectableField, JsonProperty("price"), Key(8)]
[Inspectable, JsonProperty("price"), Key(8)]
public int Price = 0;
[IgnoreMember] public string EntryName
@ -274,17 +274,17 @@ public class SimpleCommodityData : ItemData
// [InspectableField, JsonProperty("floor"), Key(11)]
// public float Floor = 5f;
[InspectableField, JsonProperty("maxStackSize"), Key(9)]
[Inspectable, JsonProperty("maxStackSize"), Key(9)]
public int MaxStack = 10;
[InspectableField, JsonProperty("category"), Key(10)]
[Inspectable, JsonProperty("category"), Key(10)]
public SimpleCommodityCategory Category;
}
[MessagePackObject, JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<CraftedItemData>))]
public abstract class CraftedItemData : ItemData
{
[InspectableField, JsonProperty("ingredientQualityWeight"), Key(9)]
[Inspectable, JsonProperty("ingredientQualityWeight"), Key(9)]
public float IngredientQualityWeight = .5f;
}
@ -294,7 +294,7 @@ public class CompoundCommodityData : CraftedItemData
[InspectableDatabaseLink(typeof(PersonalityAttribute)), JsonProperty("demandProfile"), Key(10)]
public Dictionary<Guid, float> DemandProfile = new Dictionary<Guid, float>();
[InspectableField, JsonProperty("category"), Key(11)]
[Inspectable, JsonProperty("category"), Key(11)]
public CompoundCommodityCategory Category;
}
@ -304,10 +304,10 @@ public abstract class EquippableItemData : CraftedItemData
[InspectableTexture, JsonProperty("schematic"), Key(10)]
public string Schematic;
[InspectableField, JsonProperty("behaviors"), Key(11)]
[Inspectable, JsonProperty("behaviors"), Key(11)]
public List<BehaviorData> Behaviors = new List<BehaviorData>();
[InspectableField, JsonProperty("durability"), Key(12)]
[Inspectable, JsonProperty("durability"), Key(12)]
public float Durability;
[InspectableTemperature, JsonProperty("minTemp"), Key(13)]
@ -325,10 +325,10 @@ public abstract class EquippableItemData : CraftedItemData
[InspectableAnimationCurve, JsonProperty("performanceCurve"), Key(17)]
public float4[] HeatPerformanceCurve;
[InspectableField, JsonProperty("resilience"), Key(18)]
[Inspectable, JsonProperty("resilience"), Key(18)]
public float ThermalResilience = 1;
[InspectableField, JsonProperty("sfx"), Key(19)]
[Inspectable, JsonProperty("sfx"), Key(19)]
public string SoundEffectTrigger;
[IgnoreMember]
@ -372,7 +372,7 @@ public abstract class EquippableItemData : CraftedItemData
[RethinkTable("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class GearData : EquippableItemData
{
[InspectableField, JsonProperty("hardpointType"), Key(20)]
[Inspectable, JsonProperty("hardpointType"), Key(20)]
public HardpointType Hardpoint;
[IgnoreMember] public override HardpointType HardpointType => Hardpoint;
@ -381,7 +381,7 @@ public class GearData : EquippableItemData
[RethinkTable("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class CargoBayData : EquippableItemData
{
[InspectableField, JsonProperty("interiorShape"), Key(20)]
[Inspectable, JsonProperty("interiorShape"), Key(20)]
public Shape InteriorShape;
[IgnoreMember] public override HardpointType HardpointType => HardpointType.Tool;
}
@ -389,45 +389,45 @@ public class CargoBayData : EquippableItemData
[RethinkTable("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class DockingBayData : CargoBayData
{
[InspectableField, JsonProperty("maxSize"), Key(21)]
[Inspectable, JsonProperty("maxSize"), Key(21)]
public int2 MaxSize;
}
[RethinkTable("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class WeaponItemData : GearData
{
[InspectableField, JsonProperty("range"), Key(21)]
[Inspectable, JsonProperty("range"), Key(21)]
public WeaponRange WeaponRange;
[InspectableField, JsonProperty("caliber"), Key(22)]
[Inspectable, JsonProperty("caliber"), Key(22)]
public WeaponCaliber WeaponCaliber;
[InspectableField, JsonProperty("weaponType"), Key(23)]
[Inspectable, JsonProperty("weaponType"), Key(23)]
public WeaponType WeaponType;
[InspectableField, JsonProperty("fireTypes"), Key(24)]
[Inspectable, JsonProperty("fireTypes"), Key(24)]
public WeaponFireType WeaponFireTypes;
[InspectableField, JsonProperty("modifiers"), Key(25)]
[Inspectable, JsonProperty("modifiers"), Key(25)]
public WeaponModifiers WeaponModifiers;
}
[RethinkTable("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class HullData : EquippableItemData
{
[InspectableField, JsonProperty("hardpoints"), Key(20)]
[Inspectable, JsonProperty("hardpoints"), Key(20)]
public List<HardpointData> Hardpoints = new List<HardpointData>();
[InspectablePrefab, JsonProperty("prefab"), Key(21)]
public string Prefab;
[InspectableField, JsonProperty("hullType"), Key(22)]
[Inspectable, JsonProperty("hullType"), Key(22)]
public HullType HullType;
[InspectableField, JsonProperty("gridOffset"), Key(23)]
[Inspectable, JsonProperty("gridOffset"), Key(23)]
public float GridOffset;
[InspectableField, JsonProperty("armor"), Key(24)]
[Inspectable, JsonProperty("armor"), Key(24)]
public float Armor;
[IgnoreMember]
@ -449,15 +449,15 @@ public class HullData : EquippableItemData
[IgnoreMember] public override HardpointType HardpointType => HardpointType.Hull;
}
[InspectableField, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class HardpointData : ITintInspector
{
[InspectableField, JsonProperty("type"), Key(0)] public HardpointType Type;
[InspectableField, JsonProperty("position"), Key(1)] public int2 Position;
[InspectableField, JsonProperty("shape"), Key(2)] public Shape Shape = new Shape();
[InspectableField, JsonProperty("transform"), Key(3)] public string Transform;
[InspectableField, JsonProperty("rotation"), Key(4)] public ItemRotation Rotation;
[InspectableField, JsonProperty("armor"), Key(5)] public float Armor;
[Inspectable, JsonProperty("type"), Key(0)] public HardpointType Type;
[Inspectable, JsonProperty("position"), Key(1)] public int2 Position;
[Inspectable, JsonProperty("shape"), Key(2)] public Shape Shape = new Shape();
[Inspectable, JsonProperty("transform"), Key(3)] public string Transform;
[Inspectable, JsonProperty("rotation"), Key(4)] public ItemRotation Rotation;
[Inspectable, JsonProperty("armor"), Key(5)] public float Armor;
public override string ToString()
{
@ -539,13 +539,13 @@ public class PerformanceStat
[RethinkTable("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
public class PersonalityAttribute : DatabaseEntry, INamedEntry
{
[InspectableField, JsonProperty("name"), Key(1)]
[Inspectable, JsonProperty("name"), Key(1)]
public string Name;
[InspectableField, JsonProperty("low"), Key(2)]
[Inspectable, JsonProperty("low"), Key(2)]
public string LowName;
[InspectableField, JsonProperty("high"), Key(3)]
[Inspectable, JsonProperty("high"), Key(3)]
public string HighName;
[IgnoreMember] public string EntryName

View file

@ -31,7 +31,7 @@ public class ItemManager
// private Guid _forceLoadZone;
// public GlobalData GlobalData => _globalData ?? (_globalData = ItemData.GetAll<GlobalData>().FirstOrDefault());
public DatabaseCache ItemData { get; }
public CultCache ItemData { get; }
public GameplaySettings GameplaySettings { get; }
public double Time
@ -47,7 +47,7 @@ public class ItemManager
// private readonly Dictionary<CraftedItemData, int> Tier = new Dictionary<CraftedItemData, int>();
public ItemManager(DatabaseCache itemData, GameplaySettings settings, Action<string> logger)
public ItemManager(CultCache itemData, GameplaySettings settings, Action<string> logger)
{
ItemData = itemData;
GameplaySettings = settings;

View file

@ -33,10 +33,10 @@ public class Sector
}
}
public Sector(DatabaseCache database, SavedGame savedGame)
public Sector(CultCache cultCache, SavedGame savedGame)
{
Settings = savedGame.Settings;
Factions = savedGame.Factions.Select(database.Get<Faction>).ToArray();
Factions = savedGame.Factions.Select(cultCache.Get<Faction>).ToArray();
Zones = savedGame.Zones.Select(zone =>
{
return new SectorZone
@ -67,10 +67,10 @@ public class Sector
CalculateDistanceMatrix();
}
public Sector(SectorGenerationSettings settings, DatabaseCache database, uint seed = 0, Action<string> progressCallback = null, float minLineSeparation = .01f)
public Sector(SectorGenerationSettings settings, CultCache cultCache, uint seed = 0, Action<string> progressCallback = null, float minLineSeparation = .01f)
{
Settings = settings;
var megas = database.GetAll<Faction>();
var megas = cultCache.GetAll<Faction>();
var random = new Random(seed == 0 ? (uint) (DateTime.Now.Ticks % uint.MaxValue) : seed);
Factions = megas.OrderBy(x => random.NextFloat()).Take(settings.MegaCount).ToArray();
@ -229,7 +229,7 @@ public class Sector
progressCallback?.Invoke($"Feeding Markov Chains: {i+1} / {Factions.Length}");
//if(progressCallback!=null) Thread.Sleep(250); // Inserting Delay to make it seem like it's doing more work lmao
var faction = Factions[i];
_nameGenerators[faction] = new MarkovNameGenerator(ref random, database.Get<NameFile>(faction.GeonameFile).Names, settings);
_nameGenerators[faction] = new MarkovNameGenerator(ref random, cultCache.Get<NameFile>(faction.GeonameFile).Names, settings);
}
// Generate zone name using the owner's name generator, otherwise assign catalogue ID