mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Don't use sector if null
cause it can be null on some bodies
This commit is contained in:
parent
56d52bd5cd
commit
25e9eaf16f
@ -9,7 +9,7 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
var airGO = new GameObject("Air");
|
||||
airGO.SetActive(false);
|
||||
airGO.layer = 17;
|
||||
airGO.transform.parent = sector?.transform ? sector.transform : planetGO.transform;
|
||||
airGO.transform.parent = sector?.transform ?? planetGO.transform;
|
||||
|
||||
var sc = airGO.AddComponent<SphereCollider>();
|
||||
sc.isTrigger = true;
|
||||
|
||||
@ -192,7 +192,7 @@ namespace NewHorizons.Builder.Props
|
||||
var outerFogWarpVolume = GetOuterFogWarpVolumeFromAstroObject(go);
|
||||
var fogLight = brambleNode.GetComponent<FogLight>();
|
||||
|
||||
brambleNode.transform.parent = sector.transform;
|
||||
brambleNode.transform.parent = sector?.transform ?? go.transform;
|
||||
brambleNode.transform.position = go.transform.TransformPoint(config.position ?? Vector3.zero);
|
||||
brambleNode.transform.rotation = go.transform.TransformRotation(Quaternion.Euler(config.rotation ?? Vector3.zero));
|
||||
brambleNode.name = config.name ?? "Bramble Node to " + config.linksTo;
|
||||
|
||||
@ -41,7 +41,7 @@ namespace NewHorizons.Builder.Props
|
||||
public static void MakeSocketGroup(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, PropModule.QuantumGroupInfo quantumGroup, GameObject[] propsInGroup)
|
||||
{
|
||||
var groupRoot = new GameObject("Quantum Sockets - " + quantumGroup.id);
|
||||
groupRoot.transform.parent = sector.transform;
|
||||
groupRoot.transform.parent = sector?.transform ?? go.transform;
|
||||
groupRoot.transform.localPosition = Vector3.zero;
|
||||
groupRoot.transform.localEulerAngles = Vector3.zero;
|
||||
|
||||
@ -79,7 +79,7 @@ namespace NewHorizons.Builder.Props
|
||||
public static void MakeStateGroup(GameObject go, Sector sector, PlanetConfig config, IModBehaviour mod, PropModule.QuantumGroupInfo quantumGroup, GameObject[] propsInGroup)
|
||||
{
|
||||
var groupRoot = new GameObject("Quantum States - " + quantumGroup.id);
|
||||
groupRoot.transform.parent = sector.transform;
|
||||
groupRoot.transform.parent = sector?.transform ?? go.transform;
|
||||
groupRoot.transform.localPosition = Vector3.zero;
|
||||
|
||||
var states = new List<QuantumState>();
|
||||
@ -128,7 +128,7 @@ namespace NewHorizons.Builder.Props
|
||||
//var averagePosition = propsInGroup.Aggregate(Vector3.zero, (avg, prop) => avg + prop.transform.position) / propsInGroup.Count();
|
||||
GameObject shuffleParent = new GameObject("Quantum Shuffle - " + quantumGroup.id);
|
||||
shuffleParent.SetActive(false);
|
||||
shuffleParent.transform.parent = sector.transform;
|
||||
shuffleParent.transform.parent = sector?.transform ?? go.transform;
|
||||
shuffleParent.transform.localPosition = Vector3.zero;
|
||||
propsInGroup.ToList().ForEach(p => p.transform.parent = shuffleParent.transform);
|
||||
|
||||
|
||||
@ -100,9 +100,9 @@ namespace NewHorizons.Builder.Props
|
||||
{
|
||||
var tornadoGO = downwards ? _downPrefab.InstantiateInactive() : _upPrefab.InstantiateInactive();
|
||||
tornadoGO.name = downwards ? "Tornado_Down" : "Tornado_Up";
|
||||
tornadoGO.transform.parent = sector.transform;
|
||||
tornadoGO.transform.parent = sector?.transform ?? planetGO.transform;
|
||||
tornadoGO.transform.position = planetGO.transform.TransformPoint(position);
|
||||
tornadoGO.transform.rotation = Quaternion.FromToRotation(Vector3.up, sector.transform.TransformDirection(position.normalized));
|
||||
tornadoGO.transform.rotation = Quaternion.FromToRotation(Vector3.up, planetGO.transform.TransformDirection(position.normalized));
|
||||
|
||||
// Add the sound thing before changing the scale
|
||||
var soundGO = _soundPrefab.InstantiateInactive();
|
||||
@ -168,7 +168,7 @@ namespace NewHorizons.Builder.Props
|
||||
|
||||
if (info.wanderRate != 0)
|
||||
{
|
||||
ApplyWanderer(tornadoGO, sector, info);
|
||||
ApplyWanderer(tornadoGO, planetGO, info);
|
||||
}
|
||||
|
||||
soundGO.SetActive(true);
|
||||
@ -179,9 +179,9 @@ namespace NewHorizons.Builder.Props
|
||||
{
|
||||
var hurricaneGO = _hurricanePrefab.InstantiateInactive();
|
||||
hurricaneGO.name = "Hurricane";
|
||||
hurricaneGO.transform.parent = sector.transform;
|
||||
hurricaneGO.transform.parent = sector?.transform ?? planetGO.transform;
|
||||
hurricaneGO.transform.position = planetGO.transform.TransformPoint(position);
|
||||
hurricaneGO.transform.rotation = Quaternion.FromToRotation(Vector3.up, sector.transform.TransformDirection(position.normalized));
|
||||
hurricaneGO.transform.rotation = Quaternion.FromToRotation(Vector3.up, planetGO.transform.TransformDirection(position.normalized));
|
||||
|
||||
var fluidVolume = hurricaneGO.GetComponentInChildren<HurricaneFluidVolume>();
|
||||
fluidVolume._fluidType = info.fluidType.ConvertToOW(FluidVolume.Type.CLOUD);
|
||||
@ -227,7 +227,7 @@ namespace NewHorizons.Builder.Props
|
||||
|
||||
if (info.wanderRate != 0)
|
||||
{
|
||||
ApplyWanderer(hurricaneGO, sector, info);
|
||||
ApplyWanderer(hurricaneGO, planetGO, info);
|
||||
}
|
||||
|
||||
hurricaneGO.SetActive(true);
|
||||
@ -263,13 +263,13 @@ namespace NewHorizons.Builder.Props
|
||||
}
|
||||
}
|
||||
|
||||
private static void ApplyWanderer(GameObject go, Sector sector, PropModule.TornadoInfo info)
|
||||
private static void ApplyWanderer(GameObject go, GameObject planetGO, PropModule.TornadoInfo info)
|
||||
{
|
||||
var wanderer = go.AddComponent<NHTornadoWanderController>();
|
||||
wanderer.wanderRate = info.wanderRate;
|
||||
wanderer.wanderDegreesX = info.wanderDegreesX;
|
||||
wanderer.wanderDegreesZ = info.wanderDegreesZ;
|
||||
wanderer.sector = sector;
|
||||
wanderer.planetGO = planetGO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ namespace NewHorizons.Builder.Props
|
||||
InitPrefab();
|
||||
|
||||
var launcherGO = _meteorLauncherPrefab.InstantiateInactive();
|
||||
launcherGO.transform.parent = sector.transform;
|
||||
launcherGO.transform.parent = sector?.transform ?? planetGO.transform;
|
||||
launcherGO.transform.position = planetGO.transform.TransformPoint(info.position == null ? Vector3.zero : (Vector3)info.position);
|
||||
launcherGO.transform.rotation = Quaternion.FromToRotation(launcherGO.transform.TransformDirection(Vector3.up), ((Vector3)info.position).normalized).normalized;
|
||||
launcherGO.name = "MeteorLauncher";
|
||||
|
||||
@ -7,7 +7,7 @@ namespace NewHorizons.Components
|
||||
public float wanderRate;
|
||||
public float wanderDegreesX;
|
||||
public float wanderDegreesZ;
|
||||
public Sector sector;
|
||||
public GameObject planetGO;
|
||||
|
||||
private float noiseOffset;
|
||||
private float startDegreesX;
|
||||
@ -47,7 +47,7 @@ namespace NewHorizons.Components
|
||||
var newPos = new Vector3(newX, newY, newZ);
|
||||
|
||||
transform.localPosition = newPos;
|
||||
transform.rotation = Quaternion.FromToRotation(Vector3.up, sector.transform.TransformDirection(newPos.normalized));
|
||||
transform.rotation = Quaternion.FromToRotation(Vector3.up, planetGO.transform.TransformDirection(newPos.normalized));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user