From 60dee93792cd7f95da236106f92d32ab85cf7f62 Mon Sep 17 00:00:00 2001 From: TerrificTrifid <99054745+TerrificTrifid@users.noreply.github.com> Date: Sat, 26 Nov 2022 15:01:44 -0600 Subject: [PATCH 1/2] Add vinePrefab option --- .../Builder/Body/BrambleDimensionBuilder.cs | 31 ++++++++++++++++--- NewHorizons/External/Modules/BrambleModule.cs | 23 +++++++++++--- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs index 85010cfe..ccaf5c89 100644 --- a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs +++ b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs @@ -51,7 +51,10 @@ namespace NewHorizons.Builder.Body private static GameObject _atmosphere; private static GameObject _volumes; private static GameObject _effects; - private static GameObject _geometry; + private static GameObject _hubGeometry; + private static GameObject _clusterGeometry; + private static GameObject _smallNestGeometry; + private static GameObject _exitOnlyGeometry; private static GameObject _exitWarps; private static GameObject _repelVolume; private static Material _material; @@ -68,7 +71,10 @@ namespace NewHorizons.Builder.Body if (_atmosphere == null) _atmosphere = SearchUtilities.Find("DB_HubDimension_Body/Sector_HubDimension/Atmosphere_HubDimension").InstantiateInactive().Rename("Prefab_Bramble_Atmosphere").DontDestroyOnLoad(); if (_volumes == null) _volumes = SearchUtilities.Find("DB_HubDimension_Body/Sector_HubDimension/Volumes_HubDimension").InstantiateInactive().Rename("Prefab_Bramble_Volumes").DontDestroyOnLoad(); if (_effects == null) _effects = SearchUtilities.Find("DB_HubDimension_Body/Sector_HubDimension/Effects_HubDimension").InstantiateInactive().Rename("Prefab_Bramble_Effects").DontDestroyOnLoad(); - if (_geometry == null) _geometry = SearchUtilities.Find("DB_HubDimension_Body/Sector_HubDimension/Geometry_HubDimension").InstantiateInactive().Rename("Prefab_Bramble_Geometry").DontDestroyOnLoad(); + if (_hubGeometry == null) _hubGeometry = SearchUtilities.Find("DB_HubDimension_Body/Sector_HubDimension/Geometry_HubDimension").InstantiateInactive().Rename("Prefab_Bramble_HubGeometry").DontDestroyOnLoad(); + if (_clusterGeometry == null) _clusterGeometry = SearchUtilities.Find("DB_ClusterDimension_Body/Sector_ClusterDimension/Geometry_ClusterDimension").InstantiateInactive().Rename("Prefab_Bramble_ClusterGeometry").DontDestroyOnLoad(); + if (_smallNestGeometry == null) _smallNestGeometry = SearchUtilities.Find("DB_SmallNest_Body/Sector_SmallNestDimension/Geometry_SmallNestDimension").InstantiateInactive().Rename("Prefab_Bramble_SmallNestGeometry").DontDestroyOnLoad(); + if (_exitOnlyGeometry == null) _exitOnlyGeometry = SearchUtilities.Find("DB_ExitOnlyDimension_Body/Sector_ExitOnlyDimension/Geometry_ExitOnlyDimension").InstantiateInactive().Rename("Prefab_Bramble_ExitOnlyGeometry").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 (_material == null) _material = new Material(GameObject.Find("DB_PioneerDimension_Body/Sector_PioneerDimension").GetComponent()._material).DontDestroyOnLoad(); @@ -88,8 +94,17 @@ namespace NewHorizons.Builder.Body var volumes = _volumes.InstantiateInactive(); var effects = _effects.InstantiateInactive(); + GameObject geometryPrefab; + switch (config.vinePrefab) + { + case VinePrefabType.Cluster: geometryPrefab = _clusterGeometry; break; + case VinePrefabType.SmallNest: geometryPrefab = _smallNestGeometry; break; + case VinePrefabType.ExitOnly: geometryPrefab = _exitOnlyGeometry; break; + default: geometryPrefab = _hubGeometry; break; + } + var detailInfo = new PropModule.DetailInfo(); - var geometry = DetailBuilder.Make(go, sector, _geometry, detailInfo); + var geometry = DetailBuilder.Make(go, sector, geometryPrefab, detailInfo); var exitWarps = _exitWarps.InstantiateInactive(); var repelVolume = _repelVolume.InstantiateInactive(); @@ -118,9 +133,9 @@ namespace NewHorizons.Builder.Body repelVolume.transform.parent = sector.transform; repelVolume.transform.localPosition = Vector3.zero; - // Replace batched collision with our own if removing vines - if (!config.hasVines) + if (config.vinePrefab == VinePrefabType.None) { + // Replace batched collision with our own if removing vines GameObject.Destroy(geometry.FindChild("BatchedGroup")); var geoOtherComponentsGroup = geometry.FindChild("OtherComponentsGroup"); var dimensionWalls = geoOtherComponentsGroup.FindChild("Terrain_DB_BrambleSphere_Outer_v2"); @@ -134,6 +149,11 @@ namespace NewHorizons.Builder.Body newCollider.transform.localScale = Vector3.one; newCollider.SetActive(true); } + else if (config.vinePrefab != VinePrefabType.Hub) + { + // Other stuff depends on Hub having this rotation + geometry.transform.rotation = Quaternion.Euler(new Vector3(43.5599f, 358.1138f, 24.2412f)); + } // fix some cull groups volumes.GetComponent()._sector = sector; @@ -191,6 +211,7 @@ namespace NewHorizons.Builder.Body // Set the scale var scale = config.radius / BASE_DIMENSION_RADIUS; geometry.transform.localScale = Vector3.one * scale; + if (config.vinePrefab is not VinePrefabType.None and not VinePrefabType.Hub) geometry.transform.localScale *= 1.5f; // other dimensions are 500 instead of 750 sector.gameObject.GetComponent().radius *= scale; outerFogWarpVolume._warpRadius *= scale; outerFogWarpVolume._exitRadius *= scale; diff --git a/NewHorizons/External/Modules/BrambleModule.cs b/NewHorizons/External/Modules/BrambleModule.cs index 407ad7bc..c3405e37 100644 --- a/NewHorizons/External/Modules/BrambleModule.cs +++ b/NewHorizons/External/Modules/BrambleModule.cs @@ -1,15 +1,30 @@ using NewHorizons.Utility; using Newtonsoft.Json; +using Newtonsoft.Json.Converters; using System; using System.Collections.Generic; using System.ComponentModel; +using System.Runtime.Serialization; using System.Linq; using System.Text; using System.Threading.Tasks; namespace NewHorizons.External.Modules { - + [JsonConverter(typeof(StringEnumConverter))] + public enum VinePrefabType + { + [EnumMember(Value = @"none")] None = 0, + + [EnumMember(Value = @"hub")] Hub = 1, + + [EnumMember(Value = @"cluster")] Cluster = 2, + + [EnumMember(Value = @"smallNest")] SmallNest = 3, + + [EnumMember(Value = @"exitOnly")] ExitOnly = 4 + } + [JsonObject] public class BrambleModule { @@ -50,10 +65,10 @@ namespace NewHorizons.External.Modules [DefaultValue(750f)] public float radius = 750f; /// - /// Whether this dimensions has vines. - /// Set to false if you want to create your own vines. + /// The dimension the vines will be copied from. + /// Only a handful are available due to batched colliders. /// - [DefaultValue(true)] public bool hasVines = true; + [DefaultValue("hub")] public VinePrefabType vinePrefab = VinePrefabType.Hub; /// /// 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. From 059beedca3bbf2206f49f9d45ab05647a05bd250 Mon Sep 17 00:00:00 2001 From: Ben C Date: Sat, 26 Nov 2022 21:03:46 +0000 Subject: [PATCH 2/2] Updated Schemas --- NewHorizons/Schemas/body_schema.json | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/NewHorizons/Schemas/body_schema.json b/NewHorizons/Schemas/body_schema.json index 66e70e23..03fedb7f 100644 --- a/NewHorizons/Schemas/body_schema.json +++ b/NewHorizons/Schemas/body_schema.json @@ -575,10 +575,10 @@ "format": "float", "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 + "vinePrefab": { + "description": "The dimension the vines will be copied from.\nOnly a handful are available due to batched colliders.", + "default": "hub", + "$ref": "#/definitions/VinePrefabType" }, "allowedEntrances": { "type": "array", @@ -590,6 +590,24 @@ } } }, + "VinePrefabType": { + "type": "string", + "description": "", + "x-enumNames": [ + "None", + "Hub", + "Cluster", + "SmallNest", + "ExitOnly" + ], + "enum": [ + "none", + "hub", + "cluster", + "smallNest", + "exitOnly" + ] + }, "BrambleNodeInfo": { "type": "object", "additionalProperties": false,