Purge Newtonsoft state annotations

This commit is contained in:
Meta Vens 2026-06-13 04:56:50 +01:00
commit b0d2aa1156
92 changed files with 891 additions and 1684 deletions

View file

@ -5,7 +5,7 @@ using UnityEngine;
public class AetheriaDatabaseView : DatabaseListView
{
// Singleton to avoid multiple instances of window.
// Singleton to avoid multiple instances of window.
private static DatabaseListView _instance;
private string tableName;
public static DatabaseListView Instance => _instance ? _instance : GetWindow<AetheriaDatabaseView>();
@ -23,11 +23,11 @@ public class AetheriaDatabaseView : DatabaseListView
protected override DatabaseEntryGroup[] Groupers => new DatabaseEntryGroup[]
{
new DatabaseEntryGroup<SimpleCommodityData,SimpleCommodityCategory>(
data => data.Category,
data => data.Category,
category => Enum.GetName(typeof(SimpleCommodityCategory), category),
(data, category) => data.Category = category ),
new DatabaseEntryGroup<CompoundCommodityData, CompoundCommodityCategory>(
data => data.Category,
data => data.Category,
category => Enum.GetName(typeof(CompoundCommodityCategory), category),
(data, category) => data.Category = category ),
new DatabaseEntryGroup<GearData, HardpointType>(
@ -43,4 +43,4 @@ public class AetheriaDatabaseView : DatabaseListView
type => Enum.GetName(typeof(HullType), type),
(data, type) => data.HullType = type)
};
}
}

View file

@ -1,4 +1,4 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */
@ -8,7 +8,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using UnityEditor;
using UnityEngine;
@ -21,7 +20,7 @@ public class DatabaseInspector : EditorWindow
{
public static CultCache CultCache;
public DatabaseEntry entry;
// Singleton to avoid multiple instances of window.
private static DatabaseInspector _instance;
public static DatabaseInspector Instance => _instance ? _instance : GetWindow<DatabaseInspector>();
@ -32,10 +31,10 @@ public class DatabaseInspector : EditorWindow
private Vector2 _view;
private GUIStyle _warning;
private List<(Type targetType, HashSet<Type> attributes, Type inspectorType, object instance)> _inspectors =
private List<(Type targetType, HashSet<Type> attributes, Type inspectorType, object instance)> _inspectors =
new List<(Type targetType, HashSet<Type> attributes, Type inspectorType, object instance)>();
private List<(Type targetType, HashSet<Type> attributes, Type inspectorType, Dictionary<Type, object> instances)> _genericInspectors =
private List<(Type targetType, HashSet<Type> attributes, Type inspectorType, Dictionary<Type, object> instances)> _genericInspectors =
new List<(Type targetType, HashSet<Type> attributes, Type inspectorType, Dictionary<Type, object> instances)>();
private HashSet<object> _foldouts = new HashSet<object>();
@ -60,8 +59,8 @@ public class DatabaseInspector : EditorWindow
if (genericArguments[0].ContainsGenericParameters)
{
_genericInspectors.Add((
genericArguments[0].GetGenericTypeDefinition(),
new HashSet<Type>(genericArguments.Skip(1)),
genericArguments[0].GetGenericTypeDefinition(),
new HashSet<Type>(genericArguments.Skip(1)),
type,
new Dictionary<Type, object>()
));
@ -69,16 +68,16 @@ public class DatabaseInspector : EditorWindow
else
{
_inspectors.Add((
genericArguments[0],
new HashSet<Type>(genericArguments.Skip(1)),
type,
genericArguments[0],
new HashSet<Type>(genericArguments.Skip(1)),
type,
Activator.CreateInstance(type)
));
}
}
}
}
public void Inspect(object obj, object parent = null)
{
foreach (var field in obj.GetType().GetFields().OrderBy(f=>f.GetCustomAttribute<KeyAttribute>()?.IntKey ?? 0))
@ -86,7 +85,7 @@ public class DatabaseInspector : EditorWindow
Inspect(obj, field, parent);
}
}
public void Inspect(object obj, FieldInfo field, object parent = null)
{
var inspectable = field.GetCustomAttribute<InspectableAttribute>();
@ -96,7 +95,7 @@ public class DatabaseInspector : EditorWindow
var type = field.FieldType;
var value = field.GetValue(obj);
field.SetValue(obj, InspectMember(field.Name.SplitCamelCase(), value, parent ?? obj, type, false, attributes));
}
@ -124,7 +123,7 @@ public class DatabaseInspector : EditorWindow
_listItemStyle = style;
return value;
}
if (type.IsEnum)
{
var isflags = type.GetCustomAttributes<FlagsAttribute>().Any();
@ -133,7 +132,7 @@ public class DatabaseInspector : EditorWindow
_listItemStyle = style;
return value;
}
if (type.GetCustomAttribute<InspectableAttribute>() != null)
{
if(!suppressContainer)
@ -164,7 +163,7 @@ public class DatabaseInspector : EditorWindow
_listItemStyle = style;
return value;
}
if (type.IsGenericType)
{
var genericTypeDefinition = type.GetGenericTypeDefinition();
@ -186,7 +185,7 @@ public class DatabaseInspector : EditorWindow
return value;
}
}
Debug.Log($"Field \"{label}\" has unknown type {type.Name}. No inspector was generated.");
_listItemStyle = style;
@ -231,12 +230,12 @@ public class DatabaseInspector : EditorWindow
LabelField("No Entry Selected!");
return;
}
if(entry is INamedEntry namedEntry)
GUILayout.Label(namedEntry.EntryName, EditorStyles.boldLabel);
_view = BeginScrollView(
_view,
_view,
false,
false,
GUIStyle.none,
@ -249,11 +248,11 @@ public class DatabaseInspector : EditorWindow
RegisterResolver.Register();
var previousBytes = MessagePackSerializer.Serialize<DatabaseEntry>(entry);
var previousHash = previousBytes.GetHashSHA1();
EditorGUI.BeginChangeCheck();
var dataEntry = entry;
using (new HorizontalScope())
{
// if(GUILayout.Button("Print JSON"))
@ -272,7 +271,7 @@ public class DatabaseInspector : EditorWindow
CultCache.Add(copy);
}
}
using (var h = new HorizontalScope())
{
GUILayout.Label("ID");
@ -287,7 +286,7 @@ public class DatabaseInspector : EditorWindow
if(previousHash != MessagePackSerializer.Serialize(entry).GetHashSHA1())
CultCache.Add(entry);
}
EndScrollView();
}
}

View file

@ -1,8 +1,6 @@
using System;
using System.Linq;
using JsonKnownTypes;
using MessagePack;
using Newtonsoft.Json;
using TMPro;
using UniRx.Triggers;
using UnityEngine;
@ -206,6 +204,6 @@ public class ActionBarWeaponGroupBinding : ActionBarBinding
public override void Update()
{
}
}

View file

@ -1,31 +1,27 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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;
using System.Collections.Generic;
using JsonKnownTypes;
using MessagePack;
using Newtonsoft.Json;
[MessagePackObject,
[MessagePackObject,
Union(0, typeof(StationTowing)),
Union(1, typeof(Mining)),
Union(2, typeof(Survey)),
Union(3, typeof(HaulingTask)),
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>))]
Union(3, typeof(HaulingTask))]
public abstract class AgentTask : DatabaseEntry
{
[JsonProperty("priority"), Key(1)]
[Key(1)]
public int Priority;
[JsonProperty("zone"), Key(2)]
[Key(2)]
public Guid Zone;
[JsonProperty("reserved"), Key(3)]
[Key(3)]
public bool Reserved;
[IgnoreMember] public abstract TaskType Type { get; }
}

View file

@ -1,4 +1,4 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */
@ -6,21 +6,19 @@ using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
public class HaulingTask : AgentTask
{
public override TaskType Type => TaskType.Haul;
[JsonProperty("origin"), Key(4)]
[Key(4)]
public Entity Origin;
[JsonProperty("target"), Key(5)]
[Key(5)]
public Entity Target;
[JsonProperty("itemType"), Key(6)]
[Key(6)]
public Guid ItemType;
[JsonProperty("quantity"), Key(7)]
[Key(7)]
public int Quantity;
}

View file

@ -1,20 +1,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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;
using System.Collections.Generic;
using JsonKnownTypes;
using MessagePack;
using Newtonsoft.Json;
[MessagePackObject,
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>))]
[MessagePackObject]
public class Mining : AgentTask
{
[IgnoreMember] public override TaskType Type => TaskType.Mine;
[JsonProperty("asteroids"), Key(4)]
[Key(4)]
public Guid Asteroids;
}

View file

@ -1,26 +1,22 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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;
using System.Collections.Generic;
using JsonKnownTypes;
using MessagePack;
using Newtonsoft.Json;
[MessagePackObject,
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>))]
[MessagePackObject]
public class StationTowing : AgentTask
{
[IgnoreMember] public override TaskType Type => TaskType.Tow;
[JsonProperty("station"), Key(4)]
[Key(4)]
public OrbitalEntity Station;
[JsonProperty("orbitParent"), Key(5)]
[Key(5)]
public Guid OrbitParent;
[JsonProperty("orbitDistance"), Key(6)]
[Key(6)]
public float OrbitDistance;
}

View file

@ -1,20 +1,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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;
using System.Collections.Generic;
using JsonKnownTypes;
using MessagePack;
using Newtonsoft.Json;
[MessagePackObject,
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>))]
[MessagePackObject]
public class Survey : AgentTask
{
[IgnoreMember] public override TaskType Type => TaskType.Explore;
[JsonProperty("station"), Key(4)]
[Key(4)]
public List<Guid> Planets;
}

View file

@ -3,57 +3,56 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), EntityTypeRestriction(HullType.Ship), RuntimeInspectable]
[Inspectable, MessagePackObject, EntityTypeRestriction(HullType.Ship), RuntimeInspectable]
public class AetherDriveData : BehaviorData
{
[Inspectable, JsonProperty("diameters"), Key(1)]
[Inspectable, Key(1)]
public float3 RotorDiameter;
[Inspectable, JsonProperty("masses"), Key(2)]
[Inspectable, Key(2)]
public float3 RotorMass;
[Inspectable, JsonProperty("rpm"), Key(3), RuntimeInspectable]
[Inspectable, Key(3), RuntimeInspectable]
public PerformanceStat MaximumRpm;
[Inspectable, JsonProperty("couplingLambdas"), Key(4)]
[Inspectable, Key(4)]
public float3 CouplingLambda;
[Inspectable, JsonProperty("lambdaMultiplier"), Key(5)]
[Inspectable, Key(5)]
public PerformanceStat LambdaMultiplier;
[Inspectable, JsonProperty("couplingEfficiency"), Key(6), RuntimeInspectable]
[Inspectable, Key(6), RuntimeInspectable]
public PerformanceStat CouplingEfficiency;
[Inspectable, JsonProperty("torque"), Key(7), RuntimeInspectable]
[Inspectable, Key(7), RuntimeInspectable]
public PerformanceStat Torque;
[Inspectable, JsonProperty("torqueProfile"), Key(8), RuntimeInspectable]
[Inspectable, Key(8), RuntimeInspectable]
public BezierCurve TorqueProfile;
[Inspectable, JsonProperty("draw"), Key(9), RuntimeInspectable]
[Inspectable, Key(9), RuntimeInspectable]
public PerformanceStat EnergyDraw;
[Inspectable, JsonProperty("passiveCoupling"), Key(10), RuntimeInspectable]
[Inspectable, Key(10), RuntimeInspectable]
public PerformanceStat PassiveCoupling;
[InspectableAudioParameter, JsonProperty("rpmAudio"), Key(11), RuntimeInspectable]
[InspectableAudioParameter, Key(11), RuntimeInspectable]
public uint RpmAudioParameter;
[InspectableAudioParameter, JsonProperty("torqueAudio"), Key(12), RuntimeInspectable]
[InspectableAudioParameter, Key(12), RuntimeInspectable]
public uint TorqueRatioAudioParameter;
[InspectablePrefab, JsonProperty("particles"), Key(13)]
[InspectablePrefab, Key(13)]
public string Particles;
public override Behavior CreateInstance(EquippedItem item)
{
return new AetherDrive(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new AetherDrive(this, item);
@ -91,10 +90,10 @@ public class AetherDrive : Behavior
public override bool Execute(float dt)
{
var rotorSpeed = Rpm * _data.RotorDiameter / 100;
var forward = normalize(Entity.Direction);
var right = forward.Rotate(ItemRotation.Clockwise);
var speed = float2(dot(Entity.Velocity, forward), dot(Entity.Velocity, right));
var couplingEfficiency = Evaluate(_data.CouplingEfficiency);
var efficiency = float3(saturate(1 - speed / max(rotorSpeed.xy, 1) * sign(_axis.xy)) * couplingEfficiency, 1);
@ -112,13 +111,13 @@ public class AetherDrive : Behavior
ThrustDirection = forward * (_axis.x * force.x / Entity.Mass) + right * (_axis.y * force.y / Entity.Mass);
Entity.Velocity += ThrustDirection;
Entity.Direction = mul(Entity.Direction,
Unity.Mathematics.float2x2.Rotate(force.z * _axis.z * ItemManager.GameplaySettings.AetherTorqueMultiplier / Entity.Mass));
if(float.IsNaN(Entity.Velocity.x))
ItemManager.Log("FUCK FUCK FUCK FUCK");
MaximumRpm = Evaluate(_data.MaximumRpm);
var torqueProfile = float3(
_data.TorqueProfile.Evaluate(Rpm.x / MaximumRpm),
@ -129,18 +128,18 @@ public class AetherDrive : Behavior
var actualRpmDelta = min(MaximumRpm - Rpm, potentialRpmDelta);
var torqueRatio = actualRpmDelta / potentialRpmDelta;
var draw = torqueRatio * Evaluate(_data.EnergyDraw) / 3;
Item.SetAudioParameter(SpecialAudioParameter.Intensity, max(max(abs(_axis.x), abs(_axis.y)), abs(_axis.z)));
Item.SetAudioParameter(_data.RpmAudioParameter, (Rpm.x + Rpm.y + Rpm.z) / 3 / MaximumRpm);
Item.SetAudioParameter(_data.TorqueRatioAudioParameter, max(max(torqueRatio.x, torqueRatio.y), torqueRatio.z));
if (Entity.TryConsumeEnergy((draw.x + draw.y + draw.z)*dt))
{
Rpm += actualRpmDelta;
return true;
}
return false;
}
}

View file

@ -2,11 +2,10 @@ using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class AutoWeaponData : InstantWeaponData
{
public override Behavior CreateInstance(EquippedItem item)
@ -17,7 +16,7 @@ public class AutoWeaponData : InstantWeaponData
public class AutoWeapon : InstantWeapon
{
public AutoWeapon(InstantWeaponData data, EquippedItem item) : base(data, item) { }
public AutoWeapon(InstantWeaponData data, ConsumableItemEffect item) : base(data, item) { }

View file

@ -1,4 +1,4 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */
@ -6,9 +6,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using JsonKnownTypes;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using static Unity.Mathematics.noise;
@ -51,14 +49,14 @@ public abstract class Behavior
Item = item;
ItemManager = Item.ItemManager;
}
protected Behavior(BehaviorData data, ConsumableItemEffect consumable)
{
Data = data;
Consumable = consumable;
ItemManager = consumable.Entity.ItemManager;
}
public float Evaluate(PerformanceStat stat) => Item?.Evaluate(stat) ?? Consumable.Evaluate(stat);
protected void AddHeat(float heat) => Item?.AddHeat(heat); // TODO: Heat for Consumables
@ -83,7 +81,7 @@ public abstract class Behavior
CauseDamage(Item.Wear * multiplier);
}
}
public virtual bool Execute(float dt)
{
return true;
@ -142,19 +140,17 @@ public interface IPopulationAssignment
int AssignedPopulation { get; set; }
}
[MessagePackObject,
JsonObject(MemberSerialization.OptIn),
JsonConverter(typeof(JsonKnownTypesConverter<PersistentBehaviorData>))]
[MessagePackObject]
public abstract class PersistentBehaviorData
{
}
[Inspectable,
[Inspectable,
Union(0, typeof(GuidedWeaponData)),
Union(1, typeof(LauncherData)),
Union(2, typeof(ReactorData)),
Union(3, typeof(RadiatorData)),
Union(4, typeof(StatModifierData)),
Union(2, typeof(ReactorData)),
Union(3, typeof(RadiatorData)),
Union(4, typeof(StatModifierData)),
Union(5, typeof(SensorData)),
Union(6, typeof(ReflectorData)),
Union(7, typeof(ShieldData)),
@ -187,13 +183,12 @@ public abstract class PersistentBehaviorData
Union(35, typeof(InstantWeaponData)),
Union(36, typeof(ConstantWeaponData)),
Union(37, typeof(ChargedWeaponData)),
Union(38, typeof(AutoWeaponData)),
JsonConverter(typeof(JsonKnownTypesConverter<BehaviorData>)), JsonObject(MemberSerialization.OptIn)]
Union(38, typeof(AutoWeaponData))]
public abstract class BehaviorData
{
[Inspectable, JsonProperty("group"), Key(0)]
[Inspectable, Key(0)]
public int Group;
public abstract Behavior CreateInstance(EquippedItem item);
public abstract Behavior CreateInstance(ConsumableItemEffect consumable);

View file

@ -4,24 +4,23 @@
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class CapacitorData : BehaviorData
{
[Inspectable, JsonProperty("capacity"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat Capacity = new PerformanceStat();
[Inspectable, JsonProperty("efficiency"), Key(2), RuntimeInspectable]
[Inspectable, Key(2), RuntimeInspectable]
public PerformanceStat Efficiency = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new Capacitor(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new Capacitor(this, item);

View file

@ -2,54 +2,53 @@ using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class ChargedWeaponData : InstantWeaponData
{
[Inspectable, JsonProperty("chargeTime"), Key(21), RuntimeInspectable]
[Inspectable, Key(21), RuntimeInspectable]
public PerformanceStat ChargeTime = new PerformanceStat();
[Inspectable, JsonProperty("chargeEnergy"), Key(22), RuntimeInspectable]
[Inspectable, Key(22), RuntimeInspectable]
public PerformanceStat ChargeEnergy = new PerformanceStat();
[Inspectable, JsonProperty("chargeHeat"), Key(23), RuntimeInspectable]
[Inspectable, Key(23), RuntimeInspectable]
public PerformanceStat ChargeHeat = new PerformanceStat();
[Inspectable, JsonProperty("canFireEarly"), Key(24)]
[Inspectable, Key(24)]
public bool CanFireEarly;
[Inspectable, JsonProperty("failureCharge"), Key(25)]
[Inspectable, Key(25)]
public float FailureCharge;
[Inspectable, JsonProperty("failureDamage"), Key(26)]
[Inspectable, Key(26)]
public float FailureDamage = 1;
[Inspectable, JsonProperty("chargeDamage"), Key(27)]
[Inspectable, Key(27)]
public float ChargeFiringDamageMultiplier = 1;
[Inspectable, JsonProperty("chargeSpread"), Key(28)]
[Inspectable, Key(28)]
public float ChargeFiringSpreadMultiplier = 1;
[Inspectable, JsonProperty("chargeBurstCount"), Key(29)]
[Inspectable, Key(29)]
public float ChargeFiringBurstCountMultiplier = 1;
[Inspectable, JsonProperty("chargeVisibility"), Key(30)]
[Inspectable, Key(30)]
public float ChargeFiringVisibilityMultiplier = 1;
[Inspectable, JsonProperty("chargeVelocity"), Key(31)]
[Inspectable, Key(31)]
public float ChargeFiringVelocityMultiplier = 1;
[Inspectable, JsonProperty("chargeHeatMul"), Key(32)]
[Inspectable, Key(32)]
public float ChargeFiringHeatMultiplier = 1;
public override Behavior CreateInstance(EquippedItem item)
{
return new ChargedWeapon(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new ChargedWeapon(this, item);
@ -63,11 +62,11 @@ public class ChargedWeapon : InstantWeapon
private bool _charged;
private float _charge;
private float _progress;
public float ChargeTime { get; protected set; }
public float ChargeEnergy { get; protected set; }
public float ChargeHeat { get; protected set; }
public override float DamagePerSecond => Damage * _data.ChargeFiringDamageMultiplier / (Cooldown + ChargeTime);
public override float RangeDamagePerSecond(float range)
{
@ -97,12 +96,12 @@ public class ChargedWeapon : InstantWeapon
{
get => _charge;
}
public ChargedWeapon(ChargedWeaponData data, EquippedItem item) : base(data, item)
{
_data = data;
}
public ChargedWeapon(ChargedWeaponData data, ConsumableItemEffect item) : base(data, item)
{
_data = data;

View file

@ -4,11 +4,10 @@
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class CockpitData : BehaviorData
{
public override Behavior CreateInstance(EquippedItem item)
@ -24,12 +23,12 @@ public class CockpitData : BehaviorData
public class Cockpit : Behavior
{
private CockpitData _data;
public Cockpit(CockpitData data, EquippedItem item) : base(data, item)
{
_data = data;
}
public Cockpit(CockpitData data, ConsumableItemEffect item) : base(data, item)
{
_data = data;

View file

@ -4,21 +4,20 @@
using System;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Inspectable, MessagePackObject]
public class ConstantWeaponData : WeaponData
{
[InspectablePrefab, JsonProperty("ammoInterval"), Key(17)]
[InspectablePrefab, Key(17)]
public float AmmoInterval = 1;
public override Behavior CreateInstance(EquippedItem item)
{
return new ConstantWeapon(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new ConstantWeapon(this, item);
@ -32,17 +31,17 @@ public class ConstantWeapon : Weapon, IProgressBehavior, IEventBehavior
private float _ammoInterval;
private float _reload;
private bool _reloading;
public override int Ammo
{
get => _ammo;
}
public float Progress
{
get { return saturate(_reload); }
}
public override float DamagePerSecond => Damage;
public override float RangeDamagePerSecond(float range)
{
@ -53,7 +52,7 @@ public class ConstantWeapon : Weapon, IProgressBehavior, IEventBehavior
public event Action OnReloadComplete;
public event Action OnStartFiring;
public event Action OnStopFiring;
public void ResetEvents()
{
OnReloadBegin = null;
@ -95,7 +94,7 @@ public class ConstantWeapon : Weapon, IProgressBehavior, IEventBehavior
}
return false;
}
_ammoInterval -= dt / _data.AmmoInterval;
if (_ammoInterval < 0)
{
@ -109,7 +108,7 @@ public class ConstantWeapon : Weapon, IProgressBehavior, IEventBehavior
var item = cargo.ItemsOfType[_data.AmmoType][0];
if (item is SimpleCommodity simpleCommodity)
cargo.Remove(simpleCommodity, 1);
if(_data.MagazineSize > 1)
{
_reloading = true;

View file

@ -1,25 +1,24 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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.Linq;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-10), RuntimeInspectable]
[Inspectable, MessagePackObject, Order(-10), RuntimeInspectable]
public class CooldownData : BehaviorData
{
[Inspectable, JsonProperty("cooldown"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat Cooldown = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new Cooldown(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new Cooldown(this, item);

View file

@ -1,26 +1,24 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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.Linq;
using MessagePack;
using Newtonsoft.Json;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-20), RuntimeInspectable]
[Inspectable, MessagePackObject, Order(-20), RuntimeInspectable]
public class EnergyDrawData : BehaviorData
{
[Inspectable, JsonProperty("draw"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat EnergyDraw = new PerformanceStat();
[Inspectable, JsonProperty("perSecond"), Key(2)]
[Inspectable, Key(2)]
public bool PerSecond;
public override Behavior CreateInstance(EquippedItem item)
{
return new EnergyDraw(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new EnergyDraw(this, item);

View file

@ -1,26 +1,24 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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.Linq;
using MessagePack;
using Newtonsoft.Json;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(10)]
[Inspectable, MessagePackObject, Order(10)]
public class HeatData : BehaviorData
{
[Inspectable, JsonProperty("heat"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat Heat = new PerformanceStat();
[Inspectable, JsonProperty("perSecond"), Key(2)]
[Inspectable, Key(2)]
public bool PerSecond;
public override Behavior CreateInstance(EquippedItem item)
{
return new Heat(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new Heat(this, item);

View file

@ -4,11 +4,10 @@
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class HeatStorageData : BehaviorData
{
public override Behavior CreateInstance(EquippedItem item)

View file

@ -2,23 +2,22 @@ using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class InstantWeaponData : WeaponData
{
[Inspectable, JsonProperty("count"), Key(17)]
[Inspectable, Key(17)]
public PerformanceStat Count = new PerformanceStat();
[Inspectable, JsonProperty("burstTime"), Key(18)]
[Inspectable, Key(18)]
public PerformanceStat BurstTime = new PerformanceStat();
[Inspectable, JsonProperty("cooldown"), Key(19), RuntimeInspectable]
[Inspectable, Key(19), RuntimeInspectable]
public PerformanceStat Cooldown = new PerformanceStat();
[InspectablePrefab, JsonProperty("ammoInterval"), Key(20)]
[InspectablePrefab, Key(20)]
public bool SingleAmmoBurst;
public override Behavior CreateInstance(EquippedItem item)
@ -93,7 +92,7 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior
// 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 && (!Entity.TryConsumeEnergy(Energy) || !UseAmmo())) return;
_burstRemaining = (int) BurstCount;
_burstInterval = BurstTime / _burstRemaining;
_burstTimer = 0;
@ -116,13 +115,13 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior
private bool UseAmmo()
{
if (_data.MagazineSize <= 1) return true;
if (_ammo > 0)
{
_ammo--;
return true;
}
var hasAmmo = true;
if (_data.AmmoType != Guid.Empty)
{
@ -177,7 +176,7 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior
_burstRemaining = 0;
return false;
}
_burstRemaining--;
_burstTimer -= _burstInterval;
OnFire?.Invoke();

View file

@ -1,23 +1,21 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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.Linq;
using MessagePack;
using Newtonsoft.Json;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-5), RuntimeInspectable]
[Inspectable, MessagePackObject, Order(-5), RuntimeInspectable]
public class ItemUsageData : BehaviorData
{
[InspectableDatabaseLink(typeof(SimpleCommodityData)), JsonProperty("item"), Key(1), RuntimeInspectable]
[InspectableDatabaseLink(typeof(SimpleCommodityData)), Key(1), RuntimeInspectable]
public Guid Item;
public override Behavior CreateInstance(EquippedItem item)
{
return new ItemUsage(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new ItemUsage(this, item);
@ -48,7 +46,7 @@ public class ItemUsage : Behavior
cargo.Remove(simpleCommodity, 1);
if (item is CraftedItemInstance craftedItemInstance)
cargo.Remove(craftedItemInstance);
return true;
}
}

View file

@ -3,28 +3,27 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Inspectable, MessagePackObject]
public class LauncherData : LockWeaponData
{
[InspectableAnimationCurve, JsonProperty("guidance"), Key(26)]
[InspectableAnimationCurve, Key(26)]
public float4[] GuidanceCurve;
[InspectableAnimationCurve, JsonProperty("thrustCurve"), Key(27)]
[InspectableAnimationCurve, Key(27)]
public float4[] ThrustCurve;
[InspectableAnimationCurve, JsonProperty("liftCurve"), Key(28)]
[InspectableAnimationCurve, Key(28)]
public float4[] LiftCurve;
[Inspectable, JsonProperty("thrust"), Key(29)]
[Inspectable, Key(29)]
public PerformanceStat Thrust = new PerformanceStat();
[Inspectable, JsonProperty("frequency"), Key(30)]
[Inspectable, Key(30)]
public float DodgeFrequency;
[Inspectable, JsonProperty("missileSpeed"), Key(31), RuntimeInspectable]
[Inspectable, Key(31), RuntimeInspectable]
public PerformanceStat MissileVelocity = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
@ -33,25 +32,25 @@ public class LauncherData : LockWeaponData
}
}
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Inspectable, MessagePackObject]
public class GuidedWeaponData : InstantWeaponData
{
[InspectableAnimationCurve, JsonProperty("guidance"), Key(21)]
[InspectableAnimationCurve, Key(21)]
public float4[] GuidanceCurve;
[InspectableAnimationCurve, JsonProperty("thrustCurve"), Key(22)]
[InspectableAnimationCurve, Key(22)]
public float4[] ThrustCurve;
[InspectableAnimationCurve, JsonProperty("liftCurve"), Key(23)]
[InspectableAnimationCurve, Key(23)]
public float4[] LiftCurve;
[Inspectable, JsonProperty("thrust"), Key(24)]
[Inspectable, Key(24)]
public PerformanceStat Thrust = new PerformanceStat();
[Inspectable, JsonProperty("frequency"), Key(25)]
[Inspectable, Key(25)]
public float DodgeFrequency;
[Inspectable, JsonProperty("missileSpeed"), Key(26), RuntimeInspectable]
[Inspectable, Key(26), RuntimeInspectable]
public PerformanceStat MissileVelocity = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)

View file

@ -2,28 +2,27 @@ using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class LockWeaponData : InstantWeaponData
{
[Inspectable, JsonProperty("speed"), Key(21), RuntimeInspectable]
[Inspectable, Key(21), RuntimeInspectable]
public PerformanceStat LockSpeed = new PerformanceStat();
[Inspectable, JsonProperty("sensorImpact"), Key(22)]
[Inspectable, Key(22)]
public PerformanceStat SensorImpact = new PerformanceStat();
[Inspectable, JsonProperty("threshold"), Key(23), RuntimeInspectable]
[Inspectable, Key(23), RuntimeInspectable]
public PerformanceStat LockAngle = new PerformanceStat();
[Inspectable, JsonProperty("directionImpact"), Key(24)]
[Inspectable, Key(24)]
public PerformanceStat DirectionImpact = new PerformanceStat();
[Inspectable, JsonProperty("decay"), Key(25)]
[Inspectable, Key(25)]
public PerformanceStat Decay = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new LockWeapon(this, item);
@ -59,7 +58,7 @@ public class LockWeapon : InstantWeapon
{
get => saturate(_lock);
}
public LockWeapon(LockWeaponData data, EquippedItem item) : base(data, item)
{
_data = data;

View file

@ -1,29 +1,28 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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.Linq;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(10)]
[Inspectable, MessagePackObject, Order(10)]
public class MiningToolData : BehaviorData
{
[Inspectable, JsonProperty("dps"), Key(1)]
[Inspectable, Key(1)]
public PerformanceStat DamagePerSecond = new PerformanceStat();
[Inspectable, JsonProperty("efficiency"), Key(2)]
[Inspectable, Key(2)]
public PerformanceStat Efficiency = new PerformanceStat();
[Inspectable, JsonProperty("penetration"), Key(3)]
[Inspectable, Key(3)]
public PerformanceStat Penetration = new PerformanceStat();
[Inspectable, JsonProperty("range"), Key(4)]
[Inspectable, Key(4)]
public PerformanceStat Range = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new MiningTool(this, item);
@ -38,7 +37,7 @@ public class MiningTool : Behavior
{
public Guid AsteroidBelt;
public int Asteroid;
private MiningToolData _data;
public float Range { get; private set; }
@ -56,8 +55,8 @@ public class MiningTool : Behavior
{
Range = Evaluate(_data.Range);
var belt = Entity.Zone.AsteroidBelts[AsteroidBelt];
if (AsteroidBelt != Guid.Empty &&
Entity.Zone.AsteroidExists(AsteroidBelt, Asteroid) &&
if (AsteroidBelt != Guid.Empty &&
Entity.Zone.AsteroidExists(AsteroidBelt, Asteroid) &&
length(Entity.Position.xz - belt.Transforms[Asteroid].xy) - belt.Transforms[Asteroid].w < Range)
{
Entity.Zone.MineAsteroid(

View file

@ -3,36 +3,35 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class RadiatorData : BehaviorData
{
[Inspectable, JsonProperty("emissivity"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat Emissivity = new PerformanceStat();
[Inspectable, JsonProperty("pumpedHeat"), Key(2), RuntimeInspectable]
[Inspectable, Key(2), RuntimeInspectable]
public PerformanceStat PumpedHeat = new PerformanceStat();
[InspectableTemperature, JsonProperty("temperatureFloor"), Key(3), RuntimeInspectable]
[InspectableTemperature, Key(3), RuntimeInspectable]
public float TemperatureFloor;
[Inspectable, JsonProperty("wasteHeat"), Key(4), RuntimeInspectable]
[Inspectable, Key(4), RuntimeInspectable]
public PerformanceStat WasteHeat = new PerformanceStat();
[Inspectable, JsonProperty("energyUsage"), Key(5), RuntimeInspectable]
[Inspectable, Key(5), RuntimeInspectable]
public PerformanceStat EnergyUsage = new PerformanceStat();
[Inspectable, JsonProperty("thermalMass"), Key(6), RuntimeInspectable]
[Inspectable, Key(6), RuntimeInspectable]
public PerformanceStat ThermalMass = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new Radiator(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new Radiator(this, item);
@ -42,12 +41,12 @@ public class RadiatorData : BehaviorData
public class Radiator : Behavior, IAlwaysUpdatedBehavior, IInitializableBehavior
{
public float RadiatorTemperature { get; private set; }
public float Emissivity { get; private set; }
public float PumpedHeat { get; private set; }
public float WasteHeat { get; private set; }
public float EnergyUsage { get; private set; }
private RadiatorData _data;
public Radiator(RadiatorData data, EquippedItem item) : base(data, item)
@ -67,19 +66,19 @@ public class Radiator : Behavior, IAlwaysUpdatedBehavior, IInitializableBehavior
var itemTemperature = Temperature;
var tempRatio = max(RadiatorTemperature / itemTemperature, 1);
// Temperature ratio would cause more waste heat than pump capacity, stop executing
if (tempRatio > PumpedHeat / WasteHeat) return true;
if (!Entity.TryConsumeEnergy(EnergyUsage * tempRatio * dt)) return false;
var pumpedHeat = PumpedHeat * max(itemTemperature - _data.TemperatureFloor, 0);
// Radiator temperature is below temperature floor, stop executing
if (pumpedHeat < 0.01f) return true;
var wasteHeat = WasteHeat * tempRatio;
AddHeat((wasteHeat - pumpedHeat) * dt);
RadiatorTemperature += pumpedHeat / Evaluate(_data.ThermalMass) * dt;

View file

@ -6,31 +6,30 @@ using System;
using System.Collections.Generic;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
using UniRx;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class ReactorData : BehaviorData
{
[Inspectable, JsonProperty("charge"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat Charge = new PerformanceStat();
[Inspectable, JsonProperty("efficiency"), Key(2), RuntimeInspectable]
[Inspectable, Key(2), RuntimeInspectable]
public PerformanceStat Efficiency = new PerformanceStat();
[Inspectable, JsonProperty("overload"), Key(3), RuntimeInspectable]
[Inspectable, Key(3), RuntimeInspectable]
public PerformanceStat OverloadEfficiency = new PerformanceStat();
[Inspectable, JsonProperty("underload"), Key(4), RuntimeInspectable]
[Inspectable, Key(4), RuntimeInspectable]
public PerformanceStat ThrottlingFactor = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new Reactor(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new Reactor(this, item);
@ -42,7 +41,7 @@ public class Reactor : Behavior, IOrderedBehavior, IDisposable
private ReactorData _data;
public float Draw { get; private set; }
public float CurrentLoadRatio { get; private set; }
public int Order => 100;
@ -91,7 +90,7 @@ public class Reactor : Behavior, IOrderedBehavior, IDisposable
// Subtract the baseline charge from draw
Draw -= charge;
// Generate heat using baseline efficiency
var heat = charge / efficiency;
@ -100,10 +99,10 @@ public class Reactor : Behavior, IOrderedBehavior, IDisposable
{
CurrentLoadRatio = (Draw + charge) / max(charge, .01f);
var overloadEfficiency = Evaluate(_data.OverloadEfficiency);
// Generate heat using overload efficiency, usually much less efficient!
heat += Draw / overloadEfficiency;
// Overload power will always neutralize the energy deficit
Draw = 0;
}
@ -139,9 +138,9 @@ public class Reactor : Behavior, IOrderedBehavior, IDisposable
{
CurrentLoadRatio = 1;
}
Item.SetAudioParameter(SpecialAudioParameter.Intensity, max(.25f, 1 - 1 / CurrentLoadRatio));
AddHeat(heat);
return true;
}

View file

@ -3,24 +3,23 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class ReflectorData : BehaviorData
{
[Inspectable, JsonProperty("crossSection"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat CrossSection = new PerformanceStat();
// [InspectableAnimationCurve, JsonProperty("visibility"), Key(1)]
// [InspectableAnimationCurve, Key(1)]
// public float4[] VisibilityCurve;
public override Behavior CreateInstance(EquippedItem item)
{
return new Reflector(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new Reflector(this, item);
@ -44,7 +43,7 @@ public class Reflector : Behavior
public override bool Execute(float dt)
{
Entity.VisibilitySources[this] = Evaluate(_data.CrossSection) * Entity.Zone.GetLight(Entity.Position.xz);
return true;
}
}

View file

@ -1,31 +1,30 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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.Linq;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class ResourceScannerData : BehaviorData
{
[Inspectable, JsonProperty("range"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat Range = new PerformanceStat();
[Inspectable, JsonProperty("minDensity"), Key(2), RuntimeInspectable]
[Inspectable, Key(2), RuntimeInspectable]
public PerformanceStat MinimumDensity = new PerformanceStat();
[Inspectable, JsonProperty("scanDuration"), Key(3), RuntimeInspectable]
[Inspectable, Key(3), RuntimeInspectable]
public PerformanceStat ScanDuration = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new ResourceScanner(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new ResourceScanner(this, item);
@ -35,7 +34,7 @@ public class ResourceScannerData : BehaviorData
public class ResourceScanner : Behavior, IAlwaysUpdatedBehavior
{
public int Asteroid = -1;
private ResourceScannerData _data;
private float _scanTime;
private Guid _scanTarget;

View file

@ -5,45 +5,44 @@
using System;
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class SensorData : BehaviorData
{
[Inspectable, JsonProperty("sensitivity"), Key(3), RuntimeInspectable]
[Inspectable, Key(3), RuntimeInspectable]
public PerformanceStat Sensitivity = new PerformanceStat();
[InspectableAnimationCurve, JsonProperty("sensCurve"), Key(4), RuntimeInspectable]
[InspectableAnimationCurve, Key(4), RuntimeInspectable]
public BezierCurve SensitivityCurve;
[Inspectable, JsonProperty("pingBoost"), Key(5), RuntimeInspectable]
[Inspectable, Key(5), RuntimeInspectable]
public PerformanceStat PingBoost;
[Inspectable, JsonProperty("pingEnergy"), Key(6), RuntimeInspectable]
[Inspectable, Key(6), RuntimeInspectable]
public PerformanceStat PingEnergy;
[Inspectable, JsonProperty("pingVisibility"), Key(7), RuntimeInspectable]
[Inspectable, Key(7), RuntimeInspectable]
public PerformanceStat PingVisibility;
[Inspectable, JsonProperty("pingRange"), Key(8), RuntimeInspectable]
[Inspectable, Key(8), RuntimeInspectable]
public PerformanceStat PingRange;
[Inspectable, JsonProperty("pingCooldown"), Key(9), RuntimeInspectable]
[Inspectable, Key(9), RuntimeInspectable]
public PerformanceStat PingCooldown;
[Inspectable, JsonProperty("pingDuration"), Key(10)]
[Inspectable, Key(10)]
public float PingDuration = 2;
[Inspectable, JsonProperty("pingRadiusExponent"), Key(11)]
[Inspectable, Key(11)]
public float PingRadiusExponent = .5f;
public override Behavior CreateInstance(EquippedItem item)
{
return new Sensor(this, item);
}
public override Behavior CreateInstance(ConsumableItemEffect item)
{
return new Sensor(this, item);
@ -63,7 +62,7 @@ public class Sensor : Behavior, IEventBehavior
{
get => saturate(_pingCooldown);
}
public float PingRadius
{
get => _pingRadius;
@ -118,13 +117,13 @@ public class Sensor : Behavior, IEventBehavior
}
_pingCooldown -= dt / Evaluate(_data.PingCooldown);
// TODO: Handle Active Detection / Visibility From Reflected Radiance
var forward = Direction.xz;
foreach (var entity in Entity.Zone.Entities)
{
if (entity == Entity) continue;
var diff = entity.Position.xz - Entity.Position.xz;
var angle = acos(dot(forward, normalize(diff)));
var dist = length(diff);

View file

@ -3,19 +3,18 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class ShieldData : BehaviorData
{
[Inspectable, JsonProperty("efficiency"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat Efficiency = new PerformanceStat();
[Inspectable, JsonProperty("energy"), Key(2), RuntimeInspectable]
[Inspectable, Key(2), RuntimeInspectable]
public PerformanceStat EnergyUsage = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new Shield(this, item);

View file

@ -1,27 +1,25 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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.Linq;
using MessagePack;
using Newtonsoft.Json;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Inspectable, MessagePackObject]
public class StatModifierData : BehaviorData
{
[Inspectable, JsonProperty("stat"), Key(1)]
[Inspectable, Key(1)]
public StatReference Stat = new StatReference();
[Inspectable, JsonProperty("modifier"), Key(2)]
[Inspectable, Key(2)]
public PerformanceStat Modifier = new PerformanceStat();
[Inspectable, JsonProperty("type"), Key(3)]
[Inspectable, Key(3)]
public StatModifierType Type;
[InspectableType(typeof(BehaviorData)), JsonProperty("requireBehavior"), Key(4)]
[InspectableType(typeof(BehaviorData)), Key(4)]
public Type RequireBehavior;
public override Behavior CreateInstance(EquippedItem item)
{
return new StatModifier(this, item);
@ -39,7 +37,7 @@ public class StatModifier : Behavior, IInitializableBehavior, IDisposable, IAlwa
private StatModifierData _data;
private PerformanceStat[] _stats;
private static Type[] _statObjects;
private bool _applied;
@ -130,12 +128,12 @@ public enum StatModifierType
Multiplier
}
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Inspectable, MessagePackObject]
public class StatReference
{
[InspectableType(typeof(BehaviorData)), JsonProperty("behavior"), Key(1)]
[InspectableType(typeof(BehaviorData)), Key(1)]
public string Target;
[Inspectable, JsonProperty("stat"), Key(2)]
[Inspectable, Key(2)]
public string Stat;
}

View file

@ -1,13 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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.Linq;
using MessagePack;
using Newtonsoft.Json;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-25)]
[Inspectable, MessagePackObject, Order(-25)]
public class SwitchData : BehaviorData
{
public override Behavior CreateInstance(EquippedItem item)

View file

@ -1,24 +1,22 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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.Linq;
using MessagePack;
using Newtonsoft.Json;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-22)]
[Inspectable, MessagePackObject, Order(-22)]
public class ThermotoggleData : BehaviorData
{
[InspectableTemperature, JsonProperty("targetTemp"), Key(1)]
[InspectableTemperature, Key(1)]
public float TargetTemperature;
[Inspectable, JsonProperty("highPass"), Key(2)]
[Inspectable, Key(2)]
public bool HighPass;
[Inspectable, JsonProperty("adjustable"), Key(3)]
[Inspectable, Key(3)]
public bool Adjustable;
public override Behavior CreateInstance(EquippedItem item)
{
return new Thermotoggle(this, item);

View file

@ -3,33 +3,32 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), EntityTypeRestriction(HullType.Ship), RuntimeInspectable]
[Inspectable, MessagePackObject, EntityTypeRestriction(HullType.Ship), RuntimeInspectable]
public class ThrusterData : BehaviorData
{
[Inspectable, JsonProperty("thrust"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat Thrust = new PerformanceStat();
[Inspectable, JsonProperty("visibility"), Key(2), RuntimeInspectable]
[Inspectable, Key(2), RuntimeInspectable]
public PerformanceStat Visibility = new PerformanceStat();
[Inspectable, JsonProperty("heat"), Key(3), RuntimeInspectable]
[Inspectable, Key(3), RuntimeInspectable]
public PerformanceStat Heat = new PerformanceStat();
[Inspectable, JsonProperty("energy"), Key(4), RuntimeInspectable]
[Inspectable, Key(4), RuntimeInspectable]
public PerformanceStat EnergyUsage = new PerformanceStat();
[InspectablePrefab, JsonProperty("Particles"), Key(5)]
[InspectablePrefab, Key(5)]
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);
@ -48,7 +47,7 @@ public class Thruster : Behavior, IAnalogBehavior
}
private ThrusterData _data;
private float _input;
public Thruster(ThrusterData data, EquippedItem item) : base(data, item)

View file

@ -1,13 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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.Linq;
using MessagePack;
using Newtonsoft.Json;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(-20)]
[Inspectable, MessagePackObject, Order(-20)]
public class TriggerData : BehaviorData
{
public override Behavior CreateInstance(EquippedItem item)

View file

@ -1,17 +1,16 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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 System.Linq;
using MessagePack;
using Newtonsoft.Json;
using UniRx;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using float3 = Unity.Mathematics.float3;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[MessagePackObject, RuntimeInspectable]
public class TurretControllerData : BehaviorData
{
public override Behavior CreateInstance(EquippedItem item)

View file

@ -3,16 +3,15 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[MessagePackObject, RuntimeInspectable]
public class VelocityConversionData : BehaviorData
{
[Inspectable, JsonProperty("lambda"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat Lambda = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new VelocityConversion(this, item);

View file

@ -3,16 +3,15 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class VelocityLimitData : BehaviorData
{
[Inspectable, JsonProperty("topSpeed"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat TopSpeed = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new VelocityLimit(this, item);

View file

@ -1,21 +1,19 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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.Linq;
using MessagePack;
using Newtonsoft.Json;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), RuntimeInspectable]
[Inspectable, MessagePackObject, RuntimeInspectable]
public class VisibilityData : BehaviorData
{
[Inspectable, JsonProperty("visibility"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public PerformanceStat Visibility = new PerformanceStat();
[Inspectable, JsonProperty("visibilityDecay"), Key(2)]
[Inspectable, Key(2)]
public PerformanceStat VisibilityDecay = new PerformanceStat();
public override Behavior CreateInstance(EquippedItem item)
{
return new Visibility(this, item);

View file

@ -6,64 +6,63 @@ using System;
using System.Collections.Generic;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable,
[Inspectable,
Union(0, typeof(InstantWeaponData)),
Union(1, typeof(LauncherData)),
Union(2, typeof(ConstantWeaponData)),
Union(3, typeof(ChargedWeaponData)),
Union(2, typeof(ConstantWeaponData)),
Union(3, typeof(ChargedWeaponData)),
RuntimeInspectable]
public abstract class WeaponData : BehaviorData
{
[Inspectable, JsonProperty("damageType"), Key(1), RuntimeInspectable]
[Inspectable, Key(1), RuntimeInspectable]
public DamageType DamageType;
[Inspectable, JsonProperty("damage"), Key(2), RuntimeInspectable]
[Inspectable, Key(2), RuntimeInspectable]
public PerformanceStat Damage = new PerformanceStat();
[InspectableRangedFloat(0,1), JsonProperty("penetration"), Key(3), RuntimeInspectable]
[InspectableRangedFloat(0,1), Key(3), RuntimeInspectable]
public PerformanceStat Penetration = new PerformanceStat();
[InspectableRangedFloat(0,1), JsonProperty("damageSpread"), Key(4)]
[InspectableRangedFloat(0,1), Key(4)]
public PerformanceStat DamageSpread = new PerformanceStat();
[Inspectable, JsonProperty("minRange"), Key(5)]
[Inspectable, Key(5)]
public PerformanceStat MinRange = new PerformanceStat();
[Inspectable, JsonProperty("range"), Key(6)]
[Inspectable, Key(6)]
public PerformanceStat Range = new PerformanceStat();
[InspectableAnimationCurve, JsonProperty("damageCurve"), Key(7)]
[InspectableAnimationCurve, Key(7)]
public BezierCurve DamageCurve;
[InspectablePrefab, JsonProperty("effect"), Key(8)]
[InspectablePrefab, Key(8)]
public string EffectPrefab;
[InspectablePrefab, JsonProperty("energy"), Key(9), RuntimeInspectable]
[InspectablePrefab, Key(9), RuntimeInspectable]
public PerformanceStat Energy = new PerformanceStat();
[InspectablePrefab, JsonProperty("heat"), Key(10), RuntimeInspectable]
[InspectablePrefab, Key(10), RuntimeInspectable]
public PerformanceStat Heat = new PerformanceStat();
[InspectablePrefab, JsonProperty("visibility"), Key(11), RuntimeInspectable]
[InspectablePrefab, Key(11), RuntimeInspectable]
public PerformanceStat Visibility = new PerformanceStat();
[InspectableDatabaseLink(typeof(SimpleCommodityData)), JsonProperty("ammo"), Key(12), RuntimeInspectable]
[InspectableDatabaseLink(typeof(SimpleCommodityData)), Key(12), RuntimeInspectable]
public Guid AmmoType;
[InspectablePrefab, JsonProperty("magSize"), Key(13)]
[InspectablePrefab, Key(13)]
public int MagazineSize;
[InspectablePrefab, JsonProperty("reloadTime"), Key(14)]
[InspectablePrefab, Key(14)]
public float ReloadTime = 1;
[InspectablePrefab, JsonProperty("spread"), Key(15)]
[InspectablePrefab, Key(15)]
public PerformanceStat Spread = new PerformanceStat();
[Inspectable, JsonProperty("velocity"), Key(16)]
[Inspectable, Key(16)]
public PerformanceStat Velocity = new PerformanceStat();
}
@ -75,7 +74,7 @@ public abstract class Weapon : Behavior, IActivatedBehavior
public abstract float RangeDamagePerSecond(float range);
public abstract int Ammo { get; }
public WeaponData WeaponData => _data;
public float Damage { get; protected set; }
public float Penetration { get; protected set; }
public float DamageSpread { get; protected set; }
@ -93,12 +92,12 @@ public abstract class Weapon : Behavior, IActivatedBehavior
{
get => _firing;
}
public Weapon(WeaponData data, EquippedItem item) : base(data, item)
{
_data = data;
}
public Weapon(WeaponData data, ConsumableItemEffect item) : base(data, item)
{
_data = data;

View file

@ -4,16 +4,15 @@
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn), Order(1000), RuntimeInspectable]
[Inspectable, MessagePackObject, Order(1000), RuntimeInspectable]
public class WearData : BehaviorData
{
[InspectableTemperature, JsonProperty("perSecond"), Key(1)]
[InspectableTemperature, Key(1)]
public bool PerSecond = true;
public override Behavior CreateInstance(EquippedItem item)
{
return new Wear(this, item);

View file

@ -1,21 +1,20 @@
using System;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class BezierCurve
{
[JsonProperty("keys"), Key(0)] public float4[] Keys;
[Key(0)] public float4[] Keys;
[IgnoreMember] private int2 _cachedIndices;
[IgnoreMember] private const int STEPS = 64;
[IgnoreMember] private float? _maximum;
[IgnoreMember]
public float Maximum
{
@ -38,7 +37,7 @@ public class BezierCurve
return _maximum??0;
}
}
// Integrate area under curve between start and end time
public float IntegrateCurve(float startTime, float endTime, int steps)
{
@ -61,26 +60,26 @@ public class BezierCurve
// {
// return 1 - (1 - a)*(1 - b);
// }
public float Evaluate(float time)
{
// Clamp time
time = clamp(time, Keys[0].x, Keys[Keys.Length - 1].x);
FindSurroundingKeyframes(time, Keys);
FindSurroundingKeyframes(time, Keys);
return HermiteInterpolate(time, Keys[_cachedIndices.x], Keys[_cachedIndices.y]);
}
void FindSurroundingKeyframes(float time, float4[] curve)
{
// Check that time is within cached keyframe time
if (time >= curve[_cachedIndices.x].x &&
if (time >= curve[_cachedIndices.x].x &&
time <= curve[_cachedIndices.y].x)
{
return;
}
// Fall back to using dichotomic search.
var length = curve.Length;
int half;

View file

@ -6,57 +6,56 @@ using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
[LegacyCatalogGroup("Galaxy"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[LegacyCatalogGroup("Galaxy"), Inspectable, MessagePackObject]
public class Faction : DatabaseEntry, INamedEntry
{
[Inspectable, JsonProperty("name"), Key(1)]
[Inspectable, Key(1)]
public string Name;
[Inspectable, JsonProperty("shortName"), Key(2)]
[Inspectable, Key(2)]
public string ShortName;
[InspectableText, JsonProperty("description"), Key(3)]
[InspectableText, Key(3)]
public string Description;
[InspectableTexture, JsonProperty("logo"), Key(4)]
[InspectableTexture, Key(4)]
public string Logo;
[InspectableDatabaseLink(typeof(PersonalityAttribute)), JsonProperty("personality"), Key(5)]
[InspectableDatabaseLink(typeof(PersonalityAttribute)), Key(5)]
public Dictionary<Guid, float> Personality = new Dictionary<Guid, float>();
// [Inspectable, JsonProperty("hostile"), Key(6)]
// [Inspectable, Key(6)]
// public bool PlayerHostile;
[InspectableColor, JsonProperty("primaryColor"), Key(7)]
[InspectableColor, Key(7)]
public float3 PrimaryColor;
[InspectableColor, JsonProperty("secondaryColor"), Key(8)]
[InspectableColor, Key(8)]
public float3 SecondaryColor;
[InspectableDatabaseLink(typeof(NameFile)), JsonProperty("nameFile"), Key(9)]
[InspectableDatabaseLink(typeof(NameFile)), Key(9)]
public Guid GeonameFile;
[InspectableDatabaseLink(typeof(HullData)), JsonProperty("bossHull"), Key(10)]
[InspectableDatabaseLink(typeof(HullData)), Key(10)]
public Guid BossHull;
[Inspectable, JsonProperty("influence"), Key(11)]
[Inspectable, Key(11)]
public int InfluenceDistance = 4;
[InspectableDatabaseLink(typeof(Faction)), RangedFloat(0, 1), JsonProperty("allegiance"), Key(12)]
[InspectableDatabaseLink(typeof(Faction)), RangedFloat(0, 1), Key(12)]
public Dictionary<Guid, float> Allegiance = new Dictionary<Guid, float>();
[InspectableSoundBank, JsonProperty("overworldMusic"), Key(13)]
[InspectableSoundBank, Key(13)]
public uint OverworldMusic;
[InspectableSoundBank, JsonProperty("combatMusic"), Key(14)]
[InspectableSoundBank, Key(14)]
public uint CombatMusic;
[InspectableSoundBank, JsonProperty("bossMusic"), Key(15)]
[InspectableSoundBank, Key(15)]
public uint BossMusic;
[IgnoreMember] public string EntryName
{
get => Name;

View file

@ -1,13 +1,11 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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.Linq;
using JsonKnownTypes;
using MessagePack;
using MessagePack.Formatters;
using Newtonsoft.Json;
// TODO: USE THIS EVERYWHERE
using Unity.Mathematics;
using static Unity.Mathematics.math;
@ -18,42 +16,40 @@ public interface INamedEntry
}
[MessagePackObject,
JsonObject(MemberSerialization.OptIn),
JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>)),
Union(0, typeof(SimpleCommodityData)),
Union(0, typeof(SimpleCommodityData)),
Union(1, typeof(CompoundCommodityData)),
Union(2, typeof(GearData)),
Union(3, typeof(HullData)),
Union(4, typeof(SimpleCommodity)),
Union(5, typeof(CompoundCommodity)),
Union(2, typeof(GearData)),
Union(3, typeof(HullData)),
Union(4, typeof(SimpleCommodity)),
Union(5, typeof(CompoundCommodity)),
Union(6, typeof(EquippableItem)),
Union(8, typeof(GalaxyMapLayerData)),
Union(9, typeof(NameFile)),
//Union(10, typeof(ZoneData)),
Union(11, typeof(PlayerData)),
Union(9, typeof(NameFile)),
//Union(10, typeof(ZoneData)),
Union(11, typeof(PlayerData)),
// Union(12, typeof(Corporation)),
Union(13, typeof(Faction)),
Union(14, typeof(OrbitalEntity)),
Union(15, typeof(OrbitData)),
Union(14, typeof(OrbitalEntity)),
Union(15, typeof(OrbitData)),
Union(16, typeof(BodyData)),
Union(17, typeof(PersonalityAttribute)),
Union(18, typeof(AgentTask)),
// Union(19, typeof(LoadoutData)),
Union(20, typeof(Ship)),
Union(21, typeof(Mining)),
Union(22, typeof(StationTowing)),
Union(23, typeof(Survey)),
Union(24, typeof(HaulingTask)),
Union(25, typeof(AsteroidBeltData)),
Union(26, typeof(GasGiantData)),
Union(27, typeof(SunData)),
Union(28, typeof(PlanetData)),
Union(29, typeof(CargoBayData)),
Union(30, typeof(DockingBayData)),
Union(22, typeof(StationTowing)),
Union(23, typeof(Survey)),
Union(24, typeof(HaulingTask)),
Union(25, typeof(AsteroidBeltData)),
Union(26, typeof(GasGiantData)),
Union(27, typeof(SunData)),
Union(28, typeof(PlanetData)),
Union(29, typeof(CargoBayData)),
Union(30, typeof(DockingBayData)),
Union(31, typeof(WeaponItemData))]
public abstract class DatabaseEntry
{
[JsonProperty("id"), Key(0)]
[Key(0)]
public Guid ID = Guid.NewGuid();
public override int GetHashCode()
@ -68,19 +64,19 @@ public abstract class DatabaseEntry
}
}
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class DatabaseLink<T> : DatabaseLinkBase where T : DatabaseEntry
{
[IgnoreMember]
public T Value => Cache.Get<T>(LinkID);
}
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class DatabaseLinkBase
{
[Key(0), JsonProperty("linkID")]
[Key(0)]
public Guid LinkID;
[IgnoreMember]
public static CultCache Cache;
}

View file

@ -1,169 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Unity.Mathematics;
using static Unity.Mathematics.math;
public class MathJsonConverter : JsonConverter
{
private readonly Dictionary<Type, Action<JsonWriter, object>> _writers;
private readonly Dictionary<Type, Func<JArray, object>> _readers;
public MathJsonConverter()
{
_writers = GenerateWriters();
_readers = GenerateReaders();
}
private Dictionary<Type, Action<JsonWriter, object>> GenerateWriters()
{
var writers = new Dictionary<Type, Action<JsonWriter, object>>();
writers[typeof(float2)] = (writer, o) =>
{
if (!(o is float2 v))
throw new JsonReaderException();
writer.WriteStartArray();
writer.WriteValue(v.x);
writer.WriteValue(v.y);
writer.WriteEndArray();
};
writers[typeof(int2)] = (writer, o) =>
{
if (!(o is int2 v))
throw new JsonReaderException();
writer.WriteStartArray();
writer.WriteValue(v.x);
writer.WriteValue(v.y);
writer.WriteEndArray();
};
writers[typeof(float3)] = (writer, o) =>
{
if (!(o is float3 v))
throw new JsonReaderException();
writer.WriteStartArray();
writer.WriteValue(v.x);
writer.WriteValue(v.y);
writer.WriteValue(v.z);
writer.WriteEndArray();
};
writers[typeof(float4)] = (writer, o) =>
{
if (!(o is float4 v))
throw new JsonReaderException();
writer.WriteStartArray();
writer.WriteValue(v.x);
writer.WriteValue(v.y);
writer.WriteValue(v.z);
writer.WriteValue(v.w);
writer.WriteEndArray();
};
return writers;
}
private Dictionary<Type, Func<JArray, object>> GenerateReaders()
{
var readers = new Dictionary<Type, Func<JArray, object>>();
readers[typeof(float2)] = array =>
{
if (array.Count < 2)
{
throw new JsonReaderException(
$"Could not read {typeof(float2)} from json, expected a json array with 2 elements");
}
return float2(
array[0].ToObject<float>(),
array[1].ToObject<float>());
};
readers[typeof(int2)] = array =>
{
if (array.Count < 2)
{
throw new JsonReaderException(
$"Could not read {typeof(float2)} from json, expected a json array with 2 elements");
}
return int2(
array[0].ToObject<int>(),
array[1].ToObject<int>());
};
readers[typeof(float3)] = array =>
{
if (array.Count < 3)
{
throw new JsonReaderException(
$"Could not read {typeof(float3)} from json, expected a json array with 3 elements");
}
return float3(
array[0].ToObject<float>(),
array[1].ToObject<float>(),
array[2].ToObject<float>());
};
readers[typeof(float4)] = array =>
{
if (array.Count < 4)
{
throw new JsonReaderException(
$"Could not read {typeof(float4)} from json, expected a json array with 4 elements");
}
return float4(
array[0].ToObject<float>(),
array[1].ToObject<float>(),
array[2].ToObject<float>(),
array[3].ToObject<float>());
};
return readers;
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
if (_writers.TryGetValue(value.GetType(), out var serializeAction))
serializeAction(writer, value);
else
throw new JsonReaderException($"Invalid type for ValueConverter:{value.GetType()}");
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (_readers.TryGetValue(objectType, out var deserializeFunc))
{
// Convert token from reader to array for deserialize function
var token = JToken.ReadFrom(reader);
if (!(token is JArray asArray))
throw new JsonReaderException(
$"Could not read {objectType} from json, expected a json array but got {token.Type}");
return deserializeFunc(asArray);
}
throw new JsonReaderException($"Invalid type for ValueConverter:{objectType}");
}
public override bool CanConvert(Type objectType)
{
//If the dictionary contains the key, the type can be handled by this class
return _writers.ContainsKey(objectType);
}
//Enable this JSON Converter for reading as well as writing values
public override bool CanRead => true;
public override bool CanWrite => true;
}

View file

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: fafad9d553198e942a5501ea1472ec9c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: f94c63c8b140fb34bb5d70a8d8a5dbd6
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,16 +0,0 @@
using System;
namespace JsonKnownTypes
{
public static class AttributesManager
{
public static JsonKnownTypeAttribute[] GetJsonKnownAttributes(Type type) =>
(JsonKnownTypeAttribute[])Attribute.GetCustomAttributes(type, typeof(JsonKnownTypeAttribute));
public static JsonKnownThisTypeAttribute GetJsonKnownThisAttribute(Type type) =>
(JsonKnownThisTypeAttribute)Attribute.GetCustomAttribute(type, typeof(JsonKnownThisTypeAttribute));
public static JsonDiscriminatorAttribute GetJsonDiscriminatorAttribute(Type type) =>
(JsonDiscriminatorAttribute)Attribute.GetCustomAttribute(type, typeof(JsonDiscriminatorAttribute));
}
}

View file

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 6036d25d64e90064ca92c91f6d7827b2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 01722fba3f2fd3942bca61d48508ad27
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,15 +0,0 @@
using System;
namespace JsonKnownTypes.Exceptions
{
public class JsonKnownTypesException : Exception
{
public JsonKnownTypesException(string message)
: base(message)
{ }
public JsonKnownTypesException(string message, Exception innerException)
: base(message, innerException)
{ }
}
}

View file

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 36f9ed87d773cf146bf68e828cefe89c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,18 +0,0 @@
using System;
namespace JsonKnownTypes
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)]
public class JsonDiscriminatorAttribute : Attribute
{
public string Name { get; set; }
internal bool? _autoJson;
public bool AutoJson
{
get => _autoJson != null && (bool) _autoJson;
set => _autoJson = value;
}
}
}

View file

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: f7c6582f43e22994ebbaf0e139e63dc5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,8 +0,0 @@
namespace JsonKnownTypes
{
public class JsonDiscriminatorSettings
{
public string Name { get; set; } = "$type";
public bool AutoJsonKnown { get; set; } = true;
}
}

View file

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: b5f09ee78f257904caa3ab939d3edc65
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,17 +0,0 @@
using System;
namespace JsonKnownTypes
{
public class JsonKnownThisTypeAttribute : Attribute
{
public string Discriminator { get; }
public JsonKnownThisTypeAttribute()
{ }
public JsonKnownThisTypeAttribute(string discriminator)
{
Discriminator = discriminator;
}
}
}

View file

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: c8dc4cbd1c54167409cf14ec8ec37d70
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,22 +0,0 @@
using System;
namespace JsonKnownTypes
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true)]
public class JsonKnownTypeAttribute : Attribute
{
public Type Type { get; }
public string Discriminator { get; }
public JsonKnownTypeAttribute(Type type)
{
Type = type;
}
public JsonKnownTypeAttribute(Type type, string discriminator)
{
Type = type;
Discriminator = discriminator;
}
}
}

View file

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: ecbe3646a4d9ca04eac598b60e5c77ca
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,22 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
</ItemGroup>
<PropertyGroup>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>0.2.0</Version>
<Authors>Dmitry Kaznacheev</Authors>
<PackageProjectUrl>https://github.com/dmitry-bym/JsonKnownTypes</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/dmitry-bym/JsonKnownTypes/blob/master/LICENSE</PackageLicenseUrl>
<Copyright>Dmitry Kaznacheev</Copyright>
<RepositoryUrl>https://github.com/dmitry-bym/JsonKnownTypes</RepositoryUrl>
<PackageTags>json known polymorphic types</PackageTags>
</PropertyGroup>
</Project>

View file

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 937d902757d946b47a7bea20ade37beb
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,16 +0,0 @@
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace JsonKnownTypes
{
public class JsonKnownTypesContractResolver<T> : DefaultContractResolver
{
protected override JsonConverter ResolveContractConverter(Type objectType)
{
if (typeof(T).IsAssignableFrom(objectType) && !objectType.IsAbstract)
return null;
return base.ResolveContractConverter(objectType);
}
}
}

View file

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: bce1b7fa2da230447b3614d23394ee9f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,57 +0,0 @@
using System;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace JsonKnownTypes
{
public class JsonKnownTypesConverter<T> : JsonConverter
{
private readonly JsonKnownTypesSettings _typesSettings
= JsonKnownTypesSettingsManager.GetSettings<T>();
private JsonSerializerSettings SpecifiedSubclassConversion
{
get =>
new JsonSerializerSettings
{
ContractResolver = new JsonKnownTypesContractResolver<T>()
};
}
public override bool CanConvert(Type objectType)
=> _typesSettings.TypeToDiscriminator.ContainsKey(objectType);
public override bool CanWrite { get => true; }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Null) return null;
var jo = JObject.Load(reader);
var discriminator = jo[_typesSettings.Name].ToString();
if(_typesSettings.DiscriminatorToType.TryGetValue(discriminator, out var typeForObject))
return JsonConvert.DeserializeObject(jo.ToString(), typeForObject, SpecifiedSubclassConversion);
return null;
//throw new NotImplementedException();
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var objectType = value.GetType();
if (_typesSettings.TypeToDiscriminator.TryGetValue(objectType, out var discriminator))
{
var json = JsonConvert.SerializeObject(value, SpecifiedSubclassConversion);
var jo = JObject.Parse(json);
jo.Add(_typesSettings.Name, new JValue(discriminator));
jo.WriteTo(writer);
}
else
{
throw new ArgumentException($"Json Known Types: Type Unknown {objectType.FullName}!");
}
}
}
}

View file

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: b0a6c832fc846634789aa691cd2b81d9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,64 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using JsonKnownTypes.Exceptions;
namespace JsonKnownTypes
{
internal static class JsonKnownTypesDictionaryManager
{
public static void AddJsonKnown<T>(this Dictionary<Type, string> dictionary)
{
var attrs = AttributesManager.GetJsonKnownAttributes(typeof(T));
foreach (var attr in attrs)
{
var discriminator = attr.Discriminator ?? attr.Type.Name;
dictionary.TryAdd(attr.Type, discriminator);
}
}
public static void AddJsonKnownThis(this Dictionary<Type, string> dictionary, Type[] inherited)
{
foreach (var type in inherited)
{
var attr = AttributesManager.GetJsonKnownThisAttribute(type);
if (attr != null)
{
var discriminator = attr.Discriminator ?? type.Name;
dictionary.TryAdd(type, discriminator);
}
}
}
public static void AddAutoGenerated(this Dictionary<Type, string> dictionary, Type[] inherited)
{
foreach (var type in inherited.Except(dictionary.Keys))
{
dictionary.TryAdd(type, type.Name);
}
}
public static void TryAdd(this Dictionary<Type, string> dictionary, Type key, string discriminator)
{
if (dictionary.ContainsKey(key))
throw new JsonKnownTypesException($"Dictionary already contains the key {key.Name}");//todo
if (dictionary.ContainsValue(discriminator))
throw new JsonKnownTypesException($"Dictionary already contains the value {discriminator}");//todo
dictionary.Add(key, discriminator);
}
public static Dictionary<string, Type> Revert(this Dictionary<Type, string> dictionary)
{
try
{
return dictionary.ToDictionary(x => x.Value, x => x.Key);
}
catch (ArgumentException e)
{
throw new JsonKnownTypesException("Dictionary has a repeated value", e);
}
}
}
}

View file

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 77ce621509349204a87085f089b3daa3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
namespace JsonKnownTypes
{
public class JsonKnownTypesSettings
{
public string Name { get; set; }
public Dictionary<string, Type> DiscriminatorToType { get; set; } = new Dictionary<string, Type>();
public Dictionary<Type, string> TypeToDiscriminator { get; set; } = new Dictionary<Type, string>();
}
}

View file

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 99b988650c739094aa3a5ba7040ea379
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,60 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using JsonKnownTypes.Exceptions;
using JsonKnownTypes.Utils;
namespace JsonKnownTypes
{
public static class JsonKnownTypesSettingsManager
{
public static JsonDiscriminatorSettings DefaultDiscriminatorSettings { get; set; } = new JsonDiscriminatorSettings();
private static HashSet<Assembly> RegisteredAssemblies = new HashSet<Assembly>();
public static void RegisterTypeAssembly<T>()
{
var type = typeof(T);
RegisteredAssemblies.Add(type.Assembly);
}
public static JsonKnownTypesSettings GetSettings<T>()
{
var discriminatorAttribute = AttributesManager.GetJsonDiscriminatorAttribute(typeof(T));
var discriminatorSettings = discriminatorAttribute == null ? DefaultDiscriminatorSettings : Mapper.Map(discriminatorAttribute);
var typeSettings = new JsonKnownTypesSettings
{
Name = discriminatorSettings.Name
};
var allTypes = GetAllInheritance<T>();
typeSettings.TypeToDiscriminator.AddJsonKnown<T>();
typeSettings.TypeToDiscriminator.AddJsonKnownThis(allTypes);
if (discriminatorSettings.AutoJsonKnown)
{
typeSettings.TypeToDiscriminator.AddAutoGenerated(allTypes);
}
else if(!allTypes.All(typeSettings.TypeToDiscriminator.ContainsKey))
{
throw new JsonKnownTypesException("Dictionary contains not all types of hierarchy, enable AutoJsonKnow or add attributes for all classes"); //todo
}
typeSettings.DiscriminatorToType = typeSettings.TypeToDiscriminator.Revert();
return typeSettings;
}
private static Type[] GetAllInheritance<T>()
{
RegisterTypeAssembly<T>();
var type = typeof(T);
return RegisteredAssemblies.SelectMany(a=>a.GetTypes())
.Where(x => type.IsAssignableFrom(x) && !x.IsInterface && !x.IsAbstract)
.ToArray();
}
}
}

View file

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: a361505c5408b374788cbaeed6fa2f55
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 6d6706b0998d8af458321fd5f35906fb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,15 +0,0 @@
namespace JsonKnownTypes.Utils
{
internal static class Mapper
{
public static JsonDiscriminatorSettings Map(JsonDiscriminatorAttribute entity)
{
var settings = new JsonDiscriminatorSettings();
settings.Name = entity.Name ?? settings.Name;
settings.AutoJsonKnown = entity._autoJson ?? settings.AutoJsonKnown;
return settings;
}
}
}

View file

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: c30d51fc767627a41b65f5cdd2b22cc3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,11 +1,9 @@
using System;
using MessagePack;
using Newtonsoft.Json;
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class EnumDictionary<E, T> where E : Enum
{
[JsonProperty("values"), Key(0)] public T[] Values;
[Key(0)] public T[] Values;
public EnumDictionary()
{

View file

@ -1,86 +1,85 @@
using System;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using static Unity.Mathematics.noise;
using float2 = Unity.Mathematics.float2;
[Serializable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Serializable, MessagePackObject]
public class ZoneEnvironment
{
[JsonProperty("nebula"), Key(0)] public NebulaSettings Nebula;
[JsonProperty("flow"), Key(1)] public FlowSettings Flow;
[JsonProperty("noise"), Key(2)] public NoiseSettings Noise;
[JsonProperty("lighting"), Key(3)] public AmbientLightingSettings Lighting;
[JsonProperty("grid"), Key(4)] public GridSettings Grid;
[Key(0)] public NebulaSettings Nebula;
[Key(1)] public FlowSettings Flow;
[Key(2)] public NoiseSettings Noise;
[Key(3)] public AmbientLightingSettings Lighting;
[Key(4)] public GridSettings Grid;
}
[Serializable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Serializable, MessagePackObject]
public class NebulaSettings
{
[JsonProperty("fillDensity"), Key(0)] public float FillDensity;
[JsonProperty("fillDistance"), Key(1)] public float FillDistance;
[JsonProperty("fillExponent"), Key(2)] public float FillExponent;
[JsonProperty("fillOffset"), Key(12)] public float FillOffset;
[JsonProperty("cloudDensity"), Key(3)] public float PatchDensity;
[JsonProperty("fogOffset"), Key(4)] public float FloorOffset;
[JsonProperty("fogBlend"), Key(5)] public float FloorBlend;
[JsonProperty("cloudBlend"), Key(6)] public float PatchBlend;
[JsonProperty("luminance"), Key(7)] public float Luminance;
[JsonProperty("extinction"), Key(13)] public float Extinction;
//[JsonProperty("tintExponent"), Key(8)] public float TintExponent;
[JsonProperty("tintLodExponent"), Key(9)] public float TintLodExponent;
[JsonProperty("safetyDistance"), Key(10)] public float SafetyDistance;
[Key(0)] public float FillDensity;
[Key(1)] public float FillDistance;
[Key(2)] public float FillExponent;
[Key(12)] public float FillOffset;
[Key(3)] public float PatchDensity;
[Key(4)] public float FloorOffset;
[Key(5)] public float FloorBlend;
[Key(6)] public float PatchBlend;
[Key(7)] public float Luminance;
[Key(13)] public float Extinction;
//[Key(8)] public float TintExponent;
[Key(9)] public float TintLodExponent;
[Key(10)] public float SafetyDistance;
}
[Serializable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Serializable, MessagePackObject]
public class GridSettings
{
[JsonProperty("enabled"), Key(0)] public bool Enabled;
[JsonProperty("offset"), Key(1)] public float Offset;
[Key(0)] public bool Enabled;
[Key(1)] public float Offset;
}
[Serializable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Serializable, MessagePackObject]
public class AmbientLightingSettings
{
[JsonProperty("dynamicSkyBoost"), Key(0)] public float DynamicSkyBoost;
[JsonProperty("dynamicLodHigh"), Key(1)] public float DynamicLodHigh;
[JsonProperty("dynamicLodLow"), Key(2)] public float DynamicLodLow;
[JsonProperty("dynamicIntensity"), Key(3)] public float DynamicIntensity;
[Key(0)] public float DynamicSkyBoost;
[Key(1)] public float DynamicLodHigh;
[Key(2)] public float DynamicLodLow;
[Key(3)] public float DynamicIntensity;
}
[Serializable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Serializable, MessagePackObject]
public class FlowSettings
{
[JsonProperty("scale"), Key(0)] public float GlobalScale;
[JsonProperty("amplitudeGlobal"), Key(1)] public float GlobalAmplitude;
[JsonProperty("scrollSpeed"), Key(2)] public float GlobalScrollSpeed;
[JsonProperty("period"), Key(3)] public float Period;
[JsonProperty("amplitudeSlope"), Key(4)] public float SlopeAmplitude;
[JsonProperty("amplitudeSwirl"), Key(5)] public float SwirlAmplitude;
[Key(0)] public float GlobalScale;
[Key(1)] public float GlobalAmplitude;
[Key(2)] public float GlobalScrollSpeed;
[Key(3)] public float Period;
[Key(4)] public float SlopeAmplitude;
[Key(5)] public float SwirlAmplitude;
}
[Serializable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Serializable, MessagePackObject]
public class NoiseSettings
{
[JsonProperty("scale"), Key(0)] public float Scale;
[JsonProperty("amplitude"), Key(1)] public float Amplitude;
[JsonProperty("exponent"), Key(2)] public float Exponent;
[JsonProperty("speed"), Key(3)] public float Speed;
[JsonProperty("slopeExponent"), Key(4)] public float SlopeExponent;
[Key(0)] public float Scale;
[Key(1)] public float Amplitude;
[Key(2)] public float Exponent;
[Key(3)] public float Speed;
[Key(4)] public float SlopeExponent;
}
[Union(0, typeof(PowerBrush)),
Union(1, typeof(SimplexBrush)),
Serializable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Union(0, typeof(PowerBrush)),
Union(1, typeof(SimplexBrush)),
Serializable, MessagePackObject]
public abstract class Brush
{
[JsonProperty("layerMask"), Key(0)] public BrushLayer LayerMask;
[JsonProperty("cutoff"), Key(1)] public float Cutoff;
[JsonProperty("depth"), Key(2)] public float Depth;
[JsonProperty("envelopeExponent"), Key(3)] public float EnvelopeExponent;
[Key(0)] public BrushLayer LayerMask;
[Key(1)] public float Cutoff;
[Key(2)] public float Depth;
[Key(3)] public float EnvelopeExponent;
float powerPulse( float x, float power )
{
x = saturate(abs(x))-.001f;
@ -98,7 +97,7 @@ public abstract class Brush
}
}
[Serializable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Serializable, MessagePackObject]
public class PowerBrush : Brush
{
protected override float Evaluate(float2 world, float2 uv)
@ -107,27 +106,27 @@ public class PowerBrush : Brush
}
}
[Serializable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Serializable, MessagePackObject]
public abstract class TextureBrush : Brush
{
[JsonProperty("frequency"), Key(4)] public float2 Frequency;
[JsonProperty("phase"), Key(5)] public float2 Phase;
[Key(4)] public float2 Frequency;
[Key(5)] public float2 Phase;
}
[Serializable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Serializable, MessagePackObject]
public abstract class AnimatedBrush : TextureBrush
{
[JsonProperty("animationSpeed"), Key(6)] public float AnimationSpeed;
[Key(6)] public float AnimationSpeed;
[IgnoreMember]
public float Time { get; set; }
}
[Serializable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Serializable, MessagePackObject]
public class SimplexBrush : TextureBrush
{
[JsonProperty("absolute"), Key(6)] public bool AbsoluteValue;
[Key(6)] public bool AbsoluteValue;
protected override float Evaluate(float2 world, float2 uv)
{
var noise = snoise(world * Frequency + Phase);
@ -135,11 +134,11 @@ public class SimplexBrush : TextureBrush
}
}
[Serializable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Serializable, MessagePackObject]
public class AnimatedSimplexBrush : AnimatedBrush
{
[JsonProperty("absolute"), Key(7)] public bool AbsoluteValue;
[Key(7)] public bool AbsoluteValue;
protected override float Evaluate(float2 world, float2 uv)
{
var noise = snoise(float3(float2(world * Frequency + Phase), AnimationSpeed * Time));
@ -147,11 +146,11 @@ public class AnimatedSimplexBrush : AnimatedBrush
}
}
[Serializable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Serializable, MessagePackObject]
public class RadialWaveBrush : TextureBrush
{
[JsonProperty("waveExponent"), Key(7)] public float WaveExponent;
[Key(7)] public float WaveExponent;
protected override float Evaluate(float2 world, float2 uv)
{
float dist = length(uv);

View file

@ -1,4 +1,4 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */
@ -6,36 +6,35 @@ using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Serializable, MessagePackObject, JsonObject]
[Serializable, MessagePackObject]
public class ExponentialCurve
{
[JsonProperty("exponent"), Key(0), Inspectable]
[Key(0), Inspectable]
public float Exponent;
[JsonProperty("multiplier"), Key(1), Inspectable]
[Key(1), Inspectable]
public float Multiplier;
[JsonProperty("constant"), Key(2), Inspectable]
[Key(2), Inspectable]
public float Constant;
public float Evaluate(float value) => Multiplier * pow(value, Exponent) + Constant;
}
[Serializable, MessagePackObject, JsonObject]
[Serializable, MessagePackObject]
public class ExponentialLerp
{
[JsonProperty("exponent"), Key(0), Inspectable]
[Key(0), Inspectable]
public float Exponent;
[JsonProperty("max"), Key(1), Inspectable]
[Key(1), Inspectable]
public float Minimum;
[JsonProperty("min"), Key(2), Inspectable]
[Key(2), Inspectable]
public float Maximum;
public float Evaluate(float value) => Minimum + pow(saturate(value), Exponent) * (Maximum - Minimum);
}

View file

@ -6,55 +6,54 @@ using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using static Unity.Mathematics.noise;
using static NoiseFbm;
[Inspectable, Serializable, LegacyCatalogGroup("Galaxy"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Inspectable, Serializable, LegacyCatalogGroup("Galaxy"), MessagePackObject]
public class GalaxyMapLayerData : DatabaseEntry, INamedEntry
{
[Inspectable, JsonProperty("coreBoost"), Key(1)]
[Inspectable, Key(1)]
public float CoreBoost = 1.05f;
[Inspectable, JsonProperty("coreBoostOffset"), Key(2)]
[Inspectable, Key(2)]
public float CoreBoostOffset = .1f;
[Inspectable, JsonProperty("coreBoostPower"), Key(3)]
[Inspectable, Key(3)]
public float CoreBoostPower = 2.25f;
[Inspectable, JsonProperty("spokeScale"), Key(4)]
[Inspectable, Key(4)]
public float SpokeScale = 1;
[Inspectable, JsonProperty("spokeOffset"), Key(5)]
[Inspectable, Key(5)]
public float SpokeOffset = 0;
[Inspectable, JsonProperty("edgeReduction"), Key(6)]
[Inspectable, Key(6)]
public float EdgeReduction = 3;
[Inspectable, JsonProperty("noiseOffset"), Key(7)]
[Inspectable, Key(7)]
public float NoiseOffset = 0;
[Inspectable, JsonProperty("noiseAmplitude"), Key(8)]
[Inspectable, Key(8)]
public float NoiseAmplitude = 1.5f;
[Inspectable, JsonProperty("noiseGain"), Key(9)]
[Inspectable, Key(9)]
public float NoiseGain = .7f;
[Inspectable, JsonProperty("noiseLacunarity"), Key(10)]
[Inspectable, Key(10)]
public float NoiseLacunarity = 2;
[Inspectable, JsonProperty("noiseOctaves"), Key(11)]
[Inspectable, Key(11)]
public int NoiseOctaves = 7;
[Inspectable, JsonProperty("noiseFrequency"), Key(12)]
[Inspectable, Key(12)]
public float NoiseFrequency = 1;
[Inspectable, JsonProperty("noisePosition"), Key(13)]
[Inspectable, Key(13)]
public float NoisePosition = 1337;
[Inspectable, JsonProperty("name"), Key(14)]
[Inspectable, Key(14)]
public string Name;
public float Evaluate(float2 uv, GalaxyShapeSettings settings)
@ -88,12 +87,12 @@ public static class NoiseFbm
fBm(p+10, octaves, frequency, offset, amplitude, lacunarity, gain),
fBm(p+20, octaves, frequency, offset, amplitude, lacunarity, gain));
}
public static float fBm(float2 p, int octaves, float frequency, float offset, float amplitude, float lacunarity, float gain)
{
float freq = frequency, amp = .5f;
float sum = 0;
for(int i = 0; i < octaves; i++)
float sum = 0;
for(int i = 0; i < octaves; i++)
{
sum += snoise(p * freq) * amp;
freq *= lacunarity;
@ -109,12 +108,12 @@ public static class NoiseFbm
fBm(p+10, octaves, frequency, offset, amplitude, lacunarity, gain),
fBm(p+20, octaves, frequency, offset, amplitude, lacunarity, gain));
}
public static float fBm(float p, int octaves, float frequency, float offset, float amplitude, float lacunarity, float gain)
{
float freq = frequency, amp = .5f;
float sum = 0;
for(int i = 0; i < octaves; i++)
float sum = 0;
for(int i = 0; i < octaves; i++)
{
sum += Noise1D.noise(p * freq) * amp;
freq *= lacunarity;

View file

@ -6,19 +6,17 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using JsonKnownTypes;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using float2 = Unity.Mathematics.float2;
using int2 = Unity.Mathematics.int2;
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Inspectable, MessagePackObject]
public class Shape
{
[JsonProperty("name"), Key(0)] public bool[,] Cells;
[Key(0)] public bool[,] Cells;
private bool _dirty = true;
public Shape()
@ -31,7 +29,7 @@ public class Shape
{
Cells = new bool[width, height];
}
[IgnoreMember]
public int Width
{
@ -49,7 +47,7 @@ public class Shape
public void Resize(int width, int height)
{
var newCells = new bool[width, height];
for (int x = 0; x < width; x++)
{
for (int y = 0; y < height; y++)
@ -65,7 +63,7 @@ public class Shape
int r = x%m;
return r<0 ? r+m : r;
}
public int2 Rotate(int2 position, ItemRotation rotation)
{
return rotation switch
@ -78,7 +76,7 @@ public class Shape
}
private int2[] _cachedShapeCoordinates;
[IgnoreMember]
public int2[] Coordinates
{
@ -105,7 +103,7 @@ public class Shape
}
private int2[] _cachedAllShapeCoordinates;
[IgnoreMember]
public int2[] AllCoordinates => _cachedAllShapeCoordinates ?? (_cachedAllShapeCoordinates = EnumerateAllShapeCoordinates().ToArray());
@ -142,7 +140,7 @@ public class Shape
foreach(var shapeCoord in Coordinates)
shape[shapeCoord] = (
this[shapeCoord + int2(-1,-1)] && this[shapeCoord + int2(0,-1)] && this[shapeCoord + int2(1,-1)] &&
this[shapeCoord + int2(-1,0)] && this[shapeCoord + int2(1,0)] &&
this[shapeCoord + int2(-1,0)] && this[shapeCoord + int2(1,0)] &&
this[shapeCoord + int2(-1,1)] && this[shapeCoord + int2(0,1)] && this[shapeCoord + int2(1,1)]
);
return shape;
@ -166,7 +164,7 @@ public class Shape
foreach (var shapeCoord in AllCoordinates)
shape[shapeCoord] = (
this[shapeCoord + int2(-1,-1)] || this[shapeCoord + int2(0,-1)] || this[shapeCoord + int2(1,-1)] ||
this[shapeCoord + int2(-1,0)] || this[shapeCoord] || this[shapeCoord + int2(1,0)] ||
this[shapeCoord + int2(-1,0)] || this[shapeCoord] || this[shapeCoord + int2(1,0)] ||
this[shapeCoord + int2(-1,1)] || this[shapeCoord + int2(0,1)] || this[shapeCoord + int2(1,1)]
);
return shape;
@ -191,7 +189,7 @@ public class Shape
position = int2.zero;
return false;
}
// Try to find a position with which a shape can be placed to fit within another shape
public bool FitsWithin(Shape other, ItemRotation rotation, out int2 position)
{
@ -221,11 +219,11 @@ public class Shape
// Set every cell on the line from a to b to true according to Bresenham's Line Algorithm
public void SetLine(float2 a, float2 b)
{
if (a.Equals(b))
{
if (a.Equals(b))
{
return;
}
// If line gradient is steep, swap x and y
bool steep = Math.Abs(b.y - a.y) > Math.Abs(b.x - a.x);
if (steep)
@ -241,11 +239,11 @@ public class Shape
a = b;
b = temp;
}
float dx = b.x - a.x;
float dy = b.y - a.y;
float derr = Math.Abs(dy / dx); // dx != 0
int y = (int) Math.Round(a.y);
int xStart = (int) Math.Round(a.x);
float error = (a.y - y) + (xStart - a.x) * derr;
@ -268,34 +266,34 @@ public class Shape
}
[MessagePackObject, JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<ItemData>))]
[MessagePackObject]
public abstract class ItemData : DatabaseEntry, INamedEntry
{
[Inspectable, JsonProperty("name"), Key(1)]
[Inspectable, Key(1)]
public string Name;
[InspectableText, JsonProperty("description"), Key(2)]
[InspectableText, Key(2)]
public string Description;
[InspectableDatabaseLink(typeof(Faction)), JsonProperty("creator"), Key(3)]
[InspectableDatabaseLink(typeof(Faction)), Key(3)]
public Guid Manufacturer;
[Inspectable, JsonProperty("mass"), Key(4)]
[Inspectable, Key(4)]
public float Mass;
[InspectableSchematicShape, JsonProperty("shape"), Key(5)]
[InspectableSchematicShape, Key(5)]
public Shape Shape;
// Heat needed to change temperature of 1 gram by 1 degree
[Inspectable, JsonProperty("specificHeat"), Key(6)]
[Inspectable, Key(6)]
public float SpecificHeat = 1;
[Inspectable, JsonProperty("conductivity"), Key(7)]
[Inspectable, Key(7)]
public float Conductivity = 1;
[Inspectable, JsonProperty("price"), Key(8)]
[Inspectable, Key(8)]
public int Price = 0;
[IgnoreMember] public string EntryName
{
get => Name;
@ -308,113 +306,112 @@ public abstract class ItemData : DatabaseEntry, INamedEntry
public class SimpleCommodityData : ItemData
{
// // Types of body where this resource can be found
// [InspectableField, JsonProperty("resourceBodyType"), Key(6)]
// [InspectableField, Key(6)]
// public BodyType ResourceBodyType;
//
// // Link to map(s) controlling density of resource, multiplied together when more than one
// [InspectableDatabaseLink(typeof(GalaxyMapLayerData)), JsonProperty("resourceDensity"), Key(7)]
// [InspectableDatabaseLink(typeof(GalaxyMapLayerData)), Key(7)]
// public List<Guid> ResourceDensity = new List<Guid>();
//
// // Controls the lowest value in the resource distribution curve
// [InspectableField, JsonProperty("distribution"), Key(8)]
// [InspectableField, Key(8)]
// public ExponentialLerp Distribution;
//
// // Minimum amount of resources needed for presence to register
// [InspectableField, JsonProperty("floor"), Key(11)]
// [InspectableField, Key(11)]
// public float Floor = 5f;
[Inspectable, JsonProperty("maxStackSize"), Key(9)]
[Inspectable, Key(9)]
public int MaxStack = 10;
[Inspectable, JsonProperty("category"), Key(10)]
[Inspectable, Key(10)]
public SimpleCommodityCategory Category;
}
[MessagePackObject, JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<CraftedItemData>))]
[MessagePackObject]
public abstract class CraftedItemData : ItemData
{
// [Inspectable, JsonProperty("ingredientQualityWeight"), Key(9)]
// [Inspectable, Key(9)]
// public float IngredientQualityWeight = .5f;
}
[LegacyCatalogGroup("Items"), Inspectable, MessagePackObject]
public class CompoundCommodityData : CraftedItemData
{
[InspectableDatabaseLink(typeof(PersonalityAttribute)), JsonProperty("demandProfile"), Key(10)]
[InspectableDatabaseLink(typeof(PersonalityAttribute)), Key(10)]
public Dictionary<Guid, float> DemandProfile = new Dictionary<Guid, float>();
[Inspectable, JsonProperty("category"), Key(11)]
[Inspectable, Key(11)]
public CompoundCommodityCategory Category;
}
[LegacyCatalogGroup("Items"), Inspectable, MessagePackObject]
public class ConsumableItemData : CraftedItemData
{
[Inspectable, JsonProperty("behaviors"), Key(10)]
[Inspectable, Key(10)]
public List<BehaviorData> Behaviors = new List<BehaviorData>();
[Inspectable, JsonProperty("stackable"), Key(11)]
[Inspectable, Key(11)]
public bool Stackable;
[Inspectable, JsonProperty("duration"), Key(12)]
[Inspectable, Key(12)]
public float Duration;
[InspectableTexture, JsonProperty("icon"), Key(13)]
[InspectableTexture, Key(13)]
public string Icon;
[Inspectable, JsonProperty("effectiveness"), Key(14)]
[Inspectable, Key(14)]
public BezierCurve Effectiveness;
}
[JsonObject(MemberSerialization.OptIn)]
public abstract class EquippableItemData : CraftedItemData
{
[InspectableTexture, JsonProperty("schematic"), Key(10)]
[InspectableTexture, Key(10)]
public string Schematic;
[Inspectable, JsonProperty("behaviors"), Key(11)]
[Inspectable, Key(11)]
public List<BehaviorData> Behaviors = new List<BehaviorData>();
[Inspectable, JsonProperty("durability"), Key(12)]
[Inspectable, Key(12)]
public float Durability;
[InspectableTemperature, JsonProperty("minTemp"), Key(13)]
[InspectableTemperature, Key(13)]
public float MinimumTemperature;
[InspectableTemperature, JsonProperty("maxTemp"), Key(14)]
[InspectableTemperature, Key(14)]
public float MaximumTemperature;
// [InspectableField, JsonProperty("durabilityExponent"), Key(15), SimplePerformanceStat]
// [InspectableField, Key(15), SimplePerformanceStat]
// public PerformanceStat DurabilityExponent = new PerformanceStat();
//
// [InspectableField, JsonProperty("heatExponent"), Key(16), SimplePerformanceStat]
// [InspectableField, Key(16), SimplePerformanceStat]
// public PerformanceStat HeatExponent = new PerformanceStat();
[InspectableAnimationCurve, JsonProperty("heatCurve"), Key(17)]
[InspectableAnimationCurve, Key(17)]
public BezierCurve HeatPerformanceCurve;
[Inspectable, JsonProperty("resilience"), Key(18)]
[Inspectable, Key(18)]
public float ThermalResilience = 1;
// [Inspectable, JsonProperty("sfx"), Key(19)]
// [Inspectable, Key(19)]
// public string SoundEffectTrigger;
[InspectableTexture, JsonProperty("actionIcon"), Key(20)]
[InspectableTexture, Key(20)]
public string ActionBarIcon;
[InspectableSoundBank, JsonProperty("soundBank"), Key(21)]
[InspectableSoundBank, Key(21)]
public uint SoundBank;
[Inspectable, JsonProperty("audioStats"), Key(22)]
[Inspectable, Key(22)]
public List<AudioStat> AudioStats = new List<AudioStat>();
[IgnoreMember]
public abstract HardpointType HardpointType { get; }
[IgnoreMember] private const int STEPS = 64;
[IgnoreMember] private float? _optimum;
[IgnoreMember]
public float OptimalTemperature
{
@ -446,82 +443,82 @@ public abstract class EquippableItemData : CraftedItemData
}
}
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Inspectable, MessagePackObject]
public class AudioStat
{
[InspectableAudioParameter, JsonProperty("parameter"), Key(0)]
[InspectableAudioParameter, Key(0)]
public uint Parameter;
[Inspectable, JsonProperty("stat"), Key(1)]
[Inspectable, Key(1)]
public PerformanceStat Stat = new PerformanceStat();
}
[LegacyCatalogGroup("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[LegacyCatalogGroup("Items"), Inspectable, MessagePackObject]
public class GearData : EquippableItemData
{
[Inspectable, JsonProperty("hardpointType"), Key(23)]
[Inspectable, Key(23)]
public HardpointType Hardpoint;
[IgnoreMember] public override HardpointType HardpointType => Hardpoint;
}
[LegacyCatalogGroup("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[LegacyCatalogGroup("Items"), Inspectable, MessagePackObject]
public class CargoBayData : EquippableItemData
{
[Inspectable, JsonProperty("interiorShape"), Key(24)]
[Inspectable, Key(24)]
public Shape InteriorShape;
[IgnoreMember] public override HardpointType HardpointType => HardpointType.Tool;
}
[LegacyCatalogGroup("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[LegacyCatalogGroup("Items"), Inspectable, MessagePackObject]
public class DockingBayData : CargoBayData
{
[Inspectable, JsonProperty("maxSize"), Key(25)]
[Inspectable, Key(25)]
public int2 MaxSize;
}
[LegacyCatalogGroup("Items"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[LegacyCatalogGroup("Items"), MessagePackObject]
public class WeaponItemData : GearData
{
[Inspectable, JsonProperty("range"), Key(24)]
[Inspectable, Key(24)]
public WeaponRange WeaponRange;
[Inspectable, JsonProperty("caliber"), Key(25)]
[Inspectable, Key(25)]
public WeaponCaliber WeaponCaliber;
[Inspectable, JsonProperty("weaponType"), Key(26)]
[Inspectable, Key(26)]
public WeaponType WeaponType;
[Inspectable, JsonProperty("fireTypes"), Key(27)]
[Inspectable, Key(27)]
public WeaponFireType WeaponFireTypes;
[Inspectable, JsonProperty("modifiers"), Key(28)]
[Inspectable, Key(28)]
public WeaponModifiers WeaponModifiers;
}
[LegacyCatalogGroup("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[LegacyCatalogGroup("Items"), Inspectable, MessagePackObject]
public class HullData : EquippableItemData
{
[Inspectable, JsonProperty("hardpoints"), Key(23)]
[Inspectable, Key(23)]
public List<HardpointData> Hardpoints = new List<HardpointData>();
[InspectablePrefab, JsonProperty("prefab"), Key(24)]
[InspectablePrefab, Key(24)]
public string Prefab;
[Inspectable, JsonProperty("hullType"), Key(25)]
[Inspectable, Key(25)]
public HullType HullType;
[Inspectable, JsonProperty("gridOffset"), Key(26)]
[Inspectable, Key(26)]
public float GridOffset;
[Inspectable, JsonProperty("armor"), Key(27)]
[Inspectable, Key(27)]
public float Armor;
[Inspectable, JsonProperty("drag"), Key(28)]
[Inspectable, Key(28)]
public float Drag;
[Inspectable, JsonProperty("canTow"), Key(29)]
[Inspectable, Key(29)]
public bool CanTow;
[IgnoreMember]
@ -543,15 +540,15 @@ public class HullData : EquippableItemData
[IgnoreMember] public override HardpointType HardpointType => HardpointType.Hull;
}
[Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[Inspectable, MessagePackObject]
public class HardpointData : ITintInspector
{
[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;
[Inspectable, Key(0)] public HardpointType Type;
[Inspectable, Key(1)] public int2 Position;
[Inspectable, Key(2)] public Shape Shape = new Shape();
[Inspectable, Key(3)] public string Transform;
[Inspectable, Key(4)] public ItemRotation Rotation;
[Inspectable, Key(5)] public float Armor;
public override string ToString()
{
@ -578,30 +575,30 @@ public class HardpointData : ITintInspector
return _tintColors.ContainsKey(type) ? _tintColors[type] : _tintColors[HardpointType.Hull];
}
private static Dictionary<HardpointType, float3> _tintColors;
}
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class PerformanceStat
{
[JsonProperty("min"), Key(0)] public float Min;
[Key(0)] public float Min;
[JsonProperty("max"), Key(1)] public float Max;
[Key(1)] public float Max;
[JsonProperty("heatExponentMultiplier"), Key(2)]
[Key(2)]
public float HeatExponentMultiplier;
[JsonProperty("durabilityExponentMultiplier"), Key(3)]
[Key(3)]
public float DurabilityExponentMultiplier;
[JsonProperty("qualityExponent"), Key(4)]
[Key(4)]
public float QualityExponent;
//[JsonProperty("id"), Key(5)] public Guid ID = Guid.NewGuid();
// [JsonProperty("ingredient"), Key(5)] public Guid? Ingredient;
//[Key(5)] public Guid ID = Guid.NewGuid();
// [Key(5)] public Guid? Ingredient;
[IgnoreMember] private Dictionary<Entity,Dictionary<Behavior,float>> _scaleModifiers;
[IgnoreMember] private Dictionary<Entity,Dictionary<Behavior,float>> _constantModifiers;
@ -630,18 +627,18 @@ public class PerformanceStat
}
}
[LegacyCatalogGroup("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[LegacyCatalogGroup("Items"), Inspectable, MessagePackObject]
public class PersonalityAttribute : DatabaseEntry, INamedEntry
{
[Inspectable, JsonProperty("name"), Key(1)]
[Inspectable, Key(1)]
public string Name;
[Inspectable, JsonProperty("low"), Key(2)]
[Inspectable, Key(2)]
public string LowName;
[Inspectable, JsonProperty("high"), Key(3)]
[Inspectable, Key(3)]
public string HighName;
[IgnoreMember] public string EntryName
{
get => Name;

View file

@ -1,4 +1,4 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */
@ -7,61 +7,55 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using JsonKnownTypes;
//using JM.LinqFaster;
using MessagePack;
using MessagePack.Formatters;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
[Union(0, typeof(SimpleCommodity)),
Union(1, typeof(CompoundCommodity)),
[Union(0, typeof(SimpleCommodity)),
Union(1, typeof(CompoundCommodity)),
Union(2, typeof(EquippableItem)),
Union(3, typeof(ConsumableItem)),
JsonObject(MemberSerialization.OptIn),
JsonConverter(typeof(JsonKnownTypesConverter<ItemInstance>))]
Union(3, typeof(ConsumableItem))]
public abstract class ItemInstance
{
[JsonProperty("data"), Key(0)] public DatabaseLink<ItemData> Data;
[JsonProperty("rotation"), Key(1)] public ItemRotation Rotation;
[Key(0)] public DatabaseLink<ItemData> Data;
[Key(1)] public ItemRotation Rotation;
}
[Union(0, typeof(CompoundCommodity)),
Union(1, typeof(EquippableItem)),
Union(2, typeof(ConsumableItem)),
JsonObject(MemberSerialization.OptIn),
JsonConverter(typeof(JsonKnownTypesConverter<CraftedItemInstance>))]
[Union(0, typeof(CompoundCommodity)),
Union(1, typeof(EquippableItem)),
Union(2, typeof(ConsumableItem))]
public abstract class CraftedItemInstance : ItemInstance
{
[JsonProperty("quality"), Key(2)] public float Quality;
[Key(2)] public float Quality;
//[JsonProperty("ingredients"), Key(3)] public List<ItemInstance> Ingredients = new List<ItemInstance>();
//[JsonProperty("blueprint"), Key(4)] public Guid Blueprint;
//[JsonProperty("name"), Key(3)] public string Name;
//[JsonProperty("sourceEntity"), Key(4)] public Guid SourceEntity;
//[Key(3)] public List<ItemInstance> Ingredients = new List<ItemInstance>();
//[Key(4)] public Guid Blueprint;
//[Key(3)] public string Name;
//[Key(4)] public Guid SourceEntity;
}
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class CompoundCommodity : CraftedItemInstance { }
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class SimpleCommodity : ItemInstance
{
[JsonProperty("quantity"), Key(2)] public int Quantity;
[Key(2)] public int Quantity;
}
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class EquippableItem : CraftedItemInstance
{
[JsonProperty("durability"), Key(7)] public float Durability;
[JsonProperty("override"), Key(8)] public bool OverrideShutdown;
[Key(7)] public float Durability;
[Key(8)] public bool OverrideShutdown;
}
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class ConsumableItem : CraftedItemInstance
{
}

View file

@ -1,4 +1,4 @@
using System.Collections;
using System.Collections;
using System.Linq;
using MIConvexHull;
using Unity.Mathematics;
@ -10,20 +10,20 @@ using static Unity.Mathematics.math;
public class Cell2 : TriangulationCell<Vertex2, Cell2>
{
float2? circumCenter, centroid;
public float2 Circumcenter {
get {
circumCenter = circumCenter ?? GetCircumcenter();
return circumCenter.Value;
}
}
public float2 Centroid {
get {
centroid = centroid ?? GetCentroid();
return centroid.Value;
}
}
}
public Cell2 ()
{
@ -45,20 +45,20 @@ public class Cell2 : TriangulationCell<Vertex2, Cell2>
float fCofactor00 = m[1,1] * m[2,2] - m[1,2] * m[2,1];
float fCofactor10 = m[1,2] * m[2,0] - m[1,0] * m[2,2];
float fCofactor20 = m[1,0] * m[2,1] - m[1,1] * m[2,0];
float fDet = m[0,0] * fCofactor00 + m[0,1] * fCofactor10 + m[0,2] * fCofactor20;
return fDet;
}
float2 GetCircumcenter ()
{
// From MathWorld: http://mathworld.wolfram.com/Circumcircle.html
var points = Vertices;
float[,] m = new float[3, 3];
// x, y, 1
for (int i = 0; i < 3; i++) {
m[i, 0] = points[i].x;
@ -66,35 +66,35 @@ public class Cell2 : TriangulationCell<Vertex2, Cell2>
m[i, 2] = 1;
}
var a = Determinant(m);
// size, y, 1
for (int i = 0; i < 3; i++) {
m[i, 0] = lengthsq(points[i].StoredPosition);
}
var dx = -Determinant(m);
// size, x, 1
for (int i = 0; i < 3; i++) {
m[i, 1] = points[i].x;
}
var dy = Determinant(m);
// size, x, y
//for (int i = 0; i < 3; i++) {
// m[i, 2] = points[i].y;
//}
//var c = -Det(m);
var s = -1.0f / (2.0f * a);
//var r = System.Math.Abs(s) * System.Math.Sqrt(dx * dx + dy * dy - 4 * a * c);
return new float2(s * dx, s * dy);
}
float2 GetCentroid ()
{
return new float2(Vertices.Select(v => v.Position[0]).Average(), Vertices.Select(v => v.Position[1]).Average());
}
}
}

View file

@ -4,23 +4,21 @@
using System;
using MessagePack;
using Newtonsoft.Json;
[LegacyCatalogGroup("Users"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[LegacyCatalogGroup("Users"), MessagePackObject]
public class PlayerData : DatabaseEntry, INamedEntry
{
[JsonProperty("email"), Key(1)]
[Key(1)]
public string Email;
[JsonProperty("password"), Key(2)]
[Key(2)]
public string Password;
[JsonProperty("username"), Key(3)]
[Key(3)]
public string Username;
[JsonProperty("corporation"), Key(4)]
[Key(4)]
public Guid Corporation;
[IgnoreMember] public string EntryName
{
get => Username;

View file

@ -1,4 +1,4 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */
@ -6,12 +6,11 @@ using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using static Unity.Mathematics.noise;
[Serializable, MessagePackObject(keyAsPropertyName:true), JsonObject]
[Serializable, MessagePackObject(keyAsPropertyName:true)]
public class PlanetSettings
{
public float ZoneDepthExponent;
@ -36,7 +35,7 @@ public class PlanetSettings
public ExponentialCurve OrbitPeriod;
}
[Serializable, MessagePackObject(keyAsPropertyName:true), JsonObject]
[Serializable, MessagePackObject(keyAsPropertyName:true)]
public class GalaxyShapeSettings
{
public int Arms = 4;
@ -44,7 +43,7 @@ public class GalaxyShapeSettings
public float TwistExponent = 2;
}
[Serializable, MessagePackObject(keyAsPropertyName:true), JsonObject]
[Serializable, MessagePackObject(keyAsPropertyName:true)]
public class NameGeneratorSettings
{
public int NameGeneratorMinLength = 5;
@ -52,7 +51,7 @@ public class NameGeneratorSettings
public int NameGeneratorOrder = 4;
}
[Serializable, MessagePackObject(keyAsPropertyName:true), JsonObject]
[Serializable, MessagePackObject(keyAsPropertyName:true)]
public class SectorBackgroundSettings
{
public float NoiseAmplitude;
@ -63,12 +62,12 @@ public class SectorBackgroundSettings
public float NoisePosition;
public float CloudExponent;
public float CloudAmplitude;
public float fBm(float2 p, int octaves)
{
float freq = NoiseFrequency, amp = .5f;
float sum = 0;
for(int i = 0; i < octaves; i++)
float sum = 0;
for(int i = 0; i < octaves; i++)
{
if(i<4)
sum += (1-abs(snoise(p * freq))) * amp;
@ -86,7 +85,7 @@ public class SectorBackgroundSettings
}
}
[Serializable, MessagePackObject(keyAsPropertyName:true), JsonObject]
[Serializable, MessagePackObject(keyAsPropertyName:true)]
public class SectorGenerationSettings
{
public float LinkDensity = .5f;
@ -95,7 +94,7 @@ public class SectorGenerationSettings
public int BossCount;
}
[Serializable, MessagePackObject(keyAsPropertyName:true), JsonObject]
[Serializable, MessagePackObject(keyAsPropertyName:true)]
public class TutorialGenerationSettings
{
public string ProtagonistFaction;
@ -107,11 +106,11 @@ public class TutorialGenerationSettings
public int ZoneCount = 32;
}
[Serializable, MessagePackObject(keyAsPropertyName:true), JsonObject]
[Serializable, MessagePackObject(keyAsPropertyName:true)]
public class ZoneGenerationSettings
{
public ExponentialCurve PlanetSafetyRadius;
public float MassFloor = 1;
public float SunMass = 10000;
public float GasGiantMass = 2000;
@ -127,7 +126,7 @@ public class ZoneGenerationSettings
public ExponentialLerp ZoneMass;
public ExponentialLerp SubZoneCount;
public float ZoneBoundaryRadius;
public float BeltProbability = .05f;
public float BeltMassCeiling = 500f;
@ -142,7 +141,7 @@ public class ZoneGenerationSettings
public float SunSecondaryColorDistance = .25f;
public float SunLightSaturation = .5f;
public float SunFogTintSaturation = .5f;
public ExponentialLerp GasGiantBandCount;
public float GasGiantBandColorSeparation = .25f;
public float GasGiantBandAltColorChance = .25f;
@ -152,7 +151,7 @@ public class ZoneGenerationSettings
public string[] NameData;
}
[Serializable, MessagePackObject(keyAsPropertyName: true), JsonObject]
[Serializable, MessagePackObject(keyAsPropertyName: true)]
public class GameplaySettings
{
public EntitySettings DefaultEntitySettings;
@ -214,7 +213,7 @@ public class GameplaySettings
public float AgentFiringMinDot = .99f;
}
[Serializable, MessagePackObject(keyAsPropertyName: true), JsonObject]
[Serializable, MessagePackObject(keyAsPropertyName: true)]
public class RarityTier
{
public string Name;

View file

@ -1,4 +1,4 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */
@ -8,7 +8,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using MessagePack;
using Newtonsoft.Json;
using UniRx;
using Unity.Mathematics;
using static Unity.Mathematics.math;
@ -17,7 +16,7 @@ using quaternion = Unity.Mathematics.quaternion;
[MessagePackObject]
public class Ship : Entity
{
// [Key("bindings")] public Dictionary<KeyCode,Guid> Bindings = new Dictionary<KeyCode,Guid>();
//[IgnoreMember] public int HullHardpointCount;
@ -67,7 +66,7 @@ public class Ship : Entity
public event Action OnExitedWormhole;
public event Action OnEnteredWormhole;
public quaternion Rotation { get; private set; }
public void ExitWormhole(float2 wormholePosition, float2 exitVelocity)
@ -95,25 +94,25 @@ public class Ship : Entity
_aetherDrives = new HashSet<AetherDrive>(GetBehaviors<AetherDrive>());
_aetherDriveItems = new HashSet<EquippedItem>(_aetherDrives.Select(x => x.Item));
_allThrusters = GetBehaviors<Thruster>().ToArray();
_thrusterItems = new HashSet<EquippedItem>(_allThrusters.Select(x=>x.Item));
_forwardThrusters = new HashSet<Thruster>(_allThrusters
.Where(x => x.Item.EquippableItem.Rotation == ItemRotation.Reversed));
_reverseThrusters = new HashSet<Thruster>(_allThrusters
.Where(x => x.Item.EquippableItem.Rotation == ItemRotation.None));
_rightThrusters = new HashSet<Thruster>(_allThrusters
.Where(x => x.Item.EquippableItem.Rotation == ItemRotation.CounterClockwise));
_leftThrusters = new HashSet<Thruster>(_allThrusters
.Where(x => x.Item.EquippableItem.Rotation == ItemRotation.Clockwise));
_counterClockwiseThrusters = new HashSet<Thruster>(_allThrusters
.Where(x => x.Torque < -ItemManager.GameplaySettings.TorqueFloor));
_clockwiseThrusters = new HashSet<Thruster>(_allThrusters
.Where(x => x.Torque > ItemManager.GameplaySettings.TorqueFloor));
}
@ -153,7 +152,7 @@ public class Ship : Entity
RecalculateClockwiseTorque();
RecalculateCounterClockwiseTorque();
}
private void RecalculateForwardThrust()
{
ForwardThrust = 0;
@ -283,7 +282,7 @@ public class Ship : Entity
Direction = lerp(Direction, look, min(delta, 1));
}
deltaRot = pow(abs(deltaRot), .5f) * sign(deltaRot);
foreach (var thruster in _clockwiseThrusters) thruster.Axis += deltaRot;
foreach (var thruster in _counterClockwiseThrusters) thruster.Axis += -deltaRot;
@ -294,9 +293,9 @@ public class Ship : Entity
var velocityMagnitude = length(Velocity);
if(velocityMagnitude > .01f)
Velocity = normalize(Velocity) * AetheriaMath.Decay(velocityMagnitude, HullData.Drag, delta);
Position.xz += Velocity * delta;
var normal = Zone.GetNormal(Position.xz);
var force = new float2(normal.x, normal.z);
var forceMagnitude = lengthsq(force);
@ -308,7 +307,7 @@ public class Ship : Entity
var shipRight = Direction.Rotate(ItemRotation.Clockwise);
var forward = cross(float3(shipRight.x, 0, shipRight.y), normal);
Rotation = quaternion.LookRotation(forward, normal);
base.Update(delta);
if (_exitingWormhole)
@ -360,7 +359,7 @@ public class Ship : Entity
else
{
Position.xz = _wormholePosition;
Rotation = quaternion.LookRotation(float3(0, -1, 0),
Rotation = quaternion.LookRotation(float3(0, -1, 0),
float3(-_wormholeEntryDirection.x, 0, -_wormholeEntryDirection.y));
}

View file

@ -1,15 +1,11 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
[JsonObject]
public class WwiseMetadataFile
{
public WwiseMetaSoundBanksInfo SoundBanksInfo;
}
[JsonObject]
public class WwiseMetaSoundBanksInfo
{
public WwiseMetaSoundBank[] SoundBanks;
@ -29,7 +25,6 @@ public class WwiseMetaSoundBanksInfo
}
}
[JsonObject]
public class WwiseMetaSoundBank
{
public uint Id;
@ -83,7 +78,6 @@ public class WwiseMetaSoundBank
}
}
[JsonObject]
public class WwiseMetaObject
{
public uint Id;

View file

@ -1,22 +1,20 @@
using MessagePack;
using Newtonsoft.Json;
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class WwiseSoundBinding
{
[Key(0), JsonProperty("playEvent")]
[Key(0)]
public uint PlayEvent;
}
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class WwiseLoopingSoundBinding : WwiseSoundBinding
{
[Key(1), JsonProperty("stopEvent")]
[Key(1)]
public uint StopEvent;
}
// public class WwiseParameterBinding
// {
// [Key(0), JsonProperty("parameter")]
// [Key(0)]
// public uint Parameter;
// }

View file

@ -6,62 +6,61 @@ using System;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
using Newtonsoft.Json;
using UniRx;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using float2 = Unity.Mathematics.float2;
using float3 = Unity.Mathematics.float3;
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class ZonePack
{
[JsonProperty("planets"), Key(0)]
[Key(0)]
public List<BodyData> Planets = new List<BodyData>();
[JsonProperty("orbits"), Key(1)]
[Key(1)]
public List<OrbitData> Orbits = new List<OrbitData>();
[JsonProperty("entities"), Key(2)]
[Key(2)]
public List<EntityPack> Entities = new List<EntityPack>();
[JsonProperty("radius"), Key(3)]
[Key(3)]
public float Radius = 2000;
[JsonProperty("mass"), Key(4)]
[Key(4)]
public float Mass = 10000;
[JsonProperty("time"), Key(5)]
[Key(5)]
public double Time;
}
// [LegacyCatalogGroup("Galaxy"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
// [LegacyCatalogGroup("Galaxy"), MessagePackObject]
// public class StationData : DatabaseEntry, INamedEntry
// {
// [JsonProperty("name"), Key(1)]
// [Key(1)]
// public string Name;
//
//
// // Can be Planet or Orbit
// [JsonProperty("parent"), Key(2)]
// [Key(2)]
// public Guid Parent;
//
// [JsonProperty("owner"), Key(3)]
// [Key(3)]
// public Guid Owner;
//
// [JsonProperty("inventory"), Key(4)]
// [Key(4)]
// public List<ItemInstance> Inventory = new List<ItemInstance>();
//
// [JsonProperty("buying"), Key(5)]
// [Key(5)]
// public Dictionary<Guid, float> BuyPrices = new Dictionary<Guid, float>();
//
// [JsonProperty("selling"), Key(6)]
// [Key(6)]
// public Dictionary<Guid, float> SellPrices = new Dictionary<Guid, float>();
//
// [JsonProperty("zone"), Key(7)]
// [Key(7)]
// public Guid Zone;
//
//
// [IgnoreMember] public string EntryName
// {
// get => Name;
@ -69,38 +68,37 @@ public class ZonePack
// }
// }
[MessagePackObject,
JsonObject(MemberSerialization.OptIn),
[MessagePackObject,
Union(0, typeof(PlanetData)),
Union(1, typeof(AsteroidBeltData)),
Union(2, typeof(GasGiantData)),
Union(3, typeof(SunData))]
public abstract class BodyData : DatabaseEntry, INamedEntry
{
[JsonProperty("name"), Key(1)]
[Key(1)]
public string Name = "";
[JsonProperty("orbit"), Key(2)]
[Key(2)]
public Guid Orbit;
[JsonProperty("mass"), Key(3)]
[Key(3)]
public float Mass = 0;
[JsonProperty("resources"), Key(4)]
[Key(4)]
public Dictionary<Guid, float> Resources = new Dictionary<Guid, float>();
[JsonProperty("bodyRadiusMul")] [Key(5)]
[Key(5)]
public float BodyRadiusMultiplier = 1;
[JsonProperty("gravRadiusMul")] [Key(6)]
[Key(6)]
public float GravityRadiusMultiplier = 1;
[JsonProperty("depthMul")] [Key(7)]
[Key(7)]
public float GravityDepthMultiplier = 1;
[JsonProperty("depthExp")] [Key(8)]
[Key(8)]
public float GravityDepthExponent = 16;
[IgnoreMember] public string EntryName
{
get => Name;
@ -108,100 +106,100 @@ public abstract class BodyData : DatabaseEntry, INamedEntry
}
}
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class PlanetData : BodyData
{
}
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class AsteroidBeltData : BodyData
{
[JsonProperty("asteroids"), Key(9)]
[Key(9)]
public Asteroid[] Asteroids;
}
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class GasGiantData : BodyData
{
[JsonProperty("firstOffsetDomainRotationSpeed"), Key(9)]
[Key(9)]
public float FirstOffsetDomainRotationSpeed = 1;
[JsonProperty("firstOffsetRotationSpeed"), Key(10)]
[Key(10)]
public float FirstOffsetRotationSpeed = 1;
[JsonProperty("secondOffsetDomainRotationSpeed"), Key(11)]
[Key(11)]
public float SecondOffsetDomainRotationSpeed = 1;
[JsonProperty("secondOffsetRotationSpeed"), Key(12)]
[Key(12)]
public float SecondOffsetRotationSpeed = 1;
[JsonProperty("albedoRotationSpeed"), Key(13)]
[Key(13)]
public float AlbedoRotationSpeed = 1;
[JsonProperty("gravRadiusMul")] [Key(14)]
[Key(14)]
public float WaveRadiusMultiplier = 1;
[JsonProperty("depthMul")] [Key(15)]
[Key(15)]
public float WaveDepthMultiplier = 1;
[JsonProperty("depthExp")] [Key(16)]
[Key(16)]
public float WaveDepthExponent = 8;
[JsonProperty("depthExp")] [Key(17)]
[Key(17)]
public float WaveSpeedMultiplier = 8;
[JsonProperty("materialOverrides"), Key(18)]
[Key(18)]
public List<string> MaterialOverrides = new List<string>();
[JsonProperty("colors"), Key(19)]
[Key(19)]
public float4[] Colors = new float4[0];
}
public class SunData : GasGiantData
{
[JsonProperty("lightColor"), Key(20)]
[Key(20)]
public float3 LightColor = float3.zero;
[JsonProperty("fogTintColor"), Key(21)]
[Key(21)]
public float3 FogTintColor = float3.zero;
[JsonProperty("lightRadiusMul")] [Key(22)]
[Key(22)]
public float LightRadiusMultiplier = 1;
}
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class Asteroid
{
[JsonProperty("distance"), Key(0)]
[Key(0)]
public float Distance;
[JsonProperty("phase"), Key(1)]
[Key(1)]
public float Phase;
[JsonProperty("size"), Key(2)]
[Key(2)]
public float Size;
[JsonProperty("rotationSpeed"), Key(3)]
[Key(3)]
public float RotationSpeed;
}
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class OrbitData : DatabaseEntry
{
[JsonProperty("parent"), Key(1)]
[Key(1)]
public Guid Parent;
[JsonProperty("distance"), Key(2)]
[Key(2)]
public float Distance;
[JsonProperty("phase"), Key(3)]
[Key(3)]
public float Phase;
[JsonProperty("phase"), Key(4)]
[Key(4)]
public float2 FixedPosition = float2.zero;
// [JsonProperty("period"), Key(4)]
// [Key(4)]
// public float Period;
public static float2 Evaluate(float phase)

View file

@ -1,4 +1,4 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
/* 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/. */
@ -50,7 +50,7 @@ public static class ZoneGenerator
pack.Radius = zoneSettings.ZoneRadius.Evaluate(density);
pack.Mass = zoneSettings.ZoneMass.Evaluate(density);
var targetSubzoneCount = zoneSettings.SubZoneCount.Evaluate(density);
//Debug.Log($"Generating zone at position {zone.Position} with radius {zoneRadius} and mass {zoneMass}");
var planets = new List<GeneratorPlanet>();
@ -58,10 +58,10 @@ public static class ZoneGenerator
{
var zoneBoundary = new Circle(float2.zero, pack.Radius * zoneSettings.ZoneBoundaryRadius);
float boundaryTangentRadius(float2 point) => -zoneBoundary.DistanceTo(point);
var occupiedAreas = new List<Circle>();
float tangentRadius(float2 point) => min(boundaryTangentRadius(point), occupiedAreas.Min(circle => circle.DistanceTo(point)));
var startPosition = random.NextFloat(pack.Radius * .25f, pack.Radius * .5f) * random.NextFloat2Direction();
occupiedAreas.Add(new Circle(startPosition, boundaryTangentRadius(startPosition)));
@ -91,11 +91,11 @@ public static class ZoneGenerator
}
else
planets.AddRange(GenerateEntities(zoneSettings, ref random, pack.Mass, pack.Radius, float2.zero));
// Create collections to map between zone generator output and database entries
var orbitMap = new Dictionary<GeneratorPlanet, OrbitData>();
var orbitInverseMap = new Dictionary<OrbitData, GeneratorPlanet>();
// Create orbit database entries
pack.Orbits = planets.Select(planet =>
{
@ -116,11 +116,11 @@ public static class ZoneGenerator
data.Parent = orbitInverseMap[data].Parent != null
? orbitMap[orbitInverseMap[data].Parent].ID
: Guid.Empty;
// Cache resource densities
// var resourceMaps = mapLayers.Values
// .ToDictionary(m => m.ID, m => m.Evaluate(zone.Position, settings.ShapeSettings));
pack.Planets = planets.Where(p=>!p.Empty).Select(planet =>
{
// Dictionary<Guid, float> planetResources = new Dictionary<Guid, float>();
@ -128,7 +128,7 @@ public static class ZoneGenerator
planet.Mass > zoneSettings.SunMass ? BodyType.Sun :
planet.Mass > zoneSettings.GasGiantMass ? BodyType.GasGiant :
planet.Mass > zoneSettings.PlanetMass ? BodyType.Planet : BodyType.Planetoid;
// foreach (var r in resources)
// {
// if ((bodyType & r.ResourceBodyType) != 0)
@ -164,7 +164,7 @@ public static class ZoneGenerator
planetData.Name = planetData.ID.ToString().Substring(0, 8);
if (planetData is AsteroidBeltData beltData)
{
beltData.Asteroids =
beltData.Asteroids =
Enumerable.Range(0, (int) zoneSettings.AsteroidCount.Evaluate(beltData.Mass * orbitMap[planet].Distance))
.Select(_ => new Asteroid
{
@ -197,12 +197,12 @@ public static class ZoneGenerator
float primary = random.NextFloat();
float right = frac(primary + zoneSettings.GasGiantBandColorSeparation);
float left = frac(primary + 1 - zoneSettings.GasGiantBandColorSeparation);
// Create n time keys from 0 to 1
var bandCount = (int) (zoneSettings.GasGiantBandCount.Evaluate(random.NextFloat()) + .5f);
var times = Enumerable.Range(0, bandCount)
.Select(i => (float) i / (bandCount-1));
// Each band has a chance of being either the primary or one of the adjacent hues
// Saturation and Value are random with curves applied
gas.Colors = times
@ -211,7 +211,7 @@ public static class ZoneGenerator
zoneSettings.GasGiantBandSaturation.Evaluate(random.NextFloat()),
zoneSettings.GasGiantBandSaturation.Evaluate(random.NextFloat()))),time))
.ToArray();
gas.FirstOffsetDomainRotationSpeed = 0;
}
gas.AlbedoRotationSpeed = -3;
@ -265,7 +265,7 @@ public static class ZoneGenerator
void PlaceTurret(OrbitData orbit, LoadoutGenerator loadoutGenerator, int distanceMultiplier)
{
var phase = 20f * distanceMultiplier / orbit.Distance;
var turretOrbit = new OrbitData
{
ID = Guid.NewGuid(),
@ -331,7 +331,7 @@ public static class ZoneGenerator
return pack;
}
// static float ResourceValue(ref Random random, ZoneGenerationSettings settings, SimpleCommodityData resource, float density)
// {
// return random.NextPowerDistribution(resource.Minimum, resource.Maximum, resource.Exponent,
@ -352,20 +352,20 @@ public static class ZoneGenerator
// There is some chance of generating a rosette or binary system
// Probabilities which are fixed for the entire galaxy are in GlobalData, contained in the GameContext
var rosette = random.NextFloat() < settings.RosetteProbability;
if (rosette)
{
// Create a rosette with a number of vertices between 2 and 9 inclusive
root.ExpandRosette(ref random, (int)(random.NextFloat(1, 5) + random.NextFloat(1, 5)));
// Create a small number of less massive "captured" planets orbiting past the rosette
root.ExpandSolar(
ref random,
count: (int)(random.NextFloat(1, 3) * random.NextFloat(1, 2)),
massMulMin: .6f,
massMulMax: .8f,
distMulMin: 1.25f,
distMulMax: 1.75f,
count: (int)(random.NextFloat(1, 3) * random.NextFloat(1, 2)),
massMulMin: .6f,
massMulMax: .8f,
distMulMin: 1.25f,
distMulMax: 1.75f,
jupiterJump: 1,
massFraction: .1f);
@ -376,9 +376,9 @@ public static class ZoneGenerator
// Give each child in the rosette its own mini solar system
p.ExpandSolar(
ref random,
count: (int) (random.NextFloat(1, 3 * m) + random.NextFloat(1, 3 * m)),
massMulMin: 0.75f,
massMulMax: 2.5f,
count: (int) (random.NextFloat(1, 3 * m) + random.NextFloat(1, 3 * m)),
massMulMin: 0.75f,
massMulMax: 2.5f,
distMulMin: 1 + m * .25f,
distMulMax: 1.05f + m * .5f,
jupiterJump: random.NextFloat() * random.NextFloat() * 10 + 1,
@ -391,9 +391,9 @@ public static class ZoneGenerator
// Create a regular old boring solar system
root.ExpandSolar(
ref random,
count: random.NextInt(5, 15),
massMulMin: 0.75f,
massMulMax: 2.5f,
count: random.NextInt(5, 15),
massMulMin: 0.75f,
massMulMax: 2.5f,
distMulMin: 1.1f,
distMulMax: 1.25f,
jupiterJump: random.NextFloat() * random.NextFloat() * 10 + 1,
@ -407,13 +407,13 @@ public static class ZoneGenerator
{
// Get all children that are above the satellite creation mass floor and not rosette members
var satelliteCandidates = rosette
? root.AllPlanets().Where(p =>
p != root &&
p.Parent != root &&
? root.AllPlanets().Where(p =>
p != root &&
p.Parent != root &&
p.Mass > settings.SatelliteCreationMassFloor &&
!alreadyExpanded.Contains(p))
: root.AllPlanets().Where(p =>
p != root &&
: root.AllPlanets().Where(p =>
p != root &&
p.Mass > settings.SatelliteCreationMassFloor &&
!alreadyExpanded.Contains(p));
@ -450,7 +450,7 @@ public static class ZoneGenerator
var beltCandidates = rosette
? root.AllPlanets().Where(p => p != root && p.Parent != root && p.Mass < settings.BeltMassCeiling && !binaries.Contains(p) && p.Children.Count == 0)
: root.AllPlanets().Where(p => p != root && p.Mass < settings.BeltMassCeiling && !binaries.Contains(p) && p.Children.Count == 0);
foreach(var planet in beltCandidates.Reverse())
if (random.NextFloat() < settings.BeltProbability && !planet.Parent.Children.Any(p=>p.Belt))
planet.Belt = true;
@ -493,29 +493,29 @@ public class GeneratorPlanet
public void ExpandRosette(ref Random random, int vertices)
{
//Debug.Log("Expanding Rosette");
// Rosette children replace the parent, parent orbital node is left empty
Empty = true;
// Masses in a rosette alternate, so every sequential pair has the same shared mass
var sharedMass = Mass / vertices * 2;
// Proportion of the masses of sequential pairs is random, but only for even vertex counts
var proportion = vertices % 2 == 0 ? random.NextFloat(.5f,.95f) : .5f;
// Place children at a fixed distance in the center of the range
var dist = (ChildDistanceMinimum + ChildDistanceMaximum) / 2;
// Position of first child
var p0 = new float2(0, dist);
// Position of second child
var p1 = OrbitData.Evaluate(1.0f / vertices) * dist;
// Maximum child distance is half the distance to the neighbor minus the neighbor's radius
var p0ChildDist = (distance(p0, p1) * proportion - Settings.PlanetSafetyRadius.Evaluate(sharedMass * (1 - proportion))) * .75f;
var p1ChildDist = (distance(p0, p1) * (1 - proportion) - Settings.PlanetSafetyRadius.Evaluate(sharedMass * proportion)) * .75f;
for (int i = 0; i < vertices; i++)
{
var child = new GeneratorPlanet
@ -542,14 +542,14 @@ public class GeneratorPlanet
// Expansion is impossible when child space is full
if (count == 0 || ChildDistanceMaximum < ChildDistanceMinimum)
return;
var masses = new float[count];
var distances = new float[count];
// Accumulate total mass
// Accumulate total mass
// Initialize first mass and distance, actual number doesn't matter since total mass will be divided proportionally
float massTotal = distances[0] = masses[0] = 1;
// Masses and distances multiply from one planet to the next
// Mass typically increases exponentially as you go further out
// jupiterJump is an additional mass multiplier applied after half of the planets
@ -575,7 +575,7 @@ public class GeneratorPlanet
distances[i] = lerp(ChildDistanceMinimum, ChildDistanceMaximum,
(oldDistances[i] - oldDistances[0]) / (oldDistances[count - 1] - oldDistances[0])) + Settings.PlanetSafetyRadius.Evaluate(masses[i]);
}
for (var i = 0; i < count; i++)
{
// Only instantiate children above the mass floor
@ -601,4 +601,4 @@ public class GeneratorPlanet
}
}
}
}
}

View file

@ -4,8 +4,6 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using MessagePack;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using TMPro;
using UniRx;
using UnityEngine;
@ -53,7 +51,7 @@ public class InputDisplayLayout : MonoBehaviour
private ButtonMapping _previewButton;
private ActionMapping _previewOriginalAction;
private bool _previewOriginallyActionBar;
public InputActionAsset Input { get; set; }
private class ButtonMapping
@ -77,11 +75,11 @@ public class InputDisplayLayout : MonoBehaviour
public List<ButtonMapping> ButtonMappings = new List<ButtonMapping>();
public Rect LabelRect => Label.GetComponent<RectTransform>().ScreenSpaceRect();
}
private Dictionary<string, ButtonMapping> _bindButtons = new Dictionary<string, ButtonMapping>();
private List<ButtonMapping> _buttonMappings = new List<ButtonMapping>();
private List<ActionMapping> _actionMappings = new List<ActionMapping>();
void Start()
{
_canvas = transform.root.GetComponent<Canvas>();
@ -89,22 +87,21 @@ public class InputDisplayLayout : MonoBehaviour
// _inputLayout = ParseJson(LayoutFile.text);
RegisterResolver.Register();
_inputLayout = MessagePackSerializer.Deserialize<InputLayout>(File.ReadAllBytes(path));
// _inputLayout = JsonConvert.DeserializeObject<InputLayout>(File.ReadAllText(path));
// SaveLayout();
DisplayLayout(_inputLayout);
_buttonMappings.Add(MapMouseButton(MouseLeft, "<Mouse>/leftButton"));
_buttonMappings.Add(MapMouseButton(MouseRight, "<Mouse>/rightButton"));
_buttonMappings.Add(MapMouseButton(MouseMiddle, "<Mouse>/middleButton"));
_buttonMappings.Add(MapMouseButton(MouseForward, "<Mouse>/forwardButton"));
_buttonMappings.Add(MapMouseButton(MouseBack, "<Mouse>/backButton"));
Canvas.ForceUpdateCanvases();
foreach (var buttonMapping in _buttonMappings)
{
_bindButtons[buttonMapping.Button.InputSystemPath] = buttonMapping;
buttonMapping.TestAction = new InputAction(binding: buttonMapping.Button.InputSystemPath);
buttonMapping.TestAction.started += context =>
{
@ -118,7 +115,7 @@ public class InputDisplayLayout : MonoBehaviour
buttonMapping.TestAction.canceled += context => AssignColor(buttonMapping);
buttonMapping.TestAction.Enable();
}
foreach(var actionBarInput in ActionGameManager.PlayerSettings.InputSettings.ActionBarInputs)
{
if (!_bindButtons.ContainsKey(actionBarInput)) Debug.LogError($"Unable to find input button for \"{actionBarInput}\"");
@ -128,7 +125,7 @@ public class InputDisplayLayout : MonoBehaviour
AssignColor(_bindButtons[actionBarInput]);
}
}
if(Input==null)
{
var input = new AetheriaInput();
@ -185,7 +182,7 @@ public class InputDisplayLayout : MonoBehaviour
: frac(GlobalHue + GlobalHueRange + (float) i / (bindableActions.Length - 1) * (1 - GlobalHueRange * 2))
};
_actionMappings.Add(actionMapping);
var buttonMapping = _bindButtons[binding.effectivePath];
buttonMapping.ActionMapping = actionMapping;
AssignColor(buttonMapping);
@ -310,7 +307,7 @@ public class InputDisplayLayout : MonoBehaviour
private ActionMapping[] OverlappingLabels(Rect rect) => _actionMappings
.Where(a => a.LabelRect.Overlaps(rect)).ToArray();
private Rect[] Overlap(Rect rect) => _buttonMappings
.Where(b=>b.IsActionBarButton || b.ActionMapping!=null)
.Select(b=>b.ButtonRect)
@ -345,7 +342,7 @@ public class InputDisplayLayout : MonoBehaviour
{
var buttonMapping = new ButtonMapping
{
Button = key,
Button = key,
DisplayButton = displayKey
};
_bindButtons[key.InputSystemPath] = buttonMapping;
@ -390,11 +387,11 @@ public class InputDisplayLayout : MonoBehaviour
var nextWidth = 1f;
var nextHeight = 1;
var reader = new JsonTextReader(new StringReader(layout));
reader.Read();
if (reader.TokenType != JsonToken.StartArray)
throw new JsonReaderException($"Unexpected JSON format in line {reader.LineNumber}:{reader.LinePosition}, expected: StartArray, received: {Enum.GetName(typeof(JsonToken), reader.TokenType)}");
while(reader.Read() && reader.TokenType != JsonToken.EndArray)
{
if (reader.TokenType != JsonToken.StartArray)
@ -475,12 +472,12 @@ public class InputDisplayLayout : MonoBehaviour
fillColor *= FillMultiplier;
fillColor.a = FillAlpha;
button.DisplayButton.Fill.color = fillColor;
path = "";
while (string.IsNullOrEmpty(path)) yield return null;
button.Button.InputSystemPath = path;
//Debug.Log($"Bound \"{path}\" to \"{bindableKey.MainLabel}\"");
button.DisplayButton.Outline.color = DefaultColor;
fillColor = DefaultColor;
fillColor *= FillMultiplier;
@ -623,7 +620,7 @@ public class InputDisplayLayout : MonoBehaviour
.Where(_ => _dragAction != null)
.Subscribe(EndDrag);
}
foreach (var actionMapping in _actionMappings)
{
actionMapping.Label.BeginDragTrigger.OnBeginDragAsObservable().Subscribe(_ =>

View file

@ -1,18 +1,16 @@
using System.Collections.Generic;
using JsonKnownTypes;using MessagePack;
using Newtonsoft.Json;
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
using MessagePack;
[MessagePackObject]
public class InputLayout
{
[Key(0), JsonProperty("rows")] public InputLayoutRow[] Rows;
[Key(0)] public InputLayoutRow[] Rows;
public IEnumerable<InputLayoutBindableKey> GetBindableKeys()
{
foreach (var row in Rows)
{
if (!(row is InputLayoutKeyRow keyRow)) continue;
foreach (var column in keyRow.Columns)
{
if (column is InputLayoutBindableKey bindableKey)
@ -24,27 +22,25 @@ public class InputLayout
}
}
[JsonConverter(typeof(JsonKnownTypesConverter<InputLayoutRow>)),
MessagePackObject,
[MessagePackObject,
Union(0, typeof(InputLayoutRowSpacer)),
Union(1, typeof(InputLayoutKeyRow))
]
public abstract class InputLayoutRow { }
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class InputLayoutRowSpacer : InputLayoutRow
{
[Key(0), JsonProperty("height")] public float Height;
[Key(0)] public float Height;
}
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class InputLayoutKeyRow : InputLayoutRow
{
[Key(0), JsonProperty("columns")] public InputLayoutColumn[] Columns;
[Key(0)] public InputLayoutColumn[] Columns;
}
[JsonConverter(typeof(JsonKnownTypesConverter<InputLayoutColumn>)),
MessagePackObject,
[MessagePackObject,
Union(0, typeof(InputLayoutColumnSpacer)),
Union(1, typeof(InputLayoutKey)),
Union(2, typeof(InputLayoutBindableKey)),
@ -52,21 +48,21 @@ public class InputLayoutKeyRow : InputLayoutRow
]
public abstract class InputLayoutColumn
{
[Key(0), JsonProperty("width")] public float Width;
[Key(0)] public float Width;
}
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class InputLayoutColumnSpacer : InputLayoutColumn { }
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class InputLayoutKey : InputLayoutColumn { }
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
[MessagePackObject]
public class InputLayoutBindableKey : InputLayoutKey, IBindableButton
{
[Key(1), JsonProperty("mainLabel")] public string MainLabel;
[Key(2), JsonProperty("altLabel")] public string AltLabel;
[Key(3), JsonProperty("path")] public string ShortPath;
[Key(1)] public string MainLabel;
[Key(2)] public string AltLabel;
[Key(3)] public string ShortPath;
[IgnoreMember]
public string InputSystemPath
@ -84,7 +80,7 @@ public class InputLayoutBindableKey : InputLayoutKey, IBindableButton
public class InputLayoutMultiRowKey : InputLayoutBindableKey
{
[Key(4), JsonProperty("height")] public int Height;
[Key(4)] public int Height;
}
public class InputLayoutMouseButton : IBindableButton

View file

@ -4,16 +4,15 @@
<TargetFramework>netstandard2.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\Assets\Scripts\ServerShared\**\*.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="MessagePack" Version="2.1.90" />
<PackageReference Include="MessagePack.MSBuild.Tasks" Version="2.0.323" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0-preview.1.20120.4" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="Remotion.Linq" Version="2.2.0" />
</ItemGroup>