Bramble vine removal (#450)

Option to remove default vines using bundle for unbatched collider
This commit is contained in:
Will Corby 2022-11-25 16:05:45 -08:00 committed by GitHub
commit b05394bfb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 35 additions and 16 deletions

View File

@ -1,9 +1,9 @@
ManifestFileVersion: 0 ManifestFileVersion: 0
CRC: 1932961951 CRC: 2314570133
Hashes: Hashes:
AssetFileHash: AssetFileHash:
serializedVersion: 2 serializedVersion: 2
Hash: 79142e7d68648a06c0ed2fc15ebbac48 Hash: 73793e57d83c10dbd917c9f721a4e60e
TypeTreeHash: TypeTreeHash:
serializedVersion: 2 serializedVersion: 2
Hash: fae511e2df3c6c74353879b4753cf2eb Hash: fae511e2df3c6c74353879b4753cf2eb
@ -169,5 +169,6 @@ ClassTypes:
Script: {instanceID: 0} Script: {instanceID: 0}
SerializeReferenceClassIdentifiers: [] SerializeReferenceClassIdentifiers: []
Assets: Assets:
- Assets/BrambleCollision.prefab
- Assets/Vessel_Body.prefab - Assets/Vessel_Body.prefab
Dependencies: [] Dependencies: []

View File

@ -9,6 +9,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
using Logger = NewHorizons.Utility.Logger; using Logger = NewHorizons.Utility.Logger;
using static NewHorizons.Main;
namespace NewHorizons.Builder.Body namespace NewHorizons.Builder.Body
{ {
@ -54,6 +55,7 @@ namespace NewHorizons.Builder.Body
private static GameObject _exitWarps; private static GameObject _exitWarps;
private static GameObject _repelVolume; private static GameObject _repelVolume;
private static Material _material; private static Material _material;
private static GameObject _wallCollision;
private static bool _isInit; private static bool _isInit;
@ -70,6 +72,7 @@ namespace NewHorizons.Builder.Body
if (_exitWarps == null) _exitWarps = SearchUtilities.Find("DB_HubDimension_Body/Sector_HubDimension/Interactables_HubDimension/OuterWarp_Hub").InstantiateInactive().Rename("Prefab_Bramble_OuterWarp").DontDestroyOnLoad(); 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 (_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 (_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");
} }
public static GameObject Make(NewHorizonsBody body, GameObject go, NHAstroObject ao, Sector sector, OWRigidbody owRigidBody) public static GameObject Make(NewHorizonsBody body, GameObject go, NHAstroObject ao, Sector sector, OWRigidbody owRigidBody)
@ -115,18 +118,22 @@ namespace NewHorizons.Builder.Body
repelVolume.transform.parent = sector.transform; repelVolume.transform.parent = sector.transform;
repelVolume.transform.localPosition = Vector3.zero; repelVolume.transform.localPosition = Vector3.zero;
// TODO: Remove default vines (once we create an asset bundle version of the outer sphere that has collisions // Replace batched collision with our own if removing vines
/* if (!config.hasVines)
var geoBatchedGroup = geometry.FindChild("BatchedGroup"); {
var collider = geoBatchedGroup.FindChild("BatchedMeshColliders_0"); GameObject.Destroy(geometry.FindChild("BatchedGroup"));
collider.transform.parent = geometry.transform; var geoOtherComponentsGroup = geometry.FindChild("OtherComponentsGroup");
GameObject.Destroy(geoBatchedGroup); var dimensionWalls = geoOtherComponentsGroup.FindChild("Terrain_DB_BrambleSphere_Outer_v2");
dimensionWalls.transform.parent = geometry.transform;
GameObject.Destroy(geoOtherComponentsGroup);
var geoOtherComponentsGroup = geometry.FindChild("OtherComponentsGroup"); var newCollider = _wallCollision.InstantiateInactive();
var dimensionWalls = geoOtherComponentsGroup.FindChild("Terrain_DB_BrambleSphere_Outer_v2"); newCollider.transform.parent = dimensionWalls.transform;
dimensionWalls.transform.parent = geometry.transform; newCollider.transform.localPosition = Vector3.zero;
GameObject.Destroy(geoOtherComponentsGroup); newCollider.transform.localRotation = Quaternion.identity;
*/ newCollider.transform.localScale = Vector3.one;
newCollider.SetActive(true);
}
// fix some cull groups // fix some cull groups
volumes.GetComponent<SectorCollisionGroup>()._sector = sector; volumes.GetComponent<SectorCollisionGroup>()._sector = sector;

View File

@ -49,6 +49,12 @@ namespace NewHorizons.External.Modules
/// </summary> /// </summary>
[DefaultValue(750f)] public float radius = 750f; [DefaultValue(750f)] public float radius = 750f;
/// <summary>
/// Whether this dimensions has vines.
/// Set to false if you want to create your own vines.
/// </summary>
[DefaultValue(true)] public bool hasVines = true;
/// <summary> /// <summary>
/// An array of integers from 0-5. By default, all entrances are allowed. To force this dimension to warp players in from only one point (like the anglerfish nest dimension in the base game) set this value to [3], [5], or similar. Values of 0-5 only. /// An array of integers from 0-5. By default, all entrances are allowed. To force this dimension to warp players in from only one point (like the anglerfish nest dimension in the base game) set this value to [3], [5], or similar. Values of 0-5 only.
/// </summary> /// </summary>

View File

@ -12,7 +12,6 @@ namespace NewHorizons.Handlers
{ {
public static class VesselWarpHandler public static class VesselWarpHandler
{ {
public static AssetBundle VesselBundle { get; private set; }
public static GameObject VesselPrefab { get; private set; } public static GameObject VesselPrefab { get; private set; }
public static GameObject VesselObject { get; private set; } public static GameObject VesselObject { get; private set; }
public static VesselWarpController WarpController { get; private set; } public static VesselWarpController WarpController { get; private set; }
@ -22,8 +21,7 @@ namespace NewHorizons.Handlers
public static void Initialize() public static void Initialize()
{ {
VesselBundle = Instance.ModHelper.Assets.LoadBundle("Assets/newhorizons_private"); VesselPrefab = Main.NHPrivateAssetBundle.LoadAsset<GameObject>("Vessel_Body");
VesselPrefab = VesselBundle.LoadAsset<GameObject>("Vessel_Body");
} }
public static void LoadVessel() public static void LoadVessel()

View File

@ -37,6 +37,7 @@ namespace NewHorizons
public class Main : ModBehaviour public class Main : ModBehaviour
{ {
public static AssetBundle NHAssetBundle { get; private set; } public static AssetBundle NHAssetBundle { get; private set; }
public static AssetBundle NHPrivateAssetBundle { get; private set; }
public static Main Instance { get; private set; } public static Main Instance { get; private set; }
// Settings // Settings
@ -196,6 +197,7 @@ namespace NewHorizons
GlobalMessenger.AddListener("WakeUp", OnWakeUp); GlobalMessenger.AddListener("WakeUp", OnWakeUp);
NHAssetBundle = ModHelper.Assets.LoadBundle("Assets/newhorizons_public"); NHAssetBundle = ModHelper.Assets.LoadBundle("Assets/newhorizons_public");
NHPrivateAssetBundle = ModHelper.Assets.LoadBundle("Assets/newhorizons_private");
VesselWarpHandler.Initialize(); VesselWarpHandler.Initialize();
ResetConfigs(resetTranslation: false); ResetConfigs(resetTranslation: false);

View File

@ -575,6 +575,11 @@
"format": "float", "format": "float",
"default": 750.0 "default": 750.0
}, },
"hasVines": {
"type": "boolean",
"description": "Whether this dimensions has vines.\nSet to false if you want to create your own vines.",
"default": true
},
"allowedEntrances": { "allowedEntrances": {
"type": "array", "type": "array",
"description": "An array of integers from 0-5. By default, all entrances are allowed. To force this dimension to warp players in from only one point (like the anglerfish nest dimension in the base game) set this value to [3], [5], or similar. Values of 0-5 only.", "description": "An array of integers from 0-5. By default, all entrances are allowed. To force this dimension to warp players in from only one point (like the anglerfish nest dimension in the base game) set this value to [3], [5], or similar. Values of 0-5 only.",