Cut GUID sidecars from zone runtime
This commit is contained in:
parent
40fe7197a1
commit
bd4a51f923
9 changed files with 110 additions and 90 deletions
|
|
@ -2,13 +2,11 @@
|
|||
* 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;
|
||||
|
||||
public abstract class AgentTask
|
||||
{
|
||||
public int Priority;
|
||||
|
||||
public Guid Zone;
|
||||
public string ZoneKey = "";
|
||||
|
||||
public bool Reserved;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@
|
|||
* 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;
|
||||
|
||||
public class Mining : AgentTask
|
||||
{
|
||||
public override TaskType Type => TaskType.Mine;
|
||||
|
||||
public Guid Asteroids;
|
||||
public string AsteroidBeltBodyKey = "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,11 @@
|
|||
* 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.Generic;
|
||||
|
||||
public class Survey : AgentTask
|
||||
{
|
||||
public override TaskType Type => TaskType.Explore;
|
||||
|
||||
public List<Guid> Planets;
|
||||
public List<string> PlanetBodyKeys;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,9 +27,6 @@ public class Zone
|
|||
public Dictionary<string, AsteroidBelt> AsteroidBelts = new Dictionary<string, AsteroidBelt>(StringComparer.Ordinal);
|
||||
public PlanetSettings Settings;
|
||||
|
||||
private readonly Dictionary<Guid, Planet> _planetsById = new Dictionary<Guid, Planet>();
|
||||
private readonly Dictionary<Guid, AsteroidBelt> _asteroidBeltsById = new Dictionary<Guid, AsteroidBelt>();
|
||||
|
||||
private HashSet<string> _updatedOrbits = new HashSet<string>(StringComparer.Ordinal);
|
||||
|
||||
private ItemManager _itemManager;
|
||||
|
|
@ -72,22 +69,18 @@ public class Zone
|
|||
case AsteroidBeltConstructionData belt:
|
||||
var runtimeBelt = new AsteroidBelt(belt, Orbits[belt.OrbitKey]);
|
||||
AsteroidBelts[runtimeBelt.BodyKey] = runtimeBelt;
|
||||
_asteroidBeltsById[runtimeBelt.ID] = runtimeBelt;
|
||||
break;
|
||||
case SunConstructionData sun:
|
||||
var runtimeSun = new Sun(settings, sun, Orbits[planet.OrbitKey]);
|
||||
PlanetInstances[runtimeSun.BodyKey] = runtimeSun;
|
||||
_planetsById[runtimeSun.ID] = runtimeSun;
|
||||
break;
|
||||
case GasGiantConstructionData gas:
|
||||
var runtimeGas = new GasGiant(settings, gas, Orbits[planet.OrbitKey]);
|
||||
PlanetInstances[runtimeGas.BodyKey] = runtimeGas;
|
||||
_planetsById[runtimeGas.ID] = runtimeGas;
|
||||
break;
|
||||
default:
|
||||
var runtimePlanet = new Planet(settings, planet, Orbits[planet.OrbitKey]);
|
||||
PlanetInstances[runtimePlanet.BodyKey] = runtimePlanet;
|
||||
_planetsById[runtimePlanet.ID] = runtimePlanet;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -131,17 +124,6 @@ public class Zone
|
|||
return id == Guid.Empty ? "" : $"{BodyKeyPrefix}{id:D}";
|
||||
}
|
||||
|
||||
public string GetBodyKey(Guid bodyId)
|
||||
{
|
||||
if (bodyId == Guid.Empty)
|
||||
return "";
|
||||
if (_planetsById.TryGetValue(bodyId, out var planet))
|
||||
return planet.BodyKey;
|
||||
if (_asteroidBeltsById.TryGetValue(bodyId, out var belt))
|
||||
return belt.BodyKey;
|
||||
return BodyKey(bodyId);
|
||||
}
|
||||
|
||||
public bool TryGetPlanet(string bodyKey, out Planet planet)
|
||||
{
|
||||
return PlanetInstances.TryGetValue(bodyKey ?? "", out planet);
|
||||
|
|
@ -420,7 +402,6 @@ public class Planet
|
|||
{
|
||||
public Orbit Orbit;
|
||||
protected readonly PlanetSettings Settings;
|
||||
public Guid ID { get; }
|
||||
public string BodyKey { get; }
|
||||
public string Name { get; }
|
||||
public string OrbitKey { get; }
|
||||
|
|
@ -438,7 +419,6 @@ public class Planet
|
|||
{
|
||||
Settings = settings;
|
||||
Orbit = orbit;
|
||||
ID = data.ID;
|
||||
BodyKey = data.BodyKey ?? "";
|
||||
Name = data.Name ?? "";
|
||||
OrbitKey = data.OrbitKey ?? "";
|
||||
|
|
@ -528,7 +508,6 @@ public class AsteroidBelt
|
|||
{
|
||||
private readonly Asteroid[] _asteroids;
|
||||
public Orbit Orbit { get; }
|
||||
public Guid ID { get; }
|
||||
public string BodyKey { get; }
|
||||
public string Name { get; }
|
||||
public string OrbitKey { get; }
|
||||
|
|
@ -551,7 +530,6 @@ public class AsteroidBelt
|
|||
{
|
||||
_asteroids = data.Asteroids;
|
||||
Orbit = orbit;
|
||||
ID = data.ID;
|
||||
BodyKey = data.BodyKey ?? "";
|
||||
Name = data.Name ?? "";
|
||||
OrbitKey = data.OrbitKey ?? "";
|
||||
|
|
@ -576,7 +554,6 @@ public class AsteroidBelt
|
|||
|
||||
public class Orbit
|
||||
{
|
||||
public Guid ID { get; }
|
||||
public string OrbitKey { get; }
|
||||
public string ParentOrbitKey { get; }
|
||||
public float Distance { get; }
|
||||
|
|
@ -595,7 +572,6 @@ public class Orbit
|
|||
|
||||
public Orbit(PlanetSettings settings, OrbitConstructionData data)
|
||||
{
|
||||
ID = data.ID;
|
||||
OrbitKey = data.OrbitKey ?? "";
|
||||
ParentOrbitKey = data.ParentOrbitKey ?? "";
|
||||
Distance = data.Distance;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
* 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 UniRx;
|
||||
|
|
@ -23,14 +22,10 @@ public class ZoneConstructionBlueprint
|
|||
|
||||
public abstract class BodyConstructionData : INamedEntry
|
||||
{
|
||||
public Guid ID = Guid.NewGuid();
|
||||
|
||||
public string BodyKey = "";
|
||||
|
||||
public string Name = "";
|
||||
|
||||
public Guid Orbit;
|
||||
|
||||
public string OrbitKey = "";
|
||||
|
||||
public float Mass = 0;
|
||||
|
|
@ -109,12 +104,8 @@ public class Asteroid
|
|||
|
||||
public class OrbitConstructionData
|
||||
{
|
||||
public Guid ID = Guid.NewGuid();
|
||||
|
||||
public string OrbitKey = "";
|
||||
|
||||
public Guid Parent;
|
||||
|
||||
public string ParentOrbitKey = "";
|
||||
|
||||
public float Distance;
|
||||
|
|
|
|||
|
|
@ -102,25 +102,21 @@ public static class ZoneGenerator
|
|||
{
|
||||
var data = new OrbitConstructionData
|
||||
{
|
||||
OrbitKey = "",
|
||||
OrbitKey = Zone.OrbitKey(Guid.NewGuid()),
|
||||
ParentOrbitKey = "",
|
||||
FixedPosition = planet.FixedPosition,
|
||||
Distance = planet.Distance,
|
||||
//Period = planet.Period,
|
||||
Phase = planet.Phase
|
||||
};
|
||||
data.OrbitKey = Zone.OrbitKey(data.ID);
|
||||
orbitMap[planet] = data;
|
||||
orbitInverseMap[data] = planet;
|
||||
return data;
|
||||
}).ToList();
|
||||
|
||||
// Link orbit construction parents to generated orbit IDs.
|
||||
// Link orbit construction parents to generated orbit keys.
|
||||
foreach (var data in blueprint.Orbits)
|
||||
{
|
||||
data.Parent = orbitInverseMap[data].Parent != null
|
||||
? orbitMap[orbitInverseMap[data].Parent].ID
|
||||
: Guid.Empty;
|
||||
data.ParentOrbitKey = orbitInverseMap[data].Parent != null
|
||||
? orbitMap[orbitInverseMap[data].Parent].OrbitKey
|
||||
: "";
|
||||
|
|
@ -167,12 +163,12 @@ public static class ZoneGenerator
|
|||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
planetData.BodyKey = Zone.BodyKey(planetData.ID);
|
||||
planetData.BodyKey = Zone.BodyKey(Guid.NewGuid());
|
||||
planetData.Mass = planet.Mass;
|
||||
planetData.Orbit = orbitMap[planet].ID;
|
||||
planetData.OrbitKey = orbitMap[planet].OrbitKey;
|
||||
// planetData.Resources = planetResources;
|
||||
planetData.Name = planetData.ID.ToString().Substring(0, 8);
|
||||
var bodyName = planetData.BodyKey.Substring(planetData.BodyKey.LastIndexOf(':') + 1);
|
||||
planetData.Name = bodyName.Substring(0, Math.Min(8, bodyName.Length));
|
||||
if (planetData is AsteroidBeltConstructionData beltData)
|
||||
{
|
||||
beltData.Asteroids =
|
||||
|
|
@ -264,14 +260,11 @@ public static class ZoneGenerator
|
|||
{
|
||||
var lagrangeOrbit = new OrbitConstructionData
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
OrbitKey = "",
|
||||
Parent = baseOrbit.Parent,
|
||||
OrbitKey = Zone.OrbitKey(Guid.NewGuid()),
|
||||
ParentOrbitKey = baseOrbit.ParentOrbitKey,
|
||||
Distance = baseOrbit.Distance,
|
||||
Phase = baseOrbit.Phase + PI / 3 * sign(random.NextFloat() - .5f)
|
||||
};
|
||||
lagrangeOrbit.OrbitKey = Zone.OrbitKey(lagrangeOrbit.ID);
|
||||
blueprint.Orbits.Add(lagrangeOrbit);
|
||||
return lagrangeOrbit;
|
||||
}
|
||||
|
|
@ -282,14 +275,11 @@ public static class ZoneGenerator
|
|||
|
||||
var turretOrbit = new OrbitConstructionData
|
||||
{
|
||||
ID = Guid.NewGuid(),
|
||||
OrbitKey = "",
|
||||
Parent = orbit.Parent,
|
||||
OrbitKey = Zone.OrbitKey(Guid.NewGuid()),
|
||||
ParentOrbitKey = orbit.ParentOrbitKey,
|
||||
Distance = orbit.Distance,
|
||||
Phase = orbit.Phase + phase
|
||||
};
|
||||
turretOrbit.OrbitKey = Zone.OrbitKey(turretOrbit.ID);
|
||||
blueprint.Orbits.Add(turretOrbit);
|
||||
var turret = loadoutGenerator.GenerateTurretLoadout();
|
||||
if (turret == null) return;
|
||||
|
|
|
|||
Loading…
Reference in a new issue