29 lines
5.1 KiB
Plaintext
29 lines
5.1 KiB
Plaintext
<!DOCTYPE html>
|
|
<html lang="en"><head>
|
|
<meta charset="UTF-8">
|
|
<title>Dialog — Unity-Roject-Test</title>
|
|
<style>
|
|
@import url('/fonts/barlow.css');
|
|
</style>
|
|
</head>
|
|
<body data-theme="default-roject">
|
|
<page--header></page--header>
|
|
|
|
<page--root data-theme="default-roject">
|
|
<full--width--block data--page--block="">
|
|
<full--width--area data--page--area="" contenteditable="true" spellcheck="false" autocorrect="off" autocapitalize="off" style="outline: none;"><h1>Dialog</h1><div><marked-text>Assets/Scripts/Rokojori/Dialog</marked-text> - a standalone dialog engine plus a UI-facing singleton on top of it. See <a href="../../outline/tech/index.page">outline/tech/index.page</a> for the design intent and the open assumptions this implementation made.</div></full--width--area>
|
|
</full--width--block>
|
|
<two--columns--block data--page--block="">
|
|
<two--columns--area data--page--area="" contenteditable="true" spellcheck="false" autocorrect="off" autocapitalize="off" style="outline: none;"><h2>The Three Layers</h2><div><code>DialogProcessor</code> is the engine - it only knows about <code>IDialogDisplay</code>, nothing about UI or DialogManager. <code>DialogManager</code> is the UI-facing singleton - implements <code>IDialogDisplay</code>, and <code>StartDialog()</code> is the only entry point anyone outside this folder should call. <code>DialogPhase</code> (in Simulation/) is a thin wrapper so a dialog can be one step in a turn loop.</div><div><br></div><h2>Execution Loop</h2><div><code>DialogProcessor.Run( start )</code> repeats <code>current = await current.Run( display )</code> until <code>current</code> is null. Each <code>DialogBlock</code> decides its own next step; the base class default is simply "return <code>next</code>" (linear flow), and only <code>PlayerChoice</code> / <code>DialogBranch</code> override that to branch.</div></two--columns--area>
|
|
<two--columns--area data--page--area="" contenteditable="true" spellcheck="false" autocorrect="off" autocapitalize="off" style="outline: none;"><h2>Block-by-Block Behaviour</h2><div><strong>DialogLine</strong> - calls <code>display.Show(this)</code>, awaits it, returns <code>next</code>.</div><div><strong>PlayerChoice</strong> - calls <code>display.Show(this)</code>, reads <code>answer.selectedOptionIndex</code>, runs that option's <code>action</code> if set, returns that option's <code>next</code>.</div><div><strong>DialogBranch</strong> - no display call. Returns <code>branch</code> if <code>condition.Evaluate()</code> is true, else the inherited <code>next</code>.</div><div><strong>DialogList</strong> - runs its own <code>blocks</code> in flat order, <marked-text>ignoring each child's own "next"</marked-text> while inside the list, then returns its own <code>next</code>. This is an assumption, not confirmed - see outline/tech "Implementation Status". Practical effect: don't put a PlayerChoice/DialogBranch directly inside a DialogList's <code>blocks</code>, its branch target will be silently discarded.</div><div><strong>ReturnBlock</strong> - always returns null, ending the whole dialog (even if nested inside a DialogList).</div><div><strong>CommentBlock</strong> - editor-only, no override, just falls through to <code>next</code> like the default.</div></two--columns--area>
|
|
</two--columns--block>
|
|
<two--columns--block data--page--block="">
|
|
<two--columns--area data--page--area="" contenteditable="true" spellcheck="false" autocorrect="off" autocapitalize="off" style="outline: none;"><h2>Conditions & Actions</h2><div><code>GameStateCondition</code> (CompareInt, HasObject, ListCondition) and <code>GameStateAction</code> (SetProperty, ModifyProperty, ActionList) both read/write through <code>GameStateManager.instance</code> - they never touch DialogBlock state directly. <code>HasObject</code> currently checks a <code>GameStateBoolVariable</code> flag since there's no inventory/object system to check membership against yet.</div><div><br></div><div><code>PlayerChoice.options[i].action</code> is not in the original design outline - added to give choices a way to change game state, since Conditions and Actions were described as a pair but no block explicitly triggered an Action.</div></two--columns--area>
|
|
<two--columns--area data--page--area="" contenteditable="true" spellcheck="false" autocorrect="off" autocapitalize="off" style="outline: none;"><h2>Testing Without UI</h2><div><code>HeadlessDialogDisplay</code> implements <code>IDialogDisplay</code> without any Unity UI - it logs every block it's shown into <code>visitedBlocks</code> and answers PlayerChoice via the <code>chooseOption</code> delegate (defaults to always picking option 0). Drive a dialog with <code>DialogProcessor.Create( new HeadlessDialogDisplay() ).Run( start )</code> to test branching logic in isolation.</div><div><br></div><h2>Gotcha</h2><div><code>DialogManager.Show()</code> currently <marked-text>throws NotImplementedException</marked-text> - there's no real UI wired up yet (Assets/UI is empty). Use HeadlessDialogDisplay for anything that doesn't need to render.</div></two--columns--area>
|
|
</two--columns--block>
|
|
</page--root>
|
|
|
|
<page--footer></page--footer>
|
|
|
|
</body></html>
|