Demote zone construction data names
This commit is contained in:
parent
7b605f049c
commit
bf03f27709
8 changed files with 69 additions and 51 deletions
|
|
@ -58,17 +58,17 @@ public class Zone
|
|||
Orbits.Add(orbit.ID, new Orbit(Settings, orbit));
|
||||
}
|
||||
|
||||
foreach (var planet in blueprint.Planets)
|
||||
foreach (var planet in blueprint.Bodies)
|
||||
{
|
||||
switch (planet)
|
||||
{
|
||||
case AsteroidBeltData belt:
|
||||
case AsteroidBeltConstructionData belt:
|
||||
AsteroidBelts[belt.ID] = new AsteroidBelt(belt);
|
||||
break;
|
||||
case SunData sun:
|
||||
case SunConstructionData sun:
|
||||
PlanetInstances.Add(sun.ID, new Sun(settings, sun, Orbits[planet.Orbit]));
|
||||
break;
|
||||
case GasGiantData gas:
|
||||
case GasGiantConstructionData gas:
|
||||
PlanetInstances.Add(gas.ID, new GasGiant(settings, gas, Orbits[planet.Orbit]));
|
||||
break;
|
||||
default:
|
||||
|
|
@ -379,7 +379,7 @@ public class Planet
|
|||
public float GravityWellRadius;
|
||||
public float BodyRadius;
|
||||
|
||||
public Planet(PlanetSettings settings, BodyData data, Orbit orbit)
|
||||
public Planet(PlanetSettings settings, BodyConstructionData data, Orbit orbit)
|
||||
{
|
||||
Settings = settings;
|
||||
Orbit = orbit;
|
||||
|
|
@ -421,7 +421,7 @@ public class GasGiant : Planet
|
|||
public float GravityWavesRadius;
|
||||
public float GravityWavesSpeed;
|
||||
|
||||
public GasGiant(PlanetSettings settings, GasGiantData data, Orbit orbit) : base(settings, data, orbit)
|
||||
public GasGiant(PlanetSettings settings, GasGiantConstructionData data, Orbit orbit) : base(settings, data, orbit)
|
||||
{
|
||||
FirstOffsetDomainRotationSpeed = data.FirstOffsetDomainRotationSpeed;
|
||||
FirstOffsetRotationSpeed = data.FirstOffsetRotationSpeed;
|
||||
|
|
@ -453,7 +453,7 @@ public class Sun : GasGiant
|
|||
public float LightRadiusMultiplier { get; }
|
||||
public float LightRadius;
|
||||
|
||||
public Sun(PlanetSettings settings, SunData data, Orbit orbit) : base(settings, data, orbit)
|
||||
public Sun(PlanetSettings settings, SunConstructionData data, Orbit orbit) : base(settings, data, orbit)
|
||||
{
|
||||
LightColor = data.LightColor;
|
||||
FogTintColor = data.FogTintColor;
|
||||
|
|
@ -489,7 +489,7 @@ public class AsteroidBelt
|
|||
public Dictionary<int, float> Damage = new Dictionary<int, float>();
|
||||
public Dictionary<(Entity, int), float> MiningAccumulator = new Dictionary<(Entity, int), float>();
|
||||
|
||||
public AsteroidBelt(AsteroidBeltData data)
|
||||
public AsteroidBelt(AsteroidBeltConstructionData data)
|
||||
{
|
||||
_asteroids = data.Asteroids;
|
||||
ID = data.ID;
|
||||
|
|
@ -532,7 +532,7 @@ public class Orbit
|
|||
return new float2(cos(phase), sin(phase));
|
||||
}
|
||||
|
||||
public Orbit(PlanetSettings settings, OrbitData data)
|
||||
public Orbit(PlanetSettings settings, OrbitConstructionData data)
|
||||
{
|
||||
ID = data.ID;
|
||||
Parent = data.Parent;
|
||||
|
|
|
|||
|
|
@ -13,15 +13,15 @@ using float3 = Unity.Mathematics.float3;
|
|||
|
||||
public class ZoneConstructionBlueprint
|
||||
{
|
||||
public List<BodyData> Planets = new List<BodyData>();
|
||||
public List<OrbitData> Orbits = new List<OrbitData>();
|
||||
public List<BodyConstructionData> Bodies = new List<BodyConstructionData>();
|
||||
public List<OrbitConstructionData> Orbits = new List<OrbitConstructionData>();
|
||||
public List<EntityConstructionBlueprint> Entities = new List<EntityConstructionBlueprint>();
|
||||
public float Radius = 2000;
|
||||
public float Mass = 10000;
|
||||
public double Time;
|
||||
}
|
||||
|
||||
public abstract class BodyData : INamedEntry
|
||||
public abstract class BodyConstructionData : INamedEntry
|
||||
{
|
||||
public Guid ID = Guid.NewGuid();
|
||||
|
||||
|
|
@ -48,17 +48,17 @@ public abstract class BodyData : INamedEntry
|
|||
}
|
||||
}
|
||||
|
||||
public class PlanetData : BodyData
|
||||
public class PlanetConstructionData : BodyConstructionData
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public class AsteroidBeltData : BodyData
|
||||
public class AsteroidBeltConstructionData : BodyConstructionData
|
||||
{
|
||||
public Asteroid[] Asteroids;
|
||||
}
|
||||
|
||||
public class GasGiantData : BodyData
|
||||
public class GasGiantConstructionData : BodyConstructionData
|
||||
{
|
||||
public float FirstOffsetDomainRotationSpeed = 1;
|
||||
|
||||
|
|
@ -83,7 +83,7 @@ public class GasGiantData : BodyData
|
|||
public float4[] Colors = new float4[0];
|
||||
}
|
||||
|
||||
public class SunData : GasGiantData
|
||||
public class SunConstructionData : GasGiantConstructionData
|
||||
{
|
||||
public float3 LightColor = float3.zero;
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ public class Asteroid
|
|||
public float RotationSpeed;
|
||||
}
|
||||
|
||||
public class OrbitData
|
||||
public class OrbitConstructionData
|
||||
{
|
||||
public Guid ID = Guid.NewGuid();
|
||||
|
||||
|
|
@ -94,13 +94,13 @@ public static class ZoneGenerator
|
|||
planets.AddRange(GenerateEntities(zoneSettings, ref random, blueprint.Mass, blueprint.Radius, float2.zero));
|
||||
|
||||
// Create collections to map between zone generator output and database entries
|
||||
var orbitMap = new Dictionary<GeneratorPlanet, OrbitData>();
|
||||
var orbitInverseMap = new Dictionary<OrbitData, GeneratorPlanet>();
|
||||
var orbitMap = new Dictionary<GeneratorPlanet, OrbitConstructionData>();
|
||||
var orbitInverseMap = new Dictionary<OrbitConstructionData, GeneratorPlanet>();
|
||||
|
||||
// Create orbit database entries
|
||||
blueprint.Orbits = planets.Select(planet =>
|
||||
{
|
||||
var data = new OrbitData
|
||||
var data = new OrbitConstructionData
|
||||
{
|
||||
FixedPosition = planet.FixedPosition,
|
||||
Distance = planet.Distance,
|
||||
|
|
@ -112,7 +112,7 @@ public static class ZoneGenerator
|
|||
return data;
|
||||
}).ToList();
|
||||
|
||||
// Link OrbitData parents to database GUIDs
|
||||
// Link orbit construction parents to generated orbit IDs.
|
||||
foreach (var data in blueprint.Orbits)
|
||||
data.Parent = orbitInverseMap[data].Parent != null
|
||||
? orbitMap[orbitInverseMap[data].Parent].ID
|
||||
|
|
@ -122,7 +122,7 @@ public static class ZoneGenerator
|
|||
// var resourceMaps = mapLayers.Values
|
||||
// .ToDictionary(m => m.ID, m => m.Evaluate(zone.Position, settings.ShapeSettings));
|
||||
|
||||
blueprint.Planets = planets.Where(p=>!p.Empty).Select(planet =>
|
||||
blueprint.Bodies = planets.Where(p=>!p.Empty).Select(planet =>
|
||||
{
|
||||
// Dictionary<Guid, float> planetResources = new Dictionary<Guid, float>();
|
||||
BodyType bodyType = planet.Belt ? BodyType.Asteroid :
|
||||
|
|
@ -139,21 +139,21 @@ public static class ZoneGenerator
|
|||
// }
|
||||
// }
|
||||
|
||||
BodyData planetData;
|
||||
BodyConstructionData planetData;
|
||||
switch (bodyType)
|
||||
{
|
||||
case BodyType.Asteroid:
|
||||
planetData = new AsteroidBeltData();
|
||||
planetData = new AsteroidBeltConstructionData();
|
||||
break;
|
||||
case BodyType.Planetoid:
|
||||
case BodyType.Planet:
|
||||
planetData = new PlanetData();
|
||||
planetData = new PlanetConstructionData();
|
||||
break;
|
||||
case BodyType.GasGiant:
|
||||
planetData = new GasGiantData();
|
||||
planetData = new GasGiantConstructionData();
|
||||
break;
|
||||
case BodyType.Sun:
|
||||
planetData = new SunData();
|
||||
planetData = new SunConstructionData();
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
|
|
@ -163,7 +163,7 @@ public static class ZoneGenerator
|
|||
planetData.Orbit = orbitMap[planet].ID;
|
||||
// planetData.Resources = planetResources;
|
||||
planetData.Name = planetData.ID.ToString().Substring(0, 8);
|
||||
if (planetData is AsteroidBeltData beltData)
|
||||
if (planetData is AsteroidBeltConstructionData beltData)
|
||||
{
|
||||
beltData.Asteroids =
|
||||
Enumerable.Range(0, (int) zoneSettings.AsteroidCount.Evaluate(beltData.Mass * orbitMap[planet].Distance))
|
||||
|
|
@ -177,9 +177,9 @@ public static class ZoneGenerator
|
|||
//.OrderByDescending(a=>a.Size)
|
||||
.ToArray();
|
||||
}
|
||||
else if (planetData is GasGiantData gas)
|
||||
else if (planetData is GasGiantConstructionData gas)
|
||||
{
|
||||
if (gas is SunData sun)
|
||||
if (gas is SunConstructionData sun)
|
||||
{
|
||||
float primary = random.NextFloat();
|
||||
float secondary = frac(primary + 1 + zoneSettings.SunSecondaryColorDistance * (random.NextFloat() > .5 ? 1 : -1));
|
||||
|
|
@ -250,9 +250,9 @@ public static class ZoneGenerator
|
|||
return loadoutGenerators[faction];
|
||||
}
|
||||
|
||||
OrbitData CreateLagrangeOrbit(OrbitData baseOrbit)
|
||||
OrbitConstructionData CreateLagrangeOrbit(OrbitConstructionData baseOrbit)
|
||||
{
|
||||
var lagrangeOrbit = new OrbitData
|
||||
var lagrangeOrbit = new OrbitConstructionData
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
Parent = baseOrbit.Parent,
|
||||
|
|
@ -263,11 +263,11 @@ public static class ZoneGenerator
|
|||
return lagrangeOrbit;
|
||||
}
|
||||
|
||||
void PlaceTurret(OrbitData orbit, LoadoutGenerator loadoutGenerator, int distanceMultiplier)
|
||||
void PlaceTurret(OrbitConstructionData orbit, LoadoutGenerator loadoutGenerator, int distanceMultiplier)
|
||||
{
|
||||
var phase = 20f * distanceMultiplier / orbit.Distance;
|
||||
|
||||
var turretOrbit = new OrbitData
|
||||
var turretOrbit = new OrbitConstructionData
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
Parent = orbit.Parent,
|
||||
|
|
@ -281,7 +281,7 @@ public static class ZoneGenerator
|
|||
blueprint.Entities.Add(turret);
|
||||
}
|
||||
|
||||
void PlaceTurrets(OrbitData orbit, LoadoutGenerator loadoutGenerator, int count)
|
||||
void PlaceTurrets(OrbitConstructionData orbit, LoadoutGenerator loadoutGenerator, int count)
|
||||
{
|
||||
for(int t=0; t<count; t++)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue