From b0d2aa115686d4e52fa1f060cbc22689ec2e3308 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 13 Jun 2026 04:56:50 +0100 Subject: [PATCH] Purge Newtonsoft state annotations --- .../CultCache/Editor/AetheriaDatabaseView.cs | 8 +- .../CultCache/Editor/DatabaseInspector.cs | 47 ++-- Assets/Scripts/Gameplay/ActionBarSlot.cs | 4 +- .../ServerShared/Agents/Tasks/AgentTask.cs | 22 +- .../ServerShared/Agents/Tasks/HaulingTask.cs | 20 +- .../ServerShared/Agents/Tasks/Mining.cs | 12 +- .../Agents/Tasks/StationTowing.cs | 20 +- .../ServerShared/Agents/Tasks/Survey.cs | 12 +- .../ServerShared/Behaviors/AetherDrive.cs | 67 +++-- .../ServerShared/Behaviors/AutoWeapon.cs | 5 +- .../ServerShared/Behaviors/Behaviors.cs | 29 +-- .../ServerShared/Behaviors/Capacitor.cs | 13 +- .../ServerShared/Behaviors/ChargedWeapon.cs | 43 ++-- .../Scripts/ServerShared/Behaviors/Cockpit.cs | 7 +- .../ServerShared/Behaviors/ConstantWeapon.cs | 21 +- .../ServerShared/Behaviors/Cooldown.cs | 11 +- .../ServerShared/Behaviors/EnergyDraw.cs | 16 +- Assets/Scripts/ServerShared/Behaviors/Heat.cs | 16 +- .../ServerShared/Behaviors/HeatStorage.cs | 3 +- .../ServerShared/Behaviors/InstantWeapon.cs | 23 +- .../ServerShared/Behaviors/ItemUsage.cs | 14 +- .../ServerShared/Behaviors/Launcher.cs | 29 +-- .../ServerShared/Behaviors/LockWeapon.cs | 17 +- .../ServerShared/Behaviors/MiningTool.cs | 27 +- .../ServerShared/Behaviors/Radiator.cs | 43 ++-- .../Scripts/ServerShared/Behaviors/Reactor.cs | 27 +- .../ServerShared/Behaviors/Reflector.cs | 13 +- .../ServerShared/Behaviors/ResourceScanner.cs | 21 +- .../Scripts/ServerShared/Behaviors/Sensor.cs | 31 ++- .../Scripts/ServerShared/Behaviors/Shield.cs | 9 +- .../ServerShared/Behaviors/StatModifier.cs | 30 +-- .../Scripts/ServerShared/Behaviors/Switch.cs | 6 +- .../ServerShared/Behaviors/Thermotoggle.cs | 16 +- .../ServerShared/Behaviors/Thruster.cs | 19 +- .../Scripts/ServerShared/Behaviors/Trigger.cs | 6 +- .../Behaviors/TurretController.cs | 5 +- .../Behaviors/VelocityConversion.cs | 7 +- .../ServerShared/Behaviors/VelocityLimit.cs | 7 +- .../ServerShared/Behaviors/Visibility.cs | 12 +- .../Scripts/ServerShared/Behaviors/Weapon.cs | 59 +++-- Assets/Scripts/ServerShared/Behaviors/Wear.cs | 7 +- Assets/Scripts/ServerShared/BezierCurve.cs | 23 +- Assets/Scripts/ServerShared/Corporations.cs | 47 ++-- .../ServerShared/CultCache/DatabaseEntry.cs | 54 ++-- .../CultCache/Serialization/JsonConverters.cs | 169 ------------ .../Serialization/JsonConverters.cs.meta | 11 - .../Serialization/JsonKnownTypes.meta | 8 - .../JsonKnownTypes/AttributesManager.cs | 16 -- .../JsonKnownTypes/AttributesManager.cs.meta | 11 - .../JsonKnownTypes/Exceptions.meta | 8 - .../Exceptions/JsonKnownTypesException.cs | 15 -- .../JsonKnownTypesException.cs.meta | 11 - .../JsonDiscriminatorAttribute.cs | 18 -- .../JsonDiscriminatorAttribute.cs.meta | 11 - .../JsonDiscriminatorSettings.cs | 8 - .../JsonDiscriminatorSettings.cs.meta | 11 - .../JsonKnownThisTypeAttribute.cs | 17 -- .../JsonKnownThisTypeAttribute.cs.meta | 11 - .../JsonKnownTypes/JsonKnownTypeAttribute.cs | 22 -- .../JsonKnownTypeAttribute.cs.meta | 11 - .../JsonKnownTypes/JsonKnownTypes.csproj | 22 -- .../JsonKnownTypes/JsonKnownTypes.csproj.meta | 7 - .../JsonKnownTypesContractResolver.cs | 16 -- .../JsonKnownTypesContractResolver.cs.meta | 11 - .../JsonKnownTypes/JsonKnownTypesConverter.cs | 57 ---- .../JsonKnownTypesConverter.cs.meta | 11 - .../JsonKnownTypesDictionaryManager.cs | 64 ----- .../JsonKnownTypesDictionaryManager.cs.meta | 11 - .../JsonKnownTypes/JsonKnownTypesSettings.cs | 12 - .../JsonKnownTypesSettings.cs.meta | 11 - .../JsonKnownTypesSettingsManager.cs | 60 ----- .../JsonKnownTypesSettingsManager.cs.meta | 11 - .../Serialization/JsonKnownTypes/Utils.meta | 8 - .../JsonKnownTypes/Utils/Mapper.cs | 15 -- .../JsonKnownTypes/Utils/Mapper.cs.meta | 11 - Assets/Scripts/ServerShared/EnumDictionary.cs | 6 +- Assets/Scripts/ServerShared/Environment.cs | 131 +++++----- .../Scripts/ServerShared/ExponentialCurve.cs | 31 ++- Assets/Scripts/ServerShared/GlobalData.cs | 43 ++-- Assets/Scripts/ServerShared/ItemData.cs | 243 +++++++++--------- Assets/Scripts/ServerShared/ItemInstance.cs | 54 ++-- .../ServerShared/NIH/MIConvexHull/Cell2.cs | 32 +-- Assets/Scripts/ServerShared/PlayerData.cs | 14 +- Assets/Scripts/ServerShared/Settings.cs | 33 ++- Assets/Scripts/ServerShared/Ship.cs | 31 ++- Assets/Scripts/ServerShared/WwiseMetadata.cs | 6 - .../Scripts/ServerShared/WwiseSoundBinding.cs | 12 +- Assets/Scripts/ServerShared/ZoneData.cs | 150 ++++++----- Assets/Scripts/ServerShared/ZoneGenerator.cs | 96 +++---- .../UI/InputScreen/InputDisplayLayout.cs | 35 ++- Assets/Scripts/UI/InputScreen/InputLayout.cs | 40 ++- Economy.Shared/Economy.Shared.csproj | 5 +- 92 files changed, 891 insertions(+), 1684 deletions(-) delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonConverters.cs delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonConverters.cs.meta delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes.meta delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/AttributesManager.cs delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/AttributesManager.cs.meta delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Exceptions.meta delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Exceptions/JsonKnownTypesException.cs delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Exceptions/JsonKnownTypesException.cs.meta delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonDiscriminatorAttribute.cs delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonDiscriminatorAttribute.cs.meta delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonDiscriminatorSettings.cs delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonDiscriminatorSettings.cs.meta delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownThisTypeAttribute.cs delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownThisTypeAttribute.cs.meta delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypeAttribute.cs delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypeAttribute.cs.meta delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypes.csproj delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypes.csproj.meta delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesContractResolver.cs delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesContractResolver.cs.meta delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesConverter.cs delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesConverter.cs.meta delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesDictionaryManager.cs delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesDictionaryManager.cs.meta delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesSettings.cs delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesSettings.cs.meta delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesSettingsManager.cs delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesSettingsManager.cs.meta delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Utils.meta delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Utils/Mapper.cs delete mode 100644 Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Utils/Mapper.cs.meta diff --git a/Assets/Scripts/CultCache/Editor/AetheriaDatabaseView.cs b/Assets/Scripts/CultCache/Editor/AetheriaDatabaseView.cs index 9a609b371..e18d815f6 100644 --- a/Assets/Scripts/CultCache/Editor/AetheriaDatabaseView.cs +++ b/Assets/Scripts/CultCache/Editor/AetheriaDatabaseView.cs @@ -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(); @@ -23,11 +23,11 @@ public class AetheriaDatabaseView : DatabaseListView protected override DatabaseEntryGroup[] Groupers => new DatabaseEntryGroup[] { new DatabaseEntryGroup( - data => data.Category, + data => data.Category, category => Enum.GetName(typeof(SimpleCommodityCategory), category), (data, category) => data.Category = category ), new DatabaseEntryGroup( - data => data.Category, + data => data.Category, category => Enum.GetName(typeof(CompoundCommodityCategory), category), (data, category) => data.Category = category ), new DatabaseEntryGroup( @@ -43,4 +43,4 @@ public class AetheriaDatabaseView : DatabaseListView type => Enum.GetName(typeof(HullType), type), (data, type) => data.HullType = type) }; -} \ No newline at end of file +} diff --git a/Assets/Scripts/CultCache/Editor/DatabaseInspector.cs b/Assets/Scripts/CultCache/Editor/DatabaseInspector.cs index 0ea16b439..0c896850c 100644 --- a/Assets/Scripts/CultCache/Editor/DatabaseInspector.cs +++ b/Assets/Scripts/CultCache/Editor/DatabaseInspector.cs @@ -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(); @@ -32,10 +31,10 @@ public class DatabaseInspector : EditorWindow private Vector2 _view; private GUIStyle _warning; - private List<(Type targetType, HashSet attributes, Type inspectorType, object instance)> _inspectors = + private List<(Type targetType, HashSet attributes, Type inspectorType, object instance)> _inspectors = new List<(Type targetType, HashSet attributes, Type inspectorType, object instance)>(); - private List<(Type targetType, HashSet attributes, Type inspectorType, Dictionary instances)> _genericInspectors = + private List<(Type targetType, HashSet attributes, Type inspectorType, Dictionary instances)> _genericInspectors = new List<(Type targetType, HashSet attributes, Type inspectorType, Dictionary instances)>(); private HashSet _foldouts = new HashSet(); @@ -60,8 +59,8 @@ public class DatabaseInspector : EditorWindow if (genericArguments[0].ContainsGenericParameters) { _genericInspectors.Add(( - genericArguments[0].GetGenericTypeDefinition(), - new HashSet(genericArguments.Skip(1)), + genericArguments[0].GetGenericTypeDefinition(), + new HashSet(genericArguments.Skip(1)), type, new Dictionary() )); @@ -69,16 +68,16 @@ public class DatabaseInspector : EditorWindow else { _inspectors.Add(( - genericArguments[0], - new HashSet(genericArguments.Skip(1)), - type, + genericArguments[0], + new HashSet(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()?.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(); @@ -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().Any(); @@ -133,7 +132,7 @@ public class DatabaseInspector : EditorWindow _listItemStyle = style; return value; } - + if (type.GetCustomAttribute() != 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(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(); } } diff --git a/Assets/Scripts/Gameplay/ActionBarSlot.cs b/Assets/Scripts/Gameplay/ActionBarSlot.cs index 02ecb5ae2..a02e9b9af 100644 --- a/Assets/Scripts/Gameplay/ActionBarSlot.cs +++ b/Assets/Scripts/Gameplay/ActionBarSlot.cs @@ -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() { - + } } \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/Agents/Tasks/AgentTask.cs b/Assets/Scripts/ServerShared/Agents/Tasks/AgentTask.cs index 1e6e86fb8..7bbeaa099 100644 --- a/Assets/Scripts/ServerShared/Agents/Tasks/AgentTask.cs +++ b/Assets/Scripts/ServerShared/Agents/Tasks/AgentTask.cs @@ -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))] + 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; } } diff --git a/Assets/Scripts/ServerShared/Agents/Tasks/HaulingTask.cs b/Assets/Scripts/ServerShared/Agents/Tasks/HaulingTask.cs index 137fca75f..89fb2adbf 100644 --- a/Assets/Scripts/ServerShared/Agents/Tasks/HaulingTask.cs +++ b/Assets/Scripts/ServerShared/Agents/Tasks/HaulingTask.cs @@ -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; } diff --git a/Assets/Scripts/ServerShared/Agents/Tasks/Mining.cs b/Assets/Scripts/ServerShared/Agents/Tasks/Mining.cs index d61cf31fa..32cf9a300 100644 --- a/Assets/Scripts/ServerShared/Agents/Tasks/Mining.cs +++ b/Assets/Scripts/ServerShared/Agents/Tasks/Mining.cs @@ -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))] +[MessagePackObject] public class Mining : AgentTask { [IgnoreMember] public override TaskType Type => TaskType.Mine; - - [JsonProperty("asteroids"), Key(4)] + + [Key(4)] public Guid Asteroids; } \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/Agents/Tasks/StationTowing.cs b/Assets/Scripts/ServerShared/Agents/Tasks/StationTowing.cs index 926fc3cf8..711abded7 100644 --- a/Assets/Scripts/ServerShared/Agents/Tasks/StationTowing.cs +++ b/Assets/Scripts/ServerShared/Agents/Tasks/StationTowing.cs @@ -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))] +[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; } diff --git a/Assets/Scripts/ServerShared/Agents/Tasks/Survey.cs b/Assets/Scripts/ServerShared/Agents/Tasks/Survey.cs index 5d43dcebc..261e364c7 100644 --- a/Assets/Scripts/ServerShared/Agents/Tasks/Survey.cs +++ b/Assets/Scripts/ServerShared/Agents/Tasks/Survey.cs @@ -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))] +[MessagePackObject] public class Survey : AgentTask { [IgnoreMember] public override TaskType Type => TaskType.Explore; - - [JsonProperty("station"), Key(4)] + + [Key(4)] public List Planets; } \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/Behaviors/AetherDrive.cs b/Assets/Scripts/ServerShared/Behaviors/AetherDrive.cs index 8e10ef28f..a2c09d0aa 100644 --- a/Assets/Scripts/ServerShared/Behaviors/AetherDrive.cs +++ b/Assets/Scripts/ServerShared/Behaviors/AetherDrive.cs @@ -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; } } \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/Behaviors/AutoWeapon.cs b/Assets/Scripts/ServerShared/Behaviors/AutoWeapon.cs index 0d97804ef..19ac49573 100644 --- a/Assets/Scripts/ServerShared/Behaviors/AutoWeapon.cs +++ b/Assets/Scripts/ServerShared/Behaviors/AutoWeapon.cs @@ -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) { } diff --git a/Assets/Scripts/ServerShared/Behaviors/Behaviors.cs b/Assets/Scripts/ServerShared/Behaviors/Behaviors.cs index 3a59401eb..7245f9d47 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Behaviors.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Behaviors.cs @@ -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))] +[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)), 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); diff --git a/Assets/Scripts/ServerShared/Behaviors/Capacitor.cs b/Assets/Scripts/ServerShared/Behaviors/Capacitor.cs index f25c489b6..e677b5251 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Capacitor.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Capacitor.cs @@ -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); diff --git a/Assets/Scripts/ServerShared/Behaviors/ChargedWeapon.cs b/Assets/Scripts/ServerShared/Behaviors/ChargedWeapon.cs index 50e23a735..ef0dccb3a 100644 --- a/Assets/Scripts/ServerShared/Behaviors/ChargedWeapon.cs +++ b/Assets/Scripts/ServerShared/Behaviors/ChargedWeapon.cs @@ -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; diff --git a/Assets/Scripts/ServerShared/Behaviors/Cockpit.cs b/Assets/Scripts/ServerShared/Behaviors/Cockpit.cs index a09a65905..a1146950d 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Cockpit.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Cockpit.cs @@ -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; diff --git a/Assets/Scripts/ServerShared/Behaviors/ConstantWeapon.cs b/Assets/Scripts/ServerShared/Behaviors/ConstantWeapon.cs index e7f9a98b2..eefa7028c 100644 --- a/Assets/Scripts/ServerShared/Behaviors/ConstantWeapon.cs +++ b/Assets/Scripts/ServerShared/Behaviors/ConstantWeapon.cs @@ -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; diff --git a/Assets/Scripts/ServerShared/Behaviors/Cooldown.cs b/Assets/Scripts/ServerShared/Behaviors/Cooldown.cs index b397dd50e..04890e549 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Cooldown.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Cooldown.cs @@ -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); diff --git a/Assets/Scripts/ServerShared/Behaviors/EnergyDraw.cs b/Assets/Scripts/ServerShared/Behaviors/EnergyDraw.cs index faf8ae709..13f5f0c1d 100644 --- a/Assets/Scripts/ServerShared/Behaviors/EnergyDraw.cs +++ b/Assets/Scripts/ServerShared/Behaviors/EnergyDraw.cs @@ -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); diff --git a/Assets/Scripts/ServerShared/Behaviors/Heat.cs b/Assets/Scripts/ServerShared/Behaviors/Heat.cs index e507d2b28..59aec861d 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Heat.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Heat.cs @@ -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); diff --git a/Assets/Scripts/ServerShared/Behaviors/HeatStorage.cs b/Assets/Scripts/ServerShared/Behaviors/HeatStorage.cs index 02edcb121..01c3de3e3 100644 --- a/Assets/Scripts/ServerShared/Behaviors/HeatStorage.cs +++ b/Assets/Scripts/ServerShared/Behaviors/HeatStorage.cs @@ -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) diff --git a/Assets/Scripts/ServerShared/Behaviors/InstantWeapon.cs b/Assets/Scripts/ServerShared/Behaviors/InstantWeapon.cs index 79e22ed54..afdab140e 100644 --- a/Assets/Scripts/ServerShared/Behaviors/InstantWeapon.cs +++ b/Assets/Scripts/ServerShared/Behaviors/InstantWeapon.cs @@ -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(); diff --git a/Assets/Scripts/ServerShared/Behaviors/ItemUsage.cs b/Assets/Scripts/ServerShared/Behaviors/ItemUsage.cs index f5dda8a5f..47620ff08 100644 --- a/Assets/Scripts/ServerShared/Behaviors/ItemUsage.cs +++ b/Assets/Scripts/ServerShared/Behaviors/ItemUsage.cs @@ -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; } } \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/Behaviors/Launcher.cs b/Assets/Scripts/ServerShared/Behaviors/Launcher.cs index 5e6ea44c0..3532b4d2c 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Launcher.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Launcher.cs @@ -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) diff --git a/Assets/Scripts/ServerShared/Behaviors/LockWeapon.cs b/Assets/Scripts/ServerShared/Behaviors/LockWeapon.cs index dc6fd230a..5364efb60 100644 --- a/Assets/Scripts/ServerShared/Behaviors/LockWeapon.cs +++ b/Assets/Scripts/ServerShared/Behaviors/LockWeapon.cs @@ -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; diff --git a/Assets/Scripts/ServerShared/Behaviors/MiningTool.cs b/Assets/Scripts/ServerShared/Behaviors/MiningTool.cs index 84c307849..ac6df02ae 100644 --- a/Assets/Scripts/ServerShared/Behaviors/MiningTool.cs +++ b/Assets/Scripts/ServerShared/Behaviors/MiningTool.cs @@ -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( diff --git a/Assets/Scripts/ServerShared/Behaviors/Radiator.cs b/Assets/Scripts/ServerShared/Behaviors/Radiator.cs index 1549a8d40..85ee832a4 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Radiator.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Radiator.cs @@ -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; diff --git a/Assets/Scripts/ServerShared/Behaviors/Reactor.cs b/Assets/Scripts/ServerShared/Behaviors/Reactor.cs index a5ea6e937..341cd0ba3 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Reactor.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Reactor.cs @@ -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; } diff --git a/Assets/Scripts/ServerShared/Behaviors/Reflector.cs b/Assets/Scripts/ServerShared/Behaviors/Reflector.cs index cb23004b0..c30554567 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Reflector.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Reflector.cs @@ -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; } } \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/Behaviors/ResourceScanner.cs b/Assets/Scripts/ServerShared/Behaviors/ResourceScanner.cs index 05bedb0ed..4cbb9f24d 100644 --- a/Assets/Scripts/ServerShared/Behaviors/ResourceScanner.cs +++ b/Assets/Scripts/ServerShared/Behaviors/ResourceScanner.cs @@ -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; diff --git a/Assets/Scripts/ServerShared/Behaviors/Sensor.cs b/Assets/Scripts/ServerShared/Behaviors/Sensor.cs index d967ea8a3..6b6d8c372 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Sensor.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Sensor.cs @@ -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); diff --git a/Assets/Scripts/ServerShared/Behaviors/Shield.cs b/Assets/Scripts/ServerShared/Behaviors/Shield.cs index 56f8d0165..e9abd36fe 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Shield.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Shield.cs @@ -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); diff --git a/Assets/Scripts/ServerShared/Behaviors/StatModifier.cs b/Assets/Scripts/ServerShared/Behaviors/StatModifier.cs index 6d29d5472..b03fb5db2 100644 --- a/Assets/Scripts/ServerShared/Behaviors/StatModifier.cs +++ b/Assets/Scripts/ServerShared/Behaviors/StatModifier.cs @@ -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; } \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/Behaviors/Switch.cs b/Assets/Scripts/ServerShared/Behaviors/Switch.cs index 4795a2b2e..0db096d01 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Switch.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Switch.cs @@ -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) diff --git a/Assets/Scripts/ServerShared/Behaviors/Thermotoggle.cs b/Assets/Scripts/ServerShared/Behaviors/Thermotoggle.cs index 009a04c9e..5c741464a 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Thermotoggle.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Thermotoggle.cs @@ -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); diff --git a/Assets/Scripts/ServerShared/Behaviors/Thruster.cs b/Assets/Scripts/ServerShared/Behaviors/Thruster.cs index e5908a847..45e34ae29 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Thruster.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Thruster.cs @@ -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) diff --git a/Assets/Scripts/ServerShared/Behaviors/Trigger.cs b/Assets/Scripts/ServerShared/Behaviors/Trigger.cs index 26262d8a7..a56e684ca 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Trigger.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Trigger.cs @@ -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) diff --git a/Assets/Scripts/ServerShared/Behaviors/TurretController.cs b/Assets/Scripts/ServerShared/Behaviors/TurretController.cs index f2d99e948..51004d4ab 100644 --- a/Assets/Scripts/ServerShared/Behaviors/TurretController.cs +++ b/Assets/Scripts/ServerShared/Behaviors/TurretController.cs @@ -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) diff --git a/Assets/Scripts/ServerShared/Behaviors/VelocityConversion.cs b/Assets/Scripts/ServerShared/Behaviors/VelocityConversion.cs index 35a89bfed..dfb2a3d39 100644 --- a/Assets/Scripts/ServerShared/Behaviors/VelocityConversion.cs +++ b/Assets/Scripts/ServerShared/Behaviors/VelocityConversion.cs @@ -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); diff --git a/Assets/Scripts/ServerShared/Behaviors/VelocityLimit.cs b/Assets/Scripts/ServerShared/Behaviors/VelocityLimit.cs index 2b66d512b..596e3b234 100644 --- a/Assets/Scripts/ServerShared/Behaviors/VelocityLimit.cs +++ b/Assets/Scripts/ServerShared/Behaviors/VelocityLimit.cs @@ -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); diff --git a/Assets/Scripts/ServerShared/Behaviors/Visibility.cs b/Assets/Scripts/ServerShared/Behaviors/Visibility.cs index 1311f7cff..6ce82b5af 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Visibility.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Visibility.cs @@ -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); diff --git a/Assets/Scripts/ServerShared/Behaviors/Weapon.cs b/Assets/Scripts/ServerShared/Behaviors/Weapon.cs index 5af38dd5b..330931739 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Weapon.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Weapon.cs @@ -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; diff --git a/Assets/Scripts/ServerShared/Behaviors/Wear.cs b/Assets/Scripts/ServerShared/Behaviors/Wear.cs index 945206bad..9873e71f3 100644 --- a/Assets/Scripts/ServerShared/Behaviors/Wear.cs +++ b/Assets/Scripts/ServerShared/Behaviors/Wear.cs @@ -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); diff --git a/Assets/Scripts/ServerShared/BezierCurve.cs b/Assets/Scripts/ServerShared/BezierCurve.cs index 78ac3ef22..75e0bf746 100644 --- a/Assets/Scripts/ServerShared/BezierCurve.cs +++ b/Assets/Scripts/ServerShared/BezierCurve.cs @@ -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; diff --git a/Assets/Scripts/ServerShared/Corporations.cs b/Assets/Scripts/ServerShared/Corporations.cs index 22eb20222..3ff34691e 100644 --- a/Assets/Scripts/ServerShared/Corporations.cs +++ b/Assets/Scripts/ServerShared/Corporations.cs @@ -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 Personality = new Dictionary(); - // [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 Allegiance = new Dictionary(); - [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; diff --git a/Assets/Scripts/ServerShared/CultCache/DatabaseEntry.cs b/Assets/Scripts/ServerShared/CultCache/DatabaseEntry.cs index dcbdbb5be..ac560d6da 100644 --- a/Assets/Scripts/ServerShared/CultCache/DatabaseEntry.cs +++ b/Assets/Scripts/ServerShared/CultCache/DatabaseEntry.cs @@ -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)), - 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 : DatabaseLinkBase where T : DatabaseEntry { [IgnoreMember] public T Value => Cache.Get(LinkID); } -[MessagePackObject, JsonObject(MemberSerialization.OptIn)] +[MessagePackObject] public class DatabaseLinkBase { - [Key(0), JsonProperty("linkID")] + [Key(0)] public Guid LinkID; - + [IgnoreMember] public static CultCache Cache; } diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonConverters.cs b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonConverters.cs deleted file mode 100644 index c76bcad2a..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonConverters.cs +++ /dev/null @@ -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> _writers; - private readonly Dictionary> _readers; - - public MathJsonConverter() - { - _writers = GenerateWriters(); - _readers = GenerateReaders(); - } - - private Dictionary> GenerateWriters() - { - var writers = new Dictionary>(); - - 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> GenerateReaders() - { - var readers = new Dictionary>(); - - 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(), - array[1].ToObject()); - }; - - 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(), - array[1].ToObject()); - }; - - 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(), - array[1].ToObject(), - array[2].ToObject()); - }; - - 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(), - array[1].ToObject(), - array[2].ToObject(), - array[3].ToObject()); - }; - - 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; -} diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonConverters.cs.meta b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonConverters.cs.meta deleted file mode 100644 index a45bf1a53..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonConverters.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fafad9d553198e942a5501ea1472ec9c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes.meta b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes.meta deleted file mode 100644 index 81eae7208..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: f94c63c8b140fb34bb5d70a8d8a5dbd6 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/AttributesManager.cs b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/AttributesManager.cs deleted file mode 100644 index c164613f4..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/AttributesManager.cs +++ /dev/null @@ -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)); - } -} diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/AttributesManager.cs.meta b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/AttributesManager.cs.meta deleted file mode 100644 index 692781e53..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/AttributesManager.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 6036d25d64e90064ca92c91f6d7827b2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Exceptions.meta b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Exceptions.meta deleted file mode 100644 index e7515a8b8..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Exceptions.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 01722fba3f2fd3942bca61d48508ad27 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Exceptions/JsonKnownTypesException.cs b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Exceptions/JsonKnownTypesException.cs deleted file mode 100644 index 417772b64..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Exceptions/JsonKnownTypesException.cs +++ /dev/null @@ -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) - { } - } -} diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Exceptions/JsonKnownTypesException.cs.meta b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Exceptions/JsonKnownTypesException.cs.meta deleted file mode 100644 index abc9ed520..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Exceptions/JsonKnownTypesException.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 36f9ed87d773cf146bf68e828cefe89c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonDiscriminatorAttribute.cs b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonDiscriminatorAttribute.cs deleted file mode 100644 index bfb337f38..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonDiscriminatorAttribute.cs +++ /dev/null @@ -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; - } - } -} diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonDiscriminatorAttribute.cs.meta b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonDiscriminatorAttribute.cs.meta deleted file mode 100644 index d826e354a..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonDiscriminatorAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: f7c6582f43e22994ebbaf0e139e63dc5 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonDiscriminatorSettings.cs b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonDiscriminatorSettings.cs deleted file mode 100644 index 7d9386122..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonDiscriminatorSettings.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace JsonKnownTypes -{ - public class JsonDiscriminatorSettings - { - public string Name { get; set; } = "$type"; - public bool AutoJsonKnown { get; set; } = true; - } -} diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonDiscriminatorSettings.cs.meta b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonDiscriminatorSettings.cs.meta deleted file mode 100644 index b23d572e6..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonDiscriminatorSettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b5f09ee78f257904caa3ab939d3edc65 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownThisTypeAttribute.cs b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownThisTypeAttribute.cs deleted file mode 100644 index 6733da6ff..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownThisTypeAttribute.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; - -namespace JsonKnownTypes -{ - public class JsonKnownThisTypeAttribute : Attribute - { - public string Discriminator { get; } - - public JsonKnownThisTypeAttribute() - { } - - public JsonKnownThisTypeAttribute(string discriminator) - { - Discriminator = discriminator; - } - } -} diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownThisTypeAttribute.cs.meta b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownThisTypeAttribute.cs.meta deleted file mode 100644 index d11e7fc5f..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownThisTypeAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c8dc4cbd1c54167409cf14ec8ec37d70 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypeAttribute.cs b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypeAttribute.cs deleted file mode 100644 index ef8a2dcca..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypeAttribute.cs +++ /dev/null @@ -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; - } - } -} diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypeAttribute.cs.meta b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypeAttribute.cs.meta deleted file mode 100644 index 67c7bc35e..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypeAttribute.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: ecbe3646a4d9ca04eac598b60e5c77ca -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypes.csproj b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypes.csproj deleted file mode 100644 index 1d7caa587..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypes.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - - netstandard2.0 - - - - - - - - true - 0.2.0 - Dmitry Kaznacheev - https://github.com/dmitry-bym/JsonKnownTypes - https://github.com/dmitry-bym/JsonKnownTypes/blob/master/LICENSE - Dmitry Kaznacheev - https://github.com/dmitry-bym/JsonKnownTypes - json known polymorphic types - - - diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypes.csproj.meta b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypes.csproj.meta deleted file mode 100644 index c016da1db..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypes.csproj.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 937d902757d946b47a7bea20ade37beb -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesContractResolver.cs b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesContractResolver.cs deleted file mode 100644 index 797e420a7..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesContractResolver.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; - -namespace JsonKnownTypes -{ - public class JsonKnownTypesContractResolver : DefaultContractResolver - { - protected override JsonConverter ResolveContractConverter(Type objectType) - { - if (typeof(T).IsAssignableFrom(objectType) && !objectType.IsAbstract) - return null; - return base.ResolveContractConverter(objectType); - } - } -} diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesContractResolver.cs.meta b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesContractResolver.cs.meta deleted file mode 100644 index 51f187146..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesContractResolver.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: bce1b7fa2da230447b3614d23394ee9f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesConverter.cs b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesConverter.cs deleted file mode 100644 index 343cd73a6..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesConverter.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -namespace JsonKnownTypes -{ - public class JsonKnownTypesConverter : JsonConverter - { - private readonly JsonKnownTypesSettings _typesSettings - = JsonKnownTypesSettingsManager.GetSettings(); - - private JsonSerializerSettings SpecifiedSubclassConversion - { - get => - new JsonSerializerSettings - { - ContractResolver = new JsonKnownTypesContractResolver() - }; - } - - 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}!"); - } - } - } -} diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesConverter.cs.meta b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesConverter.cs.meta deleted file mode 100644 index f075f2684..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesConverter.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: b0a6c832fc846634789aa691cd2b81d9 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesDictionaryManager.cs b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesDictionaryManager.cs deleted file mode 100644 index 09b8f5634..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesDictionaryManager.cs +++ /dev/null @@ -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(this Dictionary 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 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 dictionary, Type[] inherited) - { - foreach (var type in inherited.Except(dictionary.Keys)) - { - dictionary.TryAdd(type, type.Name); - } - } - - public static void TryAdd(this Dictionary 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 Revert(this Dictionary dictionary) - { - try - { - return dictionary.ToDictionary(x => x.Value, x => x.Key); - } - catch (ArgumentException e) - { - throw new JsonKnownTypesException("Dictionary has a repeated value", e); - } - } - } -} diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesDictionaryManager.cs.meta b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesDictionaryManager.cs.meta deleted file mode 100644 index 33f376bd2..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesDictionaryManager.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 77ce621509349204a87085f089b3daa3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesSettings.cs b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesSettings.cs deleted file mode 100644 index 6d61fdb74..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesSettings.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace JsonKnownTypes -{ - public class JsonKnownTypesSettings - { - public string Name { get; set; } - public Dictionary DiscriminatorToType { get; set; } = new Dictionary(); - public Dictionary TypeToDiscriminator { get; set; } = new Dictionary(); - } -} diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesSettings.cs.meta b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesSettings.cs.meta deleted file mode 100644 index 750329339..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesSettings.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 99b988650c739094aa3a5ba7040ea379 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesSettingsManager.cs b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesSettingsManager.cs deleted file mode 100644 index c3c011efa..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesSettingsManager.cs +++ /dev/null @@ -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 RegisteredAssemblies = new HashSet(); - public static void RegisterTypeAssembly() - { - var type = typeof(T); - RegisteredAssemblies.Add(type.Assembly); - } - - public static JsonKnownTypesSettings GetSettings() - { - var discriminatorAttribute = AttributesManager.GetJsonDiscriminatorAttribute(typeof(T)); - - var discriminatorSettings = discriminatorAttribute == null ? DefaultDiscriminatorSettings : Mapper.Map(discriminatorAttribute); - - var typeSettings = new JsonKnownTypesSettings - { - Name = discriminatorSettings.Name - }; - - var allTypes = GetAllInheritance(); - - typeSettings.TypeToDiscriminator.AddJsonKnown(); - 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() - { - RegisterTypeAssembly(); - var type = typeof(T); - return RegisteredAssemblies.SelectMany(a=>a.GetTypes()) - .Where(x => type.IsAssignableFrom(x) && !x.IsInterface && !x.IsAbstract) - .ToArray(); - } - } -} diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesSettingsManager.cs.meta b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesSettingsManager.cs.meta deleted file mode 100644 index b7a14d98d..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/JsonKnownTypesSettingsManager.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: a361505c5408b374788cbaeed6fa2f55 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Utils.meta b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Utils.meta deleted file mode 100644 index caeca5e85..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Utils.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 6d6706b0998d8af458321fd5f35906fb -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Utils/Mapper.cs b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Utils/Mapper.cs deleted file mode 100644 index c18b844ae..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Utils/Mapper.cs +++ /dev/null @@ -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; - } - } -} diff --git a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Utils/Mapper.cs.meta b/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Utils/Mapper.cs.meta deleted file mode 100644 index 21162c161..000000000 --- a/Assets/Scripts/ServerShared/CultCache/Serialization/JsonKnownTypes/Utils/Mapper.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c30d51fc767627a41b65f5cdd2b22cc3 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/ServerShared/EnumDictionary.cs b/Assets/Scripts/ServerShared/EnumDictionary.cs index ef212396f..cbeb2a695 100644 --- a/Assets/Scripts/ServerShared/EnumDictionary.cs +++ b/Assets/Scripts/ServerShared/EnumDictionary.cs @@ -1,11 +1,9 @@ using System; using MessagePack; -using Newtonsoft.Json; - -[MessagePackObject, JsonObject(MemberSerialization.OptIn)] +[MessagePackObject] public class EnumDictionary where E : Enum { - [JsonProperty("values"), Key(0)] public T[] Values; + [Key(0)] public T[] Values; public EnumDictionary() { diff --git a/Assets/Scripts/ServerShared/Environment.cs b/Assets/Scripts/ServerShared/Environment.cs index d2fcac804..4cc25b8ed 100644 --- a/Assets/Scripts/ServerShared/Environment.cs +++ b/Assets/Scripts/ServerShared/Environment.cs @@ -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); diff --git a/Assets/Scripts/ServerShared/ExponentialCurve.cs b/Assets/Scripts/ServerShared/ExponentialCurve.cs index 1ac842848..46f6506e1 100644 --- a/Assets/Scripts/ServerShared/ExponentialCurve.cs +++ b/Assets/Scripts/ServerShared/ExponentialCurve.cs @@ -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); } diff --git a/Assets/Scripts/ServerShared/GlobalData.cs b/Assets/Scripts/ServerShared/GlobalData.cs index aba2afc34..772e00e31 100644 --- a/Assets/Scripts/ServerShared/GlobalData.cs +++ b/Assets/Scripts/ServerShared/GlobalData.cs @@ -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; diff --git a/Assets/Scripts/ServerShared/ItemData.cs b/Assets/Scripts/ServerShared/ItemData.cs index f0a5f4c1b..c16665e9e 100644 --- a/Assets/Scripts/ServerShared/ItemData.cs +++ b/Assets/Scripts/ServerShared/ItemData.cs @@ -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))] +[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 ResourceDensity = new List(); // // // 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))] +[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 DemandProfile = new Dictionary(); - [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 Behaviors = new List(); - [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 Behaviors = new List(); - [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 AudioStats = new List(); - + [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 Hardpoints = new List(); - [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 _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> _scaleModifiers; [IgnoreMember] private Dictionary> _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; diff --git a/Assets/Scripts/ServerShared/ItemInstance.cs b/Assets/Scripts/ServerShared/ItemInstance.cs index d8c7e3427..287313b23 100644 --- a/Assets/Scripts/ServerShared/ItemInstance.cs +++ b/Assets/Scripts/ServerShared/ItemInstance.cs @@ -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))] + Union(3, typeof(ConsumableItem))] public abstract class ItemInstance { - [JsonProperty("data"), Key(0)] public DatabaseLink Data; - [JsonProperty("rotation"), Key(1)] public ItemRotation Rotation; + [Key(0)] public DatabaseLink Data; + [Key(1)] public ItemRotation Rotation; } -[Union(0, typeof(CompoundCommodity)), - Union(1, typeof(EquippableItem)), - Union(2, typeof(ConsumableItem)), - JsonObject(MemberSerialization.OptIn), - JsonConverter(typeof(JsonKnownTypesConverter))] +[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 Ingredients = new List(); - - //[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 Ingredients = new List(); + + //[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 { } \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/NIH/MIConvexHull/Cell2.cs b/Assets/Scripts/ServerShared/NIH/MIConvexHull/Cell2.cs index 1907e5c2e..17c10b6b8 100644 --- a/Assets/Scripts/ServerShared/NIH/MIConvexHull/Cell2.cs +++ b/Assets/Scripts/ServerShared/NIH/MIConvexHull/Cell2.cs @@ -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 { 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 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 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()); - } + } } diff --git a/Assets/Scripts/ServerShared/PlayerData.cs b/Assets/Scripts/ServerShared/PlayerData.cs index 0be302689..2e2d52a9d 100644 --- a/Assets/Scripts/ServerShared/PlayerData.cs +++ b/Assets/Scripts/ServerShared/PlayerData.cs @@ -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; diff --git a/Assets/Scripts/ServerShared/Settings.cs b/Assets/Scripts/ServerShared/Settings.cs index 8222d0127..0d5d57f0d 100644 --- a/Assets/Scripts/ServerShared/Settings.cs +++ b/Assets/Scripts/ServerShared/Settings.cs @@ -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; diff --git a/Assets/Scripts/ServerShared/Ship.cs b/Assets/Scripts/ServerShared/Ship.cs index 529c07b39..e8acb925a 100644 --- a/Assets/Scripts/ServerShared/Ship.cs +++ b/Assets/Scripts/ServerShared/Ship.cs @@ -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 Bindings = new Dictionary(); //[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(GetBehaviors()); _aetherDriveItems = new HashSet(_aetherDrives.Select(x => x.Item)); - + _allThrusters = GetBehaviors().ToArray(); _thrusterItems = new HashSet(_allThrusters.Select(x=>x.Item)); - + _forwardThrusters = new HashSet(_allThrusters .Where(x => x.Item.EquippableItem.Rotation == ItemRotation.Reversed)); _reverseThrusters = new HashSet(_allThrusters .Where(x => x.Item.EquippableItem.Rotation == ItemRotation.None)); - + _rightThrusters = new HashSet(_allThrusters .Where(x => x.Item.EquippableItem.Rotation == ItemRotation.CounterClockwise)); - + _leftThrusters = new HashSet(_allThrusters .Where(x => x.Item.EquippableItem.Rotation == ItemRotation.Clockwise)); - + _counterClockwiseThrusters = new HashSet(_allThrusters .Where(x => x.Torque < -ItemManager.GameplaySettings.TorqueFloor)); - + _clockwiseThrusters = new HashSet(_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)); } diff --git a/Assets/Scripts/ServerShared/WwiseMetadata.cs b/Assets/Scripts/ServerShared/WwiseMetadata.cs index 30b88ad29..c74186040 100644 --- a/Assets/Scripts/ServerShared/WwiseMetadata.cs +++ b/Assets/Scripts/ServerShared/WwiseMetadata.cs @@ -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; diff --git a/Assets/Scripts/ServerShared/WwiseSoundBinding.cs b/Assets/Scripts/ServerShared/WwiseSoundBinding.cs index da7a97548..5472fdafc 100644 --- a/Assets/Scripts/ServerShared/WwiseSoundBinding.cs +++ b/Assets/Scripts/ServerShared/WwiseSoundBinding.cs @@ -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; // } \ No newline at end of file diff --git a/Assets/Scripts/ServerShared/ZoneData.cs b/Assets/Scripts/ServerShared/ZoneData.cs index 48b49415c..7941ec9b3 100644 --- a/Assets/Scripts/ServerShared/ZoneData.cs +++ b/Assets/Scripts/ServerShared/ZoneData.cs @@ -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 Planets = new List(); - - [JsonProperty("orbits"), Key(1)] + + [Key(1)] public List Orbits = new List(); - - [JsonProperty("entities"), Key(2)] + + [Key(2)] public List Entities = new List(); - - [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 Inventory = new List(); // -// [JsonProperty("buying"), Key(5)] +// [Key(5)] // public Dictionary BuyPrices = new Dictionary(); // -// [JsonProperty("selling"), Key(6)] +// [Key(6)] // public Dictionary SellPrices = new Dictionary(); // -// [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 Resources = new Dictionary(); - [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 MaterialOverrides = new List(); - - [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) diff --git a/Assets/Scripts/ServerShared/ZoneGenerator.cs b/Assets/Scripts/ServerShared/ZoneGenerator.cs index b342b9d95..f6b1018f4 100644 --- a/Assets/Scripts/ServerShared/ZoneGenerator.cs +++ b/Assets/Scripts/ServerShared/ZoneGenerator.cs @@ -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(); @@ -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(); 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(); var orbitInverseMap = new Dictionary(); - + // 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 planetResources = new Dictionary(); @@ -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 } } } -} \ No newline at end of file +} diff --git a/Assets/Scripts/UI/InputScreen/InputDisplayLayout.cs b/Assets/Scripts/UI/InputScreen/InputDisplayLayout.cs index 7c8b909f3..b3dd65623 100644 --- a/Assets/Scripts/UI/InputScreen/InputDisplayLayout.cs +++ b/Assets/Scripts/UI/InputScreen/InputDisplayLayout.cs @@ -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 ButtonMappings = new List(); public Rect LabelRect => Label.GetComponent().ScreenSpaceRect(); } - + private Dictionary _bindButtons = new Dictionary(); private List _buttonMappings = new List(); private List _actionMappings = new List(); - + void Start() { _canvas = transform.root.GetComponent(); @@ -89,22 +87,21 @@ public class InputDisplayLayout : MonoBehaviour // _inputLayout = ParseJson(LayoutFile.text); RegisterResolver.Register(); _inputLayout = MessagePackSerializer.Deserialize(File.ReadAllBytes(path)); - // _inputLayout = JsonConvert.DeserializeObject(File.ReadAllText(path)); // SaveLayout(); DisplayLayout(_inputLayout); - + _buttonMappings.Add(MapMouseButton(MouseLeft, "/leftButton")); _buttonMappings.Add(MapMouseButton(MouseRight, "/rightButton")); _buttonMappings.Add(MapMouseButton(MouseMiddle, "/middleButton")); _buttonMappings.Add(MapMouseButton(MouseForward, "/forwardButton")); _buttonMappings.Add(MapMouseButton(MouseBack, "/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(_ => diff --git a/Assets/Scripts/UI/InputScreen/InputLayout.cs b/Assets/Scripts/UI/InputScreen/InputLayout.cs index 994d0d148..548220617 100644 --- a/Assets/Scripts/UI/InputScreen/InputLayout.cs +++ b/Assets/Scripts/UI/InputScreen/InputLayout.cs @@ -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 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)), - 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)), - 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 diff --git a/Economy.Shared/Economy.Shared.csproj b/Economy.Shared/Economy.Shared.csproj index 51b30b560..55b1936a7 100644 --- a/Economy.Shared/Economy.Shared.csproj +++ b/Economy.Shared/Economy.Shared.csproj @@ -4,16 +4,15 @@ netstandard2.0 true - + - + -