Project zone snapshots from runtime owners
This commit is contained in:
parent
526fa537ad
commit
1973e90b7a
4 changed files with 124 additions and 48 deletions
Binary file not shown.
|
|
@ -629,7 +629,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
.OrderBy(index => index)
|
||||
.ToArray() ?? Array.Empty<int>(),
|
||||
OwnerFactionIndex = FactionIndex(galaxyZone?.Owner),
|
||||
Orbits = ProjectZoneOrbits(zone.Blueprint),
|
||||
Orbits = ProjectZoneOrbits(zone),
|
||||
Bodies = ProjectZoneBodies(zone),
|
||||
Entities = zone.Entities
|
||||
.Select((entity, index) => ProjectEntitySnapshot(zone, entity, index))
|
||||
|
|
@ -637,9 +637,9 @@ public class ActionGameManager : MonoBehaviour
|
|||
};
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeOrbitSnapshotCommit[] ProjectZoneOrbits(RuntimeZoneBlueprint blueprint)
|
||||
private static AetheriaRuntimeOrbitSnapshotCommit[] ProjectZoneOrbits(Zone zone)
|
||||
{
|
||||
return blueprint?.Orbits?
|
||||
return zone?.Orbits?.Values
|
||||
.OrderBy(orbit => orbit.ID)
|
||||
.Select(orbit => new AetheriaRuntimeOrbitSnapshotCommit
|
||||
{
|
||||
|
|
@ -655,23 +655,26 @@ public class ActionGameManager : MonoBehaviour
|
|||
|
||||
private static AetheriaRuntimeBodySnapshotCommit[] ProjectZoneBodies(Zone zone)
|
||||
{
|
||||
return zone?.Blueprint?.Planets?
|
||||
.OrderBy(body => body.ID)
|
||||
.Select(body => ProjectZoneBody(zone, body))
|
||||
.ToArray() ?? Array.Empty<AetheriaRuntimeBodySnapshotCommit>();
|
||||
if (zone == null)
|
||||
return Array.Empty<AetheriaRuntimeBodySnapshotCommit>();
|
||||
|
||||
return zone.PlanetInstances.Values
|
||||
.Select(planet => ProjectZoneBody(planet))
|
||||
.Concat(zone.AsteroidBelts.Values.Select(belt => ProjectZoneBody(zone, belt)))
|
||||
.OrderBy(body => body.BodyLegacyId)
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeBodySnapshotCommit ProjectZoneBody(Zone zone, BodyData body)
|
||||
private static AetheriaRuntimeBodySnapshotCommit ProjectZoneBody(Planet planet)
|
||||
{
|
||||
zone.AsteroidBelts.TryGetValue(body.ID, out var asteroidBelt);
|
||||
return new AetheriaRuntimeBodySnapshotCommit
|
||||
{
|
||||
BodyLegacyId = LegacyId(body.ID),
|
||||
Kind = BodyKind(body),
|
||||
Name = body.Name ?? "",
|
||||
OrbitLegacyId = LegacyId(body.Orbit),
|
||||
Mass = body.Mass,
|
||||
Resources = body.Resources?
|
||||
BodyLegacyId = LegacyId(planet.ID),
|
||||
Kind = BodyKind(planet),
|
||||
Name = planet.Name,
|
||||
OrbitLegacyId = LegacyId(planet.OrbitId),
|
||||
Mass = planet.Mass,
|
||||
Resources = planet.Resources?
|
||||
.OrderBy(pair => pair.Key)
|
||||
.Select(pair => new AetheriaRuntimeBodyResourceCommit
|
||||
{
|
||||
|
|
@ -679,39 +682,62 @@ public class ActionGameManager : MonoBehaviour
|
|||
Amount = pair.Value
|
||||
})
|
||||
.ToArray() ?? Array.Empty<AetheriaRuntimeBodyResourceCommit>(),
|
||||
BodyRadiusMultiplier = body.BodyRadiusMultiplier,
|
||||
GravityRadiusMultiplier = body.GravityRadiusMultiplier,
|
||||
GravityDepthMultiplier = body.GravityDepthMultiplier,
|
||||
GravityDepthExponent = body.GravityDepthExponent,
|
||||
Asteroids = body is AsteroidBeltData belt
|
||||
? ProjectAsteroids(zone, belt, asteroidBelt)
|
||||
: Array.Empty<AetheriaRuntimeAsteroidCommit>(),
|
||||
GasGiantVisual = body is GasGiantData gas
|
||||
BodyRadiusMultiplier = planet.BodyRadiusMultiplier,
|
||||
GravityRadiusMultiplier = planet.GravityRadiusMultiplier,
|
||||
GravityDepthMultiplier = planet.GravityDepthMultiplier,
|
||||
GravityDepthExponent = planet.GravityDepthExponent,
|
||||
Asteroids = Array.Empty<AetheriaRuntimeAsteroidCommit>(),
|
||||
GasGiantVisual = planet is GasGiant gas
|
||||
? ProjectGasGiantVisual(gas)
|
||||
: new AetheriaRuntimeGasGiantVisualCommit(),
|
||||
SunVisual = body is SunData sun
|
||||
SunVisual = planet is Sun sun
|
||||
? ProjectSunVisual(sun)
|
||||
: new AetheriaRuntimeSunVisualCommit()
|
||||
};
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeAsteroidCommit[] ProjectAsteroids(
|
||||
Zone zone,
|
||||
AsteroidBeltData beltData,
|
||||
AsteroidBelt asteroidBelt)
|
||||
private static AetheriaRuntimeBodySnapshotCommit ProjectZoneBody(Zone zone, AsteroidBelt belt)
|
||||
{
|
||||
return beltData.Asteroids?
|
||||
.Select((asteroid, asteroidIndex) => new AetheriaRuntimeAsteroidCommit
|
||||
return new AetheriaRuntimeBodySnapshotCommit
|
||||
{
|
||||
BodyLegacyId = LegacyId(belt.ID),
|
||||
Kind = "asteroid_belt",
|
||||
Name = belt.Name,
|
||||
OrbitLegacyId = LegacyId(belt.Orbit),
|
||||
Mass = belt.Mass,
|
||||
Resources = belt.Resources?
|
||||
.OrderBy(pair => pair.Key)
|
||||
.Select(pair => new AetheriaRuntimeBodyResourceCommit
|
||||
{
|
||||
ItemDefinitionLegacyId = LegacyId(pair.Key),
|
||||
Amount = pair.Value
|
||||
})
|
||||
.ToArray() ?? Array.Empty<AetheriaRuntimeBodyResourceCommit>(),
|
||||
BodyRadiusMultiplier = belt.BodyRadiusMultiplier,
|
||||
GravityRadiusMultiplier = belt.GravityRadiusMultiplier,
|
||||
GravityDepthMultiplier = belt.GravityDepthMultiplier,
|
||||
GravityDepthExponent = belt.GravityDepthExponent,
|
||||
Asteroids = ProjectAsteroids(zone, belt),
|
||||
GasGiantVisual = new AetheriaRuntimeGasGiantVisualCommit(),
|
||||
SunVisual = new AetheriaRuntimeSunVisualCommit()
|
||||
};
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeAsteroidCommit[] ProjectAsteroids(Zone zone, AsteroidBelt asteroidBelt)
|
||||
{
|
||||
return Enumerable.Range(0, asteroidBelt.AsteroidCount)
|
||||
.Select(asteroidIndex =>
|
||||
{
|
||||
Distance = asteroid.Distance,
|
||||
Phase = asteroid.Phase,
|
||||
Size = asteroid.Size,
|
||||
RotationSpeed = asteroid.RotationSpeed,
|
||||
Damage = asteroidBelt != null && asteroidBelt.Damage.TryGetValue(asteroidIndex, out var damage) ? damage : 0,
|
||||
RespawnTimer = asteroidBelt != null && asteroidBelt.RespawnTimers.TryGetValue(asteroidIndex, out var respawnTimer) ? respawnTimer : 0,
|
||||
MiningAccumulators = asteroidBelt == null
|
||||
? Array.Empty<AetheriaRuntimeAsteroidMiningAccumulatorCommit>()
|
||||
: asteroidBelt.MiningAccumulator
|
||||
var asteroid = asteroidBelt.GetAsteroid(asteroidIndex);
|
||||
return new AetheriaRuntimeAsteroidCommit
|
||||
{
|
||||
Distance = asteroid.Distance,
|
||||
Phase = asteroid.Phase,
|
||||
Size = asteroid.Size,
|
||||
RotationSpeed = asteroid.RotationSpeed,
|
||||
Damage = asteroidBelt.Damage.TryGetValue(asteroidIndex, out var damage) ? damage : 0,
|
||||
RespawnTimer = asteroidBelt.RespawnTimers.TryGetValue(asteroidIndex, out var respawnTimer) ? respawnTimer : 0,
|
||||
MiningAccumulators = asteroidBelt.MiningAccumulator
|
||||
.Where(pair => pair.Key.Item2 == asteroidIndex)
|
||||
.Select(pair => new AetheriaRuntimeAsteroidMiningAccumulatorCommit
|
||||
{
|
||||
|
|
@ -720,11 +746,12 @@ public class ActionGameManager : MonoBehaviour
|
|||
})
|
||||
.Where(accumulator => accumulator.MinerEntityIndex >= 0)
|
||||
.ToArray()
|
||||
};
|
||||
})
|
||||
.ToArray() ?? Array.Empty<AetheriaRuntimeAsteroidCommit>();
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeGasGiantVisualCommit ProjectGasGiantVisual(GasGiantData gas)
|
||||
private static AetheriaRuntimeGasGiantVisualCommit ProjectGasGiantVisual(GasGiant gas)
|
||||
{
|
||||
return new AetheriaRuntimeGasGiantVisualCommit
|
||||
{
|
||||
|
|
@ -750,7 +777,7 @@ public class ActionGameManager : MonoBehaviour
|
|||
};
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeSunVisualCommit ProjectSunVisual(SunData sun)
|
||||
private static AetheriaRuntimeSunVisualCommit ProjectSunVisual(Sun sun)
|
||||
{
|
||||
return new AetheriaRuntimeSunVisualCommit
|
||||
{
|
||||
|
|
@ -764,15 +791,13 @@ public class ActionGameManager : MonoBehaviour
|
|||
};
|
||||
}
|
||||
|
||||
private static string BodyKind(BodyData body)
|
||||
private static string BodyKind(Planet body)
|
||||
{
|
||||
return body switch
|
||||
{
|
||||
SunData => "sun",
|
||||
GasGiantData => "gas_giant",
|
||||
AsteroidBeltData => "asteroid_belt",
|
||||
PlanetData => "planet",
|
||||
_ => "body"
|
||||
Sun => "sun",
|
||||
GasGiant => "gas_giant",
|
||||
_ => "planet"
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -409,8 +409,10 @@ public class Planet
|
|||
protected readonly PlanetSettings Settings;
|
||||
private readonly BodyData _data;
|
||||
public Guid ID { get; }
|
||||
public string Name { get; }
|
||||
public Guid OrbitId { get; }
|
||||
public float Mass { get; }
|
||||
public IReadOnlyDictionary<Guid, float> Resources { get; }
|
||||
public float BodyRadiusMultiplier { get; }
|
||||
public float GravityRadiusMultiplier { get; }
|
||||
public float GravityDepthMultiplier { get; }
|
||||
|
|
@ -425,8 +427,10 @@ public class Planet
|
|||
Orbit = orbit;
|
||||
_data = data;
|
||||
ID = data.ID;
|
||||
Name = data.Name ?? "";
|
||||
OrbitId = data.Orbit;
|
||||
Mass = data.Mass;
|
||||
Resources = data.Resources;
|
||||
BodyRadiusMultiplier = data.BodyRadiusMultiplier;
|
||||
GravityRadiusMultiplier = data.GravityRadiusMultiplier;
|
||||
GravityDepthMultiplier = data.GravityDepthMultiplier;
|
||||
|
|
@ -447,6 +451,17 @@ public class Planet
|
|||
public class GasGiant : Planet
|
||||
{
|
||||
public GasGiantData GasGiantData;
|
||||
public float FirstOffsetDomainRotationSpeed { get; }
|
||||
public float FirstOffsetRotationSpeed { get; }
|
||||
public float SecondOffsetDomainRotationSpeed { get; }
|
||||
public float SecondOffsetRotationSpeed { get; }
|
||||
public float AlbedoRotationSpeed { get; }
|
||||
public float WaveRadiusMultiplier { get; }
|
||||
public float WaveDepthMultiplier { get; }
|
||||
public float WaveDepthExponent { get; }
|
||||
public float WaveSpeedMultiplier { get; }
|
||||
public IReadOnlyList<string> MaterialOverrides { get; }
|
||||
public float4[] Colors { get; }
|
||||
public float GravityWavesDepth;
|
||||
public float GravityWavesRadius;
|
||||
public float GravityWavesSpeed;
|
||||
|
|
@ -454,6 +469,17 @@ public class GasGiant : Planet
|
|||
public GasGiant(PlanetSettings settings, GasGiantData data, Orbit orbit) : base(settings, data, orbit)
|
||||
{
|
||||
GasGiantData = data;
|
||||
FirstOffsetDomainRotationSpeed = data.FirstOffsetDomainRotationSpeed;
|
||||
FirstOffsetRotationSpeed = data.FirstOffsetRotationSpeed;
|
||||
SecondOffsetDomainRotationSpeed = data.SecondOffsetDomainRotationSpeed;
|
||||
SecondOffsetRotationSpeed = data.SecondOffsetRotationSpeed;
|
||||
AlbedoRotationSpeed = data.AlbedoRotationSpeed;
|
||||
WaveRadiusMultiplier = data.WaveRadiusMultiplier;
|
||||
WaveDepthMultiplier = data.WaveDepthMultiplier;
|
||||
WaveDepthExponent = data.WaveDepthExponent;
|
||||
WaveSpeedMultiplier = data.WaveSpeedMultiplier;
|
||||
MaterialOverrides = data.MaterialOverrides;
|
||||
Colors = data.Colors;
|
||||
CalculateProperties();
|
||||
}
|
||||
|
||||
|
|
@ -469,11 +495,17 @@ public class GasGiant : Planet
|
|||
public class Sun : GasGiant
|
||||
{
|
||||
public SunData SunData;
|
||||
public float3 LightColor { get; }
|
||||
public float3 FogTintColor { get; }
|
||||
public float LightRadiusMultiplier { get; }
|
||||
public float LightRadius;
|
||||
|
||||
public Sun(PlanetSettings settings, SunData data, Orbit orbit) : base(settings, data, orbit)
|
||||
{
|
||||
SunData = data;
|
||||
LightColor = data.LightColor;
|
||||
FogTintColor = data.FogTintColor;
|
||||
LightRadiusMultiplier = data.LightRadiusMultiplier;
|
||||
CalculateProperties();
|
||||
}
|
||||
|
||||
|
|
@ -489,8 +521,14 @@ public class AsteroidBelt
|
|||
private readonly AsteroidBeltData _data;
|
||||
private readonly Asteroid[] _asteroids;
|
||||
public Guid ID { get; }
|
||||
public string Name { get; }
|
||||
public Guid Orbit { get; }
|
||||
public float Mass { get; }
|
||||
public IReadOnlyDictionary<Guid, float> Resources { get; }
|
||||
public float BodyRadiusMultiplier { get; }
|
||||
public float GravityRadiusMultiplier { get; }
|
||||
public float GravityDepthMultiplier { get; }
|
||||
public float GravityDepthExponent { get; }
|
||||
public float4[] Transforms; // x, y, rotation, scale
|
||||
public float4[] NewTransforms; // x, y, rotation, scale
|
||||
public float Radius { get; }
|
||||
|
|
@ -505,8 +543,14 @@ public class AsteroidBelt
|
|||
_data = data;
|
||||
_asteroids = data.Asteroids;
|
||||
ID = data.ID;
|
||||
Name = data.Name ?? "";
|
||||
Orbit = data.Orbit;
|
||||
Mass = data.Mass;
|
||||
Resources = data.Resources;
|
||||
BodyRadiusMultiplier = data.BodyRadiusMultiplier;
|
||||
GravityRadiusMultiplier = data.GravityRadiusMultiplier;
|
||||
GravityDepthMultiplier = data.GravityDepthMultiplier;
|
||||
GravityDepthExponent = data.GravityDepthExponent;
|
||||
Transforms = new float4[_asteroids.Length];
|
||||
NewTransforms = new float4[_asteroids.Length];
|
||||
Radius = _asteroids.Max(a => a.Distance);
|
||||
|
|
|
|||
|
|
@ -1034,6 +1034,13 @@ First Aetheria surfaces to publish:
|
|||
- Done: move live planet mass/orbit/gravity reads off `BodyData`; `Zone`
|
||||
gravity evaluation and `ZoneRenderer` consume `Planet` runtime properties,
|
||||
with `Planet.ToData()` retained as the temporary capture/config bridge.
|
||||
- Done: move typed zone orbit snapshot projection off
|
||||
`RuntimeZoneBlueprint.Orbits`; run checkpoint commits now project current
|
||||
`Zone.Orbits` runtime wrappers into typed orbit snapshot rows.
|
||||
- Done: move typed zone body snapshot projection off `BodyData` and
|
||||
`AsteroidBeltData`; run checkpoint commits now project `Planet` and
|
||||
`AsteroidBelt` runtime wrappers, including body resources, asteroid
|
||||
runtime damage/respawn/miner accumulators, and gas/sun visual fields.
|
||||
- Done: delete the legacy `Behaviors` lists from `ConsumableItemData` and
|
||||
`EquippableItemData`; item DTOs can no longer carry behavior config state.
|
||||
- Done: move runtime blueprint price aggregation and conductivity restore
|
||||
|
|
|
|||
Loading…
Reference in a new issue