Alarm totems

This commit is contained in:
Joshua Thome 2024-10-07 21:54:35 -05:00
parent 4876cf9ef8
commit 4baf9b264e
4 changed files with 84 additions and 0 deletions

View File

@ -0,0 +1,54 @@
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 AlarmTotemBuilder
{
private static GameObject _prefab;
internal static void InitPrefab()
{
if (_prefab == null)
{
_prefab = SearchUtilities.Find("DreamWorld_Body/Sector_DreamWorld/Sector_Underground/IslandsRoot/IslandPivot_C/Island_C/Interactibles_Island_C/Prefab_IP_AlarmTotem").InstantiateInactive().Rename("Prefab_AlarmTotem").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 alarmTotem = _prefab.GetComponent<AlarmTotem>();
alarmTotem._sector = null;
}
}
}
public static GameObject Make(GameObject planetGO, Sector sector, AlarmTotemInfo info, IModBehaviour mod)
{
InitPrefab();
if (_prefab == null || sector == null) return null;
var totemObj = DetailBuilder.Make(planetGO, sector, mod, _prefab, new DetailInfo(info));
var alarmTotem = _prefab.GetComponent<AlarmTotem>();
alarmTotem._sightAngle = info.sightAngle;
alarmTotem._sightDistance = info.sightDistance;
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.alarmTotems, (totem) => AlarmTotemBuilder.Make(go, sector, totem, mod));
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);

View File

@ -138,6 +138,11 @@ namespace NewHorizons.External.Modules
/// </summary>
public GrappleTotemInfo[] grappleTotems;
/// <summary>
/// Adds dream world alarm totems to this planet.
/// </summary>
public AlarmTotemInfo[] alarmTotems;
[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,24 @@
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 AlarmTotemInfo : GeneralPropInfo
{
/// <summary>
/// The maximum distance of the alarm's "vision cone".
/// </summary>
[DefaultValue(45f)] public float sightDistance = 45;
/// <summary>
/// The width of the alarm's "vision cone" in degrees.
/// </summary>
[DefaultValue(60f)] public float sightAngle = 60f;
}
}