Encounter
Runtime-built DTO describing one currently-available affordance at the player’s location. Surfaced by GetEncounters().
public sealed class Encounter
Inheritance System.Object → Encounter
Example
var set = runtime.GetEncounters();
foreach (var enc in set.Encounters)
{
switch (enc.Trigger)
{
case CharacterTrigger c: ShowCharacterIndicator(c.EntityUuid, enc.DisplayName); break;
case ItemTrigger i: ShowItemIndicator(i.EntityUuid, enc.DisplayName); break;
case SelfTrigger _: ShowLocationFeatureIndicator(enc.DisplayName); break;
}
}
// Player picks the first one — typed overload routes through Uuid:
runtime.StartEncounter(set.Encounters.First());
Remarks
To dispatch an encounter, pattern-match on the concrete TriggerDescriptor subclass (CharacterTrigger / ItemTrigger / SelfTrigger) to choose how the host’s world view renders the affordance — e.g. CharacterTrigger draws an indicator over the NPC, ItemTrigger over the world item, SelfTrigger over the location feature itself. Then call StartEncounter(Encounter) on the player’s pick.
Properties
DisplayName
StoryBonsai.Runtime.Models.Scene.DisplayName resolved under the runtime’s active locale at the time of the GetEncounters call (spec §4.2 localization paragraph). Integrators that switch locale at runtime must re-poll to pick up updated strings.
public string DisplayName { get; }
Property Value
SceneId
Target scene’s human id (StoryBonsai.Runtime.Models.Scene.Id). Stable across rename via Uuid below.
public string SceneId { get; }
Property Value
Trigger
Non-null by construction — GetEncounters() drops pin entries whose target scene has Trigger == null. Pattern-match on the concrete subclass (CharacterTrigger / ItemTrigger / SelfTrigger) for per-kind handling.
public TriggerDescriptor Trigger { get; }
Property Value
Uuid
Target scene’s structural identifier (StoryBonsai.Runtime.Models.Scene.Uuid). Pass to StartEncounter(string) when calling the string overload.
public string Uuid { get; }
Property Value
Methods
GetTriggerEntityUuid()
Collapses the per-subtype trigger dispatch every world-layer click handler would otherwise write.
public string GetTriggerEntityUuid();
Returns
System.String
The uuid the player must click in the world to start this encounter:
EntityUuid for character triggers,
EntityUuid for item triggers,
or Uuid (the scene itself) for SelfTrigger.