Fix interaction context and adventure character name translation
- Interaction messages now show which item triggered them (e.g., "You use Golden Key — the key fits!") instead of appearing without context. - Adventure character names are resolved from their Loreline script name field before localization lookup, fixing IDs like "knight" showing instead of translated names like "Sire Boîtalot".
This commit is contained in:
parent
1b6b635335
commit
bc1857a6ae
6 changed files with 14 additions and 9 deletions
|
|
@ -343,7 +343,7 @@
|
|||
"adventure.item_removed": "Lost: {0}",
|
||||
"adventure.resource_added": "{0} +{1}",
|
||||
|
||||
"interaction.key_chest": "The key fits! The chest opens automatically!",
|
||||
"interaction.key_chest": "You use {0} — the key fits! The chest opens automatically!",
|
||||
"interaction.key_no_match": "This key seems to fit something... but you don't have it yet. Perhaps a future box will provide.",
|
||||
"interaction.treasure_located": "The map and compass align! Treasure located!",
|
||||
"interaction.map_coordinates": "The map reveals mysterious coordinates...",
|
||||
|
|
|
|||
|
|
@ -343,7 +343,7 @@
|
|||
"adventure.item_removed": "Perdu : {0}",
|
||||
"adventure.resource_added": "{0} +{1}",
|
||||
|
||||
"interaction.key_chest": "La clé rentre ! Le coffre s'ouvre automatiquement !",
|
||||
"interaction.key_chest": "Tu utilises {0} — la clé rentre ! Le coffre s'ouvre automatiquement !",
|
||||
"interaction.key_no_match": "Cette clé semble ouvrir quelque chose... mais tu ne l'as pas encore. Peut-être qu'une future boîte le fournira.",
|
||||
"interaction.treasure_located": "La carte et la boussole s'alignent ! Trésor localisé !",
|
||||
"interaction.map_coordinates": "La carte révèle des coordonnées mystérieuses...",
|
||||
|
|
|
|||
|
|
@ -194,10 +194,12 @@ public sealed class AdventureEngine
|
|||
string? displayName = dialogue.Character;
|
||||
if (displayName is not null)
|
||||
{
|
||||
string key = $"character.{displayName.ToLowerInvariant().Replace(" ", "_").Replace("'", "")}";
|
||||
// Resolve the character's full name from the script (e.g., "knight" → "Sir Boxalot")
|
||||
string characterName = dialogue.Interpreter.GetCharacterField(displayName, "name") as string
|
||||
?? displayName;
|
||||
string key = $"character.{characterName.ToLowerInvariant().Replace(" ", "_").Replace("'", "")}";
|
||||
string localized = _loc.Get(key);
|
||||
if (!localized.StartsWith("[MISSING:"))
|
||||
displayName = localized;
|
||||
displayName = !localized.StartsWith("[MISSING:") ? localized : characterName;
|
||||
}
|
||||
_renderer.ShowAdventureDialogue(displayName, dialogue.Text);
|
||||
_renderer.WaitForKeyPress();
|
||||
|
|
|
|||
|
|
@ -521,8 +521,11 @@ public static class Program
|
|||
break;
|
||||
|
||||
case InteractionTriggeredEvent interEvt:
|
||||
// Defer interaction display until after loot reveal
|
||||
deferredInteractions.Add(_loc.Get(interEvt.DescriptionKey));
|
||||
// Defer interaction display until after loot reveal, with trigger item context
|
||||
var interMsg = interEvt.TriggerItemId is not null
|
||||
? _loc.Get(interEvt.DescriptionKey, GetLocalizedName(interEvt.TriggerItemId))
|
||||
: _loc.Get(interEvt.DescriptionKey);
|
||||
deferredInteractions.Add(interMsg);
|
||||
break;
|
||||
|
||||
case ResourceChangedEvent resEvt:
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public sealed record ItemConsumedEvent(Guid InstanceId) : GameEvent;
|
|||
/// <summary>
|
||||
/// An interaction rule was triggered.
|
||||
/// </summary>
|
||||
public sealed record InteractionTriggeredEvent(string RuleId, string DescriptionKey) : GameEvent;
|
||||
public sealed record InteractionTriggeredEvent(string RuleId, string DescriptionKey, string? TriggerItemId = null) : GameEvent;
|
||||
|
||||
/// <summary>
|
||||
/// A UI feature was unlocked via a meta item.
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ public class InteractionEngine(ContentRegistry registry)
|
|||
}
|
||||
}
|
||||
|
||||
events.Add(new InteractionTriggeredEvent(rule.Id, rule.DescriptionKey));
|
||||
events.Add(new InteractionTriggeredEvent(rule.Id, rule.DescriptionKey, triggerItem.DefinitionId));
|
||||
|
||||
return events;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue