Generating and Displaying Zones
This commit is contained in:
parent
2236ecd129
commit
f756c5fe6a
67 changed files with 1343 additions and 826 deletions
|
|
@ -1,20 +0,0 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
public class OrbitInstance
|
||||
{
|
||||
private OrbitData _data;
|
||||
|
||||
public OrbitInstance(OrbitData data)
|
||||
{
|
||||
_data = data;
|
||||
}
|
||||
|
||||
public static float2 Evaluate(float phase)
|
||||
{
|
||||
phase *= (PI * 2);
|
||||
return new float2(sin(phase), cos(phase));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fc9a1d6d35b2ac14eb8c1092432ae217
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
using Unity.Mathematics;
|
||||
using static Unity.Mathematics.math;
|
||||
|
||||
[RethinkTable("Galaxy")]
|
||||
[MessagePackObject]
|
||||
|
|
@ -28,6 +29,12 @@ public class ZoneData : DatabaseEntry, INamedEntry
|
|||
[JsonProperty("orbits")] [Key(6)]
|
||||
public List<Guid> Orbits = new List<Guid>();
|
||||
|
||||
[JsonProperty("radius")] [Key(7)]
|
||||
public float Radius = 2000;
|
||||
|
||||
[JsonProperty("visited")] [Key(8)]
|
||||
public bool Visited;
|
||||
|
||||
[IgnoreMember] public string EntryName
|
||||
{
|
||||
get => Name;
|
||||
|
|
@ -86,6 +93,9 @@ public class PlanetData : DatabaseEntry, INamedEntry
|
|||
[JsonProperty("zone")] [Key(4)]
|
||||
public Guid Zone;
|
||||
|
||||
[JsonProperty("radius")] [Key(5)]
|
||||
public float GravityRadius;
|
||||
|
||||
[IgnoreMember] public string EntryName
|
||||
{
|
||||
get => Name;
|
||||
|
|
@ -99,7 +109,7 @@ public class PlanetData : DatabaseEntry, INamedEntry
|
|||
public class OrbitData : DatabaseEntry
|
||||
{
|
||||
[JsonProperty("parent")] [Key(1)]
|
||||
public Guid? Parent;
|
||||
public Guid Parent;
|
||||
|
||||
[JsonProperty("distance")] [Key(2)]
|
||||
public float Distance;
|
||||
|
|
@ -112,4 +122,10 @@ public class OrbitData : DatabaseEntry
|
|||
|
||||
[JsonProperty("zone")] [Key(5)]
|
||||
public Guid Zone;
|
||||
|
||||
public static float2 Evaluate(float phase)
|
||||
{
|
||||
phase *= (PI * 2);
|
||||
return new float2(sin(phase), cos(phase));
|
||||
}
|
||||
}
|
||||
|
|
@ -159,7 +159,7 @@ public class Planet
|
|||
var p0 = new float2(0, dist);
|
||||
|
||||
// Position of second child
|
||||
var p1 = OrbitInstance.Evaluate(1.0f / vertices) * dist;
|
||||
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 - Context.PlanetRadius(sharedMass * (1 - proportion));
|
||||
|
|
@ -217,10 +217,13 @@ public class Planet
|
|||
masses[i] = masses[i] / massTotal * Mass * massFraction;
|
||||
|
||||
// Map child distances to range between minimum and maximum
|
||||
var oldDistances = (float[]) distances.Clone();
|
||||
for (var i = 0; i < count; i++)
|
||||
distances[i] = lerp(ChildDistanceMinimum, ChildDistanceMaximum,
|
||||
(oldDistances[i] - oldDistances[0]) / (oldDistances[count - 1] - oldDistances[0])) + Context.PlanetRadius(masses[i]);
|
||||
if (count > 1)
|
||||
{
|
||||
var oldDistances = (float[]) distances.Clone();
|
||||
for (var i = 0; i < count; i++)
|
||||
distances[i] = lerp(ChildDistanceMinimum, ChildDistanceMaximum,
|
||||
(oldDistances[i] - oldDistances[0]) / (oldDistances[count - 1] - oldDistances[0])) + Context.PlanetRadius(masses[i]);
|
||||
}
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue