2020-12-22 03:13:43 +00:00
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
2020-03-22 19:05:26 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using JsonKnownTypes;
|
|
|
|
|
|
using MessagePack;
|
2021-03-30 01:17:58 +01:00
|
|
|
|
using MessagePack.Formatters;
|
2020-03-22 19:05:26 +00:00
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
// TODO: USE THIS EVERYWHERE
|
|
|
|
|
|
using Unity.Mathematics;
|
|
|
|
|
|
using static Unity.Mathematics.math;
|
|
|
|
|
|
|
|
|
|
|
|
public interface INamedEntry
|
|
|
|
|
|
{
|
|
|
|
|
|
string EntryName { get; set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-31 04:07:11 +01:00
|
|
|
|
[MessagePackObject,
|
2021-03-30 01:17:58 +01:00
|
|
|
|
JsonObject(MemberSerialization.OptIn),
|
|
|
|
|
|
JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>)),
|
2020-04-09 07:48:45 +01:00
|
|
|
|
Union(0, typeof(SimpleCommodityData)),
|
|
|
|
|
|
Union(1, typeof(CompoundCommodityData)),
|
|
|
|
|
|
Union(2, typeof(GearData)),
|
|
|
|
|
|
Union(3, typeof(HullData)),
|
2020-04-23 03:31:17 +01:00
|
|
|
|
Union(4, typeof(SimpleCommodity)),
|
|
|
|
|
|
Union(5, typeof(CompoundCommodity)),
|
2020-12-10 23:20:38 +00:00
|
|
|
|
Union(6, typeof(EquippableItem)),
|
2020-04-23 03:31:17 +01:00
|
|
|
|
Union(8, typeof(GalaxyMapLayerData)),
|
2021-03-15 11:40:46 +00:00
|
|
|
|
Union(9, typeof(NameFile)),
|
|
|
|
|
|
//Union(10, typeof(ZoneData)),
|
2020-06-11 02:55:11 +01:00
|
|
|
|
Union(11, typeof(PlayerData)),
|
2021-03-31 04:07:11 +01:00
|
|
|
|
// Union(12, typeof(Corporation)),
|
2021-03-20 04:20:17 +00:00
|
|
|
|
Union(13, typeof(Faction)),
|
2020-06-01 03:11:04 +01:00
|
|
|
|
Union(14, typeof(OrbitalEntity)),
|
2020-04-09 07:48:45 +01:00
|
|
|
|
Union(15, typeof(OrbitData)),
|
2020-11-29 22:50:12 +00:00
|
|
|
|
Union(16, typeof(BodyData)),
|
2020-05-03 00:36:47 +01:00
|
|
|
|
Union(17, typeof(PersonalityAttribute)),
|
2020-05-07 03:53:54 +01:00
|
|
|
|
Union(18, typeof(AgentTask)),
|
2021-03-22 05:22:31 +00:00
|
|
|
|
// Union(19, typeof(LoadoutData)),
|
2021-03-31 04:07:11 +01:00
|
|
|
|
Union(20, typeof(Ship)),
|
|
|
|
|
|
Union(21, typeof(Mining)),
|
2020-06-01 03:11:04 +01:00
|
|
|
|
Union(22, typeof(StationTowing)),
|
|
|
|
|
|
Union(23, typeof(Survey)),
|
2020-06-12 01:57:15 +01:00
|
|
|
|
Union(24, typeof(HaulingTask)),
|
2020-11-27 22:47:33 +00:00
|
|
|
|
Union(25, typeof(AsteroidBeltData)),
|
|
|
|
|
|
Union(26, typeof(GasGiantData)),
|
|
|
|
|
|
Union(27, typeof(SunData)),
|
2020-11-29 22:50:12 +00:00
|
|
|
|
Union(28, typeof(PlanetData)),
|
2020-12-18 13:48:03 +00:00
|
|
|
|
Union(29, typeof(CargoBayData)),
|
|
|
|
|
|
Union(30, typeof(DockingBayData)),
|
2021-03-30 01:17:58 +01:00
|
|
|
|
Union(31, typeof(WeaponItemData))]
|
2020-03-22 19:05:26 +00:00
|
|
|
|
public abstract class DatabaseEntry
|
|
|
|
|
|
{
|
2020-05-14 02:47:07 +01:00
|
|
|
|
[JsonProperty("id"), Key(0)]
|
|
|
|
|
|
public Guid ID = Guid.NewGuid();
|
2021-04-07 01:27:35 +01:00
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
|
{
|
|
|
|
|
|
return ID.GetHashCode();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (obj is DatabaseEntry entry) return entry.ID == ID;
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
2021-03-31 04:07:11 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
|
|
|
|
|
public class DatabaseLink<T> : DatabaseLinkBase where T : DatabaseEntry
|
|
|
|
|
|
{
|
|
|
|
|
|
[IgnoreMember]
|
|
|
|
|
|
public T Value => Cache.Get<T>(LinkID);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
|
|
|
|
|
public class DatabaseLinkBase
|
|
|
|
|
|
{
|
|
|
|
|
|
[Key(0), JsonProperty("linkID")]
|
|
|
|
|
|
public Guid LinkID;
|
2021-03-30 01:17:58 +01:00
|
|
|
|
|
2021-03-31 04:07:11 +01:00
|
|
|
|
[IgnoreMember]
|
2021-04-07 01:27:35 +01:00
|
|
|
|
public static CultCache Cache;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public interface ITintInspector
|
|
|
|
|
|
{
|
|
|
|
|
|
float3 TintColor { get; }
|
2020-03-22 19:05:26 +00:00
|
|
|
|
}
|