Grapple totems

This commit is contained in:
Joshua Thome 2024-10-06 18:14:36 -05:00
parent 3855d26f39
commit 4876cf9ef8
4 changed files with 111 additions and 0 deletions

View File

@ -0,0 +1,66 @@
using NewHorizons.External.Modules.Props;
using NewHorizons.External.Modules.Props.EchoesOfTheEye;
using NewHorizons.Handlers;
using NewHorizons.Utility;
using NewHorizons.Utility.OWML;
using OWML.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace NewHorizons.Builder.Props.EchoesOfTheEye
{
public static class GrappleTotemBuilder
{
private static GameObject _prefab;
internal static void InitPrefab()
{
if (_prefab == null)
{
_prefab = SearchUtilities.Find("DreamWorld_Body/Sector_DreamWorld/Sector_DreamZone_4/Interactibles_DreamZone_4_Upper/Prefab_IP_GrappleTotem").InstantiateInactive().Rename("Prefab_GrappleTotem").DontDestroyOnLoad();
if (_prefab == null)
{
NHLogger.LogWarning($"Tried to make a grapple totem but couldn't. Do you have the DLC installed?");
return;
}
else
{
_prefab.AddComponent<DestroyOnDLC>()._destroyOnDLCNotOwned = true;
var zoomPoint = _prefab.GetComponentInChildren<LanternZoomPoint>();
zoomPoint._sector = null;
var sensor = _prefab.GetComponentInChildren<SingleLightSensor>();
sensor._sector = null;
}
}
}
public static GameObject Make(GameObject planetGO, Sector sector, GrappleTotemInfo info, IModBehaviour mod)
{
InitPrefab();
if (_prefab == null || sector == null) return null;
var totemObj = DetailBuilder.Make(planetGO, sector, mod, _prefab, new DetailInfo(info));
var zoomPoint = totemObj.GetComponentInChildren<LanternZoomPoint>();
zoomPoint._minActivationDistance = info.minDistance;
zoomPoint._arrivalDistance = info.arrivalDistance;
var sensor = totemObj.GetComponentInChildren<SingleLightSensor>();
sensor._detectionAngle = info.maxAngle;
sensor._maxDistance = info.maxDistance;
if (info.allowFlashlight)
{
sensor._detectFlashlight = true;
sensor._lightSourceMask |= LightSourceType.FLASHLIGHT;
}
return totemObj;
}
}
}

View File

@ -102,6 +102,7 @@ namespace NewHorizons.Builder.Props
// If a prop has set its parentPath and the parent cannot be found, add it to the next pass and try again later
nextPass = new List<Action>();
if (Main.HasDLC) MakeGeneralProps(go, config.Props.grappleTotems, (totem) => GrappleTotemBuilder.Make(go, sector, totem, mod));
if (Main.HasDLC) MakeGeneralProps(go, config.Props.dreamCampfires, (campfire) => DreamCampfireBuilder.Make(go, sector, campfire, mod), (campfire) => campfire.id);
if (Main.HasDLC) MakeGeneralProps(go, config.Props.dreamArrivalPoints, (point) => DreamArrivalPointBuilder.Make(go, sector, point, mod), (point) => point.id);
MakeGeneralProps(go, config.Props.gravityCannons, (cannon) => GravityCannonBuilder.Make(go, sector, cannon, mod), (cannon) => cannon.shuttleID);

View File

@ -133,6 +133,11 @@ namespace NewHorizons.External.Modules
/// </summary>
public DreamArrivalPointInfo[] dreamArrivalPoints;
/// <summary>
/// Adds dream world grapple totems to this planet.
/// </summary>
public GrappleTotemInfo[] grappleTotems;
[Obsolete("reveal is deprecated. Use Volumes->revealVolumes instead.")] public RevealVolumeInfo[] reveal;
[Obsolete("audioVolumes is deprecated. Use Volumes->audioVolumes instead.")] public AudioVolumeInfo[] audioVolumes;

View File

@ -0,0 +1,39 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NewHorizons.External.Modules.Props.EchoesOfTheEye
{
[JsonObject]
public class GrappleTotemInfo : GeneralPropInfo
{
/// <summary>
/// The minimum distance that the player must be from the grapple totem for it to activate.
/// </summary>
[DefaultValue(10f)] public float minDistance = 10f;
/// <summary>
/// The distance from the grapple totem that the player will stop at when it activates.
/// </summary>
[DefaultValue(4f)] public float arrivalDistance = 4f;
/// <summary>
/// The maximum angle in degrees allowed between the grapple totem's face and the player's lantern in order to activate the totem.
/// </summary>
[DefaultValue(45f)] public float maxAngle = 45f;
/// <summary>
/// The maximum distance allowed between the grapple totem's face and the player's lantern in order to activate the totem.
/// </summary>
[DefaultValue(29f)] public float maxDistance = 29f;
/// <summary>
/// Allows the grapple totem to be activated by the player's flashlight (when placed outside of the dream world). The player must still be holding an artifact, but it can be unlit.
/// </summary>
public bool allowFlashlight;
}
}