From 2714a211556b82766a4dbaa5d89c7e273ac01831 Mon Sep 17 00:00:00 2001 From: Govorunb Date: Mon, 11 Dec 2023 00:03:25 +1100 Subject: [PATCH] add ency journal spawns todo positions todo SN --- SCHIZO/Items/CustomPDAVoicedEncy.cs | 66 +++++++++++++++++++ .../Mod/Neuro logs/Hate Vedal/PDA Log.asset | 8 ++- .../Mod/Neuro logs/Love Vedal/PDA Log.asset | 11 ++-- .../SCHIZO/Items/CustomPDAVoicedEncy.cs | 4 ++ 4 files changed, 82 insertions(+), 7 deletions(-) diff --git a/SCHIZO/Items/CustomPDAVoicedEncy.cs b/SCHIZO/Items/CustomPDAVoicedEncy.cs index e5f5c47d..bcb08386 100644 --- a/SCHIZO/Items/CustomPDAVoicedEncy.cs +++ b/SCHIZO/Items/CustomPDAVoicedEncy.cs @@ -1,4 +1,10 @@ +using System.Collections.Generic; +using System.Linq; using HarmonyLib; +using Nautilus.Assets; +using Nautilus.Assets.PrefabTemplates; +using Nautilus.Handlers; +using SCHIZO.Helpers; namespace SCHIZO.Items; @@ -9,5 +15,65 @@ protected override void Register() { encyData.Register(key); Subtitles.SubtitlesHandler.RegisterMetadata(subtitles, encyData.description.text); + JournalPDAPrefab.Register(this); + } + + private sealed class JournalPDAPrefab + { + private const string BZ_JOURNAL_PDA_CLASSID = "1c7d135c-79f1-4b7a-9528-20c0570df824"; + private static string CloneTargetClassId => RetargetHelpers.Pick("TODO", BZ_JOURNAL_PDA_CLASSID); + internal static Dictionary Prefabs = []; + + public CustomPrefab NautilusPrefab { get; } + public CloneTemplate CloneTemplate { get; } + public PrefabInfo Info { get; } + private JournalPDAPrefab(CustomPDAVoicedEncy ency) + { + Info = new PrefabInfo + { + ClassID = ClassIdFor(ency.key), + PrefabFileName = $"{nameof(JournalPDAPrefab)}_{ency.key}" + // no techtype + }; + CloneTemplate = new CloneTemplate(Info, CloneTargetClassId) + { + ModifyPrefab = prefab => + { + prefab.name = $"PDA_{ency.key}"; + StoryHandTarget handTarget = prefab.GetComponent(); + if (!string.IsNullOrEmpty(ency.pdaHandTargetText)) + handTarget.primaryTooltip = ency.pdaHandTargetText; + if (!string.IsNullOrEmpty(ency.pdaHandTargetSubtext)) + handTarget.secondaryTooltip = ency.pdaHandTargetSubtext; + handTarget.goal.key = ency.key; + } + }; + + NautilusPrefab = new CustomPrefab() { Info = Info }; + NautilusPrefab.SetGameObject(CloneTemplate); + NautilusPrefab.Register(); + } + + public static void Register(CustomPDAVoicedEncy ency) + { + JournalPDAPrefab prefab = new(ency); + Prefabs[ency.key] = prefab; + ency.spawns.Where(s => s.game == GAME) + .SelectMany(spawn => spawn.locations) + .ForEach(loc => + { + CoordinatedSpawnsHandler.RegisterCoordinatedSpawn(new SpawnInfo(prefab.Info.ClassID, loc.position, loc.rotation)); + }); + } + + private static string ClassIdFor(string key) + { + int modNameHash = nameof(SCHIZO).GetHashCode(); + int entTypeHash = nameof(JournalPDAPrefab).GetHashCode(); + int targetHash = CloneTargetClassId.GetHashCode(); + int keyHash = key.GetHashCode(); + + return $"{modNameHash:x08}{entTypeHash:x08}{targetHash:x08}{keyHash:x08}"; + } } } diff --git a/Unity/Assets/Mod/Neuro logs/Hate Vedal/PDA Log.asset b/Unity/Assets/Mod/Neuro logs/Hate Vedal/PDA Log.asset index 38351e16..94378f54 100644 --- a/Unity/Assets/Mod/Neuro logs/Hate Vedal/PDA Log.asset +++ b/Unity/Assets/Mod/Neuro logs/Hate Vedal/PDA Log.asset @@ -13,6 +13,12 @@ MonoBehaviour: m_Name: PDA Log m_EditorClassIdentifier: key: vo_pda_neuro_hatevedal + pdaHandTargetText: + pdaHandTargetSubtext: encyData: {fileID: 11400000, guid: 1d894705a6e7743439c0806c6f63a2a5, type: 2} subtitles: {fileID: 11400000, guid: 1279d8da7c8e80f4cb78e2f9713583b5, type: 2} - spawns: [] + spawns: + - game: 2 + locations: + - position: {x: -210, y: 48.3, z: -739} + rotation: {x: 0.35, y: 68, z: 0.8} diff --git a/Unity/Assets/Mod/Neuro logs/Love Vedal/PDA Log.asset b/Unity/Assets/Mod/Neuro logs/Love Vedal/PDA Log.asset index 628708c9..2689c7ae 100644 --- a/Unity/Assets/Mod/Neuro logs/Love Vedal/PDA Log.asset +++ b/Unity/Assets/Mod/Neuro logs/Love Vedal/PDA Log.asset @@ -13,15 +13,14 @@ MonoBehaviour: m_Name: PDA Log m_EditorClassIdentifier: key: vo_pda_neuro_lovevedal + pdaHandTargetText: + pdaHandTargetSubtext: encyData: {fileID: 11400000, guid: ace79d4387191d14f95f12def17ef812, type: 2} - logVO: event:/SCHIZO/ency/pda_neuro_lovevedal subtitles: {fileID: 11400000, guid: d1bd66067ffd7ac458d241050ae69d89, type: 2} spawns: - game: 1 - locations: - - position: {x: 0, y: 0, z: 0} - rotation: {x: 0, y: 0, z: 0} + locations: [] - game: 2 locations: - - position: {x: 0, y: 0, z: 0} - rotation: {x: 0, y: 0, z: 0} + - position: {x: -210, y: 48, z: -739} + rotation: {x: 0.35, y: 68, z: 0.8} diff --git a/Unity/Assets/Scripts/SCHIZO/Items/CustomPDAVoicedEncy.cs b/Unity/Assets/Scripts/SCHIZO/Items/CustomPDAVoicedEncy.cs index 0a44dde3..27551b85 100644 --- a/Unity/Assets/Scripts/SCHIZO/Items/CustomPDAVoicedEncy.cs +++ b/Unity/Assets/Scripts/SCHIZO/Items/CustomPDAVoicedEncy.cs @@ -11,6 +11,10 @@ namespace SCHIZO.Items public sealed partial class CustomPDAVoicedEncy : ModRegistryItem { public string key; + [LabelText("PDA Hover Text")] + public string pdaHandTargetText; + [LabelText("PDA Hover Subtext")] + public string pdaHandTargetSubtext; public PDAEncyclopediaInfo encyData; [InfoBox("Make sure the number of subtitle lines matches the number of audio clips in the event!", TriMessageType.Warning)] public Subtitles.SubtitlesData subtitles;