Add vinePrefab option

This commit is contained in:
TerrificTrifid 2022-11-26 15:01:44 -06:00
parent 041e915fa5
commit 60dee93792
2 changed files with 45 additions and 9 deletions

View File

@ -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<EffectRuleset>()._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<SectorCollisionGroup>()._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<SphereShape>().radius *= scale;
outerFogWarpVolume._warpRadius *= scale;
outerFogWarpVolume._exitRadius *= scale;

View File

@ -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;
/// <summary>
/// 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.
/// </summary>
[DefaultValue(true)] public bool hasVines = true;
[DefaultValue("hub")] public VinePrefabType vinePrefab = VinePrefabType.Hub;
/// <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.