Delete zone body shadow state
This commit is contained in:
parent
3eab07c9dc
commit
191a7dd1c3
6 changed files with 44 additions and 38 deletions
|
|
@ -68,35 +68,31 @@ public class ResourceScanner : Behavior, IAlwaysUpdatedBehavior
|
|||
|
||||
public override bool Execute(float dt)
|
||||
{
|
||||
var planetData = Entity.Zone.Planets[ScanTarget];
|
||||
if (planetData != null)
|
||||
if (Entity.Zone.AsteroidBelts.TryGetValue(ScanTarget, out var belt))
|
||||
{
|
||||
if (Entity.Zone.AsteroidBelts.TryGetValue(ScanTarget, out var belt))
|
||||
if (Asteroid > -1 &&
|
||||
belt.ContainsAsteroid(Asteroid) &&
|
||||
length(Entity.Position.xz - belt.Transforms[Asteroid].xy) < Range)
|
||||
{
|
||||
if(Asteroid > -1 &&
|
||||
belt.ContainsAsteroid(Asteroid) &&
|
||||
length(Entity.Position.xz - belt.Transforms[Asteroid].xy) < Range)
|
||||
_scanTime += dt;
|
||||
if (_scanTime > ScanDuration)
|
||||
{
|
||||
_scanTime += dt;
|
||||
if (_scanTime > ScanDuration)
|
||||
{
|
||||
// TODO: Implement Scanning!
|
||||
_scanTime = 0;
|
||||
}
|
||||
return true;
|
||||
// TODO: Implement Scanning!
|
||||
_scanTime = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
}
|
||||
else if (Entity.Zone.PlanetInstances.TryGetValue(ScanTarget, out var planet))
|
||||
{
|
||||
if(length(Entity.Position.xz - Entity.Zone.GetOrbitPosition(planet.OrbitId)) < Range)
|
||||
{
|
||||
if(length(Entity.Position.xz - Entity.Zone.GetOrbitPosition(planetData.Orbit)) < Range)
|
||||
_scanTime += dt;
|
||||
if (_scanTime > ScanDuration)
|
||||
{
|
||||
_scanTime += dt;
|
||||
if (_scanTime > ScanDuration)
|
||||
{
|
||||
_scanTime = 0;
|
||||
}
|
||||
return true;
|
||||
_scanTime = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -17,10 +17,7 @@ using Random = Unity.Mathematics.Random;
|
|||
public class Zone
|
||||
{
|
||||
public Action<string> Log;
|
||||
//public HashSet<Guid> Planets = new HashSet<Guid>();
|
||||
public ReactiveCollection<Entity> Entities = new ReactiveCollection<Entity>();
|
||||
//public Dictionary<Guid, OrbitData> Orbits = new Dictionary<Guid, OrbitData>();
|
||||
public Dictionary<Guid, BodyData> Planets = new Dictionary<Guid, BodyData>();
|
||||
public Dictionary<Guid, Planet> PlanetInstances = new Dictionary<Guid, Planet>();
|
||||
|
||||
public Dictionary<Guid, Orbit> Orbits = new Dictionary<Guid, Orbit>();
|
||||
|
|
@ -61,7 +58,6 @@ public class Zone
|
|||
|
||||
foreach (var planet in blueprint.Planets)
|
||||
{
|
||||
Planets.Add(planet.ID, planet);
|
||||
switch (planet)
|
||||
{
|
||||
case AsteroidBeltData belt:
|
||||
|
|
@ -112,11 +108,27 @@ public class Zone
|
|||
Mass = Blueprint.Mass,
|
||||
Entities = Entities.Select(RuntimeEntityBlueprintProjector.CaptureBlueprint).ToList(),
|
||||
Orbits = Orbits.Values.Select(o=>o.ToData()).ToList(),
|
||||
Planets = Planets.Values.ToList(),
|
||||
Planets = CaptureBodyData().ToList(),
|
||||
Time = _time
|
||||
};
|
||||
}
|
||||
|
||||
public IEnumerable<BodyData> CaptureBodyData()
|
||||
{
|
||||
foreach (var orbit in Orbits.Values)
|
||||
{
|
||||
var planet = PlanetInstances.Values.FirstOrDefault(body => body.OrbitId == orbit.ID);
|
||||
if (planet != null)
|
||||
{
|
||||
yield return planet.ToData();
|
||||
continue;
|
||||
}
|
||||
|
||||
var belt = AsteroidBelts.Values.FirstOrDefault(body => body.Orbit == orbit.ID);
|
||||
if (belt != null) yield return belt.ToData();
|
||||
}
|
||||
}
|
||||
|
||||
public void AddOrbit(OrbitData orbit)
|
||||
{
|
||||
Orbits.Add(orbit.ID, new Orbit(Settings, orbit));
|
||||
|
|
|
|||
Loading…
Reference in a new issue