Skip to content

Commit

Permalink
Merge branch 'dev' into coloured-splashes
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaPiggy committed Jan 12, 2025
2 parents 484af14 + e397d62 commit 6dc6c03
Show file tree
Hide file tree
Showing 109 changed files with 8,409 additions and 7,060 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
ManifestFileVersion: 0
CRC: 2356174904
CRC: 2772415118
Hashes:
AssetFileHash:
serializedVersion: 2
Hash: c9b4a60ca4efa0ba50065dea6e758ce7
Hash: a1c50cfbd83ea025ed5ff8a920ceb135
TypeTreeHash:
serializedVersion: 2
Hash: 65942a71d50cdc9f2387a8fa9383a3f8
Hash: 8a96558a3d9470a68866aeaaa30830cf
HashAppended: 0
ClassTypes:
- Class: 1
Expand Down Expand Up @@ -87,6 +87,8 @@ ClassTypes:
Script: {fileID: 11500000, guid: 13ab18a571ddf1b4f8dc92e3fa31b22e, type: 3}
- Class: 114
Script: {fileID: 11500000, guid: 3d5c87c5a00ca19449219c7c54f41ee7, type: 3}
- Class: 114
Script: {fileID: 11500000, guid: db82bd26294f5b848aaa8cb1ad0dc252, type: 3}
- Class: 114
Script: {fileID: 11500000, guid: 840ab63696e59254eb425242136805dd, type: 3}
- Class: 114
Expand Down Expand Up @@ -198,5 +200,6 @@ Assets:
- Assets/SlideReels/Prefab_DW_Reel_8.prefab
- Assets/Vessel_Body.prefab
- Assets/AmbientLight_QM.png
- Assets/QuantumLightning/Prefab_EYE_QuantumLightningObject.prefab
- Assets/SlideReels/Prefab_IP_Reel_7.prefab
Dependencies: []
File renamed without changes.
2 changes: 1 addition & 1 deletion NewHorizons/Builder/Atmosphere/CloudsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ internal static void InitPrefabs()
}
_qmBottomMeshGroup.variants = variants.ToArray();
}
if (_transparentCloud == null) _transparentCloud = Main.NHAssetBundle.LoadAsset<Material>("Assets/Resources/TransparentCloud.mat");
if (_transparentCloud == null) _transparentCloud = AssetBundleUtilities.NHAssetBundle.LoadAsset<Material>("Assets/Resources/TransparentCloud.mat");
}

public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atmo, bool cloaked, IModBehaviour mod)
Expand Down
37 changes: 28 additions & 9 deletions NewHorizons/Builder/Body/AsteroidBeltBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using NewHorizons.External;
using NewHorizons.External.Configs;
using NewHorizons.External.Modules;
using NewHorizons.External.Modules.Props;
using NewHorizons.External.SerializableData;
using NewHorizons.Handlers;
using NewHorizons.Utility.OWML;
Expand Down Expand Up @@ -36,7 +37,7 @@ public static void Make(string bodyName, PlanetConfig parentConfig, IModBehaviou

config.Base = new BaseModule()
{
surfaceGravity = 1,
surfaceGravity = belt.gravity,
surfaceSize = size,
gravityFallOff = GravityFallOff.InverseSquared
};
Expand All @@ -49,7 +50,8 @@ public static void Make(string bodyName, PlanetConfig parentConfig, IModBehaviou
trueAnomaly = 360f * (i + Random.Range(-0.2f, 0.2f)) / (float)count,
primaryBody = bodyName,
semiMajorAxis = Random.Range(belt.innerRadius, belt.outerRadius),
showOrbitLine = false
showOrbitLine = false,
isTidallyLocked = true
};

config.ReferenceFrame = new ReferenceFrameModule()
Expand All @@ -62,20 +64,37 @@ public static void Make(string bodyName, PlanetConfig parentConfig, IModBehaviou
enabled = false
};

config.ProcGen = belt.procGen;
if (config.ProcGen == null)
if (!string.IsNullOrEmpty(belt.assetBundle) || !string.IsNullOrEmpty(belt.path))
{
config.ProcGen = new ProcGenModule()
config.Props = new PropModule()
{
scale = size,
color = new MColor(126, 94, 73)
details = new DetailInfo[1]
{
new DetailInfo()
{
assetBundle = belt.assetBundle,
path = belt.path,
scale = size,
rotation = belt.randomOrientation ? Random.rotation.eulerAngles : Vector3.zero,
keepLoaded = true
}
}
};

}
else
else if (belt.procGen != null)
{
// Still update the size
config.ProcGen = belt.procGen;
config.ProcGen.scale = size;
}
else
{
config.ProcGen = new ProcGenModule()
{
scale = size,
color = new MColor(126, 94, 73)
};
}

var asteroid = new NewHorizonsBody(config, mod);
PlanetCreationHandler.GenerateBody(asteroid);
Expand Down
3 changes: 2 additions & 1 deletion NewHorizons/Builder/Body/BrambleDimensionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using NewHorizons.External.Modules;
using NewHorizons.External.Modules.Props;
using NewHorizons.Utility;
using NewHorizons.Utility.Files;
using NewHorizons.Utility.OWML;
using OWML.Common;
using System.Collections.Generic;
Expand Down Expand Up @@ -78,7 +79,7 @@ internal static void InitPrefabs()
if (_exitWarps == null) _exitWarps = SearchUtilities.Find("DB_HubDimension_Body/Sector_HubDimension/Interactables_HubDimension/OuterWarp_Hub").InstantiateInactive().Rename("Prefab_Bramble_OuterWarp").DontDestroyOnLoad();
if (_repelVolume == null) _repelVolume = SearchUtilities.Find("DB_HubDimension_Body/BrambleRepelVolume").InstantiateInactive().Rename("Prefab_Bramble_RepelVolume").DontDestroyOnLoad();
if (_material == null) _material = new Material(GameObject.Find("DB_PioneerDimension_Body/Sector_PioneerDimension").GetComponent<EffectRuleset>()._material).DontDestroyOnLoad();
if (_wallCollision == null) _wallCollision = Main.NHPrivateAssetBundle.LoadAsset<GameObject>("BrambleCollision");
if (_wallCollision == null) _wallCollision = AssetBundleUtilities.NHPrivateAssetBundle.LoadAsset<GameObject>("BrambleCollision");
}

public static GameObject Make(NewHorizonsBody body, GameObject go, NHAstroObject ao, Sector sector, IModBehaviour mod, OWRigidbody owRigidBody)
Expand Down
9 changes: 5 additions & 4 deletions NewHorizons/Builder/Body/HeightMapBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static GameObject Make(GameObject planetGO, Sector sector, HeightMapModul
cubeSphere.SetActive(false);
cubeSphere.transform.SetParent(sector?.transform ?? planetGO.transform, false);

if (PlanetShader == null) PlanetShader = Main.NHAssetBundle.LoadAsset<Shader>("Assets/Shaders/SphereTextureWrapperTriplanar.shader");
if (PlanetShader == null) PlanetShader = AssetBundleUtilities.NHAssetBundle.LoadAsset<Shader>("Assets/Shaders/SphereTextureWrapperTriplanar.shader");

var stretch = module.stretch != null ? (Vector3)module.stretch : Vector3.one;

Expand Down Expand Up @@ -91,14 +91,15 @@ public static GameObject Make(GameObject planetGO, Sector sector, HeightMapModul
level2.name += "1";

LODGroup.RecalculateBounds();

// do this only for LOD because only the main body uses LOD, while title screen and proxies dont
var superGroup = planetGO.GetComponent<ProxyShadowCasterSuperGroup>();
if (superGroup != null) level2.gameObject.AddComponent<ProxyShadowCaster>()._superGroup = superGroup;
}

var cubeSphereSC = cubeSphere.AddComponent<SphereCollider>();
cubeSphereSC.radius = Mathf.Min(module.minHeight, module.maxHeight) * Mathf.Min(stretch.x, stretch.y, stretch.z);

var superGroup = planetGO.GetComponent<ProxyShadowCasterSuperGroup>();
if (superGroup != null) cubeSphere.AddComponent<ProxyShadowCaster>()._superGroup = superGroup;

cubeSphere.SetActive(true);

// Now that we've made the mesh we can delete the heightmap texture
Expand Down
8 changes: 4 additions & 4 deletions NewHorizons/Builder/Body/RingBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ public static GameObject MakeRingGraphics(GameObject rootObject, Sector sector,
var ringMesh = ringMF.mesh;
var ringMR = ringGO.AddComponent<MeshRenderer>();

if (RingShader == null) RingShader = Main.NHAssetBundle.LoadAsset<Shader>("Assets/Shaders/Ring.shader");
if (UnlitRingShader == null) UnlitRingShader = Main.NHAssetBundle.LoadAsset<Shader>("Assets/Shaders/UnlitTransparent.shader");
if (RingShader1Pixel == null) RingShader1Pixel = Main.NHAssetBundle.LoadAsset<Shader>("Assets/Shaders/Ring1Pixel.shader");
if (UnlitRingShader1Pixel == null) UnlitRingShader1Pixel = Main.NHAssetBundle.LoadAsset<Shader>("Assets/Shaders/UnlitRing1Pixel.shader");
if (RingShader == null) RingShader = AssetBundleUtilities.NHAssetBundle.LoadAsset<Shader>("Assets/Shaders/Ring.shader");
if (UnlitRingShader == null) UnlitRingShader = AssetBundleUtilities.NHAssetBundle.LoadAsset<Shader>("Assets/Shaders/UnlitTransparent.shader");
if (RingShader1Pixel == null) RingShader1Pixel = AssetBundleUtilities.NHAssetBundle.LoadAsset<Shader>("Assets/Shaders/Ring1Pixel.shader");
if (UnlitRingShader1Pixel == null) UnlitRingShader1Pixel = AssetBundleUtilities.NHAssetBundle.LoadAsset<Shader>("Assets/Shaders/UnlitRing1Pixel.shader");

var mat = new Material(ring.unlit ? UnlitRingShader : RingShader);
if (ringTexture.width == 1)
Expand Down
1 change: 1 addition & 0 deletions NewHorizons/Builder/Body/StellarRemnantBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public static GameObject Make(GameObject go, OWRigidbody rb, float soi, IModBeha
NHLogger.Log($"Creating stellar remnant for [{star.Config.name}]");

var sector = SectorBuilder.Make(go, rb, soi);
sector._idString = star.Config.name;
sector.name = "StellarRemnant";

sector.gameObject.SetActive(false);
Expand Down
2 changes: 1 addition & 1 deletion NewHorizons/Builder/General/AmbientLightBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static Light Make(GameObject planetGO, Sector sector, AmbientLightModule
}
else
{
var baseCubemap = Main.NHPrivateAssetBundle.LoadAsset<Cubemap>("AmbientLight_QM");
var baseCubemap = AssetBundleUtilities.NHPrivateAssetBundle.LoadAsset<Cubemap>("AmbientLight_QM");
var cubemap = new Cubemap(baseCubemap.width, baseCubemap.format, baseCubemap.mipmapCount != 1);
cubemap.name = key;
cubemap.wrapMode = baseCubemap.wrapMode;
Expand Down
11 changes: 6 additions & 5 deletions NewHorizons/Builder/General/GravityBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ public static GravityVolume Make(GameObject planetGO, AstroObject ao, OWRigidbod
var gravityRadius = GM / 0.1f;
if (exponent == 2f) gravityRadius = Mathf.Sqrt(gravityRadius);

if (config.FocalPoint != null) gravityRadius = 0; // keep it at the lowest possible
else if (config.Base.soiOverride != 0f) gravityRadius = config.Base.soiOverride;
else if (config.Star != null) gravityRadius = Mathf.Min(gravityRadius, 15 * config.Base.surfaceSize);
// To let you actually orbit things the way you would expect we cap this at 4x the diameter if its not a star (this is what giants deep has)
if (config.Star == null) gravityRadius = Mathf.Min(gravityRadius, 4 * config.Base.surfaceSize);
else gravityRadius = Mathf.Min(gravityRadius, 15 * config.Base.surfaceSize);
if (config.Base.soiOverride != 0f) gravityRadius = config.Base.soiOverride;
else gravityRadius = Mathf.Min(gravityRadius, 4 * config.Base.surfaceSize);

var gravityGO = new GameObject("GravityWell");
gravityGO.transform.parent = planetGO.transform;
Expand Down Expand Up @@ -47,8 +48,8 @@ public static GravityVolume Make(GameObject planetGO, AstroObject ao, OWRigidbod
var alignmentRadius = config.Atmosphere?.clouds?.outerCloudRadius ?? 1.5f * config.Base.surfaceSize;
if (config.Base.surfaceGravity == 0) alignmentRadius = 0;

gravityVolume._alignmentRadius = alignmentRadius;
gravityVolume._upperSurfaceRadius = config.Base.surfaceSize;
gravityVolume._alignmentRadius = config.Base.gravityAlignmentRadiusOverride ?? alignmentRadius;
gravityVolume._upperSurfaceRadius = config.FocalPoint != null ? 0 : config.Base.surfaceSize;
gravityVolume._lowerSurfaceRadius = 0;
gravityVolume._layer = 3;
gravityVolume._priority = config.Base.gravityVolumePriority;
Expand Down
15 changes: 14 additions & 1 deletion NewHorizons/Builder/General/SpawnPointBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,20 @@ public static SpawnPoint Make(GameObject planetGO, SpawnModule module, OWRigidbo
// This was a stupid hack to stop players getting stuck in the ground and now we have to keep it forever
spawnGO.transform.position += spawnGO.transform.TransformDirection(point.offset ?? Vector3.up * 4f);

if (PlayerSpawn == null || point.GetPriority() > PlayerSpawnInfo.GetPriority())
var flagUseTHSpawn = false;
if (Main.Instance.CurrentStarSystem == "SolarSystem")
{
// When in the base solar system, treat the TH spawn point as being isDefault
// If the priority of any new spawn point is less than that, ignore it
// Do take them if they're equal tho
var minPriority = new SpawnModule.PlayerSpawnPoint() { isDefault = true }.GetPriority();
if (point.GetPriority() < minPriority)
{
flagUseTHSpawn = true;
}
}

if (!flagUseTHSpawn && (PlayerSpawn == null || point.GetPriority() > PlayerSpawnInfo.GetPriority()))
{
PlayerSpawn = playerSpawn;
PlayerSpawnInfo = point;
Expand Down
11 changes: 6 additions & 5 deletions NewHorizons/Builder/Orbital/FocalPointBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ public static void ValidateConfig(PlanetConfig config)
config.Base.surfaceGravity = gravitationalMass * GravityVolume.GRAVITATIONAL_CONSTANT;
config.Base.gravityFallOff = primary.Config.Base.gravityFallOff;

// Other stuff to make the barycenter not interact with anything in any way
config.Base.soiOverride = 0;

var separation = primary.Config.Orbit.semiMajorAxis + secondary.Config.Orbit.semiMajorAxis;
config.ReferenceFrame.bracketRadius = separation;
config.ReferenceFrame.targetColliderRadius = separation;
var separationRadius = (separation / 2);
config.Base.soiOverride = separationRadius * 1.5f;
config.ReferenceFrame.bracketRadius = separationRadius;
config.ReferenceFrame.targetColliderRadius = separationRadius;

config.Base.showMinimap = false;
}

private static float GetGravitationalMass(PlanetConfig config)
Expand Down
10 changes: 9 additions & 1 deletion NewHorizons/Builder/Props/Audio/SignalBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,15 @@ public static GameObject Make(GameObject planetGO, Sector sector, SignalInfo inf
audioSignal._onlyAudibleToScope = info.onlyAudibleToScope;
audioSignal._identificationDistance = info.identificationRadius;
audioSignal._canBePickedUpByScope = true;
audioSignal._outerFogWarpVolume = planetGO.GetComponentInChildren<OuterFogWarpVolume>(); // shouldn't break non-bramble signals
// The outsider adds outer fog warp volumes to Bramble which break any signals NH places there
if (Main.Instance.ModHelper.Interaction.ModExists("SBtT.TheOutsider") && planetGO?.GetComponent<AstroObject>()?._name == AstroObject.Name.DarkBramble)
{
audioSignal._outerFogWarpVolume = null;
}
else
{
audioSignal._outerFogWarpVolume = planetGO.GetComponentInChildren<OuterFogWarpVolume>(); // shouldn't break non-bramble signals
}

// If it can be heard regularly then we play it immediately
owAudioSource.playOnAwake = !info.onlyAudibleToScope;
Expand Down
44 changes: 28 additions & 16 deletions NewHorizons/Builder/Props/DetailBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,23 @@ namespace NewHorizons.Builder.Props
{
public static class DetailBuilder
{
private static readonly Dictionary<DetailInfo, GameObject> _detailInfoToCorrespondingSpawnedGameObject = new();
private static readonly Dictionary<(Sector, string), (GameObject prefab, bool isItem)> _fixedPrefabCache = new();
private static GameObject _emptyPrefab;

private static readonly Dictionary<DetailInfo, GameObject> _detailInfoToGameObject = new();

public static GameObject GetGameObjectFromDetailInfo(DetailInfo info)
{
if (_detailInfoToGameObject.ContainsKey(info))
{
return _detailInfoToGameObject[info];
}
else
{
return null;
}
}

static DetailBuilder()
{
SceneManager.sceneUnloaded += SceneManager_sceneUnloaded;
Expand All @@ -48,19 +61,7 @@ private static void SceneManager_sceneUnloaded(Scene scene)
UnityEngine.Object.Destroy(prefab.prefab);
}
_fixedPrefabCache.Clear();
_detailInfoToCorrespondingSpawnedGameObject.Clear();
}

public static GameObject GetSpawnedGameObjectByDetailInfo(DetailInfo detail)
{
if (!_detailInfoToCorrespondingSpawnedGameObject.ContainsKey(detail))
{
return null;
}
else
{
return _detailInfoToCorrespondingSpawnedGameObject[detail];
}
_detailInfoToGameObject.Clear();
}

/// <summary>
Expand Down Expand Up @@ -274,7 +275,8 @@ public static GameObject Make(GameObject go, Sector sector, IModBehaviour mod, G

// For DLC related props
// Make sure to do this before its set active
if (detail.path.ToLowerInvariant().StartsWith("ringworld") || detail.path.ToLowerInvariant().StartsWith("dreamworld"))
if (!string.IsNullOrEmpty(detail?.path) &&
(detail.path.ToLowerInvariant().StartsWith("ringworld") || detail.path.ToLowerInvariant().StartsWith("dreamworld")))
{
prop.AddComponent<DestroyOnDLC>()._destroyOnDLCNotOwned = true;
}
Expand All @@ -299,7 +301,7 @@ public static GameObject Make(GameObject go, Sector sector, IModBehaviour mod, G
ConditionalObjectActivation.SetUp(prop, detail.deactivationCondition, detail.blinkWhenActiveChanged, false);
}

_detailInfoToCorrespondingSpawnedGameObject[detail] = prop;
_detailInfoToGameObject[detail] = prop;

return prop;
}
Expand Down Expand Up @@ -339,6 +341,16 @@ private static void FixSectoredComponent(Component component, Sector sector, Has
{
remoteCameraPlatform._visualSector = sector;
}

else if(component is SingleLightSensor singleLightSensor && !existingSectors.Contains(singleLightSensor._sector))
{
if (singleLightSensor._sector != null)
{
singleLightSensor._sector.OnSectorOccupantsUpdated -= singleLightSensor.OnSectorOccupantsUpdated;
}
singleLightSensor._sector = sector;
singleLightSensor._sector.OnSectorOccupantsUpdated += singleLightSensor.OnSectorOccupantsUpdated;
}
}

/// <summary>
Expand Down
Loading

0 comments on commit 6dc6c03

Please sign in to comment.