mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Create sectors using parent for children without one
This commit is contained in:
parent
256fd0eb95
commit
24c43ae747
@ -31,5 +31,32 @@ namespace NewHorizons.Builder.General
|
|||||||
|
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Sector Make(GameObject planetBody, OWRigidbody owRigidBody, Sector parent)
|
||||||
|
{
|
||||||
|
if (parent == null) return null;
|
||||||
|
|
||||||
|
GameObject sectorGO = new GameObject("Sector");
|
||||||
|
sectorGO.SetActive(false);
|
||||||
|
sectorGO.transform.parent = planetBody.transform;
|
||||||
|
sectorGO.transform.localPosition = Vector3.zero;
|
||||||
|
|
||||||
|
Sector S = sectorGO.AddComponent<Sector>();
|
||||||
|
S._idString = parent._idString;
|
||||||
|
S._name = parent._name;
|
||||||
|
S._attachedOWRigidbody = owRigidBody;
|
||||||
|
S._subsectors = new List<Sector>();
|
||||||
|
S._triggerRoot = parent._triggerRoot;
|
||||||
|
S._proximityTrigger = parent._proximityTrigger;
|
||||||
|
S._volumeExcluder = parent._volumeExcluder;
|
||||||
|
S._owTriggerVolume = parent._owTriggerVolume;
|
||||||
|
S._frameCounter = parent._frameCounter;
|
||||||
|
S.SetParentSector(parent);
|
||||||
|
|
||||||
|
sectorGO.SetActive(true);
|
||||||
|
S.enabled = true;
|
||||||
|
|
||||||
|
return S;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -242,13 +242,32 @@ namespace NewHorizons.Handlers
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Sector CreateSectorFromParent(GameObject planetGO, OWRigidbody rigidbody)
|
||||||
|
{
|
||||||
|
switch (planetGO.name)
|
||||||
|
{
|
||||||
|
case "TimeLoopRing_Body":
|
||||||
|
return SectorBuilder.Make(planetGO, rigidbody, SearchUtilities.Find("TowerTwin_Body/Sector_TowerTwin/Sector_TimeLoopInterior").GetComponent<Sector>());
|
||||||
|
case "SandFunnel_Body":
|
||||||
|
return SectorBuilder.Make(planetGO, rigidbody, SearchUtilities.Find("FocalBody/Sector_HGT").GetComponent<Sector>());
|
||||||
|
case "SS_Debris_Body":
|
||||||
|
return SectorBuilder.Make(planetGO, rigidbody, SearchUtilities.Find("SunStation_Body/Sector_SunStation").GetComponent<Sector>());
|
||||||
|
case "WhiteholeStationSuperstructure_Body":
|
||||||
|
return SectorBuilder.Make(planetGO, rigidbody, SearchUtilities.Find("WhiteholeStation_Body/Sector_WhiteholeStation").GetComponent<Sector>());
|
||||||
|
case "MiningRig_Body":
|
||||||
|
return SectorBuilder.Make(planetGO, rigidbody, SearchUtilities.Find("TimberHearth_Body/Sector_TH/Sector_ZeroGCave").GetComponent<Sector>());
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Called when updating an existing planet
|
// Called when updating an existing planet
|
||||||
public static GameObject UpdateBody(NewHorizonsBody body, GameObject go)
|
public static GameObject UpdateBody(NewHorizonsBody body, GameObject go)
|
||||||
{
|
{
|
||||||
Logger.Log($"Updating existing Object {go.name}");
|
Logger.Log($"Updating existing Object {go.name}");
|
||||||
|
|
||||||
var sector = go.GetComponentInChildren<Sector>();
|
|
||||||
var rb = go.GetAttachedOWRigidbody();
|
var rb = go.GetAttachedOWRigidbody();
|
||||||
|
var sector = go.GetComponentInChildren<Sector>() ?? CreateSectorFromParent(go, rb);
|
||||||
|
|
||||||
// Since orbits are always there just check if they set a semi major axis
|
// Since orbits are always there just check if they set a semi major axis
|
||||||
if (body.Config.Orbit != null && body.Config.Orbit.semiMajorAxis != 0f)
|
if (body.Config.Orbit != null && body.Config.Orbit.semiMajorAxis != 0f)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user