beasty-visual-novel / scripting / overview.md

Scripting overview

How Beasty Visual Novel is put together, and where your own C# hooks in. Read this before you write against the API, then go to the page that covers your job.

Full C# source ships with the package. Nothing here is a black box.

Assemblies

AssemblyFolderWhat is in it
Beasty.VN.CoreCore/The data model and the pure logic: nodes, blocks, the variable store, conditions, the story director, time, routines, quests. No Unity UI.
Beasty.VN.RuntimeRuntime/The view layer and the controllers: BeastyManager, VNGameController, VisualNovelController, StageController, the uGUI views, input, saving, streaming.
Beasty.VN.EditorEditor/Every authoring tool. Never referenced by a build.

Runtime references Core; Core does not reference Runtime. That split is the point: the story engine does not know your dialogue box exists. You can replace the whole presentation layer — write your own view components, drive them from the VN API — without touching the engine that runs the story.

Namespaces mirror the assemblies: Beasty.VN.Core and Beasty.VN.Runtime. Two optional assemblies compile only when their dependency is present: Beasty.VN.Runtime.InputSystem (the new Input System) and Beasty.VN.Addressables (streaming).

The runtime objects

BeastyManager is the single component you drop in the scene. It owns every other manager as a hidden sub-component on its own GameObject, guarantees exactly one of each exists, and exposes them through typed properties (Game, VN, Stage, FreeRoam, Audio, Menus, …). It also runs the boot sequence behind a loading screen. Get it with BeastyManager.Instance.

VNGameController owns the app state machine and the one shared VariableStore that every mode reads and writes. Progress is global because this store is global: it survives a project switch, is visible from FreeRoam, and is what a save file records. Get it with VNGameController.Instance or BeastyManager.Instance.Game.

VisualNovelController hosts one running story. It builds the runtime context, the story director and the save adapter, wraps them in a VNSession, and publishes that session through the static VN API. Get it with VisualNovelController.Instance or BeastyManager.Instance.VN.

StageController paints the stage: the backdrop, the characters, the props. It is driven by the director, not by you. The persistent stage memory lives on VisualNovelController.PersistentStage, so the scene survives a node switch, a project switch, and an excursion into FreeRoam.

The four app states

VNAppState (in Beasty.VN.Runtime) has four values, and VNGameController.State is always one of them:

StateWhat is running
MainMenuNo story, no room. The menus own the screen.
VisualNovelA VisualNovelController session is playing a DialogueScene.
FreeRoamThe player is in a room on a FreeRoamMapGraph.
CustomYour code. The engine has no UI for this state — that is the whole point.

VNGameController.StateChanged fires on every transition. The save records which state was active, so a load restores the right subsystem. See Controllers for the methods that move between them, and Custom mode for the fourth one.

I want to X -> use Y

I want toUsePage
Read a variableVN.GetInt / GetBool / GetFloat / GetStringVN API
Write a variableVN.SetInt / SetBool / SetFloat / SetStringVN API
Read or write a variable without magic stringsVNVars.Money, VNChars.Maya.AffectionGenerated accessors
Read a variable outside a running storyVNGameController.Instance.SharedVariablesControllers
React when a line is shownVN.OnLineShownVN API
React when choices appear or one is takenVN.OnChoicePresented, VN.OnChoiceChosenVN API
React when a variable changesVN.OnVariableChanged, or VariableStore.Changed on the shared storeVN API
Start a story from codeVNGameController.EnterVisualNovel(project, nodeId)Controllers
Play a story and come back to the roomVNGameController.PlayVisualNovelThenReturn(...)Controllers
Advance, rewind, or pick a choice from codeVN.Advance(), VN.Back(), VN.Choose(i)VN API
Save or load a slotVNGameController.SaveToSlot / LoadSlotDetailedControllers, Saving and loading
Read or advance the clockBeastyTimeGameplay APIs
Ask where a character isBeastyRoutinesGameplay APIs
Start a quest or complete an objectiveBeastyQuestsGameplay APIs
Give, take or count itemsInventoryGameplay APIs
Add my own game modeVNGameController.EnterCustom()Custom mode
Persist my own data inside a saveCaptureCustomStateJson / RestoreCustomStateJson, or a BeastySaveable componentCustom mode, Scene state
Save a field type the engine does not knowWrite an IBeastyConverterCustom converters
Delay startup until my own system is upBeastyManager.RegisterBootBarrierControllers

See also