Better comets (#559)

## Minor features
- New `CometTail` module replacing the `hasCometTail` field. Allows
customing the colour and scale-over-time of a comet tail.
This commit is contained in:
Nick 2023-04-22 16:48:10 -04:00 committed by GitHub
commit c46c3f56ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
75 changed files with 555 additions and 280 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

View File

@ -31,7 +31,7 @@ namespace NewHorizons.Builder.Atmosphere
_isInit = true;
if (_atmospherePrefab == null) _atmospherePrefab = SearchUtilities.Find("TimberHearth_Body/Atmosphere_TH/AtmoSphere").InstantiateInactive().Rename("Atmosphere").DontDestroyOnLoad();
if (_proxyAtmospherePrefab == null) _proxyAtmospherePrefab = GameObject.FindObjectOfType<DistantProxyManager>()._proxies.FirstOrDefault(apt => apt.astroName == AstroObject.Name.TimberHearth).proxyPrefab.FindChild("Atmosphere_TH/Atmosphere_LOD3").InstantiateInactive().Rename("ProxyAtmosphere").DontDestroyOnLoad();
if (_proxyAtmospherePrefab == null) _proxyAtmospherePrefab = Object.FindObjectOfType<DistantProxyManager>()._proxies.FirstOrDefault(apt => apt.astroName == AstroObject.Name.TimberHearth).proxyPrefab.FindChild("Atmosphere_TH/Atmosphere_LOD3").InstantiateInactive().Rename("ProxyAtmosphere").DontDestroyOnLoad();
}
public static GameObject Make(GameObject planetGO, Sector sector, AtmosphereModule atmosphereModule, float surfaceSize, bool proxy = false)
@ -48,7 +48,7 @@ namespace NewHorizons.Builder.Atmosphere
if (prefab != null)
{
GameObject atmo = GameObject.Instantiate(prefab, atmoGO.transform);
GameObject atmo = Object.Instantiate(prefab, atmoGO.transform);
atmo.name = "Atmosphere";
atmo.transform.localPosition = Vector3.zero;
atmo.transform.localEulerAngles = Vector3.zero;

View File

@ -1,4 +1,5 @@
using NewHorizons.Components;
using NewHorizons.Components.Sectored;
using NewHorizons.External.Modules;
using NewHorizons.Utility;
using NewHorizons.Utility.Files;

View File

@ -50,7 +50,7 @@ namespace NewHorizons.Builder.Atmosphere
if (config.Atmosphere.hasRain)
{
var rainGO = GameObject.Instantiate(_rainEmitterPrefab, effectsGO.transform);
var rainGO = Object.Instantiate(_rainEmitterPrefab, effectsGO.transform);
rainGO.name = "RainEmitter";
rainGO.transform.position = planetGO.transform.position;
@ -74,7 +74,7 @@ namespace NewHorizons.Builder.Atmosphere
snowGO.transform.position = planetGO.transform.position;
for (int i = 0; i < 5; i++)
{
var snowEmitter = GameObject.Instantiate(_snowEmitterPrefab, snowGO.transform);
var snowEmitter = Object.Instantiate(_snowEmitterPrefab, snowGO.transform);
snowEmitter.name = "SnowEmitter";
snowEmitter.transform.position = planetGO.transform.position;

View File

@ -1,6 +1,6 @@
using NewHorizons.Builder.Props;
using NewHorizons.Components;
using NewHorizons.Components.Orbital;
using NewHorizons.Components.Sectored;
using NewHorizons.External;
using NewHorizons.External.Modules;
using NewHorizons.External.Modules.Props;
@ -134,11 +134,11 @@ namespace NewHorizons.Builder.Body
if (config.vinePrefab == VinePrefabType.None)
{
// Replace batched collision with our own if removing vines
GameObject.Destroy(geometry.FindChild("BatchedGroup"));
Object.Destroy(geometry.FindChild("BatchedGroup"));
var geoOtherComponentsGroup = geometry.FindChild("OtherComponentsGroup");
var dimensionWalls = geoOtherComponentsGroup.FindChild("Terrain_DB_BrambleSphere_Outer_v2");
dimensionWalls.transform.parent = geometry.transform;
GameObject.Destroy(geoOtherComponentsGroup);
Object.Destroy(geoOtherComponentsGroup);
var newCollider = _wallCollision.InstantiateInactive();
newCollider.transform.parent = dimensionWalls.transform;

View File

@ -1,4 +1,4 @@
using NewHorizons.Components;
using NewHorizons.Components.Sectored;
using NewHorizons.External.Modules;
using NewHorizons.Utility;
using NewHorizons.Utility.Files;
@ -36,12 +36,12 @@ namespace NewHorizons.Builder.Body
var radius = module.radius;
var newCloak = GameObject.Instantiate(_prefab, sector?.transform ?? planetGO.transform);
var newCloak = Object.Instantiate(_prefab, sector?.transform ?? planetGO.transform);
newCloak.transform.position = planetGO.transform.position;
newCloak.transform.name = "CloakingField";
newCloak.transform.localScale = Vector3.one * radius;
GameObject.Destroy(newCloak.GetComponent<PlayerCloakEntryRedirector>());
Object.Destroy(newCloak.GetComponent<PlayerCloakEntryRedirector>());
var cloakFieldController = newCloak.GetComponent<CloakFieldController>();
cloakFieldController._cloakScaleDist = radius * 2000 / 3000f;

View File

@ -1,32 +1,128 @@
using NewHorizons.Components.SizeControllers;
using NewHorizons.External.Configs;
using NewHorizons.External.Modules;
using NewHorizons.Utility;
using NewHorizons.Utility.Files;
using NewHorizons.Utility.OuterWilds;
using NewHorizons.Utility.OWML;
using UnityEngine;
namespace NewHorizons.Builder.Body
{
public static class CometTailBuilder
{
private static GameObject _tailPrefab;
private static GameObject _dustPrefab;
private static GameObject _gasPrefab;
internal static void InitPrefab()
{
if (_tailPrefab == null) _tailPrefab = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes").InstantiateInactive().Rename("Prefab_CO_Tail").DontDestroyOnLoad();
if (_dustPrefab == null)
{
_dustPrefab = new GameObject("Prefab_CO_Dust").DontDestroyOnLoad();
var dust1 = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes/Effects_CO_DustTail").Instantiate();
dust1.transform.parent = _dustPrefab.transform;
dust1.transform.localPosition = Vector3.zero;
dust1.transform.localRotation = Quaternion.Euler(0, 270, 0);
var dust2 = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes/Effects_CO_DustTail (1)").Instantiate();
dust2.transform.parent = _dustPrefab.transform;
dust2.transform.localPosition = Vector3.zero;
dust2.transform.localRotation = Quaternion.Euler(0, 270, 0);
var dust3 = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes/Effects_CO_DustTail (2)").Instantiate();
dust3.transform.parent = _dustPrefab.transform;
dust3.transform.localPosition = Vector3.zero;
dust3.transform.localRotation = Quaternion.Euler(0, 270, 0);
_dustPrefab.SetActive(false);
}
if (_gasPrefab == null)
{
_gasPrefab = new GameObject("Prefab_CO_Gas").DontDestroyOnLoad();
var gas1 = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes/Effects_CO_GasTail").Instantiate();
gas1.transform.parent = _gasPrefab.transform;
gas1.transform.localPosition = Vector3.zero;
gas1.transform.localRotation = Quaternion.Euler(0, 270, 0);
var gas2 = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes/Effects_CO_GasTail (1)").Instantiate();
gas2.transform.parent = _gasPrefab.transform;
gas2.transform.localPosition = Vector3.zero;
gas2.transform.localRotation = Quaternion.Euler(0, 270, 0);
var gas3 = SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes/Effects_CO_GasTail (2)").Instantiate();
gas3.transform.parent = _gasPrefab.transform;
gas3.transform.localPosition = Vector3.zero;
gas3.transform.localRotation = Quaternion.Euler(0, 270, 0);
_gasPrefab.SetActive(false);
}
}
public static void Make(GameObject planetGO, Sector sector, PlanetConfig config)
public static void Make(GameObject planetGO, Sector sector, CometTailModule cometTailModule, PlanetConfig config)
{
InitPrefab();
if (config.Orbit.primaryBody == null)
{
NHLogger.LogError($"Comet {planetGO.name} does not orbit anything. That makes no sense");
return;
}
var cometTail = GameObject.Instantiate(_tailPrefab, sector?.transform ?? planetGO.transform);
cometTail.transform.position = planetGO.transform.position;
cometTail.name = "CometTail";
cometTail.transform.localScale = Vector3.one * config.Base.surfaceSize / 110;
var rootObj = new GameObject("CometRoot");
rootObj.SetActive(false);
rootObj.transform.parent = sector?.transform ?? planetGO.transform;
rootObj.transform.localPosition = Vector3.zero;
Vector3 alignment = new Vector3(0, 270, 90);
if (config.Base.cometTailRotation != null) alignment = config.Base.cometTailRotation;
var controller = rootObj.AddComponent<CometTailController>();
cometTail.transform.rotation = Quaternion.Euler(alignment);
controller.size = (cometTailModule.innerRadius ?? config.Base.surfaceSize) / 110;
cometTail.SetActive(true);
if (cometTailModule.rotationOverride != null) controller.SetRotationOverride(cometTailModule.rotationOverride);
if (string.IsNullOrEmpty(cometTailModule.primaryBody)) cometTailModule.primaryBody = config.Orbit.primaryBody;
Delay.FireOnNextUpdate(() =>
{
controller.SetPrimaryBody(
AstroObjectLocator.GetAstroObject(cometTailModule.primaryBody).transform,
AstroObjectLocator.GetAstroObject(config.Orbit.primaryBody).GetAttachedOWRigidbody()
);
});
controller.SetScaleCurve(cometTailModule.curve);
var dustTail = Object.Instantiate(_dustPrefab, rootObj.transform).Rename("DustTail");
dustTail.transform.localPosition = Vector3.zero;
dustTail.transform.localRotation = Quaternion.Euler(90, 90, 0);
dustTail.SetActive(true);
controller.dustTail = dustTail;
var gasTail = Object.Instantiate(_gasPrefab, rootObj.transform).Rename("GasTail");
gasTail.transform.localPosition = Vector3.zero;
gasTail.transform.localRotation = Quaternion.Euler(90, 90, 0);
gasTail.SetActive(true);
controller.gasTail = gasTail;
if (cometTailModule.dustTint != null)
{
foreach (var dust in dustTail.GetComponentsInChildren<MeshRenderer>())
{
var untintedDust = ImageUtilities.GetTexture(Main.Instance, "Assets/textures/Effects_CO_DustTail_d.png");
dust.material.mainTexture = ImageUtilities.TintImage(untintedDust, cometTailModule.dustTint.ToColor());
}
}
if (cometTailModule.gasTint != null)
{
foreach (var gas in gasTail.GetComponentsInChildren<MeshRenderer>())
{
var untintedGas = ImageUtilities.GetTexture(Main.Instance, "Assets/textures/Effects_CO_GasTail_d.png");
gas.material.mainTexture = untintedGas;
gas.material.color = cometTailModule.gasTint.ToColor();
}
}
rootObj.SetActive(true);
}
}
}

View File

@ -68,15 +68,15 @@ namespace NewHorizons.Builder.Body
scaleRoot.transform.localPosition = Vector3.zero;
scaleRoot.transform.localScale = new Vector3(1, 1, 1);
var proxyGO = GameObject.Instantiate(_proxySandFunnel, scaleRoot.transform);
var proxyGO = Object.Instantiate(_proxySandFunnel, scaleRoot.transform);
proxyGO.name = "Proxy_Funnel";
proxyGO.SetActive(true);
var geoGO = GameObject.Instantiate(_geoSandFunnel, scaleRoot.transform);
var geoGO = Object.Instantiate(_geoSandFunnel, scaleRoot.transform);
geoGO.name = "Geo_Funnel";
geoGO.SetActive(true);
var volumesGO = GameObject.Instantiate(_volumesSandFunnel, scaleRoot.transform);
var volumesGO = Object.Instantiate(_volumesSandFunnel, scaleRoot.transform);
volumesGO.name = "Volumes_Funnel";
volumesGO.SetActive(true);
var sfv = volumesGO.GetComponentInChildren<SimpleFluidVolume>();
@ -90,7 +90,7 @@ namespace NewHorizons.Builder.Body
case FunnelType.Water:
sfv._fluidType = FluidVolume.Type.WATER;
GameObject.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject);
Object.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject);
var waterMaterials = _waterMaterials;
var materials = new Material[waterMaterials.Length];
@ -138,7 +138,7 @@ namespace NewHorizons.Builder.Body
case FunnelType.Star:
sfv._fluidType = FluidVolume.Type.PLASMA;
GameObject.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject);
Object.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject);
var lavaMaterial = new Material(_lavaMaterial);
lavaMaterial.mainTextureOffset = new Vector2(0.1f, 0.2f);

View File

@ -42,7 +42,7 @@ namespace NewHorizons.Builder.Body
moltenCore.transform.position = planetGO.transform.position;
moltenCore.transform.localScale = Vector3.one * module.size;
var lavaSphere = GameObject.Instantiate(_lavaSphere, moltenCore.transform);
var lavaSphere = Object.Instantiate(_lavaSphere, moltenCore.transform);
lavaSphere.transform.localScale = Vector3.one;
lavaSphere.transform.name = "LavaSphere";
lavaSphere.GetComponent<MeshRenderer>().material.SetFloat(HeightScale, 150f * multiplier);
@ -54,7 +54,7 @@ namespace NewHorizons.Builder.Body
var sectorCullGroup = lavaSphere.GetComponent<SectorCullGroup>();
sectorCullGroup.SetSector(sector);
var moltenCoreProxy = GameObject.Instantiate(_moltenCoreProxy, moltenCore.transform); ;
var moltenCoreProxy = Object.Instantiate(_moltenCoreProxy, moltenCore.transform); ;
moltenCoreProxy.name = "MoltenCore_Proxy";
moltenCoreProxy.SetActive(true);
@ -70,7 +70,7 @@ namespace NewHorizons.Builder.Body
sectorProxy._renderers = new List<Renderer> { proxyLavaSphere.GetComponent<MeshRenderer>() };
sectorProxy.SetSector(sector);
var destructionVolume = GameObject.Instantiate(_destructionVolume, moltenCore.transform);
var destructionVolume = Object.Instantiate(_destructionVolume, moltenCore.transform);
destructionVolume.name = "DestructionVolume";
destructionVolume.GetComponent<SphereCollider>().radius = 1;
destructionVolume.SetActive(true);

View File

@ -1,6 +1,7 @@
using NewHorizons.Builder.Atmosphere;
using NewHorizons.Builder.Props;
using NewHorizons.Components;
using NewHorizons.Components.Props;
using NewHorizons.Components.SizeControllers;
using NewHorizons.External;
using NewHorizons.External.Modules.VariableSize;
@ -53,7 +54,7 @@ namespace NewHorizons.Builder.Body
var success = SharedMake(planetGO, rootProxy, proxyController, body);
if (!success)
{
GameObject.Destroy(proxy);
UnityEngine.Object.Destroy(proxy);
return;
}
@ -194,9 +195,9 @@ namespace NewHorizons.Builder.Body
}
}
if (body.Config.Base.hasCometTail)
if (body.Config.CometTail != null)
{
CometTailBuilder.Make(proxy, null, body.Config);
CometTailBuilder.Make(proxy, null, body.Config.CometTail, body.Config);
}
if (body.Config.Props?.proxyDetails != null)
@ -214,8 +215,8 @@ namespace NewHorizons.Builder.Body
}
// Remove all collisions if there are any
foreach (var col in proxy.GetComponentsInChildren<Collider>()) GameObject.Destroy(col);
foreach (var col in proxy.GetComponentsInChildren<OWCollider>()) GameObject.Destroy(col);
foreach (var col in proxy.GetComponentsInChildren<Collider>()) UnityEngine.Object.Destroy(col);
foreach (var col in proxy.GetComponentsInChildren<OWCollider>()) UnityEngine.Object.Destroy(col);
foreach (var renderer in proxy.GetComponentsInChildren<Renderer>())
{
@ -266,7 +267,7 @@ namespace NewHorizons.Builder.Body
sphereGO.transform.localScale = Vector3.one * size;
sphereGO.transform.position = rootObj.transform.position;
GameObject.Destroy(sphereGO.GetComponent<Collider>());
UnityEngine.Object.Destroy(sphereGO.GetComponent<Collider>());
sphereGO.GetComponent<MeshRenderer>().material.color = color;

View File

@ -4,6 +4,7 @@ using NewHorizons.Components.Volumes;
using NewHorizons.External.Modules;
using NewHorizons.Utility;
using NewHorizons.Utility.Files;
using NewHorizons.Utility.Geometry;
using NewHorizons.Utility.OuterWilds;
using NewHorizons.Utility.OWML;
using OWML.Common;

View File

@ -32,7 +32,7 @@ namespace NewHorizons.Builder.Body
var sandGO = new GameObject("Sand");
sandGO.SetActive(false);
var sandSphere = GameObject.Instantiate(_sandSphere, sandGO.transform);
var sandSphere = Object.Instantiate(_sandSphere, sandGO.transform);
sandSphere.name = "Sphere";
sandSphere.SetActive(true);
if (module.tint != null)
@ -46,20 +46,20 @@ namespace NewHorizons.Builder.Body
new Material(sandMaterials[0]),
new Material(sandMaterials[1])
};
GameObject.Destroy(oldMR);
Object.Destroy(oldMR);
sandMR.sharedMaterials[0].color = module.tint.ToColor();
sandMR.sharedMaterials[1].color = module.tint.ToColor();
}
var collider = GameObject.Instantiate(_sandCollider, sandGO.transform);
var collider = Object.Instantiate(_sandCollider, sandGO.transform);
collider.name = "Collider";
collider.SetActive(true);
var occlusionSphere = GameObject.Instantiate(_sandOcclusion, sandGO.transform);
var occlusionSphere = Object.Instantiate(_sandOcclusion, sandGO.transform);
occlusionSphere.name = "Occlusion";
occlusionSphere.SetActive(true);
var proxyShadowCasterGO = GameObject.Instantiate(_sandProxyShadowCaster, sandGO.transform);
var proxyShadowCasterGO = Object.Instantiate(_sandProxyShadowCaster, sandGO.transform);
proxyShadowCasterGO.name = "ProxyShadowCaster";
var proxyShadowCaster = proxyShadowCasterGO.GetComponent<ProxyShadowCaster>();
proxyShadowCaster.SetSuperGroup(sandGO.GetComponent<ProxyShadowCasterSuperGroup>());

View File

@ -167,7 +167,7 @@ namespace NewHorizons.Builder.Body
OWAudioSource oneShotOWAudioSource = null;
var singularityAmbience = GameObject.Instantiate(_blackHoleAmbience, singularity.transform);
var singularityAmbience = Object.Instantiate(_blackHoleAmbience, singularity.transform);
singularityAmbience.name = polarity ? "BlackHoleAmbience" : "WhiteHoleAmbience";
singularityAmbience.SetActive(true);
singularityAmbience.GetComponent<SectorAudioGroup>().SetSector(sector);
@ -202,7 +202,7 @@ namespace NewHorizons.Builder.Body
}
else
{
var blackHoleOneShot = GameObject.Instantiate(_blackHoleEmissionOneShot, singularity.transform);
var blackHoleOneShot = Object.Instantiate(_blackHoleEmissionOneShot, singularity.transform);
blackHoleOneShot.name = "BlackHoleEmissionOneShot";
blackHoleOneShot.SetActive(true);
oneShotOWAudioSource = blackHoleOneShot.GetComponent<OWAudioSource>();
@ -211,7 +211,7 @@ namespace NewHorizons.Builder.Body
oneShotAudioSource.minDistance = horizon;
if (sizeController != null) sizeController.oneShotAudioSource = oneShotAudioSource;
var blackHoleVolume = GameObject.Instantiate(_blackHoleVolume, singularity.transform);
var blackHoleVolume = Object.Instantiate(_blackHoleVolume, singularity.transform);
blackHoleVolume.name = "BlackHoleVolume";
blackHoleVolume.SetActive(true);
var bhVolume = blackHoleVolume.GetComponent<BlackHoleVolume>();
@ -226,7 +226,7 @@ namespace NewHorizons.Builder.Body
{
foreach (var renderer in blackHoleVolume.GetComponentsInChildren<ParticleSystemRenderer>(true))
{
UnityEngine.Object.Destroy(renderer);
Object.Destroy(renderer);
}
});
}
@ -234,7 +234,7 @@ namespace NewHorizons.Builder.Body
}
else
{
GameObject whiteHoleVolumeGO = GameObject.Instantiate(_whiteHoleVolume);
GameObject whiteHoleVolumeGO = Object.Instantiate(_whiteHoleVolume);
whiteHoleVolumeGO.transform.parent = singularity.transform;
whiteHoleVolumeGO.transform.localPosition = Vector3.zero;
whiteHoleVolumeGO.transform.localScale = Vector3.one;

View File

@ -48,7 +48,7 @@ namespace NewHorizons.Builder.Body
if (_starAtmosphere == null) _starAtmosphere = SearchUtilities.Find("Sun_Body/Atmosphere_SUN").InstantiateInactive().Rename("Prefab_Atmosphere_Star").DontDestroyOnLoad();
if (_starAmbientLight == null) _starAmbientLight = SearchUtilities.Find("Sun_Body/AmbientLight_SUN").InstantiateInactive().Rename("Prefab_AmbientLight_Star").DontDestroyOnLoad();
if (_sunLight == null) _sunLight = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").InstantiateInactive().Rename("Prefab_SunLight").DontDestroyOnLoad();
if (_starProxyAtmosphere == null) _starProxyAtmosphere = GameObject.FindObjectOfType<DistantProxyManager>()._sunProxyPrefab.FindChild("Sun_Proxy_Body/Atmosphere_SUN").InstantiateInactive().Rename("Prefab_ProxyAtmosphere_Star").DontDestroyOnLoad();
if (_starProxyAtmosphere == null) _starProxyAtmosphere = Object.FindObjectOfType<DistantProxyManager>()._sunProxyPrefab.FindChild("Sun_Proxy_Body/Atmosphere_SUN").InstantiateInactive().Rename("Prefab_ProxyAtmosphere_Star").DontDestroyOnLoad();
if (_starSurface == null) _starSurface = SearchUtilities.Find("Sun_Body/Sector_SUN/Geometry_SUN/Surface").InstantiateInactive().Rename("Prefab_Surface_Star").DontDestroyOnLoad();
if (_starSolarFlareEmitter == null) _starSolarFlareEmitter = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SolarFlareEmitter").InstantiateInactive().Rename("Prefab_SolarFlareEmitter_Star").DontDestroyOnLoad();
if (_supernovaPrefab == null) _supernovaPrefab = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/Supernova").InstantiateInactive().Rename("Prefab_Supernova").DontDestroyOnLoad();
@ -69,7 +69,7 @@ namespace NewHorizons.Builder.Body
var sunSurfaceAudio = sunAudio.GetComponentInChildren<SunSurfaceAudioController>();
var surfaceAudio = sunSurfaceAudio.gameObject.AddComponent<StarSurfaceAudioController>();
surfaceAudio._size = starModule.size;
GameObject.Destroy(sunSurfaceAudio);
Object.Destroy(sunSurfaceAudio);
surfaceAudio.SetSector(sector);
sunAudio.name = "Audio_Star";
@ -96,7 +96,7 @@ namespace NewHorizons.Builder.Body
var fog = sunAtmosphere.transform.Find("FogSphere").GetComponent<PlanetaryFogController>();
fog.transform.localScale = Vector3.one;
fog.fogRadius = starModule.size * OuterRadiusRatio;
fog.lodFadeDistance = fog.fogRadius * (StarBuilder.OuterRadiusRatio - 1f);
fog.lodFadeDistance = fog.fogRadius * (OuterRadiusRatio - 1f);
fog.fogImpostor.material.SetFloat(Radius, starModule.size * OuterRadiusRatio);
if (starModule.tint != null)
@ -416,7 +416,7 @@ namespace NewHorizons.Builder.Body
stellarDeath.shockwaveAlpha = supernova._shockwaveAlpha;
stellarDeath.shockwaveScale = supernova._shockwaveScale;
stellarDeath.supernovaMaterial = supernova._supernovaMaterial;
GameObject.Destroy(supernova);
Object.Destroy(supernova);
if (starModule.supernovaTint != null)
{

View File

@ -1,10 +1,10 @@
using UnityEngine;
using NewHorizons.Utility;
using NewHorizons.External.Configs;
using NewHorizons.Components;
using System.Linq;
using OWML.Common;
using NewHorizons.Utility.Files;
using NewHorizons.Components.Props;
namespace NewHorizons.Builder.Body
{

View File

@ -123,7 +123,7 @@ namespace NewHorizons.Builder.Body
fluidVolume._density = module.density;
fluidVolume._layer = LayerMask.NameToLayer("BasicEffectVolume");
var fogGO = GameObject.Instantiate(_oceanFog, waterGO.transform);
var fogGO = Object.Instantiate(_oceanFog, waterGO.transform);
fogGO.name = "OceanFog";
fogGO.transform.localPosition = Vector3.zero;
fogGO.transform.localScale = Vector3.one;

View File

@ -12,7 +12,7 @@ namespace NewHorizons.Builder.General
var ambientLight = Main.Instance.CurrentStarSystem == "EyeOfTheUniverse" ? SearchUtilities.Find("EyeOfTheUniverse_Body/Sector_EyeOfTheUniverse/SixthPlanet_Root/QuantumMoonProxy_Pivot/QuantumMoonProxy_Root/MoonState_Root/AmbientLight_QM") : SearchUtilities.Find("QuantumMoon_Body/AmbientLight_QM");
if (ambientLight == null) return null;
GameObject lightGO = GameObject.Instantiate(ambientLight, sector?.transform ?? planetGO.transform);
GameObject lightGO = Object.Instantiate(ambientLight, sector?.transform ?? planetGO.transform);
lightGO.transform.position = config.position == null ? planetGO.transform.position : planetGO.transform.TransformPoint(config.position);
lightGO.name = "AmbientLight";

View File

@ -18,7 +18,7 @@ namespace NewHorizons.Builder.General
var type = AstroObject.Type.Planet;
if (config.Orbit.isMoon) type = AstroObject.Type.Moon;
// else if (config.Base.IsSatellite) type = AstroObject.Type.Satellite;
else if (config.Base.hasCometTail) type = AstroObject.Type.Comet;
else if (config.CometTail != null) type = AstroObject.Type.Comet;
else if (config.Star != null) type = AstroObject.Type.Star;
else if (config.FocalPoint != null) type = AstroObject.Type.None;
astroObject._type = type;

View File

@ -195,7 +195,7 @@ namespace NewHorizons.Builder.Props
var fogLight = brambleNode.GetComponent<FogLight>();
// This node comes with Feldspar's signal, we don't want that though
GameObject.Destroy(brambleNode.FindChild("Signal_Harmonica"));
Object.Destroy(brambleNode.FindChild("Signal_Harmonica"));
// Fix some components
fogLight._parentBody = go.GetComponent<OWRigidbody>();

View File

@ -29,7 +29,7 @@ namespace NewHorizons.Builder.Props
{
foreach (var prefab in _fixedPrefabCache.Values)
{
GameObject.Destroy(prefab.prefab);
UnityEngine.Object.Destroy(prefab.prefab);
}
_fixedPrefabCache.Clear();
_detailInfoToCorrespondingSpawnedGameObject.Clear();
@ -189,7 +189,7 @@ namespace NewHorizons.Builder.Props
child.parent = newDetailGO.transform;
}
// Have to destroy it right away, else parented props might get attached to the old one
GameObject.DestroyImmediate(prop);
UnityEngine.Object.DestroyImmediate(prop);
prop = newDetailGO;
}
@ -225,7 +225,7 @@ namespace NewHorizons.Builder.Props
// renderers/colliders get enabled later so we dont have to do that here
if (keepLoaded && component is SectorCullGroup or SectorCollisionGroup or SectorLightsCullGroup)
{
Component.DestroyImmediate(component);
UnityEngine.Object.DestroyImmediate(component);
return;
}
@ -283,7 +283,7 @@ namespace NewHorizons.Builder.Props
{
if (component is FogLight or SectoredMonoBehaviour or ISectorGroup)
{
GameObject.DestroyImmediate(component);
UnityEngine.Object.DestroyImmediate(component);
return true;
}
return false;
@ -306,7 +306,7 @@ namespace NewHorizons.Builder.Props
// I forget why this is here
else if (component is GhostIK or GhostEffects)
{
Component.DestroyImmediate(component);
UnityEngine.Object.DestroyImmediate(component);
return;
}
else if (component is DarkMatterVolume)

View File

@ -1,4 +1,4 @@
using NewHorizons.Components;
using NewHorizons.Components.Props;
using NewHorizons.External.Modules.Props.Dialogue;
using NewHorizons.Handlers;
using NewHorizons.Utility;

View File

@ -67,7 +67,7 @@ namespace NewHorizons.Builder.Props
if (_arcPrefabs == null || _childArcPrefabs == null)
{
// Just take every scroll and get the first arc
var existingArcs = GameObject.FindObjectsOfType<ScrollItem>()
var existingArcs = UnityEngine.Object.FindObjectsOfType<ScrollItem>()
.Select(x => x?._nomaiWallText?.gameObject?.transform?.Find("Arc 1")?.gameObject)
.Where(x => x != null)
.OrderBy(x => x.transform.GetPath()) // order by path so game updates dont break things
@ -95,7 +95,7 @@ namespace NewHorizons.Builder.Props
if (_ghostArcPrefabs == null)
{
var existingGhostArcs = GameObject.FindObjectsOfType<GhostWallText>()
var existingGhostArcs = UnityEngine.Object.FindObjectsOfType<GhostWallText>()
.Select(x => x?._textLine?.gameObject)
.Where(x => x != null)
.OrderBy(x => x.transform.GetPath()) // order by path so game updates dont break things
@ -253,7 +253,7 @@ namespace NewHorizons.Builder.Props
var scrollItem = customScroll.GetComponent<ScrollItem>();
// Idk why this thing is always around
GameObject.Destroy(customScroll.transform.Find("Arc_BH_City_Forum_2").gameObject);
UnityEngine.Object.Destroy(customScroll.transform.Find("Arc_BH_City_Forum_2").gameObject);
// This variable is the bane of my existence i dont get it
scrollItem._nomaiWallText = nomaiWallText;

View File

@ -208,7 +208,7 @@ namespace NewHorizons.Builder.Props
void Update()
{
if (meshFilter == null && skinnedMeshRenderer == null) { NHLogger.LogVerbose("Useless BoxShapeFixer, destroying"); GameObject.DestroyImmediate(this); }
if (meshFilter == null && skinnedMeshRenderer == null) { NHLogger.LogVerbose("Useless BoxShapeFixer, destroying"); DestroyImmediate(this); }
Mesh sharedMesh = null;
if (meshFilter != null) sharedMesh = meshFilter.sharedMesh;
@ -220,7 +220,7 @@ namespace NewHorizons.Builder.Props
shape.size = sharedMesh.bounds.size;
shape.center = sharedMesh.bounds.center;
GameObject.DestroyImmediate(this);
DestroyImmediate(this);
}
}
}

View File

@ -14,7 +14,7 @@ namespace NewHorizons.Builder.Props
{
if (_prefab == null)
{
_prefab = GameObject.FindObjectOfType<RaftController>()?.gameObject?.InstantiateInactive()?.Rename("Raft_Body_Prefab")?.DontDestroyOnLoad();
_prefab = Object.FindObjectOfType<RaftController>()?.gameObject?.InstantiateInactive()?.Rename("Raft_Body_Prefab")?.DontDestroyOnLoad();
if (_prefab == null)
{
NHLogger.LogWarning($"Tried to make a raft but couldn't. Do you have the DLC installed?");

View File

@ -65,7 +65,7 @@ namespace NewHorizons.Builder.Props
quad.AddComponent<OWRenderer>();
quad.GetComponent<MeshRenderer>().sharedMaterial = _decalMaterial;
quad.name = "AstroBodySymbolRenderer";
GameObject.DestroyImmediate(AstroBodySymbolRenderer);
UnityEngine.Object.DestroyImmediate(AstroBodySymbolRenderer);
}
if (_whiteboardPrefab == null)
@ -86,7 +86,7 @@ namespace NewHorizons.Builder.Props
quadW.AddComponent<OWRenderer>();
quadW.GetComponent<MeshRenderer>().sharedMaterial = _decalMaterial;
quadW.name = "AstroBodySymbolRenderer";
GameObject.DestroyImmediate(AstroBodySymbolRendererW);
UnityEngine.Object.DestroyImmediate(AstroBodySymbolRendererW);
}
if (_shareStonePrefab == null)
@ -109,7 +109,7 @@ namespace NewHorizons.Builder.Props
TransformAnimator transformAnimator = animRoot.AddComponent<TransformAnimator>();
item._animator = transformAnimator;
OWRenderer renderer = SearchUtilities.FindResourceOfTypeAndName<OWRenderer>("Props_NOM_SharedStone");
if (renderer != null) GameObject.Instantiate(renderer.gameObject, animRoot.transform);
if (renderer != null) UnityEngine.Object.Instantiate(renderer.gameObject, animRoot.transform);
GameObject planetDecal = GameObject.CreatePrimitive(PrimitiveType.Quad);
planetDecal.name = "PlanetDecal";
planetDecal.transform.parent = animRoot.transform;
@ -137,7 +137,7 @@ namespace NewHorizons.Builder.Props
{
try
{
RemoteBuilder.MakePlatform(go, sector, id, decal, info.platform, mod);
MakePlatform(go, sector, id, decal, info.platform, mod);
}
catch (Exception ex)
{
@ -149,7 +149,7 @@ namespace NewHorizons.Builder.Props
{
try
{
RemoteBuilder.MakeWhiteboard(go, sector, id, decal, info.whiteboard, nhBody);
MakeWhiteboard(go, sector, id, decal, info.whiteboard, nhBody);
}
catch (Exception ex)
{
@ -163,7 +163,7 @@ namespace NewHorizons.Builder.Props
{
try
{
RemoteBuilder.MakeStone(go, sector, id, decal, stoneInfo, mod);
MakeStone(go, sector, id, decal, stoneInfo, mod);
}
catch (Exception ex)
{

View File

@ -139,7 +139,7 @@ namespace NewHorizons.Builder.Props
prop.SetActive(true);
}
GameObject.Destroy(scatterPrefab);
Object.Destroy(scatterPrefab);
}
}
}

View File

@ -1,4 +1,4 @@
using NewHorizons.Components;
using NewHorizons.Components.Props;
using NewHorizons.External.Modules.Props;
using NewHorizons.Handlers;
using NewHorizons.Utility;

View File

@ -148,12 +148,12 @@ namespace NewHorizons.Builder.Props.TranslatorText
this.outerWidth = profile.outerWidth;
this.uvScale = profile.uvScale;
this.uvOffset = UnityEngine.Random.value;
this.uvOffset = Random.value;
}
public override void Randomize() {
base.Randomize();
uvOffset = UnityEngine.Random.value; // this way even two spirals that are exactly the same shape will look different (this changes the starting point of the handwriting texture)
uvOffset = Random.value; // this way even two spirals that are exactly the same shape will look different (this changes the starting point of the handwriting texture)
}
internal void updateMesh() {
@ -288,11 +288,11 @@ namespace NewHorizons.Builder.Props.TranslatorText
}
public virtual void Randomize() {
this.a = UnityEngine.Random.Range(profile.a.x, profile.a.y);
this.b = UnityEngine.Random.Range(profile.b.x, profile.b.y);
this.endS = UnityEngine.Random.Range(profile.endS.x, profile.endS.y);
this.startS = UnityEngine.Random.Range(profile.startS.x, profile.startS.y);
this.scale = UnityEngine.Random.Range(profile.skeletonScale.x, profile.skeletonScale.y);
this.a = Random.Range(profile.a.x, profile.a.y);
this.b = Random.Range(profile.b.x, profile.b.y);
this.endS = Random.Range(profile.endS.x, profile.endS.y);
this.startS = Random.Range(profile.startS.x, profile.startS.y);
this.scale = Random.Range(profile.skeletonScale.x, profile.skeletonScale.y);
}
internal virtual void updateChild(MathematicalSpiral child) {

View File

@ -176,7 +176,7 @@ namespace NewHorizons.Builder.Props.TranslatorText
var scrollItem = customScroll.GetComponent<ScrollItem>();
// Idk why this thing is always around
GameObject.Destroy(customScroll.transform.Find("Arc_BH_City_Forum_2").gameObject);
UnityEngine.Object.Destroy(customScroll.transform.Find("Arc_BH_City_Forum_2").gameObject);
// This variable is the bane of my existence i dont get it
scrollItem._nomaiWallText = nomaiWallText;

View File

@ -28,7 +28,7 @@ namespace NewHorizons.Builder.Props
meteorLauncher._dynamicProbability = 0f;
var meteorPrefab = meteorLauncher._meteorPrefab.InstantiateInactive().Rename("Prefab_VM_MoltenMeteor").DontDestroyOnLoad();
var meteor = meteorPrefab.GetComponent<MeteorController>();
GameObject.DestroyImmediate(meteorPrefab.FindChild("ConstantDetectors"));
Object.DestroyImmediate(meteorPrefab.FindChild("ConstantDetectors"));
var detectors = meteorPrefab.FindChild("DynamicDetector");
var rigidbody = meteor.GetComponent<OWRigidbody>();
meteor._owRigidbody = rigidbody;

View File

@ -52,7 +52,7 @@ namespace NewHorizons.Builder.Props
_detailedReceiverPrefab.DontDestroyOnLoad();
GameObject.Destroy(_detailedReceiverPrefab.GetComponentInChildren<NomaiWarpStreaming>().gameObject);
Object.Destroy(_detailedReceiverPrefab.GetComponentInChildren<NomaiWarpStreaming>().gameObject);
}
if (_receiverPrefab == null)
@ -60,7 +60,7 @@ namespace NewHorizons.Builder.Props
_receiverPrefab = SearchUtilities.Find("SunStation_Body/Sector_SunStation/Sector_WarpModule/Interactables_WarpModule/Prefab_NOM_WarpReceiver")
.InstantiateInactive()
.DontDestroyOnLoad();
GameObject.Destroy(_receiverPrefab.GetComponentInChildren<NomaiWarpStreaming>().gameObject);
Object.Destroy(_receiverPrefab.GetComponentInChildren<NomaiWarpStreaming>().gameObject);
var structure = _platformContainerPrefab.Instantiate();
structure.transform.parent = _receiverPrefab.transform;
@ -74,7 +74,7 @@ namespace NewHorizons.Builder.Props
_transmitterPrefab = SearchUtilities.Find("TowerTwin_Body/Sector_TowerTwin/Sector_Tower_SS/Interactables_Tower_SS/Tower_SS_VisibleFrom_TowerTwin/Prefab_NOM_WarpTransmitter")
.InstantiateInactive()
.DontDestroyOnLoad();
GameObject.Destroy(_transmitterPrefab.GetComponentInChildren<NomaiWarpStreaming>().gameObject);
Object.Destroy(_transmitterPrefab.GetComponentInChildren<NomaiWarpStreaming>().gameObject);
var structure = _platformContainerPrefab.Instantiate();
structure.transform.parent = _transmitterPrefab.transform;

View File

@ -133,7 +133,7 @@ namespace NewHorizons.Builder.ShipLog
astroObject._image = revealedImage;
}
astroObject._unviewedObj = GameObject.Instantiate(unviewedReference, gameObject.transform, false);
astroObject._unviewedObj = UnityEngine.Object.Instantiate(unviewedReference, gameObject.transform, false);
astroObject._invisibleWhenHidden = body.Config.ShipLog?.mapMode?.invisibleWhenHidden ?? false;
Rect imageRect = astroObject._imageObj.GetComponent<RectTransform>().rect;

View File

@ -1,4 +1,4 @@
namespace NewHorizons.Components
namespace NewHorizons.Components.EyeOfTheUniverse
{
public class EyeAstroObject : AstroObject
{

View File

@ -1,4 +1,4 @@
namespace NewHorizons.Components
namespace NewHorizons.Components.EyeOfTheUniverse
{
/*
public class EyeSunLightParamUpdater : MonoBehaviour

View File

@ -1,3 +1,4 @@
using NewHorizons.Components.Props;
using NewHorizons.Components.SizeControllers;
using NewHorizons.Handlers;
using NewHorizons.Utility.OuterWilds;

View File

@ -15,7 +15,7 @@ namespace NewHorizons.Components.Orbital
public override void InitializeLineRenderer()
{
base.GetComponent<LineRenderer>().positionCount = this._numVerts;
GetComponent<LineRenderer>().positionCount = this._numVerts;
}
public override void OnValidate()
@ -24,7 +24,7 @@ namespace NewHorizons.Components.Orbital
{
_numVerts = Mathf.Clamp(_numVerts, 0, 4096);
}
if (base.GetComponent<LineRenderer>().positionCount != this._numVerts)
if (GetComponent<LineRenderer>().positionCount != this._numVerts)
{
InitializeLineRenderer();
}
@ -46,7 +46,7 @@ namespace NewHorizons.Components.Orbital
transform.localRotation = Quaternion.Euler(270, 90, 0);
base.enabled = false;
enabled = false;
}
public override void Update()
@ -58,7 +58,7 @@ namespace NewHorizons.Components.Orbital
// If it has nothing to orbit then why is this here
if (primary == null || !primary.gameObject.activeSelf)
{
base.enabled = false;
enabled = false;
return;
}

View File

@ -34,7 +34,7 @@ namespace NewHorizons.Components.Orbital
base.Start();
_vertices = new Vector3[_numVerts];
base.enabled = true;
enabled = true;
_lineRenderer.enabled = false;
}
@ -75,8 +75,8 @@ namespace NewHorizons.Components.Orbital
_vertices[0] = transform.parent.position - origin;
_lineRenderer.SetPositions(_vertices);
base.transform.position = origin;
base.transform.rotation = Quaternion.AngleAxis(0f, Vector3.up);
transform.position = origin;
transform.rotation = Quaternion.AngleAxis(0f, Vector3.up);
float num2 = DistanceToTrackingOrbitLine(Locator.GetActiveCamera().transform.position);
float widthMultiplier = Mathf.Min(num2 * (_lineWidth / 1000f), _maxLineWidth);
@ -108,8 +108,8 @@ namespace NewHorizons.Components.Orbital
var primary = _astroObject.GetPrimaryBody();
Vector3 origin = primary == null ? Locator.GetRootTransform().position : primary.transform.position;
base.transform.position = origin;
base.transform.rotation = Quaternion.AngleAxis(0f, Vector3.up);
transform.position = origin;
transform.rotation = Quaternion.AngleAxis(0f, Vector3.up);
for (int i = _numVerts - 1; i > 0; i--)
{

View File

@ -1,4 +1,4 @@
namespace NewHorizons.Components
namespace NewHorizons.Components.Props
{
public class NHCharacterDialogueTree : CharacterDialogueTree
{

View File

@ -3,7 +3,7 @@ using NewHorizons.Handlers;
using UnityEngine;
using static SupernovaPlanetEffectController;
namespace NewHorizons.Components
namespace NewHorizons.Components.Props
{
public class NHSupernovaPlanetEffectController : MonoBehaviour
{

View File

@ -1,6 +1,6 @@
using UnityEngine;
using Random = UnityEngine.Random;
namespace NewHorizons.Components
namespace NewHorizons.Components.Props
{
public class NHTornadoWanderController : MonoBehaviour
{

View File

@ -136,7 +136,7 @@ namespace NewHorizons.Components.Quantum
num += _probabilities[j];
}
}
int num2 = UnityEngine.Random.Range(0, num);
int num2 = Random.Range(0, num);
int num3 = 0;
int num4 = 0;
foreach (int k in indices)

View File

@ -1,5 +1,6 @@
using System.Collections.Generic;
using UnityEngine;
namespace NewHorizons.Components
{
public class RingShape : Shape
@ -185,7 +186,7 @@ namespace NewHorizons.Components
public override bool PointInside(Vector3 point)
{
return (!_innerCylinderShape.PointInside(point) && _outerCylinderShape.PointInside(point));
return !_innerCylinderShape.PointInside(point) && _outerCylinderShape.PointInside(point);
}
private List<Shape> _shapesInInner = new List<Shape>();

View File

@ -1,6 +1,6 @@
using UnityEngine;
namespace NewHorizons.Components
namespace NewHorizons.Components.Sectored
{
public class BrambleSectorController : MonoBehaviour, ISectorGroup
{

View File

@ -1,5 +1,5 @@
using UnityEngine;
namespace NewHorizons.Components
namespace NewHorizons.Components.Sectored
{
public class CloakSectorController : MonoBehaviour
{

View File

@ -1,6 +1,6 @@
using UnityEngine;
namespace NewHorizons.Components
namespace NewHorizons.Components.Sectored
{
[RequireComponent(typeof(TessellatedSphereRenderer))]
public class CloakedTessSphereSectorToggle : SectoredMonoBehaviour

View File

@ -3,7 +3,7 @@ using NewHorizons.Utility;
using NewHorizons.Utility.OWML;
using UnityEngine;
namespace NewHorizons.Components
namespace NewHorizons.Components.Ship
{
public class ShipWarpController : MonoBehaviour
{
@ -65,7 +65,7 @@ namespace NewHorizons.Components
if (blackHoleShader == null) blackHoleShader = _blackHolePrefab.GetComponent<MeshRenderer>().sharedMaterial.shader;
var blackHoleRender = new GameObject("BlackHoleRender");
blackHoleRender.transform.parent = base.transform;
blackHoleRender.transform.parent = transform;
blackHoleRender.transform.localPosition = new Vector3(0, 1, 0);
blackHoleRender.transform.localScale = Vector3.one * size;
@ -92,7 +92,7 @@ namespace NewHorizons.Components
if (whiteHoleShader == null) whiteHoleShader = _whiteHolePrefab.GetComponent<MeshRenderer>().sharedMaterial.shader;
var whiteHoleRenderer = new GameObject("WhiteHoleRenderer");
whiteHoleRenderer.transform.parent = base.transform;
whiteHoleRenderer.transform.parent = transform;
whiteHoleRenderer.transform.localPosition = new Vector3(0, 1, 0);
whiteHoleRenderer.transform.localScale = Vector3.one * size * 2.8f;
@ -126,7 +126,7 @@ namespace NewHorizons.Components
public void WarpOut()
{
NHLogger.LogVerbose("Starting warp-out");
_oneShotSource.PlayOneShot(global::AudioType.VesselSingularityCreate, 1f);
_oneShotSource.PlayOneShot(AudioType.VesselSingularityCreate, 1f);
_blackhole.Create();
}
@ -165,7 +165,7 @@ namespace NewHorizons.Components
private void StartWarpInEffect()
{
NHLogger.LogVerbose("Starting warp-in effect");
_oneShotSource.PlayOneShot(global::AudioType.VesselSingularityCollapse, 1f);
_oneShotSource.PlayOneShot(AudioType.VesselSingularityCollapse, 1f);
Locator.GetDeathManager()._invincible = true;
if (Main.Instance.CurrentStarSystem.Equals("SolarSystem")) TeleportToShip();
_whitehole.Create();
@ -178,7 +178,7 @@ namespace NewHorizons.Components
private void TeleportToShip()
{
var playerSpawner = GameObject.FindObjectOfType<PlayerSpawner>();
var playerSpawner = FindObjectOfType<PlayerSpawner>();
playerSpawner.DebugWarp(playerSpawner.GetSpawnPoint(SpawnLocation.Ship));
}

View File

@ -0,0 +1,64 @@
using NewHorizons.Utility;
using NewHorizons.Utility.OWML;
using UnityEngine;
namespace NewHorizons.Components.SizeControllers
{
public class CometTailController : SizeController
{
private Transform _dustTargetBody;
private OWRigidbody _primaryBody;
private OWRigidbody _body;
private bool _hasRotationOverride;
private bool _hasPrimaryBody;
public GameObject gasTail;
public GameObject dustTail;
private Vector3 _gasTarget;
private Vector3 _dustTarget;
public void Start()
{
_body = transform.GetAttachedOWRigidbody();
}
public override void FixedUpdate()
{
base.FixedUpdate();
if (!_hasRotationOverride && _hasPrimaryBody)
{
UpdateTargetPositions();
dustTail?.LookDir(_dustTarget);
gasTail?.LookDir(_gasTarget);
}
}
private void UpdateTargetPositions()
{
var toPrimary = (_body.transform.position - _dustTargetBody.transform.position).normalized;
var velocityDirection = (_primaryBody?.GetVelocity() ?? Vector3.zero) -_body.GetVelocity(); // Accept that this is flipped ok
var tangentVel = Vector3.ProjectOnPlane(velocityDirection, toPrimary) / velocityDirection.magnitude;
_gasTarget = toPrimary;
_dustTarget = (toPrimary + tangentVel).normalized;
}
public void SetRotationOverride(Vector3 eulerAngles)
{
_hasRotationOverride = true;
transform.localRotation = Quaternion.Euler(eulerAngles);
}
public void SetPrimaryBody(Transform dustTarget, OWRigidbody primaryBody)
{
_hasPrimaryBody = true;
_dustTargetBody = dustTarget;
_primaryBody = primaryBody;
}
}
}

View File

@ -8,7 +8,7 @@ namespace NewHorizons.Components.SizeControllers
public Material material;
public Material proxyMaterial;
protected new void FixedUpdate()
public override void FixedUpdate()
{
base.FixedUpdate();

View File

@ -71,6 +71,8 @@ namespace NewHorizons.Components.SizeControllers
public void SetScaleCurve(TimeValuePair[] curve)
{
if (curve == null) return;
scaleCurve = new AnimationCurve();
foreach (var pair in curve)
{

View File

@ -19,8 +19,8 @@ namespace NewHorizons.Components.Volumes
public void Start()
{
_gameOverController = GameObject.FindObjectOfType<GameOverController>();
_playerCameraEffectController = GameObject.FindObjectOfType<PlayerCameraEffectController>();
_gameOverController = FindObjectOfType<GameOverController>();
_playerCameraEffectController = FindObjectOfType<PlayerCameraEffectController>();
}
public override void OnTriggerVolumeEntry(GameObject hitObj)

View File

@ -22,6 +22,7 @@ namespace NewHorizons.External.Configs
[JsonObject(Title = "Celestial Body")]
public class PlanetConfig
{
#region Fields
/// <summary>
/// Unique name of your planet
/// </summary>
@ -33,6 +34,34 @@ namespace NewHorizons.External.Configs
/// </summary>
[DefaultValue("SolarSystem")] public string starSystem = "SolarSystem";
/// <summary>
/// Does this config describe a quantum state of a custom planet defined in another file?
/// </summary>
public bool isQuantumState;
/// <summary>
/// Does this config describe a stellar remnant of a custom star defined in another file?
/// </summary>
public bool isStellarRemnant;
/// <summary>
/// Should this planet ever be shown on the title screen?
/// </summary>
[DefaultValue(true)] public bool canShowOnTitle = true;
/// <summary>
/// `true` if you want to delete this planet
/// </summary>
public bool destroy;
/// <summary>
/// A list of paths to child GameObjects to destroy on this planet
/// </summary>
public string[] removeChildren;
#endregion
#region Modules
/// <summary>
/// Add ambient lights to this body
/// </summary>
@ -58,37 +87,11 @@ namespace NewHorizons.External.Configs
/// </summary>
public BrambleModule Bramble;
/// <summary>
/// Should this planet ever be shown on the title screen?
/// </summary>
[DefaultValue(true)] public bool canShowOnTitle = true;
#region Obsolete
[Obsolete("ChildrenToDestroy is deprecated, please use RemoveChildren instead")]
public string[] childrenToDestroy;
[Obsolete("Singularity is deprecated, please use Props->singularities")]
public SingularityModule Singularity;
[Obsolete("Signal is deprecated, please use Props->signals")]
public SignalModule Signal;
[Obsolete("Ring is deprecated, please use Rings")]
public RingModule Ring;
#endregion Obsolete
/// <summary>
/// Add a cloaking field to this planet
/// </summary>
public CloakModule Cloak;
/// <summary>
/// `true` if you want to delete this planet
/// </summary>
public bool destroy;
/// <summary>
/// Make this body into a focal point (barycenter)
/// </summary>
@ -104,16 +107,6 @@ namespace NewHorizons.External.Configs
/// </summary>
public HeightMapModule HeightMap;
/// <summary>
/// Does this config describe a quantum state of a custom planet defined in another file?
/// </summary>
public bool isQuantumState;
/// <summary>
/// Does this config describe a stellar remnant of a custom star defined in another file?
/// </summary>
public bool isStellarRemnant;
/// <summary>
/// Add lava to this planet
/// </summary>
@ -139,11 +132,6 @@ namespace NewHorizons.External.Configs
/// </summary>
public ReferenceFrameModule ReferenceFrame;
/// <summary>
/// A list of paths to child GameObjects to destroy on this planet
/// </summary>
public string[] removeChildren;
/// <summary>
/// Create rings around the planet
/// </summary>
@ -184,11 +172,35 @@ namespace NewHorizons.External.Configs
/// </summary>
public VolumesModule Volumes;
/// <summary>
/// Add a comet tail to this body, like the Interloper
/// </summary>
public CometTailModule CometTail;
/// <summary>
/// Extra data that may be used by extension mods
/// </summary>
public object extras;
#endregion
#region Obsolete
[Obsolete("ChildrenToDestroy is deprecated, please use RemoveChildren instead")]
public string[] childrenToDestroy;
[Obsolete("Singularity is deprecated, please use Props->singularities")]
public SingularityModule Singularity;
[Obsolete("Signal is deprecated, please use Props->signals")]
public SignalModule Signal;
[Obsolete("Ring is deprecated, please use Rings")]
public RingModule Ring;
#endregion Obsolete
#region ctor validation and migration
public PlanetConfig()
{
// Always have to have a base module
@ -567,6 +579,16 @@ namespace NewHorizons.External.Configs
}
}
}
if (Base.hasCometTail)
{
CometTail ??= new();
if (Base.cometTailRotation != null)
{
CometTail.rotationOverride = Base.cometTailRotation;
}
}
}
#endregion
}
}

View File

@ -25,11 +25,6 @@ namespace NewHorizons.External.Modules
/// </summary>
public bool centerOfSolarSystem;
/// <summary>
/// If it has a comet tail, it'll be oriented according to these Euler angles.
/// </summary>
public MVector3 cometTailRotation;
/// <summary>
/// How gravity falls off with distance. Most planets use linear but the sun and some moons use inverseSquared.
/// </summary>
@ -41,11 +36,6 @@ namespace NewHorizons.External.Modules
/// </summary>
public float groundSize;
/// <summary>
/// If you want the body to have a tail like the Interloper.
/// </summary>
public bool hasCometTail;
/// <summary>
/// If the body should have a marker on the map screen.
/// </summary>
@ -116,6 +106,12 @@ namespace NewHorizons.External.Modules
[Obsolete("zeroGravityRadius is deprecated, please use Volumes->ZeroGravityVolumes instead")]
public float zeroGravityRadius;
[Obsolete("hasCometTail is deprecated, please use CometTail instead")]
public bool hasCometTail;
[Obsolete("cometTailRotation is deprecated, please use CometTail->rotationOverride instead")]
public MVector3 cometTailRotation;
#endregion Obsolete
}
}

View File

@ -0,0 +1,35 @@
using NewHorizons.External.Modules.VariableSize;
using NewHorizons.External.SerializableData;
using Newtonsoft.Json;
namespace NewHorizons.External.Modules
{
[JsonObject]
public class CometTailModule : VariableSizeModule
{
/// <summary>
/// Manually sets the local rotation
/// </summary>
public MVector3 rotationOverride;
/// <summary>
/// Inner radius of the comet tail, defaults to match surfaceSize
/// </summary>
public float? innerRadius;
/// <summary>
/// The body that the comet tail should always point away from
/// </summary>
public string primaryBody;
/// <summary>
/// Colour of the dust tail (the shorter part)
/// </summary>
public MColor dustTint;
/// <summary>
/// Colour of the gas tail (the longer part)
/// </summary>
public MColor gasTint;
}
}

View File

@ -26,5 +26,7 @@ namespace NewHorizons.External.SerializableData
{
return new Vector3(vec.x, vec.y, vec.z);
}
public override string ToString() => $"{x}, {y}, {z}";
}
}

View File

@ -1,5 +1,5 @@
using NewHorizons.Builder.General;
using NewHorizons.Components;
using NewHorizons.Components.EyeOfTheUniverse;
using NewHorizons.Components.Stars;
using NewHorizons.External.SerializableData;
using NewHorizons.Utility;

View File

@ -52,15 +52,15 @@ namespace NewHorizons.Handlers
starController.Intensity = 0.9859f;
starController.SunColor = new Color(1f, 0.8845f, 0.6677f, 1f);
var starLightGO = GameObject.Instantiate(sun.GetComponentInChildren<SunLightController>().gameObject);
var starLightGO = UnityEngine.Object.Instantiate(sun.GetComponentInChildren<SunLightController>().gameObject);
foreach (var comp in starLightGO.GetComponents<Component>())
{
if (!(comp is SunLightController) && !(comp is SunLightParamUpdater) && !(comp is Light) && !(comp is Transform))
{
GameObject.Destroy(comp);
UnityEngine.Object.Destroy(comp);
}
}
GameObject.Destroy(starLightGO.GetComponent<Light>());
UnityEngine.Object.Destroy(starLightGO.GetComponent<Light>());
starLightGO.name = "StarLightController";
starLightGO.AddComponent<SunLightEffectsController>();
@ -599,9 +599,9 @@ namespace NewHorizons.Handlers
AsteroidBeltBuilder.Make(body.Config.name, body.Config, body.Mod);
}
if (body.Config.Base.hasCometTail)
if (body.Config.CometTail != null)
{
CometTailBuilder.Make(go, sector, body.Config);
CometTailBuilder.Make(go, sector, body.Config.CometTail, body.Config);
}
if (body.Config.Lava != null)
@ -715,7 +715,7 @@ namespace NewHorizons.Handlers
// We need these for later
var children = AstroObjectLocator.GetChildren(ao).Concat(AstroObjectLocator.GetMoons(ao)).ToArray();
AstroObjectLocator.DeregisterCustomAstroObject(ao);
GameObject.Destroy(ao);
UnityEngine.Object.Destroy(ao);
Locator.RegisterAstroObject(newAO);
AstroObjectLocator.RegisterCustomAstroObject(newAO);
@ -727,7 +727,7 @@ namespace NewHorizons.Handlers
// QM and stuff don't have orbit lines
var orbitLine = go.GetComponentInChildren<OrbitLine>()?.gameObject;
if (orbitLine != null) GameObject.Destroy(orbitLine);
if (orbitLine != null) UnityEngine.Object.Destroy(orbitLine);
var isMoon = newAO.GetAstroObjectType() is AstroObject.Type.Moon or AstroObject.Type.Satellite or AstroObject.Type.SpaceStation;
if (body.Config.Orbit.showOrbitLine) OrbitlineBuilder.Make(go, newAO, isMoon, body.Config);

View File

@ -107,7 +107,7 @@ namespace NewHorizons.Handlers
RemoveBody(AstroObjectLocator.GetAstroObject(AstroObject.Name.WhiteHole.ToString()), delete, toDestroy);
// Might prevent leftover fragments from existing
// Might also prevent people from using their own detachable fragments however
foreach(var fragment in GameObject.FindObjectsOfType<DetachableFragment>())
foreach(var fragment in UnityEngine.Object.FindObjectsOfType<DetachableFragment>())
{
DisableBody(fragment.gameObject, delete);
}
@ -120,7 +120,7 @@ namespace NewHorizons.Handlers
case AstroObject.Name.GiantsDeep:
// Might prevent leftover jellyfish from existing
// Might also prevent people from using their own jellyfish however
foreach (var jelly in GameObject.FindObjectsOfType<JellyfishController>())
foreach (var jelly in UnityEngine.Object.FindObjectsOfType<JellyfishController>())
{
DisableBody(jelly.gameObject, delete);
}
@ -131,11 +131,11 @@ namespace NewHorizons.Handlers
// Always just fucking kill this one to stop THE WARP BUG!!!
DisableBody(SearchUtilities.Find("StreamingGroup_TH"), true);
foreach (var obj in GameObject.FindObjectsOfType<DayNightTracker>())
foreach (var obj in UnityEngine.Object.FindObjectsOfType<DayNightTracker>())
{
DisableBody(obj.gameObject, true);
}
foreach (var obj in GameObject.FindObjectsOfType<VillageMusicVolume>())
foreach (var obj in UnityEngine.Object.FindObjectsOfType<VillageMusicVolume>())
{
DisableBody(obj.gameObject, true);
}
@ -144,27 +144,27 @@ namespace NewHorizons.Handlers
var starController = ao.gameObject.GetComponent<StarController>();
SunLightEffectsController.RemoveStar(starController);
SunLightEffectsController.RemoveStarLight(ao.transform.Find("Sector_SUN/Effects_SUN/SunLight").GetComponent<Light>());
GameObject.Destroy(starController);
UnityEngine.Object.Destroy(starController);
var audio = ao.GetComponentInChildren<SunSurfaceAudioController>();
GameObject.Destroy(audio);
UnityEngine.Object.Destroy(audio);
foreach (var owAudioSource in ao.GetComponentsInChildren<OWAudioSource>())
{
owAudioSource.Stop();
GameObject.Destroy(owAudioSource);
UnityEngine.Object.Destroy(owAudioSource);
}
foreach (var audioSource in ao.GetComponentsInChildren<AudioSource>())
{
audioSource.Stop();
GameObject.Destroy(audioSource);
UnityEngine.Object.Destroy(audioSource);
}
foreach (var sunProxy in GameObject.FindObjectsOfType<SunProxy>())
foreach (var sunProxy in UnityEngine.Object.FindObjectsOfType<SunProxy>())
{
NHLogger.LogVerbose($"Destroying SunProxy {sunProxy.gameObject.name}");
GameObject.Destroy(sunProxy.gameObject);
UnityEngine.Object.Destroy(sunProxy.gameObject);
}
// Stop the sun from breaking stuff when the supernova gets triggered
@ -203,7 +203,7 @@ namespace NewHorizons.Handlers
}
// Deal with proxies
foreach (var p in GameObject.FindObjectsOfType<ProxyOrbiter>())
foreach (var p in UnityEngine.Object.FindObjectsOfType<ProxyOrbiter>())
{
if (p._originalBody == ao.gameObject)
{
@ -215,18 +215,18 @@ namespace NewHorizons.Handlers
Delay.RunWhen(() => Main.IsSystemReady, () => DisableBody(ao.gameObject, delete));
foreach (ProxyBody proxy in GameObject.FindObjectsOfType<ProxyBody>())
foreach (ProxyBody proxy in UnityEngine.Object.FindObjectsOfType<ProxyBody>())
{
if (proxy?._realObjectTransform?.gameObject == ao.gameObject)
{
GameObject.Destroy(proxy.gameObject);
UnityEngine.Object.Destroy(proxy.gameObject);
}
}
}
public static void RemoveAllProxies()
{
GameObject.Destroy(GameObject.FindObjectOfType<DistantProxyManager>().gameObject);
UnityEngine.Object.Destroy(UnityEngine.Object.FindObjectOfType<DistantProxyManager>().gameObject);
foreach (var name in _solarSystemBodies)
{
@ -274,7 +274,7 @@ namespace NewHorizons.Handlers
if (delete)
{
GameObject.Destroy(go);
UnityEngine.Object.Destroy(go);
}
else
{
@ -294,8 +294,8 @@ namespace NewHorizons.Handlers
var distantProxy = SearchUtilities.Find(name + "_DistantProxy", false);
var distantProxyClone = SearchUtilities.Find(name + "_DistantProxy(Clone)", false);
if (distantProxy != null) GameObject.Destroy(distantProxy.gameObject);
if (distantProxyClone != null) GameObject.Destroy(distantProxyClone.gameObject);
if (distantProxy != null) UnityEngine.Object.Destroy(distantProxy.gameObject);
if (distantProxyClone != null) UnityEngine.Object.Destroy(distantProxyClone.gameObject);
if (distantProxy == null && distantProxyClone == null)
NHLogger.LogVerbose($"Couldn't find proxy for {name}");

View File

@ -35,7 +35,7 @@ namespace NewHorizons.Handlers
ShipLogStarChartMode = starChartLog.AddComponent<ShipLogStarChartMode>();
GameObject.Instantiate(reticleImage, starChartLog.transform);
Object.Instantiate(reticleImage, starChartLog.transform);
var scaleRoot = new GameObject("ScaleRoot");
scaleRoot.transform.parent = starChartLog.transform;

View File

@ -1,4 +1,4 @@
using NewHorizons.Components;
using NewHorizons.Components.Props;
using NewHorizons.Components.SizeControllers;
using System.Collections.Generic;
using UnityEngine;

View File

@ -156,11 +156,11 @@ namespace NewHorizons.Handlers
}
}
var pivot = GameObject.Instantiate(SearchUtilities.Find("Scene/Background/PlanetPivot"), SearchUtilities.Find("Scene/Background").transform);
var pivot = Object.Instantiate(SearchUtilities.Find("Scene/Background/PlanetPivot"), SearchUtilities.Find("Scene/Background").transform);
pivot.GetComponent<RotateTransform>()._degreesPerSecond = 10f;
foreach (Transform child in pivot.transform)
{
GameObject.Destroy(child.gameObject);
Object.Destroy(child.gameObject);
}
pivot.name = "Pivot";

View File

@ -1,11 +1,11 @@
using UnityEngine;
using NewHorizons.Components;
using NewHorizons.Utility;
using static NewHorizons.Main;
using NewHorizons.Builder.Props;
using NewHorizons.Utility.OWML;
using NewHorizons.Components;
using NewHorizons.Components.EyeOfTheUniverse;
using NewHorizons.Utility;
using NewHorizons.Utility.OuterWilds;
using NewHorizons.Utility.OWML;
using UnityEngine;
using static NewHorizons.Main;
namespace NewHorizons.Handlers
{
@ -20,7 +20,7 @@ namespace NewHorizons.Handlers
public static void Initialize()
{
VesselPrefab = Main.NHPrivateAssetBundle.LoadAsset<GameObject>("Vessel_Body");
VesselPrefab = NHPrivateAssetBundle.LoadAsset<GameObject>("Vessel_Body");
}
public static bool IsVesselPresentAndActive()
@ -61,7 +61,7 @@ namespace NewHorizons.Handlers
public static void TeleportToVessel()
{
var playerSpawner = GameObject.FindObjectOfType<PlayerSpawner>();
var playerSpawner = Object.FindObjectOfType<PlayerSpawner>();
playerSpawner.DebugWarp(_vesselSpawnPoint);
Builder.General.SpawnPointBuilder.SuitUp();
@ -109,34 +109,34 @@ namespace NewHorizons.Handlers
GameObject warpBH = WarpPlatform.transform.Find("BlackHole").gameObject;
GameObject warpWH = WarpPlatform.transform.Find("WhiteHole").gameObject;
GameObject sourceBH = GameObject.Instantiate(warpBH, vesselWarpController._sourceWarpPlatform.transform, false);
GameObject sourceBH = Object.Instantiate(warpBH, vesselWarpController._sourceWarpPlatform.transform, false);
sourceBH.name = "BlackHole";
vesselWarpController._sourceWarpPlatform._blackHole = sourceBH.GetComponentInChildren<SingularityController>();
vesselWarpController._sourceWarpPlatform._blackHole.OnCollapse += vesselWarpController._sourceWarpPlatform.OnBlackHoleCollapse;
GameObject sourceWH = GameObject.Instantiate(warpWH, vesselWarpController._sourceWarpPlatform.transform, false);
GameObject sourceWH = Object.Instantiate(warpWH, vesselWarpController._sourceWarpPlatform.transform, false);
sourceWH.name = "WhiteHole";
vesselWarpController._sourceWarpPlatform._whiteHole = sourceWH.GetComponentInChildren<SingularityController>();
vesselWarpController._sourceWarpPlatform._whiteHole.OnCollapse += vesselWarpController._sourceWarpPlatform.OnWhiteHoleCollapse;
GameObject targetBH = GameObject.Instantiate(warpBH, vesselWarpController._targetWarpPlatform.transform, false);
GameObject targetBH = Object.Instantiate(warpBH, vesselWarpController._targetWarpPlatform.transform, false);
targetBH.name = "BlackHole";
vesselWarpController._targetWarpPlatform._blackHole = targetBH.GetComponentInChildren<SingularityController>();
vesselWarpController._targetWarpPlatform._blackHole.OnCollapse += vesselWarpController._targetWarpPlatform.OnBlackHoleCollapse;
GameObject targetWH = GameObject.Instantiate(warpWH, vesselWarpController._targetWarpPlatform.transform, false);
GameObject targetWH = Object.Instantiate(warpWH, vesselWarpController._targetWarpPlatform.transform, false);
targetWH.name = "WhiteHole";
vesselWarpController._targetWarpPlatform._whiteHole = targetWH.GetComponentInChildren<SingularityController>();
vesselWarpController._targetWarpPlatform._whiteHole.OnCollapse += vesselWarpController._targetWarpPlatform.OnWhiteHoleCollapse;
GameObject blackHole = SearchUtilities.Find("DB_VesselDimension_Body/Sector_VesselDimension/Sector_VesselBridge/Interactibles_VesselBridge/BlackHole");
GameObject newBlackHole = GameObject.Instantiate(blackHole, Vector3.zero, Quaternion.identity, singularityRoot.transform);
GameObject newBlackHole = Object.Instantiate(blackHole, Vector3.zero, Quaternion.identity, singularityRoot.transform);
newBlackHole.name = "BlackHole";
vesselWarpController._blackHole = newBlackHole.GetComponentInChildren<SingularityController>();
vesselWarpController._blackHoleOneShot = vesselWarpController._blackHole.transform.parent.Find("BlackHoleAudio_OneShot").GetComponent<OWAudioSource>();
GameObject whiteHole = SearchUtilities.Find("DB_VesselDimension_Body/Sector_VesselDimension/Sector_VesselBridge/Interactibles_VesselBridge/WhiteHole");
GameObject newWhiteHole = GameObject.Instantiate(whiteHole, Vector3.zero, Quaternion.identity, singularityRoot.transform);
GameObject newWhiteHole = Object.Instantiate(whiteHole, Vector3.zero, Quaternion.identity, singularityRoot.transform);
newWhiteHole.name = "WhiteHole";
vesselWarpController._whiteHole = newWhiteHole.GetComponentInChildren<SingularityController>();
vesselWarpController._whiteHoleOneShot = vesselWarpController._whiteHole.transform.parent.Find("WhiteHoleAudio_OneShot").GetComponent<OWAudioSource>();
@ -154,14 +154,14 @@ namespace NewHorizons.Handlers
else
{
vesselAO._owRigidbody = null;
UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent<KinematicRigidbody>());
UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent<CenterOfTheUniverseOffsetApplier>());
UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent<OWRigidbody>());
UnityEngine.Object.DestroyImmediate(vesselObject.GetComponent<Rigidbody>());
Object.DestroyImmediate(vesselObject.GetComponent<KinematicRigidbody>());
Object.DestroyImmediate(vesselObject.GetComponent<CenterOfTheUniverseOffsetApplier>());
Object.DestroyImmediate(vesselObject.GetComponent<OWRigidbody>());
Object.DestroyImmediate(vesselObject.GetComponent<Rigidbody>());
var rfVolume = vesselObject.transform.Find("RFVolume");
if (rfVolume != null)
{
GameObject.Destroy(rfVolume.gameObject);
Object.Destroy(rfVolume.gameObject);
}
}
@ -181,7 +181,7 @@ namespace NewHorizons.Handlers
var zeroGVolume = vesselObject.transform.Find("Sector_VesselBridge/Volumes_VesselBridge/ZeroGVolume");
if (zeroGVolume != null)
{
GameObject.Destroy(zeroGVolume.gameObject);
Object.Destroy(zeroGVolume.gameObject);
}
}
@ -232,7 +232,7 @@ namespace NewHorizons.Handlers
{
if (core.GetWarpCoreType().Equals(WarpCoreType.Vessel))
{
var newCore = GameObject.Instantiate(core, AstroObjectLocator.GetAstroObject("Vessel Dimension")?.transform ?? Locator.GetPlayerBody()?.transform);
var newCore = Object.Instantiate(core, AstroObjectLocator.GetAstroObject("Vessel Dimension")?.transform ?? Locator.GetPlayerBody()?.transform);
newCore._visible = true;
foreach (OWRenderer render in newCore._renderers)
{

View File

@ -4,7 +4,6 @@ using NewHorizons.Builder.Body;
using NewHorizons.Builder.General;
using NewHorizons.Builder.Props;
using NewHorizons.Builder.Props.TranslatorText;
using NewHorizons.Components;
using NewHorizons.Components.Fixers;
using NewHorizons.Components.SizeControllers;
using NewHorizons.External;
@ -32,6 +31,7 @@ using UnityEngine.SceneManagement;
using NewHorizons.Utility.DebugTools;
using NewHorizons.Utility.DebugTools.Menu;
using NewHorizons.Components.Ship;
using NewHorizons.Builder.Props.Audio;
namespace NewHorizons
@ -332,7 +332,7 @@ namespace NewHorizons
{
TimeLoopUtilities.SetSecondsElapsed(SecondsElapsedInLoop);
// Prevent the OPC from firing
var launchController = GameObject.FindObjectOfType<OrbitalProbeLaunchController>();
var launchController = FindObjectOfType<OrbitalProbeLaunchController>();
if (launchController != null)
{
GlobalMessenger<int>.RemoveListener("StartOfTimeLoop", launchController.OnStartOfTimeLoop);
@ -386,7 +386,7 @@ namespace NewHorizons
if (isSolarSystem)
{
foreach (var supernovaPlanetEffectController in GameObject.FindObjectsOfType<SupernovaPlanetEffectController>())
foreach (var supernovaPlanetEffectController in FindObjectsOfType<SupernovaPlanetEffectController>())
{
SupernovaEffectBuilder.ReplaceVanillaWithNH(supernovaPlanetEffectController);
}
@ -417,7 +417,7 @@ namespace NewHorizons
IsWarpingFromVessel = false;
DidWarpFromVessel = shouldWarpInFromVessel;
var map = GameObject.FindObjectOfType<MapController>();
var map = FindObjectOfType<MapController>();
if (map != null) map._maxPanDistance = FurthestOrbit * 1.5f;
// Fix the map satellite
@ -499,7 +499,7 @@ namespace NewHorizons
var ssrLight = solarSystemRoot.AddComponent<Light>();
ssrLight.innerSpotAngle = 0;
ssrLight.spotAngle = 179;
ssrLight.range = Main.FurthestOrbit * (4f / 3f);
ssrLight.range = FurthestOrbit * (4f / 3f);
ssrLight.intensity = 0.001f;
var fluid = playerBody.FindChild("PlayerDetector").GetComponent<DynamicFluidDetector>();

View File

@ -1,4 +1,5 @@
using HarmonyLib;
using NewHorizons.Components.Sectored;
using NewHorizons.Handlers;
namespace NewHorizons.Patches.CameraPatches
@ -10,7 +11,7 @@ namespace NewHorizons.Patches.CameraPatches
[HarmonyPatch(nameof(ProbeCamera.HasInterference))]
public static void ProbeCamera_HasInterference(ProbeCamera __instance, ref bool __result)
{
__result = __result || (__instance._id != ProbeCamera.ID.PreLaunch && (Components.CloakSectorController.isPlayerInside != Components.CloakSectorController.isProbeInside || !InterferenceHandler.IsPlayerSameAsProbe()));
__result = __result || (__instance._id != ProbeCamera.ID.PreLaunch && (CloakSectorController.isPlayerInside != CloakSectorController.isProbeInside || !InterferenceHandler.IsPlayerSameAsProbe()));
}
}
}

View File

@ -1,7 +1,7 @@
using HarmonyLib;
using NewHorizons.Components;
using NewHorizons.OtherMods.AchievementsPlus.NH;
using NewHorizons.OtherMods.AchievementsPlus;
using NewHorizons.Components.Props;
namespace NewHorizons.Patches.DialoguePatches;

View File

@ -1,4 +1,5 @@
using HarmonyLib;
using NewHorizons.Components.Sectored;
namespace NewHorizons.Patches.EchoesOfTheEyePatches
{
@ -16,21 +17,21 @@ namespace NewHorizons.Patches.EchoesOfTheEyePatches
[HarmonyPatch(nameof(CloakFieldController.isPlayerInsideCloak), MethodType.Getter)]
public static void CloakFieldController_isPlayerInsideCloak(ref bool __result)
{
__result = __result || Components.CloakSectorController.isPlayerInside;
__result = __result || CloakSectorController.isPlayerInside;
}
[HarmonyPostfix]
[HarmonyPatch(nameof(CloakFieldController.isProbeInsideCloak), MethodType.Getter)]
public static void CloakFieldController_isProbeInsideCloak(ref bool __result)
{
__result = __result || Components.CloakSectorController.isProbeInside;
__result = __result || CloakSectorController.isProbeInside;
}
[HarmonyPostfix]
[HarmonyPatch(nameof(CloakFieldController.isShipInsideCloak), MethodType.Getter)]
public static void CloakFieldController_isShipInsideCloak(ref bool __result)
{
__result = __result || Components.CloakSectorController.isShipInside;
__result = __result || CloakSectorController.isShipInside;
}
}
}

View File

@ -1,4 +1,5 @@
using HarmonyLib;
using NewHorizons.Components.Sectored;
using NewHorizons.Handlers;
namespace NewHorizons.Patches.HUDPatches
@ -30,7 +31,7 @@ namespace NewHorizons.Patches.HUDPatches
bool insideQM = __instance._quantumMoon != null && (__instance._quantumMoon.IsPlayerInside() || __instance._quantumMoon.IsProbeInside());
bool insideRW = Locator.GetRingWorldController() != null && Locator.GetRingWorldController().isPlayerInside == Locator.GetRingWorldController().isProbeInside;
bool insideIP = Locator.GetCloakFieldController() != null && Locator.GetCloakFieldController().isPlayerInsideCloak == Locator.GetCloakFieldController().isProbeInsideCloak;
bool insideCloak = Components.CloakSectorController.isPlayerInside == Components.CloakSectorController.isProbeInside;
bool insideCloak = CloakSectorController.isPlayerInside == CloakSectorController.isProbeInside;
bool sameInterference = InterferenceHandler.IsPlayerSameAsProbe();
bool isActive = __instance.gameObject.activeInHierarchy || __instance._isTLCDuplicate;

View File

@ -1,4 +1,5 @@
using HarmonyLib;
using NewHorizons.Components.Sectored;
using NewHorizons.Handlers;
namespace NewHorizons.Patches.HUDPatches
@ -14,7 +15,7 @@ namespace NewHorizons.Patches.HUDPatches
bool insideQM = __instance._quantumMoon != null && (__instance._quantumMoon.IsPlayerInside() || __instance._quantumMoon.IsShipInside());
bool insideRW = Locator.GetRingWorldController() != null && Locator.GetRingWorldController().isPlayerInside;
bool insideIP = Locator.GetCloakFieldController() != null && Locator.GetCloakFieldController().isPlayerInsideCloak == Locator.GetCloakFieldController().isShipInsideCloak;
bool insideCloak = Components.CloakSectorController.isPlayerInside == Components.CloakSectorController.isShipInside;
bool insideCloak = CloakSectorController.isPlayerInside == CloakSectorController.isShipInside;
bool sameInterference = InterferenceHandler.IsPlayerSameAsShip();
__instance._isVisible = !insideEYE && !insideQM && !insideRW && !__instance._translatorEquipped && !__instance._inConversation && !__instance._shipDestroyed && !__instance._playerInShip && PlayerState.HasPlayerEnteredShip() && __instance._isWearingHelmet && insideIP && insideCloak && sameInterference;

View File

@ -1,4 +1,5 @@
using HarmonyLib;
using NewHorizons.Components.Sectored;
namespace NewHorizons.Patches.HUDPatches
{
@ -14,7 +15,7 @@ namespace NewHorizons.Patches.HUDPatches
bool insideQM = __instance._quantumMoon != null && __instance._quantumMoon.IsPlayerInside();
bool insideRW = Locator.GetRingWorldController() != null && Locator.GetRingWorldController().isPlayerInside && ShipLogEntryHUDMarker.s_entryLocationID == "IP_RING_WORLD";
bool insideIP = hasEntryLocation && ShipLogEntryHUDMarker.s_entryLocation.IsWithinCloakField() || !(Locator.GetCloakFieldController() != null && Locator.GetCloakFieldController().isPlayerInsideCloak);
bool insideCloak = hasEntryLocation && ShipLogEntryHUDMarker.s_entryLocation.IsWithinCloakField() || !Components.CloakSectorController.isPlayerInside;
bool insideCloak = hasEntryLocation && ShipLogEntryHUDMarker.s_entryLocation.IsWithinCloakField() || !CloakSectorController.isPlayerInside;
__instance._isVisible = !insideEYE && !insideQM && !insideRW && !__instance._translatorEquipped && !__instance._inConversation && hasEntryLocation && (__instance._isWearingHelmet || __instance._atFlightConsole) && insideIP && insideCloak;

View File

@ -18,6 +18,30 @@
"description": "Unique star system containing your planet. If you set this to be a custom solar system remember to add a Spawn module to one of the bodies, or else you can't get to the system.",
"default": "SolarSystem"
},
"isQuantumState": {
"type": "boolean",
"description": "Does this config describe a quantum state of a custom planet defined in another file?"
},
"isStellarRemnant": {
"type": "boolean",
"description": "Does this config describe a stellar remnant of a custom star defined in another file?"
},
"canShowOnTitle": {
"type": "boolean",
"description": "Should this planet ever be shown on the title screen?",
"default": true
},
"destroy": {
"type": "boolean",
"description": "`true` if you want to delete this planet"
},
"removeChildren": {
"type": "array",
"description": "A list of paths to child GameObjects to destroy on this planet",
"items": {
"type": "string"
}
},
"AmbientLights": {
"type": "array",
"description": "Add ambient lights to this body",
@ -41,19 +65,10 @@
"description": "Add bramble nodes to this planet and/or make this planet a bramble dimension",
"$ref": "#/definitions/BrambleModule"
},
"canShowOnTitle": {
"type": "boolean",
"description": "Should this planet ever be shown on the title screen?",
"default": true
},
"Cloak": {
"description": "Add a cloaking field to this planet",
"$ref": "#/definitions/CloakModule"
},
"destroy": {
"type": "boolean",
"description": "`true` if you want to delete this planet"
},
"FocalPoint": {
"description": "Make this body into a focal point (barycenter)",
"$ref": "#/definitions/FocalPointModule"
@ -66,14 +81,6 @@
"description": "Generate the surface of this planet using a heightmap",
"$ref": "#/definitions/HeightMapModule"
},
"isQuantumState": {
"type": "boolean",
"description": "Does this config describe a quantum state of a custom planet defined in another file?"
},
"isStellarRemnant": {
"type": "boolean",
"description": "Does this config describe a stellar remnant of a custom star defined in another file?"
},
"Lava": {
"description": "Add lava to this planet",
"$ref": "#/definitions/LavaModule"
@ -94,13 +101,6 @@
"description": "Reference frame properties of this body",
"$ref": "#/definitions/ReferenceFrameModule"
},
"removeChildren": {
"type": "array",
"description": "A list of paths to child GameObjects to destroy on this planet",
"items": {
"type": "string"
}
},
"Rings": {
"type": "array",
"description": "Create rings around the planet",
@ -136,6 +136,10 @@
"description": "Add various volumes on this body",
"$ref": "#/definitions/VolumesModule"
},
"CometTail": {
"description": "Add a comet tail to this body, like the Interloper",
"$ref": "#/definitions/CometTailModule"
},
"extras": {
"type": "object",
"description": "Extra data that may be used by extension mods",
@ -515,10 +519,6 @@
"type": "boolean",
"description": "Set this to true if you are replacing the sun with a different body. Only one object in a star system should ever\nhave this set to true."
},
"cometTailRotation": {
"description": "If it has a comet tail, it'll be oriented according to these Euler angles.",
"$ref": "#/definitions/MVector3"
},
"gravityFallOff": {
"description": "How gravity falls off with distance. Most planets use linear but the sun and some moons use inverseSquared.",
"default": "linear",
@ -529,10 +529,6 @@
"description": "Radius of a simple sphere used as the ground for the planet. If you want to use more complex terrain, leave this as\n0.",
"format": "float"
},
"hasCometTail": {
"type": "boolean",
"description": "If you want the body to have a tail like the Interloper."
},
"hasMapMarker": {
"type": "boolean",
"description": "If the body should have a marker on the map screen."
@ -4331,6 +4327,43 @@
"final",
"kazoo"
]
},
"CometTailModule": {
"type": "object",
"additionalProperties": false,
"properties": {
"curve": {
"type": "array",
"description": "Scale this object over time",
"items": {
"$ref": "#/definitions/TimeValuePair"
}
},
"rotationOverride": {
"description": "Manually sets the local rotation",
"$ref": "#/definitions/MVector3"
},
"innerRadius": {
"type": [
"null",
"number"
],
"description": "Inner radius of the comet tail, defaults to match surfaceSize",
"format": "float"
},
"primaryBody": {
"type": "string",
"description": "The body that the comet tail should always point away from"
},
"dustTint": {
"description": "Colour of the dust tail (the shorter part)",
"$ref": "#/definitions/MColor"
},
"gasTint": {
"description": "Colour of the gas tail (the longer part)",
"$ref": "#/definitions/MColor"
}
}
}
},
"$docs": {

View File

@ -80,13 +80,13 @@ namespace NewHorizons.Utility.DebugTools
var normText = Vector3ToString(data.norm);
var rotText = Vector3ToString(data.rot.eulerAngles);
if (_surfaceSphere != null) GameObject.Destroy(_surfaceSphere);
if (_normalSphere1 != null) GameObject.Destroy(_normalSphere1);
if (_normalSphere2 != null) GameObject.Destroy(_normalSphere2);
if (_planeUpRightSphere != null) GameObject.Destroy(_planeUpRightSphere);
if (_planeUpLeftSphere != null) GameObject.Destroy(_planeUpLeftSphere);
if (_planeDownLeftSphere != null) GameObject.Destroy(_planeDownLeftSphere);
if (_planeDownRightSphere != null) GameObject.Destroy(_planeDownRightSphere);
if (_surfaceSphere != null) Destroy(_surfaceSphere);
if (_normalSphere1 != null) Destroy(_normalSphere1);
if (_normalSphere2 != null) Destroy(_normalSphere2);
if (_planeUpRightSphere != null) Destroy(_planeUpRightSphere);
if (_planeUpLeftSphere != null) Destroy(_planeUpLeftSphere);
if (_planeDownLeftSphere != null) Destroy(_planeDownLeftSphere);
if (_planeDownRightSphere != null) Destroy(_planeDownRightSphere);
_surfaceSphere = AddDebugShape.AddSphere(data.hitBodyGameObject, 0.1f, Color.green);
_normalSphere1 = AddDebugShape.AddSphere(data.hitBodyGameObject, 0.01f, Color.red);

View File

@ -250,11 +250,11 @@ namespace NewHorizons.Utility
bool xCorrect = nomaiCoordinateInterface._nodeControllers[0].CheckCoordinate(coordinates.x);
bool yCorrect = nomaiCoordinateInterface._nodeControllers[1].CheckCoordinate(coordinates.y);
bool zCorrect = nomaiCoordinateInterface._nodeControllers[2].CheckCoordinate(coordinates.z);
OWML.NHLogger.LogVerbose($"Coordinate Check for {system}: {xCorrect}, {yCorrect}, {zCorrect} [{string.Join("-", coordinates.x)}, {string.Join("-", coordinates.y)}, {string.Join("-", coordinates.z)}]");
NHLogger.LogVerbose($"Coordinate Check for {system}: {xCorrect}, {yCorrect}, {zCorrect} [{string.Join("-", coordinates.x)}, {string.Join("-", coordinates.y)}, {string.Join("-", coordinates.z)}]");
return xCorrect && yCorrect && zCorrect;
}
public static FluidVolume.Type ConvertToOW(this NHFluidType fluidType, FluidVolume.Type @default = FluidVolume.Type.NONE)
public static FluidVolume.Type ConvertToOW(this NHFluidType fluidType, FluidVolume.Type @default = FluidVolume.Type.NONE)
=> EnumUtils.Parse(fluidType.ToString().ToUpper(), @default);
public static OWAudioMixer.TrackName ConvertToOW(this NHAudioMixerTrackName trackName, OWAudioMixer.TrackName @default = OWAudioMixer.TrackName.Environment)
@ -262,5 +262,20 @@ namespace NewHorizons.Utility
public static OWAudioSource.ClipSelectionOnPlay ConvertToOW(this NHClipSelectionType clipSelection, OWAudioSource.ClipSelectionOnPlay @default = OWAudioSource.ClipSelectionOnPlay.RANDOM)
=> EnumUtils.Parse(clipSelection.ToString().ToUpper(), @default);
public static void SmoothLookDir(this GameObject go, Vector3 direction, float dt, float angularVelocity)
{
var start = go.transform.rotation;
var end = Quaternion.FromToRotation(Vector3.forward, direction);
var angle = Quaternion.Angle(start, end);
go.transform.rotation = Quaternion.Slerp(start, end, (angularVelocity / angle) * dt);
}
public static void LookDir(this GameObject go, Vector3 direction)
{
go.transform.rotation = Quaternion.FromToRotation(Vector3.forward, direction);
}
}
}

View File

@ -13,16 +13,16 @@ namespace NewHorizons.Utility.OWML
_logLevel = newLevel;
}
private static void Log(string text, LogType type)
private static void Log(object text, LogType type)
{
if (type < _logLevel) return;
Main.Instance.ModHelper.Console.WriteLine($"{Enum.GetName(typeof(LogType), type)} : {text}", LogTypeToMessageType(type));
}
public static void LogVerbose(string text) => Log(text, LogType.Verbose);
public static void Log(string text) => Log(text, LogType.Log);
public static void LogWarning(string text) => Log(text, LogType.Warning);
public static void LogError(string text) => Log(text, LogType.Error);
public static void LogVerbose(object text) => Log(text, LogType.Verbose);
public static void Log(object text) => Log(text, LogType.Log);
public static void LogWarning(object text) => Log(text, LogType.Warning);
public static void LogError(object text) => Log(text, LogType.Error);
public enum LogType
{

View File

@ -15,7 +15,7 @@ namespace NewHorizons.Utility
}
for (var x = 0; x < count; x++)
{
var randomIndex = UnityEngine.Random.Range(0, numbersInOrder.Count);
var randomIndex = Random.Range(0, numbersInOrder.Count);
result[x] = numbersInOrder[randomIndex];
numbersInOrder.RemoveAt(randomIndex);
}

View File

@ -19,7 +19,7 @@ namespace NewHorizons.Utility
public static List<T> FindObjectsOfTypeAndName<T>(string name) where T : Object
{
T[] firstList = GameObject.FindObjectsOfType<T>();
T[] firstList = Object.FindObjectsOfType<T>();
List<T> finalList = new List<T>();
for (var i = 0; i < firstList.Length; i++)
@ -35,7 +35,7 @@ namespace NewHorizons.Utility
public static T FindObjectOfTypeAndName<T>(string name) where T : Object
{
T[] firstList = GameObject.FindObjectsOfType<T>();
T[] firstList = Object.FindObjectsOfType<T>();
for (var i = 0; i < firstList.Length; i++)
{