2020-03-22 19:05:26 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using JsonKnownTypes;
|
|
|
|
|
|
using MessagePack;
|
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
// TODO: USE THIS EVERYWHERE
|
|
|
|
|
|
using Unity.Mathematics;
|
|
|
|
|
|
using static Unity.Mathematics.math;
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
|
using UnityEditor;
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
public interface INamedEntry
|
|
|
|
|
|
{
|
|
|
|
|
|
string EntryName { get; set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-04-09 07:48:45 +01:00
|
|
|
|
[InspectableField,
|
|
|
|
|
|
MessagePackObject,
|
|
|
|
|
|
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)),
|
|
|
|
|
|
Union(6, typeof(Gear)),
|
|
|
|
|
|
Union(7, typeof(BlueprintData)),
|
|
|
|
|
|
Union(8, typeof(GalaxyMapLayerData)),
|
2020-04-09 07:48:45 +01:00
|
|
|
|
Union(9, typeof(GlobalData)),
|
|
|
|
|
|
Union(10, typeof(ZoneData)),
|
|
|
|
|
|
Union(11, typeof(Player)),
|
|
|
|
|
|
Union(12, typeof(Corporation)),
|
2020-05-10 00:16:33 +01:00
|
|
|
|
Union(13, typeof(MegaCorporation)),
|
2020-04-16 03:08:18 +01:00
|
|
|
|
Union(14, typeof(StationData)),
|
2020-04-09 07:48:45 +01:00
|
|
|
|
Union(15, typeof(OrbitData)),
|
|
|
|
|
|
Union(16, typeof(PlanetData)),
|
2020-05-03 00:36:47 +01:00
|
|
|
|
Union(17, typeof(PersonalityAttribute)),
|
2020-05-07 03:53:54 +01:00
|
|
|
|
Union(18, typeof(AgentTask)),
|
2020-05-10 00:16:33 +01:00
|
|
|
|
Union(19, typeof(LoadoutData)),
|
2020-04-09 07:48:45 +01:00
|
|
|
|
JsonObject(MemberSerialization.OptIn), JsonConverter(typeof(JsonKnownTypesConverter<DatabaseEntry>))]
|
2020-03-22 19:05:26 +00:00
|
|
|
|
//[Union(21, typeof(ContractData))]
|
|
|
|
|
|
//[Union(22, typeof(Station))]
|
|
|
|
|
|
public abstract class DatabaseEntry
|
|
|
|
|
|
{
|
2020-05-14 02:47:07 +01:00
|
|
|
|
[JsonProperty("id"), Key(0)]
|
|
|
|
|
|
public Guid ID = Guid.NewGuid();
|
2020-03-22 19:05:26 +00:00
|
|
|
|
[IgnoreMember] public GameContext Context { get; set; }
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-04-09 07:48:45 +01:00
|
|
|
|
[RethinkTable("Users"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
2020-03-24 14:36:22 +00:00
|
|
|
|
public class Player : DatabaseEntry, INamedEntry
|
2020-03-22 19:05:26 +00:00
|
|
|
|
{
|
2020-05-14 02:47:07 +01:00
|
|
|
|
[JsonProperty("email"), Key(1)]
|
|
|
|
|
|
public string Email;
|
2020-04-09 07:48:45 +01:00
|
|
|
|
|
2020-05-14 02:47:07 +01:00
|
|
|
|
[JsonProperty("password"), Key(2)]
|
|
|
|
|
|
public string Password;
|
2020-04-09 07:48:45 +01:00
|
|
|
|
|
2020-05-14 02:47:07 +01:00
|
|
|
|
[JsonProperty("username"), Key(3)]
|
|
|
|
|
|
public string Username;
|
2020-04-09 07:48:45 +01:00
|
|
|
|
|
2020-05-14 02:47:07 +01:00
|
|
|
|
[JsonProperty("corporation"), Key(4)]
|
|
|
|
|
|
public Guid Corporation;
|
2020-03-24 21:51:38 +00:00
|
|
|
|
|
2020-03-24 14:36:22 +00:00
|
|
|
|
[IgnoreMember] public string EntryName
|
|
|
|
|
|
{
|
|
|
|
|
|
get => Username;
|
|
|
|
|
|
set => Username = value;
|
|
|
|
|
|
}
|
2020-03-22 19:05:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-04-09 07:48:45 +01:00
|
|
|
|
[RethinkTable("Galaxy"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
2020-03-22 19:05:26 +00:00
|
|
|
|
public class Corporation : DatabaseEntry, INamedEntry
|
|
|
|
|
|
{
|
2020-05-07 03:53:54 +01:00
|
|
|
|
[JsonProperty("name"), Key(1)]
|
|
|
|
|
|
public string Name;
|
2020-05-14 02:47:07 +01:00
|
|
|
|
|
|
|
|
|
|
[JsonProperty("parent"), Key(2)]
|
|
|
|
|
|
public Guid Parent;
|
2020-05-07 03:53:54 +01:00
|
|
|
|
|
2020-05-14 02:47:07 +01:00
|
|
|
|
[JsonProperty("tasks"), Key(3)]
|
2020-05-07 03:53:54 +01:00
|
|
|
|
public List<Guid> Tasks = new List<Guid>();
|
2020-03-22 19:05:26 +00:00
|
|
|
|
|
|
|
|
|
|
[IgnoreMember] public string EntryName
|
|
|
|
|
|
{
|
|
|
|
|
|
get => Name;
|
|
|
|
|
|
set => Name = value;
|
|
|
|
|
|
}
|
2020-04-23 03:31:17 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-05-10 00:16:33 +01:00
|
|
|
|
[RethinkTable("Galaxy"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
|
|
|
|
|
public class MegaCorporation : DatabaseEntry, INamedEntry
|
2020-04-23 03:31:17 +01:00
|
|
|
|
{
|
2020-05-10 00:16:33 +01:00
|
|
|
|
[InspectableField, JsonProperty("name"), Key(1)]
|
|
|
|
|
|
public string Name;
|
|
|
|
|
|
|
2020-05-11 01:17:10 +01:00
|
|
|
|
[InspectableText, JsonProperty("description"), Key(2)]
|
|
|
|
|
|
public string Description;
|
|
|
|
|
|
|
|
|
|
|
|
[InspectableTexture, JsonProperty("logo"), Key(3)]
|
2020-05-10 00:16:33 +01:00
|
|
|
|
public string Logo;
|
2020-04-23 03:31:17 +01:00
|
|
|
|
|
2020-05-11 01:17:10 +01:00
|
|
|
|
[InspectableDatabaseLink(typeof(PersonalityAttribute)), JsonProperty("personality"), Key(4)]
|
2020-05-10 00:16:33 +01:00
|
|
|
|
public Dictionary<Guid, float> Personality = new Dictionary<Guid, float>();
|
|
|
|
|
|
|
2020-05-11 01:17:10 +01:00
|
|
|
|
[InspectableDatabaseLink(typeof(LoadoutData)), JsonProperty("initialFleet"), Key(5)]
|
2020-05-10 00:16:33 +01:00
|
|
|
|
public Dictionary<Guid, int> InitialFleet = new Dictionary<Guid, int>();
|
|
|
|
|
|
|
2020-05-11 01:17:10 +01:00
|
|
|
|
[InspectableDatabaseLink(typeof(BlueprintData)), JsonProperty("initialTechs"), Key(6)]
|
|
|
|
|
|
public List<Guid> InitialTechnologies = new List<Guid>();
|
2020-05-18 01:06:30 +01:00
|
|
|
|
|
|
|
|
|
|
[JsonProperty("parent"), Key(7)]
|
|
|
|
|
|
public Guid HomeZone;
|
2020-05-11 01:17:10 +01:00
|
|
|
|
|
2020-05-10 00:16:33 +01:00
|
|
|
|
[IgnoreMember] public string EntryName
|
|
|
|
|
|
{
|
|
|
|
|
|
get => Name;
|
|
|
|
|
|
set => Name = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[RethinkTable("Items"), Inspectable, MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
|
|
|
|
|
public class LoadoutData : DatabaseEntry, INamedEntry
|
|
|
|
|
|
{
|
|
|
|
|
|
[InspectableField, JsonProperty("name"), Key(1)]
|
|
|
|
|
|
public string Name;
|
|
|
|
|
|
|
|
|
|
|
|
[InspectableDatabaseLink(typeof(HullData)), JsonProperty("hull"), Key(2)]
|
|
|
|
|
|
public Guid Hull;
|
|
|
|
|
|
|
|
|
|
|
|
[JsonProperty("items"), Key(3)]
|
|
|
|
|
|
public List<Guid> Items = new List<Guid>();
|
|
|
|
|
|
|
|
|
|
|
|
[IgnoreMember] public string EntryName
|
|
|
|
|
|
{
|
|
|
|
|
|
get => Name;
|
|
|
|
|
|
set => Name = value;
|
|
|
|
|
|
}
|
2020-03-22 19:05:26 +00:00
|
|
|
|
}
|