Aetheria/Assets/Scripts/ServerShared/ZoneData.cs

210 lines
4 KiB
C#
Raw Normal View History

2026-06-13 04:30:24 +01: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;
using System.Collections;
using System.Collections.Generic;
using MessagePack;
using UniRx;
using Unity.Mathematics;
2020-03-29 04:19:24 +01:00
using static Unity.Mathematics.math;
using float2 = Unity.Mathematics.float2;
using float3 = Unity.Mathematics.float3;
2026-06-13 04:56:50 +01:00
[MessagePackObject]
public class ZonePack
{
2026-06-13 04:56:50 +01:00
[Key(0)]
public List<BodyData> Planets = new List<BodyData>();
2026-06-13 04:56:50 +01:00
[Key(1)]
public List<OrbitData> Orbits = new List<OrbitData>();
2026-06-13 04:56:50 +01:00
[Key(2)]
public List<EntityPack> Entities = new List<EntityPack>();
2026-06-13 04:56:50 +01:00
[Key(3)]
public float Radius = 2000;
2026-06-13 04:56:50 +01:00
[Key(4)]
public float Mass = 10000;
2026-06-13 04:56:50 +01:00
[Key(5)]
public double Time;
2026-06-13 04:56:50 +01:00
}
2026-06-13 04:56:50 +01:00
// [LegacyCatalogGroup("Galaxy"), MessagePackObject]
// public class StationData : DatabaseEntry, INamedEntry
// {
2026-06-13 04:56:50 +01:00
// [Key(1)]
// public string Name;
2026-06-13 04:56:50 +01:00
//
// // Can be Planet or Orbit
2026-06-13 04:56:50 +01:00
// [Key(2)]
// public Guid Parent;
//
2026-06-13 04:56:50 +01:00
// [Key(3)]
// public Guid Owner;
//
2026-06-13 04:56:50 +01:00
// [Key(4)]
// public List<ItemInstance> Inventory = new List<ItemInstance>();
//
2026-06-13 04:56:50 +01:00
// [Key(5)]
// public Dictionary<Guid, float> BuyPrices = new Dictionary<Guid, float>();
//
2026-06-13 04:56:50 +01:00
// [Key(6)]
// public Dictionary<Guid, float> SellPrices = new Dictionary<Guid, float>();
//
2026-06-13 04:56:50 +01:00
// [Key(7)]
// public Guid Zone;
2026-06-13 04:56:50 +01:00
//
// [IgnoreMember] public string EntryName
// {
// get => Name;
// set => Name = value;
// }
// }
2026-06-13 04:56:50 +01:00
[MessagePackObject,
Union(0, typeof(PlanetData)),
Union(1, typeof(AsteroidBeltData)),
Union(2, typeof(GasGiantData)),
Union(3, typeof(SunData))]
public abstract class BodyData : DatabaseEntry, INamedEntry
{
2026-06-13 04:56:50 +01:00
[Key(1)]
public string Name = "";
2026-06-13 04:56:50 +01:00
[Key(2)]
public Guid Orbit;
2026-06-13 04:56:50 +01:00
[Key(3)]
public float Mass = 0;
2026-06-13 04:56:50 +01:00
[Key(4)]
public Dictionary<Guid, float> Resources = new Dictionary<Guid, float>();
2026-06-13 04:56:50 +01:00
[Key(5)]
public float BodyRadiusMultiplier = 1;
2026-06-13 04:56:50 +01:00
[Key(6)]
public float GravityRadiusMultiplier = 1;
2026-06-13 04:56:50 +01:00
[Key(7)]
public float GravityDepthMultiplier = 1;
2026-06-13 04:56:50 +01:00
[Key(8)]
public float GravityDepthExponent = 16;
2026-06-13 04:56:50 +01:00
[IgnoreMember] public string EntryName
{
get => Name;
set => Name = value;
}
}
2026-06-13 04:56:50 +01:00
[MessagePackObject]
public class PlanetData : BodyData
{
2026-06-13 04:56:50 +01:00
}
2026-06-13 04:56:50 +01:00
[MessagePackObject]
public class AsteroidBeltData : BodyData
{
2026-06-13 04:56:50 +01:00
[Key(9)]
public Asteroid[] Asteroids;
}
2026-06-13 04:56:50 +01:00
[MessagePackObject]
public class GasGiantData : BodyData
{
2026-06-13 04:56:50 +01:00
[Key(9)]
public float FirstOffsetDomainRotationSpeed = 1;
2026-06-13 04:56:50 +01:00
[Key(10)]
public float FirstOffsetRotationSpeed = 1;
2026-06-13 04:56:50 +01:00
[Key(11)]
public float SecondOffsetDomainRotationSpeed = 1;
2026-06-13 04:56:50 +01:00
[Key(12)]
public float SecondOffsetRotationSpeed = 1;
2026-06-13 04:56:50 +01:00
[Key(13)]
public float AlbedoRotationSpeed = 1;
2026-06-13 04:56:50 +01:00
[Key(14)]
public float WaveRadiusMultiplier = 1;
2026-06-13 04:56:50 +01:00
[Key(15)]
public float WaveDepthMultiplier = 1;
2026-06-13 04:56:50 +01:00
[Key(16)]
public float WaveDepthExponent = 8;
2026-06-13 04:56:50 +01:00
[Key(17)]
public float WaveSpeedMultiplier = 8;
2026-06-13 04:56:50 +01:00
[Key(18)]
public List<string> MaterialOverrides = new List<string>();
2026-06-13 04:56:50 +01:00
[Key(19)]
public float4[] Colors = new float4[0];
}
public class SunData : GasGiantData
{
2026-06-13 04:56:50 +01:00
[Key(20)]
public float3 LightColor = float3.zero;
2026-06-13 04:56:50 +01:00
[Key(21)]
public float3 FogTintColor = float3.zero;
2026-06-13 04:56:50 +01:00
[Key(22)]
public float LightRadiusMultiplier = 1;
}
2026-06-13 04:56:50 +01:00
[MessagePackObject]
public class Asteroid
{
2026-06-13 04:56:50 +01:00
[Key(0)]
public float Distance;
2026-06-13 04:56:50 +01:00
[Key(1)]
public float Phase;
2026-06-13 04:56:50 +01:00
[Key(2)]
public float Size;
2026-06-13 04:56:50 +01:00
[Key(3)]
public float RotationSpeed;
}
2026-06-13 04:56:50 +01:00
[MessagePackObject]
public class OrbitData : DatabaseEntry
{
2026-06-13 04:56:50 +01:00
[Key(1)]
2020-03-29 04:19:24 +01:00
public Guid Parent;
2026-06-13 04:56:50 +01:00
[Key(2)]
public float Distance;
2026-06-13 04:56:50 +01:00
[Key(3)]
public float Phase;
2026-06-13 04:56:50 +01:00
[Key(4)]
public float2 FixedPosition = float2.zero;
2026-06-13 04:56:50 +01:00
// [Key(4)]
// public float Period;
2020-03-29 04:19:24 +01:00
public static float2 Evaluate(float phase)
{
phase *= PI * 2;
return new float2(cos(phase), sin(phase));
2020-03-29 04:19:24 +01:00
}
}