Move orbital runtime seam onto typed orbit keys
This commit is contained in:
parent
cfc1ddac6d
commit
33f289dcac
10 changed files with 125 additions and 20 deletions
|
|
@ -12,7 +12,7 @@ public static class EntityConstructionBlueprintProjector
|
|||
if (entity is OrbitalEntity orbital)
|
||||
blueprint = new OrbitalEntityConstructionBlueprint
|
||||
{
|
||||
Orbit = orbital.OrbitId,
|
||||
OrbitKey = orbital.OrbitKey,
|
||||
SecurityLevel = orbital.SecurityLevel,
|
||||
SecurityRadius = orbital.SecurityRadius
|
||||
};
|
||||
|
|
@ -66,7 +66,7 @@ public static class EntityConstructionBlueprintProjector
|
|||
|
||||
private static OrbitalEntity InstantiateFromBlueprint(ItemManager itemManager, Zone zone, OrbitalEntityConstructionBlueprint blueprint, bool instantiate = false)
|
||||
{
|
||||
var entity = new OrbitalEntity(itemManager, zone, instantiate ? (EquippableItem) itemManager.Instantiate(blueprint.Hull) : blueprint.Hull, blueprint.Orbit, blueprint.Settings);
|
||||
var entity = new OrbitalEntity(itemManager, zone, instantiate ? (EquippableItem) itemManager.Instantiate(blueprint.Hull) : blueprint.Hull, blueprint.OrbitKey, blueprint.Settings);
|
||||
Restore(itemManager, zone, blueprint, entity, instantiate);
|
||||
entity.SecurityLevel = blueprint.SecurityLevel;
|
||||
entity.SecurityRadius = blueprint.SecurityRadius;
|
||||
|
|
@ -128,7 +128,7 @@ public class ShipConstructionBlueprint : EntityConstructionBlueprint
|
|||
|
||||
public class OrbitalEntityConstructionBlueprint : EntityConstructionBlueprint
|
||||
{
|
||||
public Guid Orbit;
|
||||
public string OrbitKey = "";
|
||||
public int Story = -1;
|
||||
public SecurityLevel SecurityLevel;
|
||||
public float SecurityRadius;
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ public class LoadoutGenerator
|
|||
return null;
|
||||
}
|
||||
var hull = ItemManager.CreateEquippableInstance(hullRow);
|
||||
var entity = new OrbitalEntity(ItemManager, null, hull, Guid.Empty, ItemManager.GameplaySettings.DefaultEntitySettings);
|
||||
var entity = new OrbitalEntity(ItemManager, null, hull, "", ItemManager.GameplaySettings.DefaultEntitySettings);
|
||||
entity.Faction = Faction;
|
||||
OutfitEntity(entity);
|
||||
return EntityConstructionBlueprintProjector.CaptureBlueprint(entity) as OrbitalEntityConstructionBlueprint;
|
||||
|
|
@ -96,7 +96,7 @@ public class LoadoutGenerator
|
|||
return null;
|
||||
}
|
||||
var hull = ItemManager.CreateEquippableInstance(hullRow);
|
||||
var entity = new OrbitalEntity(ItemManager, null, hull, Guid.Empty, ItemManager.GameplaySettings.DefaultEntitySettings);
|
||||
var entity = new OrbitalEntity(ItemManager, null, hull, "", ItemManager.GameplaySettings.DefaultEntitySettings);
|
||||
entity.Faction = Faction;
|
||||
|
||||
var emptyShape = entity.UnoccupiedSpace;
|
||||
|
|
|
|||
|
|
@ -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 Unity.Mathematics;
|
||||
|
|
@ -11,23 +10,23 @@ using float2 = Unity.Mathematics.float2;
|
|||
|
||||
public class OrbitalEntity : Entity
|
||||
{
|
||||
public Guid OrbitId;
|
||||
public string OrbitKey = "";
|
||||
public SecurityLevel SecurityLevel;
|
||||
public float SecurityRadius;
|
||||
public LocationStory Story;
|
||||
public bool CanTow;
|
||||
|
||||
public OrbitalEntity(ItemManager itemManager, Zone zone, EquippableItem hull, Guid orbit, EntitySettings settings) : base(itemManager, zone, hull, settings)
|
||||
public OrbitalEntity(ItemManager itemManager, Zone zone, EquippableItem hull, string orbitKey, EntitySettings settings) : base(itemManager, zone, hull, settings)
|
||||
{
|
||||
OrbitId = orbit;
|
||||
OrbitKey = orbitKey ?? "";
|
||||
}
|
||||
|
||||
public override void Update(float delta)
|
||||
{
|
||||
if (OrbitId != Guid.Empty)
|
||||
if (!string.IsNullOrWhiteSpace(OrbitKey))
|
||||
{
|
||||
Position.xz = Zone.GetOrbitPosition(OrbitId);
|
||||
Velocity = Zone.GetOrbitVelocity(OrbitId);
|
||||
Position.xz = Zone.GetOrbitPosition(OrbitKey);
|
||||
Velocity = Zone.GetOrbitVelocity(OrbitKey);
|
||||
}
|
||||
|
||||
base.Update(delta);
|
||||
|
|
|
|||
|
|
@ -244,6 +244,11 @@ public class Zone
|
|||
return float2.zero;
|
||||
}
|
||||
|
||||
public float2 GetOrbitVelocity(string orbitKey)
|
||||
{
|
||||
return GetOrbitVelocity(ParseOrbitGuid(orbitKey));
|
||||
}
|
||||
|
||||
public int NearestAsteroid(Guid planetDataID, float2 position)
|
||||
{
|
||||
var belt = AsteroidBelts[planetDataID];
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ public static class ZoneGenerator
|
|||
blueprint.Orbits.Add(turretOrbit);
|
||||
var turret = loadoutGenerator.GenerateTurretLoadout();
|
||||
if (turret == null) return;
|
||||
turret.Orbit = turretOrbit.ID;
|
||||
turret.OrbitKey = Zone.OrbitKey(turretOrbit.ID);
|
||||
blueprint.Entities.Add(turret);
|
||||
}
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ public static class ZoneGenerator
|
|||
var orbit = selectedStationOrbits[i];
|
||||
var lagrangeOrbit = CreateLagrangeOrbit(orbit);
|
||||
var station = GetLoadoutGenerator(story.Faction).GenerateStationLoadout();
|
||||
station.Orbit = lagrangeOrbit.ID;
|
||||
station.OrbitKey = Zone.OrbitKey(lagrangeOrbit.ID);
|
||||
station.SecurityLevel = story.Security;
|
||||
station.SecurityRadius = blueprint.Radius;
|
||||
station.Story = i;
|
||||
|
|
@ -314,7 +314,7 @@ public static class ZoneGenerator
|
|||
var lagrangeOrbit = CreateLagrangeOrbit(orbit);
|
||||
var station = GetLoadoutGenerator(nearestFaction).GenerateStationLoadout();
|
||||
if (station == null) continue;
|
||||
station.Orbit = lagrangeOrbit.ID;
|
||||
station.OrbitKey = Zone.OrbitKey(lagrangeOrbit.ID);
|
||||
station.SecurityLevel = security;
|
||||
station.SecurityRadius = blueprint.Radius;
|
||||
blueprint.Entities.Add(station);
|
||||
|
|
|
|||
Loading…
Reference in a new issue