Fix positions

This commit is contained in:
Nick 2022-05-12 01:47:20 -04:00
parent 9830441a1d
commit 55e8be6546
39 changed files with 173 additions and 176 deletions

View File

@ -7,12 +7,12 @@ namespace NewHorizons.Builder.Atmosphere
{
public static class AirBuilder
{
public static void Make(GameObject body, Sector sector, AtmosphereModule.AirInfo info)
public static void Make(GameObject planetGO, Sector sector, AtmosphereModule.AirInfo info)
{
GameObject airGO = new GameObject("Air");
airGO.SetActive(false);
airGO.layer = 17;
airGO.transform.parent = sector?.transform ?? body.transform;
airGO.transform.parent = sector?.transform ?? planetGO.transform;
SphereCollider SC = airGO.AddComponent<SphereCollider>();
SC.isTrigger = true;
@ -60,7 +60,7 @@ namespace NewHorizons.Builder.Atmosphere
airGO.AddComponent<AudioVolume>();
}
airGO.transform.localPosition = Vector3.zero;
airGO.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
airGO.SetActive(true);
}
}

View File

@ -6,17 +6,17 @@ namespace NewHorizons.Builder.Atmosphere
{
public static class AtmosphereBuilder
{
public static void Make(GameObject body, Sector sector, AtmosphereModule atmosphereModule, float surfaceSize)
public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atmosphereModule, float surfaceSize)
{
GameObject atmoGO = new GameObject("Atmosphere");
atmoGO.SetActive(false);
atmoGO.transform.parent = sector?.transform ?? body.transform;
atmoGO.transform.parent = sector?.transform ?? planetGO.transform;
if (atmosphereModule.HasAtmosphere)
{
GameObject atmo = GameObject.Instantiate(GameObject.Find("TimberHearth_Body/Atmosphere_TH/AtmoSphere"));
atmo.transform.parent = atmoGO.transform;
atmo.transform.localPosition = Vector3.zero;
atmo.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
atmo.transform.localScale = Vector3.one * atmosphereModule.Size * 1.2f;
foreach(var meshRenderer in atmo.GetComponentsInChildren<MeshRenderer>())
{
@ -29,7 +29,7 @@ namespace NewHorizons.Builder.Atmosphere
atmo.SetActive(true);
}
atmoGO.transform.localPosition = Vector3.zero;
atmoGO.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
atmoGO.SetActive(true);
}
}

View File

@ -11,7 +11,7 @@ namespace NewHorizons.Builder.Atmosphere
public static class CloudsBuilder
{
private static Shader _sphereShader = null;
public static void Make(GameObject body, Sector sector, AtmosphereModule atmo, IModBehaviour mod)
public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atmo, IModBehaviour mod)
{
Texture2D image, cap, ramp;
@ -34,7 +34,7 @@ namespace NewHorizons.Builder.Atmosphere
GameObject cloudsMainGO = new GameObject("Clouds");
cloudsMainGO.SetActive(false);
cloudsMainGO.transform.parent = sector?.transform ?? body.transform;
cloudsMainGO.transform.parent = sector?.transform ?? planetGO.transform;
GameObject cloudsTopGO = new GameObject("TopClouds");
cloudsTopGO.SetActive(false);
@ -158,14 +158,14 @@ namespace NewHorizons.Builder.Atmosphere
fluidCLFV._disableOnStart = false;
// Fix the rotations once the rest is done
cloudsMainGO.transform.localRotation = Quaternion.Euler(0, 0, 0);
cloudsMainGO.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(0, 0, 0));
// For the base shader it has to be rotated idk
if(atmo.UseBasicCloudShader) cloudsMainGO.transform.localRotation = Quaternion.Euler(90, 0, 0);
if(atmo.UseBasicCloudShader) cloudsMainGO.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(90, 0, 0));
cloudsMainGO.transform.localPosition = Vector3.zero;
cloudsBottomGO.transform.localPosition = Vector3.zero;
cloudsFluidGO.transform.localPosition = Vector3.zero;
cloudsTopGO.transform.localPosition = Vector3.zero;
cloudsMainGO.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
cloudsBottomGO.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
cloudsFluidGO.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
cloudsTopGO.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
cloudsTopGO.SetActive(true);
cloudsBottomGO.SetActive(true);

View File

@ -8,12 +8,12 @@ namespace NewHorizons.Builder.Atmosphere
{
public static class EffectsBuilder
{
public static void Make(GameObject body, Sector sector, AtmosphereModule.AirInfo info, float surfaceSize)
public static void Make(GameObject planetGO, Sector sector, AtmosphereModule.AirInfo info, float surfaceSize)
{
GameObject effectsGO = new GameObject("Effects");
effectsGO.SetActive(false);
effectsGO.transform.parent = sector?.transform ?? body.transform;
effectsGO.transform.localPosition = Vector3.zero;
effectsGO.transform.parent = sector?.transform ?? planetGO.transform;
effectsGO.transform.position = planetGO.transform.position;
SectorCullGroup SCG = effectsGO.AddComponent<SectorCullGroup>();
SCG._sector = sector;
@ -25,7 +25,7 @@ namespace NewHorizons.Builder.Atmosphere
if(info.IsRaining)
{
var rainGO = GameObject.Instantiate(SearchUtilities.CachedFind("/GiantsDeep_Body/Sector_GD/Sector_GDInterior/Effects_GDInterior/Effects_GD_Rain"), effectsGO.transform);
rainGO.transform.localPosition = Vector3.zero;
rainGO.transform.position = planetGO.transform.position;
var pvc = rainGO.GetComponent<PlanetaryVectionController>();
pvc._densityByHeight = new AnimationCurve(new Keyframe[]
@ -44,12 +44,12 @@ namespace NewHorizons.Builder.Atmosphere
{
var snowGO = new GameObject("SnowEffects");
snowGO.transform.parent = effectsGO.transform;
snowGO.transform.localPosition = Vector3.zero;
snowGO.transform.position = planetGO.transform.position;
for(int i = 0; i < 5; i++)
{
var snowEmitter = GameObject.Instantiate(SearchUtilities.CachedFind("/BrittleHollow_Body/Sector_BH/Effects_BH/Effects_BH_Snowflakes"), snowGO.transform);
snowEmitter.name = "SnowEmitter";
snowEmitter.transform.localPosition = Vector3.zero;
snowEmitter.transform.position = planetGO.transform.position;
var pvc = snowEmitter.GetComponent<PlanetaryVectionController>();
pvc._densityByHeight = new AnimationCurve(new Keyframe[]
@ -65,7 +65,7 @@ namespace NewHorizons.Builder.Atmosphere
}
}
effectsGO.transform.localPosition = Vector3.zero;
effectsGO.transform.position = planetGO.transform.position;
effectsGO.SetActive(true);
}
}

View File

@ -12,11 +12,11 @@ namespace NewHorizons.Builder.Atmosphere
{
public static class FogBuilder
{
public static void Make(GameObject body, Sector sector, AtmosphereModule atmo)
public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atmo)
{
GameObject fogGO = new GameObject("FogSphere");
fogGO.SetActive(false);
fogGO.transform.parent = sector?.transform ?? body.transform;
fogGO.transform.parent = sector?.transform ?? planetGO.transform;
fogGO.transform.localScale = Vector3.one;
// Going to copy from dark bramble
@ -59,8 +59,8 @@ namespace NewHorizons.Builder.Atmosphere
lodFogSectorProxy.SetSector(sector);
*/
fogGO.transform.localPosition = Vector3.zero;
lodFogGO.transform.localPosition = Vector3.zero;
fogGO.transform.position = planetGO.transform.position;
lodFogGO.transform.position = planetGO.transform.position;
fogGO.SetActive(true);
lodFogGO.SetActive(true);

View File

@ -7,11 +7,11 @@ namespace NewHorizons.Builder.Atmosphere
{
public static class SunOverrideBuilder
{
public static void Make(GameObject body, Sector sector, AtmosphereModule atmo, float surfaceSize)
public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atmo, float surfaceSize)
{
GameObject overrideGO = new GameObject("SunOverride");
overrideGO.SetActive(false);
overrideGO.transform.parent = sector?.transform ?? body.transform;
overrideGO.transform.parent = sector?.transform ?? planetGO.transform;
GiantsDeepSunOverrideVolume GDSOV = overrideGO.AddComponent<GiantsDeepSunOverrideVolume>();
GDSOV._sector = sector;
@ -20,7 +20,7 @@ namespace NewHorizons.Builder.Atmosphere
GDSOV._waterOuterRadius = surfaceSize;
GDSOV._waterInnerRadius = 0f;
overrideGO.transform.localPosition = Vector3.zero;
overrideGO.transform.position = planetGO.transform.position;
overrideGO.SetActive(true);
}
}

View File

@ -8,11 +8,11 @@ namespace NewHorizons.Builder.Atmosphere
{
public static class VolumesBuilder
{
public static void Make(GameObject body, float innerRadius, float outerRadius, bool useMiniMap)
public static void Make(GameObject planetGO, float innerRadius, float outerRadius, bool useMiniMap)
{
GameObject volumesGO = new GameObject("Volumes");
volumesGO.SetActive(false);
volumesGO.transform.parent = body.transform;
volumesGO.transform.parent = planetGO.transform;
GameObject rulesetGO = new GameObject("Ruleset");
rulesetGO.SetActive(false);
@ -38,7 +38,7 @@ namespace NewHorizons.Builder.Atmosphere
ER._material = GameObject.Find("RulesetVolumes_GD").GetComponent<RulesetVolume>().GetValue<Material>("_material");
ER._cloudMaterial = GameObject.Find("RulesetVolumes_GD").GetComponent<RulesetVolume>().GetValue<Material>("_cloudMaterial");
volumesGO.transform.localPosition = Vector3.zero;
volumesGO.transform.position = planetGO.transform.position;
rulesetGO.SetActive(true);
volumesGO.SetActive(true);
}

View File

@ -11,12 +11,12 @@ namespace NewHorizons.Builder.Body
{
public static class CloakBuilder
{
public static void Make(GameObject body, Sector sector, float radius)
public static void Make(GameObject planetGO, Sector sector, float radius)
{
var cloak = SearchUtilities.Find("RingWorld_Body/CloakingField_IP");
var newCloak = GameObject.Instantiate(cloak, body.transform);
newCloak.transform.localPosition = Vector3.zero;
var newCloak = GameObject.Instantiate(cloak, sector?.transform ?? planetGO.transform);
newCloak.transform.position = planetGO.transform.position;
newCloak.transform.name = "CloakingField";
newCloak.transform.localScale = Vector3.one * radius;
@ -28,11 +28,11 @@ namespace NewHorizons.Builder.Body
cloakFieldController._innerCloakRadius = radius * 900 / 3000f;
cloakFieldController._nearCloakRadius = radius * 800 / 3000f;
cloakFieldController._referenceFrameVolume = body.GetAttachedOWRigidbody()._attachedRFVolume;
cloakFieldController._referenceFrameVolume = planetGO.GetAttachedOWRigidbody()._attachedRFVolume;
cloakFieldController._exclusionSector = null;
var cloakSectorController = newCloak.AddComponent<CloakSectorController>();
cloakSectorController.Init(newCloak.GetComponent<CloakFieldController>(), body);
cloakSectorController.Init(newCloak.GetComponent<CloakFieldController>(), planetGO);
newCloak.SetActive(true);
cloakFieldController.enabled = true;

View File

@ -12,10 +12,10 @@ namespace NewHorizons.Builder.Body
{
public static class CometTailBuilder
{
public static void Make(GameObject go, Sector sector, IPlanetConfig config, AstroObject primary)
public static void Make(GameObject planetGO, Sector sector, IPlanetConfig config, AstroObject primary)
{
var cometTail = GameObject.Instantiate(GameObject.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes"), sector?.transform ?? go.transform);
cometTail.transform.localPosition = Vector3.zero;
var cometTail = GameObject.Instantiate(GameObject.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes"), sector?.transform ?? planetGO.transform);
cometTail.transform.position = planetGO.transform.position;
cometTail.name = "CometTail";
cometTail.transform.localScale = Vector3.one * config.Base.SurfaceSize / 110;

View File

@ -21,16 +21,16 @@ namespace NewHorizons.Builder.Body
STAR
}
public static void Make(GameObject go, ConstantForceDetector detector, OWRigidbody rigidbody, FunnelModule module)
public static void Make(GameObject planetGO, ConstantForceDetector detector, OWRigidbody rigidbody, FunnelModule module)
{
var funnelType = FunnelType.SAND;
if (module.Type.ToUpper().Equals("WATER")) funnelType = FunnelType.WATER;
else if (module.Type.ToUpper().Equals("LAVA")) funnelType = FunnelType.LAVA;
else if (module.Type.ToUpper().Equals("STAR")) funnelType = FunnelType.STAR;
var funnelGO = new GameObject($"{go.name.Replace("_Body", "")}Funnel_Body");
var funnelGO = new GameObject($"{planetGO.name.Replace("_Body", "")}Funnel_Body");
funnelGO.SetActive(false);
funnelGO.transform.parent = go.transform;
funnelGO.transform.parent = planetGO.transform;
var owrb = funnelGO.AddComponent<OWRigidbody>();
@ -149,7 +149,7 @@ namespace NewHorizons.Builder.Body
break;
}
var sector = go.GetComponent<AstroObject>().GetPrimaryBody().GetRootSector();
var sector = planetGO.GetComponent<AstroObject>().GetPrimaryBody().GetRootSector();
proxyGO.GetComponent<SectorProxy>().SetSector(sector);
geoGO.GetComponent<SectorCullGroup>().SetSector(sector);
volumesGO.GetComponent<SectorCollisionGroup>().SetSector(sector);
@ -167,7 +167,7 @@ namespace NewHorizons.Builder.Body
}
funnelSizeController.scaleCurve = curve;
}
funnelSizeController.anchor = go.transform;
funnelSizeController.anchor = planetGO.transform;
// Finish up next tick
Main.Instance.ModHelper.Events.Unity.FireOnNextUpdate(() => PostMake(funnelGO, funnelSizeController, module));

View File

@ -5,12 +5,12 @@ namespace NewHorizons.Builder.Body
{
public static class GeometryBuilder
{
public static void Make(GameObject body, Sector sector, float groundScale)
public static void Make(GameObject planetGO, Sector sector, float groundScale)
{
GameObject groundGO = GameObject.CreatePrimitive(PrimitiveType.Sphere);
groundGO.transform.parent = sector?.transform ?? body.transform;
groundGO.transform.parent = sector?.transform ?? planetGO.transform;
groundGO.transform.localScale = new Vector3(groundScale, groundScale, groundScale);
groundGO.transform.localPosition = Vector3.zero;
groundGO.transform.position = planetGO.transform.position;
groundGO.GetComponent<MeshFilter>().mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh;
groundGO.GetComponent<SphereCollider>().radius = 1f;
groundGO.SetActive(true);

View File

@ -17,7 +17,7 @@ namespace NewHorizons.Builder.Body
{
public static Shader PlanetShader;
public static void Make(GameObject go, Sector sector, HeightMapModule module, IModBehaviour mod)
public static void Make(GameObject planetGO, Sector sector, HeightMapModule module, IModBehaviour mod)
{
Texture2D heightMap, textureMap;
try
@ -35,7 +35,7 @@ namespace NewHorizons.Builder.Body
GameObject cubeSphere = new GameObject("CubeSphere");
cubeSphere.SetActive(false);
cubeSphere.transform.parent = sector?.transform ?? go.transform;
cubeSphere.transform.parent = sector?.transform ?? planetGO.transform;
cubeSphere.transform.rotation = Quaternion.Euler(90, 0, 0);
Mesh mesh = CubeSphere.Build(51, heightMap, module.MinHeight, module.MaxHeight, module.Stretch);
@ -55,11 +55,11 @@ namespace NewHorizons.Builder.Body
var cubeSphereMC = cubeSphere.AddComponent<MeshCollider>();
cubeSphereMC.sharedMesh = mesh;
if(go.GetComponent<ProxyShadowCasterSuperGroup>() != null) cubeSphere.AddComponent<ProxyShadowCaster>();
if(planetGO.GetComponent<ProxyShadowCasterSuperGroup>() != null) cubeSphere.AddComponent<ProxyShadowCaster>();
// Fix rotation in the end
cubeSphere.transform.localRotation = Quaternion.Euler(90, 0, 0);
cubeSphere.transform.localPosition = Vector3.zero;
cubeSphere.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(90, 0, 0));
cubeSphere.transform.position = planetGO.transform.position;
cubeSphere.SetActive(true);
}

View File

@ -12,7 +12,7 @@ namespace NewHorizons.Builder.Body
{
public static class LavaBuilder
{
public static void Make(GameObject go, Sector sector, OWRigidbody rb, LavaModule module)
public static void Make(GameObject planetGO, Sector sector, OWRigidbody rb, LavaModule module)
{
var heightScale = module.Size;
if(module.Curve != null)
@ -27,8 +27,8 @@ namespace NewHorizons.Builder.Body
var moltenCore = new GameObject("MoltenCore");
moltenCore.SetActive(false);
moltenCore.transform.parent = sector?.transform ?? go.transform;
moltenCore.transform.localPosition = Vector3.zero;
moltenCore.transform.parent = sector?.transform ?? planetGO.transform;
moltenCore.transform.position = planetGO.transform.position;
moltenCore.transform.localScale = Vector3.one * module.Size;
var lavaSphere = GameObject.Instantiate(GameObject.Find("VolcanicMoon_Body/MoltenCore_VM/LavaSphere"), moltenCore.transform);

View File

@ -6,17 +6,18 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using NewHorizons.Utility;
namespace NewHorizons.Builder.Body
{
public static class ProcGenBuilder
{
public static void Make(GameObject go, Sector sector, ProcGenModule module)
public static void Make(GameObject planetGO, Sector sector, ProcGenModule module)
{
GameObject icosphere = new GameObject("Icosphere");
icosphere.transform.parent = sector?.transform ?? go.transform;
icosphere.transform.parent = sector?.transform ?? planetGO.transform;
icosphere.transform.rotation = Quaternion.Euler(90, 0, 0);
icosphere.transform.localPosition = Vector3.zero;
icosphere.transform.position = planetGO.transform.position;
Mesh mesh = Icosphere.Build(4, module.Scale, module.Scale * 1.2f);
@ -29,7 +30,7 @@ namespace NewHorizons.Builder.Body
var cubeSphereMC = icosphere.AddComponent<MeshCollider>();
cubeSphereMC.sharedMesh = mesh;
icosphere.transform.localRotation = Quaternion.Euler(90, 0, 0);
icosphere.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(90, 0, 0));
icosphere.AddComponent<ProxyShadowCaster>();
}

View File

@ -21,7 +21,7 @@ namespace NewHorizons.Builder.Body
public static Shader UnlitRingShader;
public static Shader UnlitRingShader1Pixel;
public static GameObject Make(GameObject body, Sector sector, RingModule ring, IModBehaviour mod)
public static GameObject Make(GameObject planetGO, Sector sector, RingModule ring, IModBehaviour mod)
{
// Properly lit shader doesnt work yet
ring.Unlit = true;
@ -38,9 +38,9 @@ namespace NewHorizons.Builder.Body
}
var ringGO = new GameObject("Ring");
ringGO.transform.parent = sector?.transform ?? body.transform;
ringGO.transform.localPosition = Vector3.zero;
ringGO.transform.localRotation = Quaternion.Euler(0, 0, 0);
ringGO.transform.parent = sector?.transform ?? planetGO.transform;
ringGO.transform.position = planetGO.transform.position;
ringGO.transform.rotation = planetGO.transform.rotation;
ringGO.transform.Rotate(ringGO.transform.TransformDirection(Vector3.up), ring.LongitudeOfAscendingNode);
ringGO.transform.Rotate(ringGO.transform.TransformDirection(Vector3.right), ring.Inclination);

View File

@ -11,7 +11,7 @@ namespace NewHorizons.Builder.Body
{
public static class SandBuilder
{
public static void Make(GameObject go, Sector sector, OWRigidbody rb, SandModule module)
public static void Make(GameObject planetGO, Sector sector, OWRigidbody rb, SandModule module)
{
var sandGO = new GameObject("Sand");
sandGO.SetActive(false);
@ -56,8 +56,8 @@ namespace NewHorizons.Builder.Body
levelController._scaleCurve = curve;
}
sandGO.transform.parent = sector?.transform ?? go.transform;
sandGO.transform.localPosition = Vector3.zero;
sandGO.transform.parent = sector?.transform ?? planetGO.transform;
sandGO.transform.position = planetGO.transform.position;
sandGO.transform.localScale = Vector3.one * module.Size * 2f;
sandGO.SetActive(true);

View File

@ -94,12 +94,12 @@ namespace NewHorizons.Builder.Body
}
}
public static GameObject MakeBlackHole(GameObject go, Sector sector, Vector3 localPosition, float size, bool hasDestructionVolume, string targetSolarSystem, bool makeAudio = true)
public static GameObject MakeBlackHole(GameObject planetGO, Sector sector, Vector3 localPosition, float size, bool hasDestructionVolume, string targetSolarSystem, bool makeAudio = true)
{
var blackHole = new GameObject("BlackHole");
blackHole.SetActive(false);
blackHole.transform.parent = sector?.transform ?? go.transform;
blackHole.transform.localPosition = localPosition;
blackHole.transform.parent = sector?.transform ?? planetGO.transform;
blackHole.transform.position = planetGO.transform.TransformPoint(localPosition);
var blackHoleRender = new GameObject("BlackHoleRender");
blackHoleRender.transform.parent = blackHole.transform;
@ -165,12 +165,12 @@ namespace NewHorizons.Builder.Body
return blackHole;
}
public static GameObject MakeWhiteHole(GameObject body, Sector sector, OWRigidbody OWRB, Vector3 localPosition, float size, bool makeZeroGVolume = true)
public static GameObject MakeWhiteHole(GameObject planetGO, Sector sector, OWRigidbody OWRB, Vector3 localPosition, float size, bool makeZeroGVolume = true)
{
var whiteHole = new GameObject("WhiteHole");
whiteHole.SetActive(false);
whiteHole.transform.parent = sector?.transform ?? body.transform;
whiteHole.transform.localPosition = localPosition;
whiteHole.transform.parent = sector?.transform ?? planetGO.transform;
whiteHole.transform.position = planetGO.transform.TransformPoint(localPosition);
var whiteHoleRenderer = new GameObject("WhiteHoleRenderer");
whiteHoleRenderer.transform.parent = whiteHole.transform;
@ -214,7 +214,7 @@ namespace NewHorizons.Builder.Body
whiteHoleVolume._whiteHoleSector = sector;
whiteHoleVolume._fluidVolume = whiteHoleFluidVolume;
whiteHoleVolume._whiteHoleBody = OWRB;
whiteHoleVolume._whiteHoleProxyShadowSuperGroup = body.GetComponent<ProxyShadowCasterSuperGroup>();
whiteHoleVolume._whiteHoleProxyShadowSuperGroup = planetGO.GetComponent<ProxyShadowCasterSuperGroup>();
whiteHoleVolume._radius = size * 0.5f;
whiteHoleVolumeGO.GetComponent<SphereCollider>().radius = size;
@ -230,7 +230,7 @@ namespace NewHorizons.Builder.Body
zeroGVolume.GetComponent<SphereCollider>().radius = size * 10f;
zeroGVolume.GetComponent<ZeroGVolume>()._attachedBody = OWRB;
var rulesetVolume = GameObject.Instantiate(GameObject.Find("WhiteHole_Body/Sector_WhiteHole/RulesetVolumes_WhiteHole"), body.transform);
var rulesetVolume = GameObject.Instantiate(GameObject.Find("WhiteHole_Body/Sector_WhiteHole/RulesetVolumes_WhiteHole"), planetGO.transform);
rulesetVolume.name = "RulesetVolume";
rulesetVolume.transform.localPosition = Vector3.zero;
rulesetVolume.transform.localScale = Vector3.one * size / 100f;

View File

@ -19,15 +19,15 @@ namespace NewHorizons.Builder.Body
public const float OuterRadiusRatio = 1.5f;
private static Texture2D _colorOverTime;
public static StarController Make(GameObject go, Sector sector, StarModule starModule)
public static StarController Make(GameObject planetGO, Sector sector, StarModule starModule)
{
if (_colorOverTime == null) _colorOverTime = ImageUtilities.GetTexture(Main.Instance, "AssetBundle/StarColorOverTime.png");
var starGO = new GameObject("Star");
starGO.transform.parent = sector?.transform ?? go.transform;
starGO.transform.parent = sector?.transform ?? planetGO.transform;
var sunSurface = GameObject.Instantiate(GameObject.Find("Sun_Body/Sector_SUN/Geometry_SUN/Surface"), starGO.transform);
sunSurface.transform.localPosition = Vector3.zero;
sunSurface.transform.position = planetGO.transform.position;
sunSurface.transform.localScale = Vector3.one;
sunSurface.name = "Surface";
@ -67,8 +67,8 @@ namespace NewHorizons.Builder.Body
if(starModule.HasAtmosphere)
{
var sunAtmosphere = GameObject.Instantiate(GameObject.Find("Sun_Body/Atmosphere_SUN"), go.transform);
sunAtmosphere.transform.localPosition = Vector3.zero;
var sunAtmosphere = GameObject.Instantiate(GameObject.Find("Sun_Body/Atmosphere_SUN"), planetGO.transform);
sunAtmosphere.transform.position = planetGO.transform.position;
sunAtmosphere.transform.localScale = Vector3.one;
sunAtmosphere.name = "Atmosphere_Star";
PlanetaryFogController fog = sunAtmosphere.transform.Find("FogSphere").GetComponent<PlanetaryFogController>();
@ -151,13 +151,13 @@ namespace NewHorizons.Builder.Body
if(starModule.SolarFlareTint != null)
solarFlareEmitter.GetComponent<SolarFlareEmitter>().tint = starModule.SolarFlareTint.ToColor();
starGO.transform.localPosition = Vector3.zero;
starGO.transform.position = planetGO.transform.position;
starGO.transform.localScale = starModule.Size * Vector3.one;
StarController starController = null;
if (starModule.SolarLuminosity != 0)
{
starController = go.AddComponent<StarController>();
starController = planetGO.AddComponent<StarController>();
starController.Light = light;
starController.AmbientLight = ambientLight;
starController.FaceActiveCamera = faceActiveCamera;

View File

@ -11,14 +11,14 @@ namespace NewHorizons.Builder.Body
{
public static class WaterBuilder
{
public static void Make(GameObject go, Sector sector, OWRigidbody rb, WaterModule module)
public static void Make(GameObject planetGO, Sector sector, OWRigidbody rb, WaterModule module)
{
var waterSize = module.Size;
GameObject waterGO = new GameObject("Water");
waterGO.SetActive(false);
waterGO.layer = 15;
waterGO.transform.parent = sector?.transform ?? go.transform;
waterGO.transform.parent = sector?.transform ?? planetGO.transform;
waterGO.transform.localScale = new Vector3(waterSize, waterSize, waterSize);
var GDTSR = GameObject.Find("Ocean_GD").GetComponent<TessellatedSphereRenderer>();
@ -113,7 +113,7 @@ namespace NewHorizons.Builder.Body
// TODO: fix ruleset making the sand bubble pop up
waterGO.transform.localPosition = Vector3.zero;
waterGO.transform.position = planetGO.transform.position;
waterGO.SetActive(true);
}
}

View File

@ -8,10 +8,10 @@ namespace NewHorizons.Builder.General
{
public static class AmbientLightBuilder
{
public static void Make(GameObject body, Sector sector, float scale)
public static void Make(GameObject planetGO, Sector sector, float scale)
{
GameObject lightGO = GameObject.Instantiate(GameObject.Find("BrittleHollow_Body/AmbientLight_BH_Surface"), sector?.transform ?? body.transform);
lightGO.transform.localPosition = Vector3.zero;
GameObject lightGO = GameObject.Instantiate(GameObject.Find("BrittleHollow_Body/AmbientLight_BH_Surface"), sector?.transform ?? planetGO.transform);
lightGO.transform.position = planetGO.transform.position;
lightGO.name = "Light";
var light = lightGO.GetComponent<Light>();

View File

@ -14,11 +14,11 @@ namespace NewHorizons.Builder.General
{
public static class DetectorBuilder
{
public static GameObject Make(GameObject body, OWRigidbody OWRB, AstroObject primaryBody, AstroObject astroObject, IPlanetConfig config)
public static GameObject Make(GameObject planetGO, OWRigidbody OWRB, AstroObject primaryBody, AstroObject astroObject, IPlanetConfig config)
{
GameObject detectorGO = new GameObject("FieldDetector");
detectorGO.SetActive(false);
detectorGO.transform.parent = body.transform;
detectorGO.transform.parent = planetGO.transform;
detectorGO.transform.localPosition = Vector3.zero;
detectorGO.layer = LayerMask.NameToLayer("BasicDetector");

View File

@ -11,7 +11,7 @@ namespace NewHorizons.Builder.General
{
public static class GravityBuilder
{
public static GravityVolume Make(GameObject body, AstroObject ao, IPlanetConfig config)
public static GravityVolume Make(GameObject planetGO, AstroObject ao, IPlanetConfig config)
{
var exponent = config.Base.GravityFallOff.Equals("linear") ? 1f : 2f;
var GM = config.Base.SurfaceGravity * Mathf.Pow(config.Base.SurfaceSize, exponent);
@ -26,7 +26,7 @@ namespace NewHorizons.Builder.General
if (config.Base.SphereOfInfluence != 0f) gravityRadius = config.Base.SphereOfInfluence;
GameObject gravityGO = new GameObject("GravityWell");
gravityGO.transform.parent = body.transform;
gravityGO.transform.parent = planetGO.transform;
gravityGO.transform.localPosition = Vector3.zero;
gravityGO.layer = 17;
gravityGO.SetActive(false);

View File

@ -7,10 +7,10 @@ namespace NewHorizons.Builder.General
{
public static class RFVolumeBuilder
{
public static void Make(GameObject body, OWRigidbody rigidbody, float sphereOfInfluence)
public static void Make(GameObject planetGO, OWRigidbody owRigidBody, float sphereOfInfluence)
{
GameObject rfGO = new GameObject("RFVolume");
rfGO.transform.parent = body.transform;
rfGO.transform.parent = planetGO.transform;
rfGO.transform.localPosition = Vector3.zero;
rfGO.layer = 19;
rfGO.SetActive(false);
@ -21,7 +21,7 @@ namespace NewHorizons.Builder.General
ReferenceFrameVolume RFV = rfGO.AddComponent<ReferenceFrameVolume>();
ReferenceFrame RV = new ReferenceFrame(rigidbody);
ReferenceFrame RV = new ReferenceFrame(owRigidBody);
RV._minSuitTargetDistance = sphereOfInfluence;
RV._maxTargetDistance = 0;
RV._autopilotArrivalDistance = 2.0f * sphereOfInfluence;

View File

@ -8,11 +8,11 @@ namespace NewHorizons.Builder.General
{
public static class MakeSector
{
public static Sector Make(GameObject body, OWRigidbody rigidbody, float sphereOfInfluence)
public static Sector Make(GameObject planetBody, OWRigidbody owRigidBody, float sphereOfInfluence)
{
GameObject sectorGO = new GameObject("Sector");
sectorGO.SetActive(false);
sectorGO.transform.parent = body.transform;
sectorGO.transform.parent = planetBody.transform;
sectorGO.transform.localPosition = Vector3.zero;
SphereShape SS = sectorGO.AddComponent<SphereShape>();
@ -27,7 +27,7 @@ namespace NewHorizons.Builder.General
Sector S = sectorGO.AddComponent<Sector>();
S._name = (Sector.Name)24;
S._attachedOWRigidbody = rigidbody;
S._attachedOWRigidbody = owRigidBody;
S._subsectors = new List<Sector>();
sectorGO.SetActive(true);

View File

@ -10,25 +10,25 @@ namespace NewHorizons.Builder.General
public static class SpawnPointBuilder
{
private static bool suitUpQueued = false;
public static SpawnPoint Make(GameObject body, SpawnModule module, OWRigidbody rb)
public static SpawnPoint Make(GameObject planetGO, SpawnModule module, OWRigidbody owRigidBody)
{
SpawnPoint playerSpawn = null;
if(!Main.Instance.IsWarping && module.PlayerSpawnPoint != null)
{
GameObject spawnGO = new GameObject("PlayerSpawnPoint");
spawnGO.transform.parent = body.transform;
spawnGO.transform.parent = planetGO.transform;
spawnGO.layer = 8;
spawnGO.transform.localPosition = module.PlayerSpawnPoint;
playerSpawn = spawnGO.AddComponent<SpawnPoint>();
spawnGO.transform.rotation = Quaternion.FromToRotation(Vector3.up, (playerSpawn.transform.position - body.transform.position).normalized);
spawnGO.transform.rotation = Quaternion.FromToRotation(Vector3.up, (playerSpawn.transform.position - planetGO.transform.position).normalized);
spawnGO.transform.position = spawnGO.transform.position + spawnGO.transform.TransformDirection(Vector3.up) * 4f;
}
if(module.ShipSpawnPoint != null)
{
GameObject spawnGO = new GameObject("ShipSpawnPoint");
spawnGO.transform.parent = body.transform;
spawnGO.transform.parent = planetGO.transform;
spawnGO.layer = 8;
spawnGO.transform.localPosition = module.ShipSpawnPoint;
@ -38,11 +38,11 @@ namespace NewHorizons.Builder.General
var ship = GameObject.Find("Ship_Body");
ship.transform.position = spawnPoint.transform.position;
ship.transform.rotation = Quaternion.FromToRotation(Vector3.up, (spawnPoint.transform.position - body.transform.position).normalized);
ship.transform.rotation = Quaternion.FromToRotation(Vector3.up, (spawnPoint.transform.position - planetGO.transform.position).normalized);
// Move it up a bit more
ship.transform.position = ship.transform.position + ship.transform.TransformDirection(Vector3.up) * 4f;
ship.GetRequiredComponent<MatchInitialMotion>().SetBodyToMatch(rb);
ship.GetRequiredComponent<MatchInitialMotion>().SetBodyToMatch(owRigidBody);
if(Main.Instance.IsWarping)
{
@ -63,7 +63,7 @@ namespace NewHorizons.Builder.General
Main.Instance.ModHelper.Events.Unity.RunWhen(() => Main.IsSystemReady, () => SuitUp());
}
Logger.Log("Made spawnpoint on [" + body.name + "]");
Logger.Log("Made spawnpoint on [" + planetGO.name + "]");
return playerSpawn;
}

View File

@ -11,10 +11,10 @@ namespace NewHorizons.Builder.Orbital
{
public static class OrbitlineBuilder
{
public static OrbitLine Make(GameObject body, NHAstroObject astroObject, bool isMoon, IPlanetConfig config)
public static OrbitLine Make(GameObject planetGO, NHAstroObject astroObject, bool isMoon, IPlanetConfig config)
{
GameObject orbitGO = new GameObject("Orbit");
orbitGO.transform.parent = body.transform;
orbitGO.transform.parent = planetGO.transform;
orbitGO.transform.localPosition = Vector3.zero;
var lineRenderer = orbitGO.AddComponent<LineRenderer>();

View File

@ -60,7 +60,7 @@ namespace NewHorizons.Builder.Props
return MakeDetail(go, sector, prefab, position, rotation, scale, alignWithNormal);
}
public static GameObject MakeDetail(GameObject go, Sector sector, GameObject prefab, MVector3 position, MVector3 rotation, float scale, bool alignWithNormal)
public static GameObject MakeDetail(GameObject planetGO, Sector sector, GameObject prefab, MVector3 position, MVector3 rotation, float scale, bool alignWithNormal)
{
if (prefab == null) return null;
@ -105,7 +105,7 @@ namespace NewHorizons.Builder.Props
{
try
{
(component as AnglerfishController)._chaseSpeed += OWPhysics.CalculateOrbitVelocity(go.GetAttachedOWRigidbody(), go.GetComponent<AstroObject>().GetPrimaryBody().GetAttachedOWRigidbody()).magnitude;
(component as AnglerfishController)._chaseSpeed += OWPhysics.CalculateOrbitVelocity(planetGO.GetAttachedOWRigidbody(), planetGO.GetComponent<AstroObject>().GetPrimaryBody().GetAttachedOWRigidbody()).magnitude;
}
catch (Exception e)
{
@ -150,20 +150,20 @@ namespace NewHorizons.Builder.Props
});
}
prop.transform.position = position == null ? go.transform.position : go.transform.TransformPoint((Vector3)position);
prop.transform.position = position == null ? planetGO.transform.position : planetGO.transform.TransformPoint((Vector3)position);
Quaternion rot = rotation == null ? Quaternion.identity : Quaternion.Euler((Vector3)rotation);
prop.transform.localRotation = Quaternion.identity;
prop.transform.rotation = planetGO.transform.TransformRotation(Quaternion.identity);
if (alignWithNormal)
{
// Apply the rotation after aligning it with normal
var up = prop.transform.localPosition.normalized;
var up = planetGO.transform.InverseTransformPoint(prop.transform.position).normalized;
prop.transform.rotation = Quaternion.FromToRotation(prop.transform.up, up) * prop.transform.rotation;
prop.transform.rotation *= rot;
}
else
{
prop.transform.localRotation = rot;
prop.transform.rotation = planetGO.transform.TransformRotation(rot);
}
prop.transform.localScale = scale != 0 ? Vector3.one * scale : prefab.transform.localScale;

View File

@ -28,7 +28,7 @@ namespace NewHorizons.Builder.Props
if (!string.IsNullOrEmpty(info.pathToAnimController)) MakePlayerTrackingZone(go, dialogue, info);
}
public static void MakeRemoteDialogueTrigger(GameObject go, Sector sector, PropModule.DialogueInfo info, CharacterDialogueTree dialogue)
public static void MakeRemoteDialogueTrigger(GameObject planetGO, Sector sector, PropModule.DialogueInfo info, CharacterDialogueTree dialogue)
{
GameObject conversationTrigger = new GameObject("ConversationTrigger");
conversationTrigger.SetActive(false);
@ -53,12 +53,12 @@ namespace NewHorizons.Builder.Props
sphereCollider.radius = info.remoteTriggerRadius == 0 ? info.radius : info.remoteTriggerRadius;
conversationTrigger.transform.parent = sector?.transform ?? go.transform;
conversationTrigger.transform.localPosition = info.remoteTriggerPosition ?? info.position;
conversationTrigger.transform.parent = sector?.transform ?? planetGO.transform;
conversationTrigger.transform.position = planetGO.transform.TransformPoint(info.remoteTriggerPosition ?? info.position);
conversationTrigger.SetActive(true);
}
public static CharacterDialogueTree MakeConversationZone(GameObject go, Sector sector, PropModule.DialogueInfo info, IModHelper mod)
public static CharacterDialogueTree MakeConversationZone(GameObject planetGO, Sector sector, PropModule.DialogueInfo info, IModHelper mod)
{
GameObject conversationZone = new GameObject("ConversationZone");
conversationZone.SetActive(false);
@ -87,8 +87,8 @@ namespace NewHorizons.Builder.Props
dialogueTree.SetTextXml(text);
AddTranslation(xml);
conversationZone.transform.parent = sector?.transform ?? go.transform;
conversationZone.transform.localPosition = info.position;
conversationZone.transform.parent = sector?.transform ?? planetGO.transform;
conversationZone.transform.position = planetGO.transform.TransformPoint(info.position);
conversationZone.SetActive(true);
return dialogueTree;

View File

@ -11,11 +11,11 @@ namespace NewHorizons.Builder.Props
{
public static class GeyserBuilder
{
public static void Make(GameObject go, Sector sector, PropModule.GeyserInfo info)
public static void Make(GameObject planetGO, Sector sector, PropModule.GeyserInfo info)
{
var original = GameObject.Find("TimberHearth_Body/Sector_TH/Interactables_TH/Geysers/Geyser_Village");
GameObject geyserGO = original.InstantiateInactive();
geyserGO.transform.parent = sector?.transform ?? go.transform;
geyserGO.transform.parent = sector?.transform ?? planetGO.transform;
geyserGO.name = "Geyser";
var pos = ((Vector3)info.position);
@ -24,11 +24,11 @@ namespace NewHorizons.Builder.Props
var length = pos.magnitude - 65;
// About 130 high and the surface is at 65
geyserGO.transform.localPosition = pos.normalized * length;
geyserGO.transform.position = planetGO.transform.TransformPoint(pos.normalized * length);
geyserGO.transform.localScale = Vector3.one;
var up = go.transform.TransformPoint(pos) - go.transform.position;
var up = planetGO.transform.TransformPoint(pos) - planetGO.transform.position;
geyserGO.transform.rotation = Quaternion.FromToRotation(geyserGO.transform.up, up) * geyserGO.transform.rotation;
var controller = geyserGO.GetComponent<GeyserController>();

View File

@ -71,7 +71,7 @@ namespace NewHorizons.Builder.Props
_recorderPrefab.transform.rotation = Quaternion.identity;
}
public static void Make(GameObject go, Sector sector, PropModule.NomaiTextInfo info, IModBehaviour mod)
public static void Make(GameObject planetGO, Sector sector, PropModule.NomaiTextInfo info, IModBehaviour mod)
{
if (_scrollPrefab == null) InitPrefabs();
@ -79,22 +79,22 @@ namespace NewHorizons.Builder.Props
if (info.type == "wall")
{
var nomaiWallTextObj = MakeWallText(go, sector, info, xmlPath).gameObject;
var nomaiWallTextObj = MakeWallText(planetGO, sector, info, xmlPath).gameObject;
nomaiWallTextObj.transform.parent = sector?.transform ?? go.transform;
nomaiWallTextObj.transform.localPosition = info.position;
nomaiWallTextObj.transform.parent = sector?.transform ?? planetGO.transform;
nomaiWallTextObj.transform.position = planetGO.transform.TransformPoint(info.position);
if (info.normal != null)
{
// In global coordinates (normal was in local coordinates)
var up = (nomaiWallTextObj.transform.position - go.transform.position).normalized;
var forward = go.transform.TransformDirection(info.normal).normalized;
var up = (nomaiWallTextObj.transform.position - planetGO.transform.position).normalized;
var forward = planetGO.transform.TransformDirection(info.normal).normalized;
nomaiWallTextObj.transform.up = up;
nomaiWallTextObj.transform.forward = forward;
}
if (info.rotation != null)
{
nomaiWallTextObj.transform.localRotation = Quaternion.Euler(info.rotation);
nomaiWallTextObj.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(info.rotation));
}
nomaiWallTextObj.SetActive(true);
@ -103,7 +103,7 @@ namespace NewHorizons.Builder.Props
{
var customScroll = _scrollPrefab.InstantiateInactive();
var nomaiWallText = MakeWallText(go, sector, info, xmlPath);
var nomaiWallText = MakeWallText(planetGO, sector, info, xmlPath);
nomaiWallText.transform.parent = customScroll.transform;
nomaiWallText.transform.localPosition = Vector3.zero;
nomaiWallText.transform.localRotation = Quaternion.identity;
@ -130,10 +130,10 @@ namespace NewHorizons.Builder.Props
customScroll.GetComponent<OWCollider>()._physicsRemoved = false;
// Place scroll
customScroll.transform.parent = sector?.transform ?? go.transform;
customScroll.transform.localPosition = info.position ?? Vector3.zero;
customScroll.transform.parent = sector?.transform ?? planetGO.transform;
customScroll.transform.position = planetGO.transform.TransformPoint(info.position ?? Vector3.zero);
var up = customScroll.transform.localPosition.normalized;
var up = planetGO.transform.InverseTransformPoint(customScroll.transform.position).normalized;
customScroll.transform.rotation = Quaternion.FromToRotation(customScroll.transform.up, up) * customScroll.transform.rotation;
customScroll.SetActive(true);
@ -157,11 +157,11 @@ namespace NewHorizons.Builder.Props
{
var computerObject = _computerPrefab.InstantiateInactive();
computerObject.transform.parent = sector?.transform ?? go.transform;
computerObject.transform.localPosition = info?.position ?? Vector3.zero;
computerObject.transform.parent = sector?.transform ?? planetGO.transform;
computerObject.transform.position = planetGO.transform.TransformPoint(info?.position ?? Vector3.zero);
var up = computerObject.transform.position - go.transform.position;
if (info.normal != null) up = go.transform.TransformDirection(info.normal);
var up = computerObject.transform.position - planetGO.transform.position;
if (info.normal != null) up = planetGO.transform.TransformDirection(info.normal);
computerObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * computerObject.transform.rotation;
var computer = computerObject.GetComponent<NomaiComputer>();
@ -181,17 +181,17 @@ namespace NewHorizons.Builder.Props
{
var cairnObject = _cairnPrefab.InstantiateInactive();
cairnObject.transform.parent = sector?.transform ?? go.transform;
cairnObject.transform.localPosition = info?.position ?? Vector3.zero;
cairnObject.transform.parent = sector?.transform ?? planetGO.transform;
cairnObject.transform.position = planetGO.transform.TransformPoint(info?.position ?? Vector3.zero);
if (info.rotation != null)
{
cairnObject.transform.localRotation = Quaternion.Euler(info.rotation);
cairnObject.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(info.rotation));
}
else
{
// By default align it to normal
var up = (cairnObject.transform.position - go.transform.position).normalized;
var up = (cairnObject.transform.position - planetGO.transform.position).normalized;
cairnObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * cairnObject.transform.rotation;
}
@ -224,16 +224,16 @@ namespace NewHorizons.Builder.Props
{
var recorderObject = _recorderPrefab.InstantiateInactive();
recorderObject.transform.parent = sector?.transform ?? go.transform;
recorderObject.transform.localPosition = info?.position ?? Vector3.zero;
recorderObject.transform.parent = sector?.transform ?? planetGO.transform;
recorderObject.transform.position = planetGO.transform.TransformPoint(info?.position ?? Vector3.zero);
if (info.rotation != null)
{
recorderObject.transform.localRotation = Quaternion.Euler(info.rotation);
recorderObject.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler(info.rotation));
}
else
{
var up = recorderObject.transform.position - go.transform.position;
var up = recorderObject.transform.position - planetGO.transform.position;
recorderObject.transform.rotation = Quaternion.FromToRotation(Vector3.up, up) * recorderObject.transform.rotation;
}

View File

@ -24,7 +24,7 @@ namespace NewHorizons.Builder.Props
else Logger.LogError($"Invalid projection type {info.type}");
}
private static void MakeSlideReel(GameObject go, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod)
private static void MakeSlideReel(GameObject planetGO, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod)
{
if (_slideReelPrefab == null)
{
@ -51,9 +51,9 @@ namespace NewHorizons.Builder.Props
renderer.enabled = true;
}
slideReelObj.transform.parent = sector?.transform ?? go.transform;
slideReelObj.transform.localPosition = (Vector3)(info.position ?? Vector3.zero);
slideReelObj.transform.localRotation = Quaternion.Euler((Vector3)(info.rotation ?? Vector3.zero));
slideReelObj.transform.parent = sector?.transform ?? planetGO.transform;
slideReelObj.transform.position = planetGO.transform.TransformPoint((Vector3)(info.position ?? Vector3.zero));
slideReelObj.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler((Vector3)(info.rotation ?? Vector3.zero)));
// Now we replace the slides
int slidesCount = info.slides.Length;
@ -102,7 +102,7 @@ namespace NewHorizons.Builder.Props
slideReelObj.SetActive(true);
}
public static void MakeAutoProjector(GameObject go, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod)
public static void MakeAutoProjector(GameObject planetGO, Sector sector, PropModule.ProjectionInfo info, IModBehaviour mod)
{
if (_autoPrefab == null)
{
@ -123,9 +123,9 @@ namespace NewHorizons.Builder.Props
var slideCollectionContainer = autoProjector.GetRequiredComponent<SlideCollectionContainer>();
autoProjector.transform.parent = sector?.transform ?? go.transform;
autoProjector.transform.localPosition = (Vector3)(info.position ?? Vector3.zero);
autoProjector.transform.localRotation = Quaternion.Euler((Vector3)(info.rotation ?? Vector3.zero));
autoProjector.transform.parent = sector?.transform ?? planetGO.transform;
autoProjector.transform.position = planetGO.transform.TransformPoint((Vector3)(info.position ?? Vector3.zero));
autoProjector.transform.rotation = planetGO.transform.TransformRotation(Quaternion.Euler((Vector3)(info.rotation ?? Vector3.zero)));
// Now we replace the slides
int slidesCount = info.slides.Length;

View File

@ -34,8 +34,8 @@ namespace NewHorizons.Builder.Props
GameObject raftObject = _prefab.InstantiateInactive();
raftObject.name = "Raft_Body";
raftObject.transform.parent = sector?.transform ?? planetGO.transform;
raftObject.transform.localPosition = info.position;
raftObject.transform.localRotation = Quaternion.identity;
raftObject.transform.position = planetGO.transform.TransformPoint(info.position);
raftObject.transform.rotation = planetGO.transform.TransformRotation(Quaternion.identity);
sector.OnOccupantEnterSector += (sd) => OWAssetHandler.OnOccupantEnterSector(raftObject, sd, sector);
OWAssetHandler.LoadObject(raftObject);
@ -63,15 +63,6 @@ namespace NewHorizons.Builder.Props
sector.OnSectorOccupantsUpdated += lightSensor.OnSectorOccupantsUpdated;
}
/*
// Debug
foreach (var point in fluidDetector._localAlignmentCheckPoints)
{
var sphere = AddDebugShape.AddSphere(fluidDetector.gameObject, 0.5f, Color.green);
sphere.transform.localPosition = point;
}
*/
raftObject.SetActive(true);
}
}

View File

@ -142,7 +142,7 @@ namespace NewHorizons.Builder.Props
var signalGO = new GameObject($"Signal_{info.Name}");
signalGO.SetActive(false);
signalGO.transform.parent = sector?.transform ?? planetGO.transform;
signalGO.transform.localPosition = info.Position != null ? (Vector3)info.Position : Vector3.zero;
signalGO.transform.position = planetGO.transform.TransformPoint(info.Position != null ? (Vector3)info.Position : Vector3.zero);
signalGO.layer = LayerMask.NameToLayer("AdvancedEffectVolume");
var source = signalGO.AddComponent<AudioSource>();
@ -211,7 +211,7 @@ namespace NewHorizons.Builder.Props
var signalDetectionGO = new GameObject($"SignalDetectionTrigger_{info.Name}");
signalDetectionGO.SetActive(false);
signalDetectionGO.transform.parent = sector?.transform ?? planetGO.transform;
signalDetectionGO.transform.localPosition = info.Position != null ? (Vector3)info.Position : Vector3.zero;
signalDetectionGO.transform.position = planetGO.transform.TransformPoint(info.Position != null ? (Vector3)info.Position : Vector3.zero);
signalDetectionGO.layer = LayerMask.NameToLayer("AdvancedEffectVolume");
var sphereShape = signalDetectionGO.AddComponent<SphereShape>();

View File

@ -19,7 +19,7 @@ namespace NewHorizons.Builder.Props
private static GameObject downPrefab;
private static GameObject soundPrefab;
public static void Make(GameObject go, Sector sector, PropModule.TornadoInfo info, bool hasClouds)
public static void Make(GameObject planetGO, Sector sector, PropModule.TornadoInfo info, bool hasClouds)
{
if (upPrefab == null)
{
@ -57,7 +57,7 @@ namespace NewHorizons.Builder.Props
var tornadoGO = info.downwards ? downPrefab.InstantiateInactive() : upPrefab.InstantiateInactive();
tornadoGO.transform.parent = sector.transform;
tornadoGO.transform.localPosition = position;
tornadoGO.transform.position = planetGO.transform.TransformPoint(position);
tornadoGO.transform.rotation = Quaternion.FromToRotation(Vector3.up, sector.transform.TransformDirection(position.normalized));
// Add the sound thing before changing the scale

View File

@ -10,13 +10,13 @@ namespace NewHorizons.Builder.Props
private static Color defaultStoneTint = new Color(0.07450981f, 0.07450981f, 0.07450981f);
private static Color defaultLavaTint = new Color(4.594794f, 0.3419145f, 0f, 1f);
public static void Make(GameObject go, Sector sector, PropModule.VolcanoInfo info)
public static void Make(GameObject planetGO, Sector sector, PropModule.VolcanoInfo info)
{
var prefab = GameObject.Find("VolcanicMoon_Body/Sector_VM/Effects_VM/VolcanoPivot (2)/MeteorLauncher");
var launcherGO = prefab.InstantiateInactive();
launcherGO.transform.parent = sector.transform;
launcherGO.transform.localPosition = info.position == null ? Vector3.zero : (Vector3)info.position;
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";

View File

@ -20,7 +20,7 @@ namespace NewHorizons.Builder.ShipLog
GameObject entryLocationGameObject = new GameObject("Entry Location (" + info.id + ")");
entryLocationGameObject.SetActive(false);
entryLocationGameObject.transform.parent = sector?.transform ?? go.transform;
entryLocationGameObject.transform.localPosition = info.position ?? Vector3.zero;
entryLocationGameObject.transform.position = go.transform.TransformPoint(info.position ?? Vector3.zero);
ShipLogEntryLocation newLocation = entryLocationGameObject.AddComponent<ShipLogEntryLocation>();
newLocation._entryID = info.id;
newLocation._isWithinCloakField = info.cloaked;

View File

@ -44,12 +44,12 @@ namespace NewHorizons.Builder.ShipLog
return newShape;
}
private static GameObject MakeGameObject(GameObject go, Sector sector, PropModule.RevealInfo info, IModBehaviour mod)
private static GameObject MakeGameObject(GameObject planetGO, Sector sector, PropModule.RevealInfo info, IModBehaviour mod)
{
GameObject revealTriggerVolume = new GameObject("Reveal Volume (" + info.revealOn + ")");
revealTriggerVolume.SetActive(false);
revealTriggerVolume.transform.parent = sector?.transform ?? go.transform;
revealTriggerVolume.transform.localPosition = info.position ?? Vector3.zero;
revealTriggerVolume.transform.parent = sector?.transform ?? planetGO.transform;
revealTriggerVolume.transform.position = planetGO.transform.TransformPoint(info.position ?? Vector3.zero);
return revealTriggerVolume;
}

View File

@ -181,7 +181,7 @@ namespace NewHorizons.Handlers
var rb = existingPlanet.GetComponent<OWRigidbody>();
var sector = MakeSector.Make(existingPlanet, rb, GetSphereOfInfluence(body));
sector.name = $"Sector-{existingPlanet.GetComponents<Sector>().Count()}";
sector.name = $"Sector-{existingPlanet.GetComponentsInChildren<Sector>().Count()}";
SharedGenerateBody(body, existingPlanet, sector, rb);

View File

@ -117,5 +117,10 @@ namespace NewHorizons.Utility
original.SetActive(true);
return copy;
}
public static Quaternion TransformRotation(this Transform transform, Quaternion localRotation)
{
return transform.rotation * localRotation;
}
}
}