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
Player-facing name resolved under the runtime’s active locale at the time of the GetEncounters call (spec §4.2 localization paragraph) — the target scene’s StoryBonsai.Runtime.Models.Scene.DisplayName on plain entries, the trigger node’s title on node entries. Integrators that switch locale at runtime must re-poll to pick up updated strings.
public string DisplayName { get; }
Property Value
NodeId
Trigger node’s human id (StoryBonsai.Runtime.Models.Node.Id) on node-trigger entries; null on
plain (scene-trigger) entries. Also the entry-kind discriminator — a
null NodeId is a plain entry, a non-null NodeId is a node entry
(in which case Uuid is the node’s uuid, not the scene’s).
public string? NodeId { get; }
Property Value
SceneId
Owning scene’s human id (StoryBonsai.Runtime.Models.Scene.Id). Always populated. Hosts can resolve to a StoryBonsai.Runtime.Models.Scene for logs/labels via their own scene index.
public string SceneId { get; }
Property Value
TimeCost
What dispatching this entry charges, in minutes — the scene’s StoryBonsai.Runtime.Models.Scene.EncounterTimeCost on plain entries, the node’s StoryBonsai.Runtime.Models.Node.TimeCost on node entries. Null when no time runtime is configured (mirrors Choice.TimeCost). For host UI display.
public Nullable<int> TimeCost { get; }
Property Value
Trigger
Non-null by construction — GetEncounters() only emits entries that have a trigger: the scene-level trigger for plain entries, the node’s trigger for fan-out entries (NodeId != null).
public TriggerDescriptor Trigger { get; }
Property Value
Uuid
Dispatch-target uuid — the value StartEncounter(string) receives to open this entry. On plain (scene-trigger) entries this is the target scene’s StoryBonsai.Runtime.Models.Scene.Uuid; on node-trigger entries (see NodeId) it is the trigger node’s StoryBonsai.Runtime.Models.Node.Uuid. Kind is discriminated by NodeId: null = plain entry (Uuid targets the scene), non-null = node entry (Uuid targets the node, its owning scene is SceneId).
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 dispatch target itself — the scene on plain entries, the node on
node entries) for SelfTrigger.