## Bug fixes
- Fix translation keys containing <CDATA> breaking. Thanks orclecle for
the report!
- Added a sphere collision to item props if they had none. Thanks
Hawkbar!
This commit is contained in:
xen-42 2024-03-15 14:29:53 -04:00 committed by GitHub
commit 13ea363c5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 28 additions and 6 deletions

View File

@ -171,6 +171,11 @@ namespace NewHorizons.Builder.Props
if (detail.item != null) if (detail.item != null)
{ {
ItemBuilder.MakeItem(prop, go, sector, detail.item, mod); ItemBuilder.MakeItem(prop, go, sector, detail.item, mod);
isItem = true;
if (detail.hasPhysics)
{
NHLogger.LogWarning($"An item with the path {detail.path} has both '{nameof(DetailInfo.hasPhysics)}' and '{nameof(DetailInfo.item)}' set. This will usually result in undesirable behavior.");
}
} }
if (detail.itemSocket != null) if (detail.itemSocket != null)

View File

@ -79,6 +79,12 @@ namespace NewHorizons.Builder.Props
item.ClearPickupConditionOnDrop = info.clearPickupConditionOnDrop; item.ClearPickupConditionOnDrop = info.clearPickupConditionOnDrop;
item.PickupFact = info.pickupFact; item.PickupFact = info.pickupFact;
if (info.colliderRadius > 0f)
{
go.AddComponent<SphereCollider>().radius = info.colliderRadius;
go.GetAddComponent<OWCollider>();
}
Delay.FireOnNextUpdate(() => Delay.FireOnNextUpdate(() =>
{ {
if (item != null && !string.IsNullOrEmpty(info.pathToInitialSocket)) if (item != null && !string.IsNullOrEmpty(info.pathToInitialSocket))

View File

@ -19,7 +19,7 @@ namespace NewHorizons.External.Modules.Props.Item
/// </summary> /// </summary>
public string name; public string name;
/// <summary> /// <summary>
/// The type of the item, which determines its orientation when held and what sockets it fits into. This can be a custom string, or a vanilla ItemType (Scroll, WarpCode, SharedStone, ConversationStone, Lantern, SlideReel, DreamLantern, or VisionTorch). Defaults to the item name. /// The type of the item, which determines its orientation when held and what sockets it fits into. This can be a custom string, or a vanilla ItemType (Scroll, WarpCore, SharedStone, ConversationStone, Lantern, SlideReel, DreamLantern, or VisionTorch). Defaults to the item name.
/// </summary> /// </summary>
public string itemType; public string itemType;
/// <summary> /// <summary>
@ -27,6 +27,11 @@ namespace NewHorizons.External.Modules.Props.Item
/// </summary> /// </summary>
[DefaultValue(2f)] public float interactRange = 2f; [DefaultValue(2f)] public float interactRange = 2f;
/// <summary> /// <summary>
/// The radius that the added sphere collider will use for collision and hover detection.
/// If there's already a collider on the detail, you can make this 0.
/// </summary>
[DefaultValue(0.5f)] public float colliderRadius = 0.5f;
/// <summary>
/// Whether the item can be dropped. Defaults to true. /// Whether the item can be dropped. Defaults to true.
/// </summary> /// </summary>
[DefaultValue(true)] public bool droppable = true; [DefaultValue(true)] public bool droppable = true;

View File

@ -57,7 +57,7 @@ namespace NewHorizons.Handlers
return translatedText; return translatedText;
} }
// Try without whitespace if its missing // Try without whitespace if its missing
else if (table.TryGetValue(text.TruncateWhitespace(), out translatedText)) else if (table.TryGetValue(text.TruncateWhitespaceAndToLower(), out translatedText))
{ {
return translatedText; return translatedText;
} }
@ -99,7 +99,7 @@ namespace NewHorizons.Handlers
// Fix new lines in dialogue translations, remove whitespace from keys else if the dialogue has weird whitespace and line breaks it gets really annoying // Fix new lines in dialogue translations, remove whitespace from keys else if the dialogue has weird whitespace and line breaks it gets really annoying
// to write translation keys for (can't just copy paste out of xml, have to start adding \\n and \\r and stuff // to write translation keys for (can't just copy paste out of xml, have to start adding \\n and \\r and stuff
// If any of these issues become relevant to other dictionaries we can bring this code over, but for now why fix what isnt broke // If any of these issues become relevant to other dictionaries we can bring this code over, but for now why fix what isnt broke
var key = originalKey.Replace("\\n", "\n").TruncateWhitespace().Replace("&lt;", "<").Replace("&gt;", ">").Replace("<![CDATA[", "").Replace("]]>", ""); var key = originalKey.Replace("\\n", "\n").Replace("&lt;", "<").Replace("&gt;", ">").Replace("<![CDATA[", "").Replace("]]>", "").TruncateWhitespaceAndToLower();
var value = config.DialogueDictionary[originalKey].Replace("\\n", "\n").Replace("&lt;", "<").Replace("&gt;", ">").Replace("<![CDATA[", "").Replace("]]>", ""); var value = config.DialogueDictionary[originalKey].Replace("\\n", "\n").Replace("&lt;", "<").Replace("&gt;", ">").Replace("<![CDATA[", "").Replace("]]>", "");
if (!_dialogueTranslationDictionary[language].ContainsKey(key)) _dialogueTranslationDictionary[language].Add(key, value); if (!_dialogueTranslationDictionary[language].ContainsKey(key)) _dialogueTranslationDictionary[language].Add(key, value);

View File

@ -1402,7 +1402,7 @@
}, },
"itemType": { "itemType": {
"type": "string", "type": "string",
"description": "The type of the item, which determines its orientation when held and what sockets it fits into. This can be a custom string, or a vanilla ItemType (Scroll, WarpCode, SharedStone, ConversationStone, Lantern, SlideReel, DreamLantern, or VisionTorch). Defaults to the item name." "description": "The type of the item, which determines its orientation when held and what sockets it fits into. This can be a custom string, or a vanilla ItemType (Scroll, WarpCore, SharedStone, ConversationStone, Lantern, SlideReel, DreamLantern, or VisionTorch). Defaults to the item name."
}, },
"interactRange": { "interactRange": {
"type": "number", "type": "number",
@ -1410,6 +1410,12 @@
"format": "float", "format": "float",
"default": 2.0 "default": 2.0
}, },
"colliderRadius": {
"type": "number",
"description": "The radius that the added sphere collider will use for collision and hover detection.\nIf there's already a collider on the detail, you can make this 0.",
"format": "float",
"default": 0.5
},
"droppable": { "droppable": {
"type": "boolean", "type": "boolean",
"description": "Whether the item can be dropped. Defaults to true.", "description": "Whether the item can be dropped. Defaults to true.",

View File

@ -351,7 +351,7 @@ namespace NewHorizons.Utility
return parentNode.ChildNodes.Cast<XmlNode>().First(node => node.LocalName == tagName); return parentNode.ChildNodes.Cast<XmlNode>().First(node => node.LocalName == tagName);
} }
public static string TruncateWhitespace(this string text) public static string TruncateWhitespaceAndToLower(this string text)
{ {
// return Regex.Replace(text.Trim(), @"[^\S\r\n]+", "GUH"); // return Regex.Replace(text.Trim(), @"[^\S\r\n]+", "GUH");
return Regex.Replace(text.Trim(), @"\s+", " ").ToLowerInvariant(); return Regex.Replace(text.Trim(), @"\s+", " ").ToLowerInvariant();

View File

@ -4,7 +4,7 @@
"author": "xen, Bwc9876, JohnCorby, MegaPiggy, Clay, Trifid, and friends", "author": "xen, Bwc9876, JohnCorby, MegaPiggy, Clay, Trifid, and friends",
"name": "New Horizons", "name": "New Horizons",
"uniqueName": "xen.NewHorizons", "uniqueName": "xen.NewHorizons",
"version": "1.19.0", "version": "1.19.1",
"owmlVersion": "2.9.8", "owmlVersion": "2.9.8",
"dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ], "dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ],
"conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_CommonResources" ], "conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_CommonResources" ],