diff --git a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs index 42769576..48a1cc4e 100644 --- a/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs +++ b/NewHorizons/Builder/Props/TranslatorText/TranslatorTextBuilder.cs @@ -546,7 +546,7 @@ namespace NewHorizons.Builder.Props.TranslatorText // make an entry in the cache for all these spirals - if (nhBody.Cache != null) + if (nhBody?.Cache != null) { var cacheData = arranger.spirals.Select(spiralManipulator => new ArcCacheData() { diff --git a/NewHorizons/INewHorizons.cs b/NewHorizons/INewHorizons.cs index 717819c0..c4447d28 100644 --- a/NewHorizons/INewHorizons.cs +++ b/NewHorizons/INewHorizons.cs @@ -147,6 +147,15 @@ namespace NewHorizons /// (CharacterDialogueTree, RemoteDialogueTrigger) CreateDialogueFromXML(string textAssetID, string xml, string dialogueInfo, GameObject planetGO); + /// + /// Allows the creation of Nomai text by directly passing the xml and translatorTextInfo json contents as strings + /// + /// The contents of the translator text file as a string + /// The json translator text info as a string. See the documentation/schema for what this can contain. + /// The root planet rigidbody that this text is attached to. Any paths in the translatorTextInfo are relative to this body. + /// + GameObject CreateNomaiText(string xml, string textInfo, GameObject planetGO); + /// /// Directly add ship logs from XML. Call this method right before ShipLogManager awake. /// diff --git a/NewHorizons/NewHorizonsApi.cs b/NewHorizons/NewHorizonsApi.cs index e395bfa1..5eaf322e 100644 --- a/NewHorizons/NewHorizonsApi.cs +++ b/NewHorizons/NewHorizonsApi.cs @@ -1,5 +1,6 @@ using NewHorizons.Builder.Props; using NewHorizons.Builder.Props.Audio; +using NewHorizons.Builder.Props.TranslatorText; using NewHorizons.Builder.ShipLog; using NewHorizons.External; using NewHorizons.External.Configs; @@ -7,6 +8,7 @@ using NewHorizons.External.Modules; using NewHorizons.External.Modules.Props; using NewHorizons.External.Modules.Props.Audio; using NewHorizons.External.Modules.Props.Dialogue; +using NewHorizons.External.Modules.TranslatorText; using NewHorizons.External.SerializableData; using NewHorizons.Utility; using NewHorizons.Utility.OWML; @@ -259,6 +261,12 @@ namespace NewHorizons return DialogueBuilder.Make(planetGO, null, info, xml, textAssetID); } + public GameObject CreateNomaiText(string xml, string textInfo, GameObject planetGO) + { + var info = JsonConvert.DeserializeObject(textInfo); + return TranslatorTextBuilder.Make(planetGO, null, info, null, xml); + } + public void AddShipLogXML(IModBehaviour mod, XElement xml, string planetName, string imageFolder, Dictionary entryPositions, Dictionary curiousityColours) { // This method has to be called each time the ship log manager is created, i.e. each time a system loads so it will only ever be relevant to the current one.