Skip to content

Commit

Permalink
add ency journal spawns
Browse files Browse the repository at this point in the history
todo positions
todo SN
  • Loading branch information
Govorunb committed Dec 10, 2023
1 parent ab22580 commit 2714a21
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 7 deletions.
66 changes: 66 additions & 0 deletions SCHIZO/Items/CustomPDAVoicedEncy.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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<string, JournalPDAPrefab> 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<StoryHandTarget>();
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}";
}
}
}
8 changes: 7 additions & 1 deletion Unity/Assets/Mod/Neuro logs/Hate Vedal/PDA Log.asset
Original file line number Diff line number Diff line change
Expand Up @@ -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}
11 changes: 5 additions & 6 deletions Unity/Assets/Mod/Neuro logs/Love Vedal/PDA Log.asset
Original file line number Diff line number Diff line change
Expand Up @@ -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}
4 changes: 4 additions & 0 deletions Unity/Assets/Scripts/SCHIZO/Items/CustomPDAVoicedEncy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2714a21

Please sign in to comment.