2020-03-22 19:05:26 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using MessagePack;
|
|
|
|
|
|
using Newtonsoft.Json;
|
2020-11-29 22:50:12 +00:00
|
|
|
|
using UniRx;
|
2020-03-24 00:02:23 +00:00
|
|
|
|
using Unity.Mathematics;
|
2020-03-29 04:19:24 +01:00
|
|
|
|
using static Unity.Mathematics.math;
|
2020-11-29 22:50:12 +00:00
|
|
|
|
using float3 = Unity.Mathematics.float3;
|
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 ZoneData : DatabaseEntry, INamedEntry
|
|
|
|
|
|
{
|
2020-05-04 00:07:36 +01:00
|
|
|
|
[JsonProperty("name"), Key(1)]
|
2020-03-22 19:05:26 +00:00
|
|
|
|
public string Name;
|
2020-04-09 07:48:45 +01:00
|
|
|
|
|
2020-05-04 00:07:36 +01:00
|
|
|
|
[JsonProperty("position"), Key(2)]
|
2020-03-24 00:02:23 +00:00
|
|
|
|
public float2 Position = 500;
|
2020-03-22 19:05:26 +00:00
|
|
|
|
|
2020-05-04 00:07:36 +01:00
|
|
|
|
[JsonProperty("radius"), Key(3)]
|
|
|
|
|
|
public float Radius = 2000;
|
2020-04-09 07:48:45 +01:00
|
|
|
|
|
2020-05-18 01:06:30 +01:00
|
|
|
|
[JsonProperty("mass"), Key(4)]
|
|
|
|
|
|
public float Mass = 10000;
|
|
|
|
|
|
|
2020-11-27 22:47:33 +00:00
|
|
|
|
// [JsonProperty("visited"), Key(5)]
|
|
|
|
|
|
// public bool Visited;
|
2020-04-09 07:48:45 +01:00
|
|
|
|
|
2020-11-27 22:47:33 +00:00
|
|
|
|
[JsonProperty("wormholes"), Key(5)]
|
2020-05-04 00:07:36 +01:00
|
|
|
|
public List<Guid> Wormholes = new List<Guid>();
|
2020-04-09 07:48:45 +01:00
|
|
|
|
|
2020-11-27 22:47:33 +00:00
|
|
|
|
// [JsonProperty("planets"), Key(7)]
|
|
|
|
|
|
// public Guid[] Planets;// = new List<Guid>();
|
|
|
|
|
|
//
|
|
|
|
|
|
// [JsonProperty("orbits"), Key(8)]
|
|
|
|
|
|
// public List<Guid> Orbits = new List<Guid>();
|
2020-03-29 04:19:24 +01:00
|
|
|
|
|
2020-03-22 19:05:26 +00:00
|
|
|
|
[IgnoreMember] public string EntryName
|
|
|
|
|
|
{
|
|
|
|
|
|
get => Name;
|
|
|
|
|
|
set => Name = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-11-27 22:47:33 +00:00
|
|
|
|
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
|
|
|
|
|
public class ZonePack : INamedEntry
|
|
|
|
|
|
{
|
|
|
|
|
|
[JsonProperty("data"), Key(0)]
|
|
|
|
|
|
public ZoneData Data;
|
|
|
|
|
|
|
|
|
|
|
|
[JsonProperty("planets"), Key(1)]
|
2020-11-29 22:50:12 +00:00
|
|
|
|
public List<BodyData> Planets = new List<BodyData>();
|
2020-11-27 22:47:33 +00:00
|
|
|
|
|
|
|
|
|
|
[JsonProperty("orbits"), Key(2)]
|
|
|
|
|
|
public List<OrbitData> Orbits = new List<OrbitData>();
|
|
|
|
|
|
|
|
|
|
|
|
[JsonProperty("entities"), Key(3)]
|
|
|
|
|
|
public List<Entity> Entities = new List<Entity>();
|
|
|
|
|
|
|
|
|
|
|
|
[IgnoreMember] public string EntryName
|
|
|
|
|
|
{
|
|
|
|
|
|
get => Data.Name;
|
|
|
|
|
|
set => Data.Name = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-06-01 03:11:04 +01:00
|
|
|
|
// [RethinkTable("Galaxy"), MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
|
|
|
|
|
// public class StationData : DatabaseEntry, INamedEntry
|
|
|
|
|
|
// {
|
|
|
|
|
|
// [JsonProperty("name"), Key(1)]
|
|
|
|
|
|
// public string Name;
|
|
|
|
|
|
//
|
|
|
|
|
|
// // Can be Planet or Orbit
|
|
|
|
|
|
// [JsonProperty("parent"), Key(2)]
|
|
|
|
|
|
// public Guid Parent;
|
|
|
|
|
|
//
|
|
|
|
|
|
// [JsonProperty("owner"), Key(3)]
|
|
|
|
|
|
// public Guid Owner;
|
|
|
|
|
|
//
|
|
|
|
|
|
// [JsonProperty("inventory"), Key(4)]
|
|
|
|
|
|
// public List<ItemInstance> Inventory = new List<ItemInstance>();
|
|
|
|
|
|
//
|
|
|
|
|
|
// [JsonProperty("buying"), Key(5)]
|
|
|
|
|
|
// public Dictionary<Guid, float> BuyPrices = new Dictionary<Guid, float>();
|
|
|
|
|
|
//
|
|
|
|
|
|
// [JsonProperty("selling"), Key(6)]
|
|
|
|
|
|
// public Dictionary<Guid, float> SellPrices = new Dictionary<Guid, float>();
|
|
|
|
|
|
//
|
|
|
|
|
|
// [JsonProperty("zone"), Key(7)]
|
|
|
|
|
|
// public Guid Zone;
|
|
|
|
|
|
//
|
|
|
|
|
|
// [IgnoreMember] public string EntryName
|
|
|
|
|
|
// {
|
|
|
|
|
|
// get => Name;
|
|
|
|
|
|
// set => Name = value;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
2020-03-22 19:05:26 +00:00
|
|
|
|
|
2020-11-27 22:47:33 +00:00
|
|
|
|
[MessagePackObject,
|
|
|
|
|
|
JsonObject(MemberSerialization.OptIn),
|
2020-11-29 22:50:12 +00:00
|
|
|
|
Union(0, typeof(PlanetData)),
|
2020-11-27 22:47:33 +00:00
|
|
|
|
Union(1, typeof(AsteroidBeltData)),
|
|
|
|
|
|
Union(2, typeof(GasGiantData)),
|
|
|
|
|
|
Union(3, typeof(SunData))]
|
2020-11-29 22:50:12 +00:00
|
|
|
|
public abstract class BodyData : DatabaseEntry, INamedEntry
|
2020-03-22 19:05:26 +00:00
|
|
|
|
{
|
2020-04-09 07:48:45 +01:00
|
|
|
|
[JsonProperty("name"), Key(1)]
|
2020-11-29 22:50:12 +00:00
|
|
|
|
public ReactiveProperty<string> Name = new ReactiveProperty<string>("");
|
2020-04-09 07:48:45 +01:00
|
|
|
|
|
|
|
|
|
|
[JsonProperty("orbit"), Key(2)]
|
2020-03-22 19:05:26 +00:00
|
|
|
|
public Guid Orbit;
|
2020-04-09 07:48:45 +01:00
|
|
|
|
|
|
|
|
|
|
[JsonProperty("mass"), Key(3)]
|
2020-11-29 22:50:12 +00:00
|
|
|
|
public ReactiveProperty<float> Mass = new ReactiveProperty<float>(0);
|
2020-04-09 07:48:45 +01:00
|
|
|
|
|
2020-11-27 22:47:33 +00:00
|
|
|
|
[JsonProperty("resources"), Key(4)]
|
2020-04-09 07:48:45 +01:00
|
|
|
|
public Dictionary<Guid, float> Resources = new Dictionary<Guid, float>();
|
2020-05-02 01:30:33 +01:00
|
|
|
|
|
2020-12-01 00:16:11 +00:00
|
|
|
|
[JsonProperty("bodyRadiusMul")] [Key(5)]
|
|
|
|
|
|
public ReactiveProperty<float> BodyRadiusMultiplier = new ReactiveProperty<float>(1);
|
|
|
|
|
|
|
|
|
|
|
|
[JsonProperty("gravRadiusMul")] [Key(6)]
|
2020-11-29 22:50:12 +00:00
|
|
|
|
public ReactiveProperty<float> GravityRadiusMultiplier = new ReactiveProperty<float>(1);
|
2020-11-27 22:47:33 +00:00
|
|
|
|
|
2020-12-01 00:16:11 +00:00
|
|
|
|
[JsonProperty("depthMul")] [Key(7)]
|
2020-11-29 22:50:12 +00:00
|
|
|
|
public ReactiveProperty<float> GravityDepthMultiplier = new ReactiveProperty<float>(1);
|
|
|
|
|
|
|
2020-12-01 00:16:11 +00:00
|
|
|
|
[JsonProperty("depthExp")] [Key(8)]
|
2020-11-29 22:50:12 +00:00
|
|
|
|
public ReactiveProperty<float> GravityDepthExponent = new ReactiveProperty<float>(8);
|
2020-03-29 04:19:24 +01:00
|
|
|
|
|
2020-03-22 19:05:26 +00:00
|
|
|
|
[IgnoreMember] public string EntryName
|
|
|
|
|
|
{
|
2020-11-29 22:50:12 +00:00
|
|
|
|
get => Name.Value;
|
|
|
|
|
|
set => Name.Value = value;
|
2020-03-22 19:05:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-11-29 22:50:12 +00:00
|
|
|
|
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
|
|
|
|
|
public class PlanetData : BodyData
|
2020-11-27 22:47:33 +00:00
|
|
|
|
{
|
2020-11-29 22:50:12 +00:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
|
|
|
|
|
public class AsteroidBeltData : BodyData
|
|
|
|
|
|
{
|
2020-12-01 00:16:11 +00:00
|
|
|
|
[JsonProperty("asteroids"), Key(9)]
|
2020-11-27 22:47:33 +00:00
|
|
|
|
public Asteroid[] Asteroids;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-11-29 22:50:12 +00:00
|
|
|
|
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
|
|
|
|
|
public class GasGiantData : BodyData
|
2020-11-27 22:47:33 +00:00
|
|
|
|
{
|
2020-12-01 00:16:11 +00:00
|
|
|
|
[JsonProperty("firstOffsetDomainRotationSpeed"), Key(9)]
|
2020-11-29 22:50:12 +00:00
|
|
|
|
public ReactiveProperty<float> FirstOffsetDomainRotationSpeed = new ReactiveProperty<float>(1);
|
2020-11-27 22:47:33 +00:00
|
|
|
|
|
2020-12-01 00:16:11 +00:00
|
|
|
|
[JsonProperty("firstOffsetRotationSpeed"), Key(10)]
|
2020-11-29 22:50:12 +00:00
|
|
|
|
public ReactiveProperty<float> FirstOffsetRotationSpeed = new ReactiveProperty<float>(1);
|
2020-11-27 22:47:33 +00:00
|
|
|
|
|
2020-12-01 00:16:11 +00:00
|
|
|
|
[JsonProperty("secondOffsetDomainRotationSpeed"), Key(11)]
|
2020-11-29 22:50:12 +00:00
|
|
|
|
public ReactiveProperty<float> SecondOffsetDomainRotationSpeed = new ReactiveProperty<float>(1);
|
2020-11-27 22:47:33 +00:00
|
|
|
|
|
2020-12-01 00:16:11 +00:00
|
|
|
|
[JsonProperty("secondOffsetRotationSpeed"), Key(12)]
|
2020-11-29 22:50:12 +00:00
|
|
|
|
public ReactiveProperty<float> SecondOffsetRotationSpeed = new ReactiveProperty<float>(1);
|
2020-11-27 22:47:33 +00:00
|
|
|
|
|
2020-12-01 00:16:11 +00:00
|
|
|
|
[JsonProperty("albedoRotationSpeed"), Key(13)]
|
2020-11-29 22:50:12 +00:00
|
|
|
|
public ReactiveProperty<float> AlbedoRotationSpeed = new ReactiveProperty<float>(1);
|
2020-12-01 00:16:11 +00:00
|
|
|
|
|
|
|
|
|
|
[JsonProperty("gravRadiusMul")] [Key(14)]
|
|
|
|
|
|
public ReactiveProperty<float> WaveRadiusMultiplier = new ReactiveProperty<float>(1);
|
|
|
|
|
|
|
|
|
|
|
|
[JsonProperty("depthMul")] [Key(15)]
|
|
|
|
|
|
public ReactiveProperty<float> WaveDepthMultiplier = new ReactiveProperty<float>(1);
|
|
|
|
|
|
|
|
|
|
|
|
[JsonProperty("depthExp")] [Key(16)]
|
|
|
|
|
|
public ReactiveProperty<float> WaveDepthExponent = new ReactiveProperty<float>(8);
|
|
|
|
|
|
|
|
|
|
|
|
[JsonProperty("depthExp")] [Key(17)]
|
|
|
|
|
|
public ReactiveProperty<float> WaveSpeedMultiplier = new ReactiveProperty<float>(8);
|
2020-11-27 22:47:33 +00:00
|
|
|
|
|
2020-12-01 00:16:11 +00:00
|
|
|
|
[JsonProperty("materialOverrides"), Key(18)]
|
2020-11-27 22:47:33 +00:00
|
|
|
|
public List<string> MaterialOverrides = new List<string>();
|
|
|
|
|
|
|
2020-12-01 00:16:11 +00:00
|
|
|
|
[JsonProperty("colors"), Key(19)]
|
2020-11-29 22:50:12 +00:00
|
|
|
|
public ReactiveProperty<float4[]> Colors = new ReactiveProperty<float4[]>();
|
2020-11-27 22:47:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public class SunData : GasGiantData
|
|
|
|
|
|
{
|
2020-12-01 00:16:11 +00:00
|
|
|
|
[JsonProperty("lightColor"), Key(20)]
|
2020-11-29 22:50:12 +00:00
|
|
|
|
public ReactiveProperty<float3> LightColor = new ReactiveProperty<float3>(float3.zero);
|
2020-11-27 22:47:33 +00:00
|
|
|
|
|
2020-12-01 00:16:11 +00:00
|
|
|
|
[JsonProperty("fogTintColor"), Key(21)]
|
2020-11-29 22:50:12 +00:00
|
|
|
|
public ReactiveProperty<float3> FogTintColor = new ReactiveProperty<float3>(float3.zero);
|
2020-11-27 22:47:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-05-28 04:50:40 +01:00
|
|
|
|
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
|
|
|
|
|
public class Asteroid
|
|
|
|
|
|
{
|
2020-12-01 00:16:11 +00:00
|
|
|
|
[JsonProperty("distance"), Key(0)]
|
2020-05-28 04:50:40 +01:00
|
|
|
|
public float Distance;
|
2020-12-01 00:16:11 +00:00
|
|
|
|
|
|
|
|
|
|
[JsonProperty("phase"), Key(1)]
|
2020-05-28 04:50:40 +01:00
|
|
|
|
public float Phase;
|
2020-12-01 00:16:11 +00:00
|
|
|
|
|
|
|
|
|
|
[JsonProperty("size"), Key(2)]
|
2020-05-28 04:50:40 +01:00
|
|
|
|
public float Size;
|
2020-12-01 00:16:11 +00:00
|
|
|
|
|
|
|
|
|
|
[JsonProperty("rotationSpeed"), Key(3)]
|
2020-05-28 04:50:40 +01:00
|
|
|
|
public float RotationSpeed;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-11-27 22:47:33 +00:00
|
|
|
|
[MessagePackObject, JsonObject(MemberSerialization.OptIn)]
|
2020-03-22 19:05:26 +00:00
|
|
|
|
public class OrbitData : DatabaseEntry
|
|
|
|
|
|
{
|
2020-04-09 07:48:45 +01:00
|
|
|
|
[JsonProperty("parent"), Key(1)]
|
2020-03-29 04:19:24 +01:00
|
|
|
|
public Guid Parent;
|
2020-04-09 07:48:45 +01:00
|
|
|
|
|
|
|
|
|
|
[JsonProperty("distance"), Key(2)]
|
2020-12-01 00:16:11 +00:00
|
|
|
|
public ReactiveProperty<float> Distance;
|
2020-04-09 07:48:45 +01:00
|
|
|
|
|
|
|
|
|
|
[JsonProperty("phase"), Key(3)]
|
2020-03-22 19:05:26 +00:00
|
|
|
|
public float Phase;
|
2020-12-01 00:16:11 +00:00
|
|
|
|
|
|
|
|
|
|
// [JsonProperty("period"), Key(4)]
|
|
|
|
|
|
// public float Period;
|
2020-04-09 07:48:45 +01:00
|
|
|
|
|
2020-03-29 04:19:24 +01:00
|
|
|
|
public static float2 Evaluate(float phase)
|
|
|
|
|
|
{
|
2020-05-10 00:16:33 +01:00
|
|
|
|
phase *= PI * 2;
|
2020-05-27 03:43:30 +01:00
|
|
|
|
return new float2(cos(phase), sin(phase));
|
2020-03-29 04:19:24 +01:00
|
|
|
|
}
|
2020-03-22 19:05:26 +00:00
|
|
|
|
}
|