diff --git a/NewHorizons/Builder/Props/EchoesOfTheEye/AlarmTotemBuilder.cs b/NewHorizons/Builder/Props/EchoesOfTheEye/AlarmTotemBuilder.cs new file mode 100644 index 00000000..245127bb --- /dev/null +++ b/NewHorizons/Builder/Props/EchoesOfTheEye/AlarmTotemBuilder.cs @@ -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()._destroyOnDLCNotOwned = true; + var alarmTotem = _prefab.GetComponent(); + 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._sightAngle = info.sightAngle; + alarmTotem._sightDistance = info.sightDistance; + + return totemObj; + } + } +} diff --git a/NewHorizons/Builder/Props/PropBuildManager.cs b/NewHorizons/Builder/Props/PropBuildManager.cs index e600841d..cb8be189 100644 --- a/NewHorizons/Builder/Props/PropBuildManager.cs +++ b/NewHorizons/Builder/Props/PropBuildManager.cs @@ -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(); + 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); diff --git a/NewHorizons/External/Modules/PropModule.cs b/NewHorizons/External/Modules/PropModule.cs index e717ef3e..539d0bed 100644 --- a/NewHorizons/External/Modules/PropModule.cs +++ b/NewHorizons/External/Modules/PropModule.cs @@ -138,6 +138,11 @@ namespace NewHorizons.External.Modules /// public GrappleTotemInfo[] grappleTotems; + /// + /// Adds dream world alarm totems to this planet. + /// + 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; diff --git a/NewHorizons/External/Modules/Props/EchoesOfTheEye/AlarmTotemInfo.cs b/NewHorizons/External/Modules/Props/EchoesOfTheEye/AlarmTotemInfo.cs new file mode 100644 index 00000000..cc902dbf --- /dev/null +++ b/NewHorizons/External/Modules/Props/EchoesOfTheEye/AlarmTotemInfo.cs @@ -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 + { + /// + /// The maximum distance of the alarm's "vision cone". + /// + [DefaultValue(45f)] public float sightDistance = 45; + + /// + /// The width of the alarm's "vision cone" in degrees. + /// + [DefaultValue(60f)] public float sightAngle = 60f; + } +}