Rendered from reconstruction/ORIGINAL-GAME-FUNCTIONAL-SPECIFICATION.md

OpenZT2 Original Game Functional Specification

The Rust reconstruction preserves Zoo Tycoon 2's product-domain contract: native types, source-hydrated data, runtime managers, hardcoded message/method surfaces, and adapter boundaries.

Named native types are registered with a known name, parent, and owner domain. The architecture is described at the product-domain level: inheritance, source data, runtime ownership, message surfaces, state transitions, and host-adapter boundaries.

Architecture At A Glance

Every concrete game object is a BFTyped object; almost everything is a BFComponent. Authored Z2F data hydrates these objects; singleton managers interpret them; the renderer/audio/host layers project them behind a preservation boundary. The class names in each layer are registered native types.

flowchart TB
  Source["Shipped source data
Z2F XML/MAXML, AI .tsk/.beh, scenarios, Lua,
ui/layout, skins, lang, materials, models, sounds"] Runtime["Generic source runtime
BFResourceMgr, BFXMLObj/BFXMLDocument, BFXMLSchemaMgr,
BFLocaleMgr, BFTypedBinder, register_type"] Mgrs["Native game managers
ZTApp, ZTWorldMgr, ZTAIMgr, ZTEconomyMgr,
ZTDiseaseMgr, ZTScenarioMgr, ZTResearchMgr"] State["Runtime domain state
entities (component graphs), AI tokens, world grid,
UI widget tree, profile/save/scenario state"] Proj["Projection + host adapters (REPLACEABLE)
Gamebryo/D3D, sound factories, Win32/winit,
registry/profile/fs, Lua/CRT, network/MOTD"] Source --> Runtime --> Mgrs --> State Mgrs -.project.-> Proj State -.project.-> Proj

Modern adapters may replace renderer/audio/windowing/archive/parser/script/OS mechanics. Animal, UI, economy, placement, disease, scenario, save, and manager semantics stay on the original class boundary.

Foundational Type System: BFTyped

Every native object is a node in one single-inheritance hierarchy rooted at BFTypedObj. Each class registers lazily: a per-type cache global guarded by an init flag, the parent obtained from the parent's own getter, and the class-name string interned by register_type. The type registry enumerates this hierarchy completely — 2,068 registered types over 128 distinct parents; the spine is BFComponent (186 direct children), then BFXMLObj (75), BFBehavior (78), BFPhysComponent (42), and ZTMode (24).

classDiagram
  BFTypedObj <|-- BFSafeHandledObj
  BFSafeHandledObj <|-- BFXMLObj
  BFXMLObj <|-- BFComponent
  BFXMLObj <|-- BFXMLNode
  BFXMLNode <|-- BFXMLDocument
  BFComponent <|-- BFComponentContainer
  BFComponentContainer <|-- BFComponentNameMap
  BFComponentContainer <|-- BFComponentList
  BFComponentNameMap <|-- BFBinder
  BFBinder <|-- BFTypedBinder
  BFComponentNameMap <|-- BFGEntity
  BFComponentList <|-- BFAIEntityData
  BFAIEntityData <|-- BFAIEntityDataShared
  class BFTypedObj { type identity + cache global }
  class BFSafeHandledObj { safehandleID }
  class BFXMLObj { read_xml_node() write_xml_node() }
  class BFComponentNameMap { name-keyed component map }
  class BFTypedBinder { binderName/Type/Version; shared+instance XML }
  class BFGEntity { entity = component graph }

Reconstructed members: BFComponent carries type_name, component_name, owner_entity; BFComponentContainer holds components : Vec~BFComponent~ plus a name_map : BFComponentNameMap and a stack : BFComponentStack: the literal "everything is a named component bag" shape.

Contract consequences (each traced to a ledger parent edge):

Hardcoded Native vs Data-Driven Hydration

The original game's data-driven surfaces hydrate native source objects via BFTypedBinder and BFGEntity; source keys are read through the XML attribute reader, and messages are interned via register_type. Native registries and managers then interpret those objects through hardcoded C++ classes, vtables, message handlers, and update algorithms.

flowchart LR
  XML["authored XML / assets"] --> Schema["BFXMLSchemaMgr validate"]
  Schema --> Binder["BFTypedBinder create"]
  Binder --> Comp["component tree (BFComponent*)"]
  Comp --> Mgr["managers interpret + update"]
  Mgr --> Msg["UI_/BFAI_/ZT_ message + value handlers"]
Surface Data-driven source Hardcoded native contract
Entity and animal content Binder XML, ancestry paths, components, attributes, assets, localization BFTypedBinder, entity/component factories, catalog queries, AI/world/economy managers
UI screens ui/layout, ui/template, skin replacements, localization, image/font refs, event blocks UIApp, UIRoot, widget classes, message dispatch, value handlers, focus/input semantics
AI behavior .tsk and .beh task templates, selectors, scores, completion/failure nodes BFAIMgr, thinkers, sensors, behavior node classes, scheduler/tie-break/update policy
Economy/fame/research/disease config/*.xml, source transactions, disease records, research items, scripts manager algorithms, message handlers, reward/status side effects, persistence
World placement placement data, footprints, biome config, terrain/path/fence/tank source mode classes, validators, transactions, undo, collision/traversability updates
Renderer/audio .bfmat, .fx, models, textures, UI images, sound tags resource managers and projection semantics; backend mechanics are replaceable

Source Object Model

The generic document layer turns authored Z2F XML into native objects. It has four cooperating pieces under the BFTyped hierarchy: an XML DOM, a schema validator, a component-container spine, and the binder that loads typed entity/source documents. Game classes declare components and let this layer hydrate them.

XML document model

classDiagram
  BFTypedObj <|-- BFSafeHandledObj
  BFSafeHandledObj <|-- BFXMLObj
  BFXMLObj <|-- BFXMLNode
  BFXMLNode <|-- BFXMLDocument
  BFXMLNode <|-- BFXMLElement
  BFXMLNode <|-- BFXMLText
  BFXMLNode <|-- BFXMLComment
  BFXMLNode <|-- BFXMLDeclaration
  BFXMLNode <|-- BFXMLUnknown
  BFTypedObj <|-- BFXMLAttribute
  BFEvent <|-- BFXMLObjEvent
  BFEvent <|-- BFXMLNodeEvent
  BFEvent <|-- BFXMLObjHandleEvent

Reconstructed: BFXMLDocument holds path, declaration, root : BFXMLElement, schema; BFXMLElement holds name, attributes : Vec~BFXMLAttribute~, children : Vec~BFXMLNode~; BFXMLAttribute is name/value. Every binder reads this parsed DOM.

BFXMLObj is the universal base (every game object can read/write itself as XML); BFXMLNode and its subtypes are the parsed DOM; change events propagate as BFXMLObjEvent/BFXMLNodeEvent.

Schema

classDiagram
  BFTypedObj <|-- BFXMLSchemaType
  BFXMLSchemaType <|-- BFXMLSchemaElementType
  BFXMLSchemaType <|-- BFXMLSchemaAttributeType
  BFXMLSchemaType <|-- BFXMLSchemaRestriction
  BFComponent <|-- BFXMLSchemaMgr

BFXMLSchemaMgr validates documents against .xdr/schema types (e.g. schema/bfgentitymorphdata.xdr) before hydration; BFRegistry (app_key, types : BTreeMap~String,BFType~, factories) is the global type/factory registry, and BFTypedBinderSchema (binder_type, type_rules, sub_binders) is the binder's declared shape.

Component containers and binders

classDiagram
  BFXMLObj <|-- BFComponent
  BFComponent <|-- BFComponentContainer
  BFComponentContainer <|-- BFComponentList
  BFComponentContainer <|-- BFComponentNameMap
  BFComponentList <|-- BFComponentStack
  BFComponentNameMap <|-- BFBinder
  BFBinder <|-- BFTypedBinder
  BFComponent <|-- BFBinderRoot
  BFXMLObj <|-- BFComponentHandleVector
  BFXMLObj <|-- BFComponentPointerVector

The container spine is what makes "everything is a component map" work: a BFComponentNameMap keys components by name; a BFBinder/BFTypedBinder is that map plus name/type/version identity. Entities, animals, and source documents are all binders. BFTypedBinder holds binder : BFBinder, type_name, unique_name, version, version_replace, shared_xml : BFXMLDocument; BFBinder holds path, load_status, binder_type, children : Vec~BFBinder~ — the recursive binder tree.

Source-object inheritance

The generic source objects are nodes in the BFTypedObj single-inheritance hierarchy. Because BFBinder/BFTypedBinder descend from BFComponentNameMap, a binder is a named, typed, versioned component map. BFAIEntityDataShared is a sibling type registered on the same hierarchy.

BFTypedBinder Document Schema

The binder document root element is binder. The create/open/save path and the binder property-name table define these source keys:

shared versus instance separate per-type shared XML from per-entity instance XML. Concrete typed entity classes named at the binder create path include BFGEntity and ZTFenceEntity; binder files persist with the .xml extension.

BFAIEntityDataShared Property Maps

Shared entity/animal attribute data is hydrated by a property-child reader that dispatches on the key prefix into typed containers:

read_property_children clears and repopulates these maps from XML children; the A binder read-node additionally resolves randomized float-expression entries (rand(...)) into concrete float values at read time. Observed concrete keys at consumer callsites: s_Species, s_Zoopedia, b_NoPerceiveOverride, f_adoptRarity, f_needPointsGood, f_needPointsGoodCum, f_needPointsBad, f_needPointsBadCum. Descriptor-table field strings include fadeHold, wrapValue, minRange, maxRange, maxAlpha, stateList.

BFAITaskTemplate Source Schema

BFAITaskTemplate is a native BFComponent subtype. Its type getter registers the class name with register_type under the BFComponent parent getter, with its own type-cache global. Sibling registered native types in the same task family are BFAITaskRoot, BFAITaskTemplateList, BFAITaskThinker, BFAICreateData, BFAIEvalData, BFAICompletionData, BFBehExecTask, and BFBehExecPath; these are separate component classes.

The template's XML read method hydrates these source keys via the binder attribute readers:

The template is a hydrated configuration component. Scoring, execution, completion, and failure are runtime behaviors owned by the AI thinker/behavior classes (BFAITaskThinker, BFAIEvalData, BFBehExecTask).

catalog relationship model

classDiagram
  AdoptionConfig "*" --> AdoptionSlot : slots
  CatalogItem "1" --> CatalogFilters : filters
  CatalogItem "1" --> PlacementAffordance : placement
  EntityAuthoredEvent "*" --> EntityDataNode : payload_nodes
  EntityDefinition "*" --> EntityTypePath : type_paths
  EntityDefinition "1" --> SharedEntityData : shared
  EntityDefinition "0..1" --> EntityInstanceData : instance
  EntityDefinition "*" --> EntitySubBinder : sub_binders
  EntityFileBinder "*" --> EntityFileState : open_files
  EntityFileBinder "1" --> BFTypedBinderSchema : schema
  EntityFileBinderCommand "1" --> EntityFileCommandKind : command
classDiagram
  EntityFileCommandResult "1" --> EntityFileCommandStatus : status
  EntityInstanceData "*" --> EntityDataNode : nodes
  EntityInstanceData "*" --> EntityAuthoredEvent : authored_events
  EntityInstanceData "*" --> EntityComponentRef : components
  EntityInstanceData "0..1" --> BFComponentContainer : component_container
  EntitySubBinder "*" --> EntityDataNode : instance_nodes
  EntitySubBinder "*" --> EntityDataNode : shared_nodes
  EntitySubBinder "*" --> EntityAuthoredEvent : authored_events
  PlacementAffordance "1" --> CrateVisibility : crate_visibility
  SelectedEntityState "1" --> EntityInfoPanel : panel
  SharedEntityData "*" --> EntityDataNode : nodes
  SharedEntityData "*" --> EntityAuthoredEvent : authored_events

data relationship model

classDiagram
  DataDocument "1" --> DataRoot : root

Open Contracts (Source Object Model)

Primary hydrated source families:

Family Source-owned data Native consumer
BFTypedBinder / BFTypedObj binder name/type/version, ancestry, shared and instance XML, child binders, safe-handle identity entity catalog, component factories, source queries
BFAIEntityDataShared b_*, s_*, f_*, p_* property maps and expressions AI, animal/entity attributes, filters, task evaluation
BFAITaskTemplate (BFComponent subtype) UniqueID/version/Priority, TaskDelayMin/Max, CursorTask/UseForKeeperPanel/DoNotDisturb flags, Subjects/Targets/Objects/Qualifiers(_AND) selection sets, reserve/attach/sensor/defaultSensor tags, objectContainer/objectName task family components (BFAICreateData, BFAIEvalData, BFBehExecTask, BFAICompletionData); AI thinker scheduler and behavior runtime
UI XML retained widget tree, images, loc ids, state, events, templates, skins UIApp/UIRoot/widget classes and message handlers
ZTTransaction min/max/step, frequency, costType, aggregate, parent tracking, next transaction economy manager and placement validation
ZTDiseaseMgr XML disease definitions, filters, cause/cure records, chance/reward fields disease manager, cure mode, status/scenario hooks
Renderer/audio assets .bfmat, .fx, model/material/texture/sound tags resource managers and projection adapters

Native Managers and Global Runtime Ownership

Managers are singleton BFComponent subtypes registered in the type system like any other native type. Each manager owns one domain's runtime state and exposes it through messages/value-handlers. The 66 managers share ownership and singleton lifetime, then stack in three layers under the application.

flowchart TB
  App["ZTApp < BFGApp < UIApp < BF3DApp (owns all managers)"]
  subgraph Source["Source runtime layer"]
    R[BFResourceMgr]
    L[BFLocaleMgr]
    X[BFXMLSchemaMgr]
    Reg[BFRegistry]
    Sc[BFScriptContextMgr]
    P[BFUserProfileMgr]
    T[BFTimeKeeper]
  end
  subgraph Domain["Domain layer"]
    W[ZTWorldMgr]
    AI[ZTAIMgr]
    E[ZTEconomyMgr]
    D[ZTDiseaseMgr]
    Sn[BFSoundMgr]
  end
  subgraph Proj["Projection layer"]
    Rn[BFRenderer]
    Sp[BFSpriteMgr]
  end
  App --> Source --> Domain --> Proj

Source runtime managers

These cross-cutting managers underpin every domain:

Reconstructed fields: BFResourceMgr holds root_path, zip_paths, archive_paths, binder_roots, entries : Vec~BFResourceEntry~, resource_tree; BFLocaleMgr holds locale + string_tables; BFTimeKeeper holds elapsed_seconds, delta_seconds, paused, and a BFTimeEventRoot — the sim clock that fans out scheduled updates; BFXMLSchemaMgr holds schemas : BTreeMap~String, BFXMLSchema~.

Domain managers

Each domain manager is documented in its own section. The game-level subclass usually descends from a Blue Fang base: ZTWorldMgr, ZTAIMgr (< BFAIMgr), ZTEconomyMgr, ZTResearchMgr, ZTDiseaseMgr, ZTAdoptionMgr (→ ZTAdoptionSlotMgr), ZTAwardMgr, ZTScenarioMgr (< BFScenarioMgr), ZTTankMgr, ZTTransportationMgr (< BFGTransportationMgr), ZTWorldSndMgr, BFGTraversabilityMgr, BFGPathFinderMgr, BFGRampageMgr, BFGInfluenceMgr, BFGCollisionMgr, BFSteeringMgr, BFLocomotionMgr, the ZTAI*Mgr per-entity-type managers, BFSoundMgr/BFSoundStageMgr, BFRenderer/ BFSpriteMgr, and the undo chain (BFUndoMgr → BF3DUndoMgr → BFGUndoMgr → ZTUndoMgr).

Cross-cutting/tooling managers

Managers without a dedicated domain section: ZTToolMgr (active tool), ZTGestureMgr (gesture input, with cloning/training gesture modes), ZTLocationMgr (named map locations), ZTViewableObjectMgr/ZTViewableSubMgr (< BFGViewableObjectMgr — visible object tracking for tours/photos), ZTFeedbackMgr (player feedback), ZTPuzzleMgr (< BFGPuzzleMgr), ZTFavoriteAnimalMgr, ZTTrickButtonMgr.

Registration and lifetime contract

Every manager is obtained through its lazy type getter (guarded cache global, parent via the parent getter, name interned by register_type). The application root (ZTApp) constructs and owns them; their state is what Persistence serializes.

Runtime config and the simulation clock

The game-speed/tick controller is reconstructed: ZTSimController holds paused, speed_index, feedback_control/gain, min_interval_seconds/ max_interval_seconds, and a simulation_time : BFTimeKeeper. It is the adaptive clock that paces all scheduled component updates.

Manager behaviour is config-driven; each manager has an authored *Config schema, e.g. ZTAIGuestMgrConfig (max_guests_base, max_guests_per_star, spawn_at_entrance, displacement_*), BFGRampageConfig (the rampage formula — see World), and BFGCollisionTesterConfig/BFGTraversabilityViewingConfig.

app relationship model

classDiagram
  UiListRowChildProjection "0..1" --> BFUITextDocument : rich_text
  UiListRowChildProjection "*" --> UiEvent : activate_events
  UiListRowProjection "*" --> UiListRowChildProjection : children
  UiListRowProjection "*" --> UiEvent : on_events
  UiRuntimeValues "*" --> UiNamedTextValue : named_text
  UiTemplateDocument "1" --> UiDocument : document
  UiWidgetRuntimeState "0..1" --> UiRegion : region
  UiWidgetRuntimeState "1" --> UiPoint : scroll_position
  UiWidgetRuntimeState "0..1" --> UIDragAxis : thumb_axis
  UiWidgetRuntimeState "0..1" --> UiSliderThumbTrack : thumb_track
  ZTConfirmationRuntime "0..1" --> ZTExitConfirmation : exit_confirmation

managers relationship model

classDiagram
  BFGPathRequest "0..1" --> BFGPathResult : result
  BFGPathGraph "*" --> BFGPathNode : nodes
  BFGPathGraph "*" --> BFGPathEdge : edges
  BFGTraversabilityRuntimeCollections "*" --> BFGTraversableArea : area_collection_offset_44
  BFGTraversabilityRuntimeCollections "*" --> ChangedTriangleRecord : changed_triangles_offset_b4
  BFGTraversabilityRuntimeCollections "*" --> ChangedTriangleRecord : immediate_changed_triangles_offset_c0
  BFGTraversabilityInvalidationQueue "*" --> ChangedTriangleRecord : delayed
  BFGTraversabilityInvalidationQueue "*" --> ChangedTriangleRecord : immediate
  BFGTraversabilityCollisionTest "1" --> BFGCollisionTesterConfig : tester
  BFGTraversabilityCollisionTest "0..1" --> BFGTraversabilityCollisionResult : result
  ZTFeedbackGlobalThought "0..1" --> ZTMessageInfo : message
  ZTFeedbackGlobalDisplay "*" --> ZTFeedbackDisplayTemplate : templates
classDiagram
  ZTPAPTBFAICognitiveMgr "*" --> ZTPAPTCognitiveTemplate : registered_templates
  ZTPAPTBFAICognitiveMgr "*" --> ZTPAPTCognitiveInstance : active_instances
  ZTPAPTBFBehaviorMgr "*" --> ZTPAPTBehaviorTemplate : behavior_templates
  ZTPAPTBFBehaviorMgr "*" --> ZTPAPTBehaviorInstance : active_behaviors

runtime support relationship model

classDiagram
  BFBinder <|-- BFNamedBinder
  BFXMLObj <|-- BFRefCountedXMLObj
  BFGManagerContextComponent "*" --> BFContextComponent : children
  BFLuaConfig "0..1" --> BFLuaLogConfig : log
  BFLuaLogConfig "*" --> BFLuaLogChannelConfig : channels
  BFNamedBinder "1" --> BFBinder : binder
  BFPerformanceCommandQueue "*" --> BFPerformanceCommand : pending
  BFPerformanceCommandQueue "*" --> BFPerformanceCommand : completed
  BFPerformanceMonitor "1" --> BFPerformanceCommandQueue : commands
  BFRefCountedXMLObj "1" --> BFXMLObj : object
  BFTypedBinderDescriptor "*" --> BFTypedBinderDataRoot : data_roots
  BFTypedBinderDescriptor "*" --> BFTypedBinderTypeRule : type_rules
  BFTypedBinderCommandDispatcher "*" --> BFTypedBinderCommand : commands
  BFTypedBinderCommandDispatcher "0..1" --> BFTypedBinderCommandResult : last_result
classDiagram
  BFUndoEventRoot "0..1" --> BFUndoActivateTransaction : active_transaction
  BFUserOptions "1" --> BFGraphicsOptions : graphics
  BFUserOptions "1" --> BFAudioOptions : audio
  BFUserProfileEventRoot "*" --> BFUserProfileCommand : commands
  BFUserProfileEventRoot "*" --> BFUserProfileActionResult : results
  DxDiag "*" --> DxDiagSoundDevice : sound_devices
  DxDiag "*" --> DxDiagDisplayDevice : display_devices
  DxDiag "*" --> DxDiagResultCopy : copied_results
  UIRootAppConfig "0..1" --> UIRootRegionConfig : region
  UIRootAppConfig "*" --> UIRootHotKeyConfig : hotkeys
  UIRootAppConfig "*" --> UiHotKeyBinding : hotkey_bindings
  UIRootAppConfig "0..1" --> UiDocument : document
  UserSettings "1" --> BFGraphicsOptions : safe_graphics
classDiagram
  VinceLog "0..1" --> VinceLogGuid : guid
  ZT2Client "1" --> BF3DApp : app
  ZTCommandStateSet "*" --> ZTCommandStateEvent : history
  ZTDebugCommandQueue "*" --> ZTDebugCommand : pending
  ZTDebugCommandQueue "*" --> ZTDebugCommand : completed
  ZTDevConsole "*" --> ZTDevConsoleCommand : commands
  ZTDevConsole "*" --> ZTDevConsoleAlias : aliases
  ZTDevConsole "*" --> ZTDevConsoleResponse : bad_word_responses
  ZTDevConsole "*" --> ZTDevConsoleMessageCommand : pending_messages
  ZTDownloadsState "*" --> ZTWebFileTransfer : active_downloads
  ZTEULACheckAppConfig "*" --> ZTEulaConfig : eulas
classDiagram
  ZTFilePathResolver "0..1" --> ZTAbsoluteFilePathRequest : last_request
  ZTHardwareConfigRegistry "*" --> ZTHardwareRequirementSet : requirement_sets
  ZTHardwareRequirementSet "1" --> ZTGraphicsRequirement : graphics
  ZTWEB "*" --> ZTWebEvent : events
  ZTWEB "*" --> ZTWebFileTransfer : transfers
  ZTWEB "1" --> ZTWebRequestQueue : requests
  ZTWEB "1" --> ZTWebCommandQueue : commands
  ZTWEB "1" --> ZTWebMotdState : motd
  ZTWebCommandQueue "*" --> ZTWebCommand : pending
  ZTWebCommandQueue "*" --> ZTWebCommand : completed
  ZTWebFileTransfer "1" --> ZTWebRequestKind : request_kind
  ZTWebMotdState "0..1" --> ZTWebMotdDefaultIconResource : default_icon
  ZTWebMotdState "*" --> ZTWebMotdMessage : messages
  ZTWebMotdMessage "1" --> BFUITextDocument : content
  ZTWebRequestQueue "*" --> ZTWebRequest : pending
  ZTWebRequestQueue "*" --> ZTWebRequest : completed
  ZTWebRequest "1" --> ZTWebRequestKind : kind

Open contracts (Managers)

UI Runtime and App Lifecycle

The UI is a custom retained widget tree. Widgets are BFComponent subtypes hydrated from ui/layout XML into a tree; behaviour runs through a message bus of 183 interned UI_* tokens; widget values are bound to game state through value-handlers. The whole application is a UI app.

The application is a UI app

classDiagram
  BFComponentList <|-- BFApp
  BFApp <|-- BF3DApp
  BF3DApp <|-- UIApp
  UIApp <|-- BFGApp
  BFGApp <|-- ZTApp
  UIContainer <|-- UIRoot

ZTApp is a BFGApp is a UIApp is a BF3DApp: the game application is layered on the UI/3D app stack. UIApp owns the active widget tree whose root is UIRoot (< UIContainer), focus/hover, input routing, and the message/value registries.

Widget class tree

classDiagram
  BFComponent <|-- UIComponent
  UIComponent <|-- UIStatic
  UIComponent <|-- UIContainer
  UIContainer <|-- UIRoot
  UIContainer <|-- UIWindow
  UIContainer <|-- UILayout
  UIContainer <|-- UIDropList
  UIContainer <|-- UISlider
  UIWindow <|-- UIListBox
  UIWindow <|-- UITool
  UIListBox <|-- UIToggleSet
  UIListBox <|-- UITreeElement
  UIListBox <|-- UIXMLEdit
  UILayout <|-- UIText
  UILayout <|-- UIGraph
  UILayout <|-- UIDrag
  UILayout <|-- UICompositeButton
  UICompositeButton <|-- UICompositeHoverButton
  UIText <|-- UIButton
  UIText <|-- UITextEdit
  UIText <|-- UITooltip
  UITextEdit <|-- UITextBuffer
  UIButton <|-- UIPushButton
  UIButton <|-- UIHoverButton
  UIButton <|-- UIToggleButton
  UIButton <|-- UIMultiIcon
  UIToggleButton <|-- UIToggleHoverButton

Reconstructed widget base (UiComponentBase): every widget carries type_name, template, name, cursor, modal, and can_be_cached_when_called_from_lua — confirming widgets are Lua-addressable, cached source objects.

Note the real lineage: a button is a text widget (UIButton < UIText < UILayout < UIContainer < UIComponent), so every button carries text/layout/containment capability.

Reconstructed widget fields

Each widget nests a typed state struct:

classDiagram
  class UIButtonState { +auto_size; +min_height; +toggle; +sticky; +repress }
  class UITextState { +auto_size; +text_type; +text_format; +loc_id }
  class UIListBoxState { +columns; +rows; +x_spacer; +y_spacer; +column_width }
  class UISliderState { +value_type; +span; +min; +max; +increment }
  class UITextEditState { +max_length; +change_sound; +error_sound; +legal_filename_only; +highlight }
  class UIDropList { +droplist_layout; +horizontal_layout; +selected_index; +items[] }
  class UIToggleSet { +active_toggle; +toggles[]; +allow_repress }
  UIButton *-- UIButtonState
  UIText *-- UITextState
  UIListBox *-- UIListBoxState
  UISlider *-- UISliderState
  UITextEdit *-- UITextEditState

UISlider carries a typed range (value_type/span/min/max/increment); UITextEdit carries max_length, validation (legal_filename_only), and edit sounds; UIListBox is a grid (columns/rows/spacers).

Geometry, data, and presentation objects

Non-widget UI data are BFXMLObj/BFTypedObj value objects: geometry UIRegion, UIRectObj, UIPointObj, UIColorObj; data UIChildData, UIEventList, UIFontData, UIKeyData, UIMouseData, UINotifyData; presentation/state UIState, UIAspect, UIAnimation, UIHelpInfo, UIHotKeys. UISoundMgr (< BFComponent) plays UI sound.

Message bus

The 183 UI_* names are interned tokens, registered through the same register_type registrar as native types via the registration table. They form the dispatch contract, grouped by role:

Reconstructed dispatch infrastructure: a BFMessageBus holds listeners : Vec~BFMessageListener~ + queued_events : BFEventList; each BFMessageListener binds owner/message/callback_name. Widget values cross the bus as UIInlineTypedValue (value_type : UiValueTypeHandle, ref_count, payload), with typed payloads UIFloatPayloadValue/UIStringPayloadValue/UIPointerPayloadValue — the ref-counted value objects behind UI_CHANGED_VALUE.

Reconstructed field detail (UI animation)

Modeled fields: UIAnimation carries start_region/end_region (BfRect), colors (UiShowHideColors), and a UIAnimationRuntime (running, elapsed_seconds, exit_rate, initial_time, initial_dir) with UIAnimationKeyFrames (time_seconds/region/color/alpha), the concrete backing for the UI_SET_ANIM_RECT_*/UI_SET_ANIM_COLOR_* messages.

Value-handler binding (UI <-> game state)

Managers register named value-handlers that widgets bind to. Examples are register_globe_ui_value_handlers, register_scenario_campaign_ui_value_handlers, and handle_<x>_ui_value bodies; the producer/consumer side is the economy/fame make_<x>_value/accept_<x>_value pattern. ZT_GET_ZOO_CASH etc. reach labels through this value-handler path.

Startup lifecycle

stateDiagram-v2
  [*] --> Boot
  Boot --> LoadSources : mount Z2F, UI, loc, assets
  LoadSources --> Splash : source UI visible
  Splash --> Title : ZT_SPLASH_CLOSED
  Title --> MainMenu : ui/layout/mainmenu
  MainMenu --> InGame : profile/campaign/scenario -> ZT_SETMODE

ZT_SPLASH_CLOSED is a lifecycle transition interpreted by ZTApp; ui/layout/mainmenu.xml drives the menu widget tree. App bootstrap is authored (ZTAppConfig): components, log : BFLogAppConfig, resource_mgr : BFResourceMgrAppConfig, registry, extra_paths, eula_check, xp_info_folder — the startup component/config graph (options/app.xml).

Data flow

sequenceDiagram
  participant XML as ui/layout XML
  participant Root as UIRoot / UIApp
  participant W as widget (UIButton ...)
  participant Bus as UI_* message bus
  participant H as value handler -> manager
  XML->>Root: hydrate widget tree (+skins, loc, fonts)
  W->>Bus: user input -> UI_ACTIVATE / UI_CHANGED_VALUE
  Bus->>H: routed event block (authored order)
  H->>W: UI_MODIFY / push value back (make_*_value)

Boundary

Data-driven: widget instances, event message order, child target names, image/skin paths, loc ids, font/format ids. Hardcoded native: the set of legal UI_* messages and their meaning, value-handler registration, focus/input routing, and widget vtable methods. Lua remains a scenario/script surface.

ui contract relationship model

classDiagram
  BFLocaleMgrConfig "1" --> BFLocaleDateFormats : date_formats
  BFLocaleMgrConfig "1" --> BFLocaleMonthAbbreviations : month_abbreviations
  BFUITextDocument "*" --> BFUITextNode : nodes
  BfFont "0..1" --> BfColor : color
  LocalizationTextFormat "0..1" --> BfColor : color
  UIButtonVisualState "0..1" --> BfRect : region
  UIButtonVisualState "0..1" --> BfColor : text_color
  UIDragCommand "1" --> UiComponentBase : base
  UIDragCommand "1" --> UIDragAxis : axis
  UIGraphState "*" --> UIGraphSeries : series
  UIGraphState "1" --> UIGraphAxis : x_axis
  UIGraphState "1" --> UIGraphAxis : y_axis
  UIGraphState "*" --> UIGraphLabel : labels
classDiagram
  UIMultiIconState "*" --> UIMultiIconEntry : entries
  UIMultiIconEntry "0..1" --> UiMetricRect : rect
  UiAspect "1" --> UiAspectHitPolicy : always_hit
  UiAspect "0..1" --> UiVisualState : default
  UiAspect "*" --> UiNamedVisualState : standard
  UiAspect "*" --> UiNamedVisualState : alternate
  UiDocument "1" --> UiNode : root
  UiDocument "*" --> UiSkin : skins
  UiEvent "0..1" --> BfColor : color
  UiEvent "0..1" --> BfColor : child_color
  UiEvent "*" --> UiPayloadNode : payload_nodes
  UiEventBlock "1" --> UiEventTrigger : trigger
  UiEventBlock "*" --> UiEvent : events
  UiHotKeyBinding "1" --> UiHotKeyTrigger : trigger
  UiHotKeyBinding "1" --> UiEvent : event
  UiMetricRect "1" --> UiMetric : x
  UiMetricRect "1" --> UiMetric : y
  UiMetricRect "1" --> UiMetric : width
  UiMetricRect "1" --> UiMetric : height
  UiNamedVisualState "1" --> UiVisualState : visual
classDiagram
  UiNode "1" --> UiWidget : widget
  UiNode "0..1" --> UiRegion : region
  UiNode "1" --> UiState : state
  UiNode "0..1" --> UiShowHideAnim : show_hide_anim
  UiNode "0..1" --> UiAspect : aspect
  UiNode "0..1" --> UiAspectHitPolicy : always_hit
  UiNode "0..1" --> UiHelpInfo : help
  UiNode "*" --> UiFieldBinding : fields
  UiNode "*" --> UiHotKeyBinding : hotkeys
  UiNode "*" --> UiEventBlock : events
  UiNode "*" --> UiAttribute : unknown_attributes
  UiPayloadNode "*" --> UiAttribute : attributes
  UiRegion "1" --> UiMetric : x
  UiRegion "1" --> UiMetric : y
  UiRegion "1" --> UiMetric : width
  UiRegion "1" --> UiMetric : height
  UiRegion "1" --> UiRegionAlign : x_align
  UiRegion "1" --> UiRegionAlign : y_align
  UiRegion "1" --> UiRegionAlign : width_align
  UiRegion "1" --> UiRegionAlign : height_align
  UiShowHideAnim "0..1" --> BfRect : start_region
  UiShowHideAnim "0..1" --> BfRect : end_region
  UiShowHideAnim "0..1" --> UiShowHideColors : colors
classDiagram
  UiSkin "*" --> UiSkinReplacement : replacements
  UiSkin "*" --> UiSkinTheme : themes
  UiSkinTheme "*" --> UiSkinReplacement : replacements
  UiState "1" --> UiActiveState : active
  UiVisualState "0..1" --> UiAspectHitPolicy : always_hit
  UiVisualState "0..1" --> UiMetricRect : rect
  UiVisualState "0..1" --> BfColor : color
  UiVisualState "0..1" --> BfFont : font
  ZTUITimedEvents "1" --> UiComponentBase : base
  ZTUITimedEvents "*" --> ZTUITimedEvent : events
  ZTUITimedEvent "1" --> UiEvent : event

ui binding relationship model

classDiagram
  BFFontData "1" --> UIFontData : font
  UIActivationCommand "1" --> UICommandTarget : target
  UIAlphaCommand "1" --> UICommandTarget : target
  UIColorCommand "1" --> UICommandTarget : target
  UIEnableCommand "1" --> UICommandTarget : target
  UIEventNotification "1" --> UIEventRoute : route
  UIHotKeyDocument "1" --> UIHotKeys : hotkeys
  UIHotKeyDocument "*" --> UIHotKeyBinding : bindings
  UIPositionCommand "1" --> UICommandTarget : target
  UIRegionCommand "1" --> UICommandTarget : target
  UIRegionCommand "0..1" --> UIRectObj : rect
  UIScrollCommand "1" --> UICommandTarget : target
  UISizeCommand "1" --> UICommandTarget : target
  UITextCommand "1" --> UICommandTarget : target
classDiagram
  UIVisibilityCommand "1" --> UICommandTarget : target
classDiagram
  UiBindingDomain "1" --> UiValueHandlerRegistry : handler_registry
  UiBindingDomain "1" --> BFMessageBus : message_bus
  UiBindingDomain "1" --> UiNamedValueAssignmentList : named_assignments
  UiBindingDomain "1" --> ZTUITimedEvents : timed_events
  UiBindingDomain "1" --> UIHotKeyDocument : hotkeys
  UiBindingDomain "1" --> ZTMessagesDocument : messages
  UiBindingDomain "1" --> ZTEntriesDocument : entries
  UiBindingDomain "1" --> ZTChallengesDocument : challenges
  UiBindingDomain "*" --> UiMoneyEvent : money_events
  UiBindingDomain "*" --> ZTUITypeList : type_lists
  UiBindingDomain "*" --> ZTUIResearchButton : research_buttons
  UiBindingDomain "*" --> ZTUIAdoptionButton : adoption_buttons
  UiBindingDomain "0..1" --> ZTUIFullscreenButton : fullscreen_button
  UiBindingDomain "1" --> ZTBuyInfoPanel : buy_info_panel
  UiBindingDomain "1" --> ZTGoalPanel : goal_panel
  UiBindingDomain "*" --> ZTMultiList : multi_lists
  UiBindingDomain "1" --> ZTAwardPanel : award_panel
  UiBindingDomain "1" --> ZTZoopediaTOC : zoopedia_toc
  UiBindingDomain "*" --> ZTGenericConfirmation : confirmations
  UiBindingDomain "*" --> ZTNamedEventRoute : named_event_routes
  UiBindingDomain "*" --> ZTUIAutoPopulateList : auto_populate_lists
  UiBindingDomain "*" --> ZTUITypeFilterCommand : type_filter_commands
  UiBindingDomain "*" --> ZTUIActivateButtonCommand : activate_button_commands
  UiBindingDomain "*" --> ZTMultiListCommand : multi_list_commands
  UiBindingDomain "*" --> ZTZoopediaNavigation : zoopedia_navigation
  UiBindingDomain "1" --> ZTLogEntitySelection : log_entity_selection
classDiagram
  UiMoneyEvent "1" --> UiMoneyEventKind : kind
  UiMoneyEvent "1" --> UIFloatPayloadValue : amount_payload
  UiNamedValueAssignment "1" --> UiValueTypeHandle : value_type
  UiNamedValueAssignment "1" --> UiValueAssignmentBase : base
  UiNamedValueAssignmentList "*" --> UiNamedValueAssignment : assignments
  UiPayloadTypedValue "1" --> UiValueTypeHandle : value_type
  UiPayloadTypedValue "1" --> UiPayloadValue : payload
  UiValueAssignmentBase "0..1" --> UiTypedValue : current_value
  UiValueAssignmentBase "*" --> UiValueAssignmentDependentRef : dependent_refs
  UiValueAssignmentDependentRef "1" --> UiDependentRefKey : key
  UiValueHandlerEntry "1" --> UiHandlerOwner : owner
  UiValueHandlerRegistry "*" --> UiValueHandlerEntry : entries
  ZTAwardPanel "*" --> ZTAwardPanelEntry : current_awards
  ZTAwardPanel "*" --> ZTAwardPanelEntry : persistent_awards
classDiagram
  ZTBuyInfoPanel "0..1" --> ZTBuyInfoKind : info_kind
  ZTBuyInfoPanel "*" --> ZTBuyInfoFilter : filters
  ZTBuyInfoPanel "*" --> ZTBuyInfoRow : property_rows
  ZTChallengesDocument "*" --> ZTMessageInfo : challenge_messages
  ZTEntriesDocument "*" --> ZTZoopediaEntry : entries
  ZTFeedbackData "*" --> ZTFeedbackRecord : records
  ZTFeedbackDataSet "*" --> ZTFeedbackRecord : records
  ZTFeedbackRecord "0..1" --> ZTFeedbackClickTarget : click_target
  ZTMessagesDocument "*" --> ZTMessageInfo : messages
  ZTMultiList "*" --> ZTMultiListTab : tabs
  ZTMultiList "*" --> ZTMultiListRow : rows
  ZTNamedEventRoute "*" --> UiValueMessage : events
classDiagram
  ZTSharedFeedbackData "*" --> ZTFeedbackDataSet : feedback_sets
  ZTSharedFeedbackData "*" --> ZTFeedbackData : feedback_data
  ZTUIAutoPopulateList "*" --> ZTUITypeListFilter : filters
  ZTUIAutoPopulateList "*" --> ZTUITypeListEntry : rows
  ZTZoopediaNavigation "1" --> ZTZoopediaNavigationDirection : direction

Open contracts (UI)

Entity and Animal Model

An entity is a component aggregate. BFGEntity (parent BFComponentNameMap) is a named component map. Its single native C++ subtype in the binary is ZTFenceEntity. Every other kind of object the player sees — animal, guest, staff, scenery, building, food, path, tank, gate, ride, vehicle — uses the same BFGEntity class, distinguished by binder type and aggregated BFComponent subtypes. "Animal" is a composition over that shared entity class.

classDiagram
  class BFGEntity {
    name-keyed component map
    mainObjName component (cached)
    read_instance_xml_node()
    resolve_main_object_name_value()
  }
  BFComponentNameMap <|-- BFGEntity
  BFGEntity <|-- ZTFenceEntity : ONLY native subtype
  BFGEntity *-- BFGEntityContainer : containment
  BFGEntity *-- BFGEntitySndComponent : sound
  BFGEntity *-- BFGEnvironmentComponent : environment
  BFGEntity *-- BFGInfluenceComponent : influence field
  BFGEntity *-- BFGridCollisionComponent : collision
  BFGEntity *-- BFSceneGraphComponent : render/scene attach
  BFGEntity *-- BFGEntityTriggerMgr : triggers
  BFGEntity *-- BFGPlacementData : placement footprint
  BFGEntity ..> BFAIEntityDataShared : AI/animal entities only
  BFGEntity ..> BFAICognitiveComponent : AI/animal entities only
  BFGEntity ..> BFLocomotion : moving entities only

Component roles

Each aggregated component is itself a registered native type (a BFComponent unless noted). The entity's behaviour is the union of whichever components its binder attaches:

Component Parent Role
BFGEntityContainer (+ …Slot, …SlotHeavy/Light) BFComponent / BFXMLObj holds other entities (guests on rides, animals in tanks)
BFGEntitySndComponent BFComponent per-entity sound emission
BFGEnvironmentComponent BFComponent local environment contribution/effect
BFGInfluenceComponent (+ BFGInfluenceMgr, BFGInfluenceController) BFComponent / BFAIDataController influence-field source read by AI
BFGridCollisionComponent BFPhysComponent grid collision footprint
BFSceneGraphComponent BFPhysComponent attaches the entity into the render scene graph
BFGEntityTriggerMgr BFComponent event triggers (config/entitytriggers.xml); rules are BFGEntityTriggerRule (primary/secondary/count/proximity/attribute -> on_message/off_message)
BFGPlacementData BFComponent placement footprint/flags
BFGContainerData, BFGEntityMoveData, BFGEntityMorphData, BFGEntitySharedEventData, BFGEntityFittingSurface BFXMLObj / BFWorldFittingSurface per-entity data holders (BFGEntityMorphData has schema bfgentitymorphdata.xdr)

Hydration

An entity is created through a BFTypedBinder, which separates per-type shared XML from per-instance instance XML. The instance document is read to populate the entity's component set. The main-object-name component is built lazily from the s_mainObjName key by querying the entity's own component provider, then cached on the entity.

Animal = entity + AI/animal components

An animal is a BFGEntity binder type that additionally aggregates the AI/animal component set:

The reconstruction aggregates the component-derived animal state into a ZTAnimal runtime view, and the authored type into ZTAnimalTypeDefinition. These are the real animal state surfaces, sourced across the entity's binder + components:

classDiagram
  class ZTAnimal {
    +entity_id; +source_identity
    +species; +family; +biome; +endangerment; +sex
    +variant : ZTAnimalVariantState
    +status_flags : ZTAnimalStatusFlags
    +life_cycle : ZTAnimalLifeCycleState
    +needs / training / disease_state / conservation
    +adoption_state / release_state / crate_state / family_tree
  }
  class ZTAnimalLifeCycleState {
    +stage; +adult; +pregnant
    +pregnancy_months_remaining; +offspring_count
    +total_endangered_births; +pregnancy; +pending_birth
  }
  class ZTAnimalVariantState { +adult_type; +young_type; +male_type; +female_type; +current_variant_type }
  class ZTAnimalTypeDefinition {
    +entity_type; +binder_type; +abstract_type
    +species; +family; +biome; +source_identity
  }
  ZTAnimal *-- ZTAnimalLifeCycleState
  ZTAnimal *-- ZTAnimalVariantState
  ZTAnimalTypeDefinition ..> ZTAnimal : hydrate_runtime_animal_from_source_type

Lifecycle (ZTAnimalLifeCycleState) and breeding (ZTAnimalPregnancyRecord: mother_entity/father_entity/offspring_source_type/litter_size/ inherited_variant) are concrete; select_runtime_variant resolves adult/young/ male/female variants. update_status_from_components shows the state is read from the entity's components, confirming the composition model. Adoption is owned by ZTAdoptionMgr/ZTAdoptionSlotMgr, favorites by ZTFavoriteAnimalMgr.

Open (from todo!()): breeding/offspring rules, training learning deltas, and the component→status read for several flags.

Consumers

World/AI managers read and mutate entities through their components: BFGManager, BFGPlacementGrid, BFGTraversabilityMgr, BFGPathFinderMgr, BFGRampageMgr, BFGTransportationMgr, BFGInfluenceMgr, BFGEntityTriggerMgr, ZTWorldMgr, ZTAIMgr. Cross-entity commands travel as BFG_EVENT / BFGECONOMY_EVENT messages. Adoption/buy is owned by ZTAdoptionMgr / ZTAdoptionSlot. Selection/info: ZTSelectedEntity (entity_id/entity_type/panel_family) and ZTEntitySelector drive the entity-info panels. The buy/catalog panels are backed by ZTUITypeList (root_type/type_filter/selected_type) over ZTUITypeListEntry (entity_type/display_name/icon/loc_id) with ZTUITypeListFilter (property_name/selected_value).

animal relationship model

classDiagram
  ZTAdoptionMgr <|-- ZTAdoptionSlotMgr
  AnimalDomain "1" --> ZTAdoptionMgr : adoption_mgr
  AnimalDomain "1" --> ZTAdoptionSlotMgr : adoption_slot_mgr
  AnimalDomain "1" --> ZTFavoriteAnimalMgr : favorite_animal_mgr
  AnimalDomain "*" --> ZTAnimal : animals
  AnimalDomain "*" --> ZTAnimalSourceIdentity : source_resolutions
  AnimalDomain "*" --> ZTAnimalBirthEvent : birth_events
  AnimalDomain "*" --> ZTAnimalUiAction : user_actions
  ZTAnimalFamilyTree "*" --> ZTAnimalLineageRecord : relation_rows
  ZTAnimalNeeds "*" --> ZTAnimalNeed : rows
  ZTAnimalNeeds "1" --> ZTHappyFactors : happy_factors

entity info relationship model

classDiagram
  EntityInfoDomain "0..1" --> ZTSelectedEntity : selected
  EntityInfoDomain "1" --> ZTEntitySelector : selector
  EntityInfoDomain "*" --> ZTEntitySelectionRequest : selection_requests
  EntityInfoDomain "*" --> ZTEntityInfoActionCommand : action_commands
  EntityInfoDomain "*" --> ZTEntityInfoPanel : panels
  EntityInfoDomain "1" --> ZTBuyInfoPanel : buy_panel
  ZTAnimalFamilyTreePanel "*" --> ZTAnimalFamilyRelationRow : rows
  ZTDonationListPanel "*" --> ZTDonationListRow : rows
  ZTEntityInfoPanel "1" --> ZTEntityActionControls : action_controls
  ZTEntityInfoPanel "1" --> ZTEntityNeedsPanel : needs
  ZTEntityInfoPanel "1" --> ZTAnimalFamilyTreePanel : family_tree
  ZTEntityInfoPanel "1" --> ZTTrainingAreaListPanel : training
  ZTEntityInfoPanel "1" --> ZTDonationListPanel : donations
  ZTEntityInfoPanel "1" --> ZTInventoryPanel : inventory
  ZTEntityInfoPanel "1" --> ZTGenderDisplay : gender
  ZTEntityInfoPanel "1" --> ZTQuantityDisplay : quantity
  ZTEntityNeedsPanel "*" --> ZTEntityNeedRow : rows
classDiagram
  ZTEntitySelectionRequest "0..1" --> ZTEntitySelectionQuery : query
  ZTInventoryPanel "*" --> ZTInventoryRow : rows
  ZTTrainingAreaListPanel "*" --> ZTTrainingAreaRow : rows

Open contracts (Entity)

AI, Behavior, Guests, Staff, and Shows

AI is a four-layer component stack mounted on an entity, plus per-entity-type managers. Cognition decides what, the task pipeline picks a concrete job, a behavior carries it out, and steering/locomotion moves the body. Every layer is a registered BFComponent subtype attached by the entity's binder.

Cognition layer (perceive and decide)

BFAIComponent descends from BFScriptComponent — AI components are scriptable. The cognition base BFAICognitiveComponent fans out into perception (BFAISensor) and two thinkers (state-machine and task-selection); the game subclasses each.

classDiagram
  BFScriptComponent <|-- BFAIComponent
  BFAIComponent <|-- BFAIEntityComponent
  BFAIComponent <|-- BFAIEntityMgr
  BFAIEntityComponent <|-- BFAICognitiveComponent
  BFAICognitiveComponent <|-- BFAISensor
  BFAICognitiveComponent <|-- BFAIStateThinker
  BFAICognitiveComponent <|-- BFAITaskThinker
  BFAISensor <|-- BFAISensorSelf
  BFAISensor <|-- ZTAISensor
  ZTAISensor <|-- ZTAISensorExplore
  ZTAISensor <|-- ZTAISensorTour
  BFAIStateThinker <|-- ZTAIStateThinker
  BFAITaskThinker <|-- ZTAITaskThinker
  BFAITaskThinker <|-- ZTAIStaffTaskThinker
  BFAITaskThinker <|-- ZTAITourTaskThinker

Reconstructed cognition fields: BFAISensor has sensor_type/subject_type/ target_types; BFAIStateThinker has current_state + state_vars : Vec~BFAIStateVar~; BFAIDataController holds thresholds : Vec~BFAIDataThresholdController~ (property_name/minimum/maximum); and BFAIEntityDataShared is literally the b_*/s_*/f_*/p_* maps — bool_properties, string_properties, float_properties, float_maps, vector_properties (keyed BTreeMaps).

Sensors are a wide family (ZTAISensorExplore, …Land, …Path, …Show, …Tour, …Transport, …VA view-area, …TA traversable-area, …FossilSites, …Rampage, …RampagingAnimals). Cognition reads attribute data — BFAIAttributeFloatMap (BFAIBiomeMap, BFAINeedAdjusts), BFAISubjectData/BFAITargetData — and is driven on a ThinkerInterval schedule.

Task pipeline (pick a concrete job)

BFAITaskThinker selects from BFAITaskTemplates (authored under BFAITaskCatalog/ BFAITaskDocument):

classDiagram
  class BFAITaskTemplate {
    +name : Name
    +unique_id : UniqueID
    +task_delay_min_seconds : TaskDelayMin
    +task_delay_max_seconds : TaskDelayMax
    +create_data / eval_data / execution_data
    +completion_data / failure_data
    +follow_up_behaviors[] / sections[]
    +evaluate()  TODO
    +instantiate() BFAITaskRoot  TODO
  }
  class BFAICreateData {
    +behavior_type / subject_type / target_type
    +subject_selectors[] / target_selectors[] / object_selectors[]
    +qualifiers[]
  }
  class BFAIEvalData {
    +evaluator_name; +fixed_score; +need_points_bad; +threshold
    +evaluators[]; +controllers[]; +multi_controller
  }
  class BFAICompletionData {
    +token_name; +success
    +mutations[]; +feedback[]; +follow_up
  }
  class BFAITaskRoot {
    +template_name; +behavior; +execution; +state
    +run()  TODO
    +complete()  TODO
    +fail()  TODO
  }
  class BFAIToken {
    +name; +give_to; +payload; +force
    +owner_entity; +target_entity; +target_position
  }
  BFAITaskTemplate *-- BFAICreateData
  BFAITaskTemplate *-- BFAIEvalData
  BFAITaskTemplate *-- BFAICompletionData
  BFAICompletionData <|-- BFAIFailureData
  BFAITaskTemplate ..> BFAITaskRoot : instantiate
  BFAITaskThinker --> BFAITaskTemplateList : candidates
  BFAITaskThinker o-- BFAITaskRoot : active_task
  BFAITaskRoot ..> BFAIToken : reserves

BFAICreateData selects subjects/targets/objects via selector lists + qualifiers (BFAISubjectSelector wraps a BFAISelector + BFAISubjectData subject_type/token_name; BFAIQualifier carries required_tokens/rejected_tokens/required_properties); BFAIEvalData scores (fixed score, need-points, threshold, evaluators + data controllers); instantiate turns a chosen template into a BFAITaskRoot whose run drives a behavior tree and whose complete/fail apply mutations, feedback, and follow-up behaviors. BFAIToken/BFAITokenList reserve targets (give_to, force).

Open (from todo!()): template evaluate/instantiate, BFAITaskRoot run/ complete/fail, and the suppress-failure-message policy.

Behavior layer (do the job)

BFBehavior < BFComponent has ~78 subtypes — the verbs of the simulation. BFBehExecTask is the bridge from the task pipeline; BFBehaviorMgr sequences them.

classDiagram
  BFComponent <|-- BFBehavior
  BFBehavior <|-- BFBehExecTask
  BFBehavior <|-- BFBehaviorMgr
  BFBehavior <|-- BFBehRoute
  BFBehavior <|-- BFBehDock
  BFBehavior <|-- BFBehGotoPos
  BFBehavior <|-- BFBehFollowEntity
  BFBehavior <|-- BFBehAnimate
  BFBehavior <|-- BFBehSendEvent
  BFBehRoute <|-- BFBehExecPath
  BFBehRoute <|-- ZTBehPathRoute
  BFBehRoute <|-- ZTBehTransportRoute
  BFBehDock <|-- BFBehDockSpline
  BFBehDockSpline <|-- ZTBehDockPortal
  BFBehDockSpline <|-- ZTBehDockTankWall
  BFBehavior <|-- ZTBehUseGate
  ZTBehUseGate <|-- ZTBehUsePortal
  ZTBehUseGate <|-- ZTBehUseTankGate
  ZTBehUseGate <|-- ZTBehExitTankGate
  BFBehavior <|-- ZTBehVehicleBase
  ZTBehVehicleBase <|-- ZTBehVehicleGround
  ZTBehVehicleBase <|-- ZTBehVehicleSky

Reconstructed: BFBehavior base carries behavior_type, subject, target, event_root; each subtype adds its own params.

Behavior families: routing (BFBehRoute/ExecPath/PathRoute/TransportRoute), docking (BFBehDock* Now/Queue/Radial/Spline/TAP), movement (GotoPos, FollowEntity, FollowSpline, Wander, Fall, EscapeObstacle, Evasion), animation (BFBehAnimate*, AnimSwitchSet), messaging (SendEvent, SendToken, SendTrigger, SetAttribute, Spawn, Script), and the ZT verbs (CureDisease, DigArtifact, Tour, WatchShow, RideVehicle, ClimbLadder, Morph, SplashGuest, StaffTrainAnimal, ChangeWaterDirtiness, KickOffRider, ...).

Motor layer (move the body)

classDiagram
  BFComponent <|-- BFSteer
  BFComponent <|-- BFSteeringMgr
  BFSteer <|-- BFSteerSeek
  BFSteer <|-- BFSteerPursuit
  BFSteer <|-- BFSteerAvoidObstacle
  BFSteer <|-- BFSteerAvoidEntity
  BFSteer <|-- BFSteerWander
  BFComponent <|-- BFLocomotion
  BFLocomotion <|-- BFLocoAnimate
  BFComponentContainer <|-- BFLocomotionMgr

BFSteeringMgr blends active BFSteer behaviors (Seek/Pursuit/Avoid*/Align/Depth/ Evasion/Wander/Vector) into a desired vector; BFLocomotionMgr realizes it as animated movement (BFLocoAnimate). BFSteeringProfiles aggregates the per-entity active steering set (align / avoid_entity / avoid_obstacle(_ahead) / avoid_vehicle / depth / evasion / pursuit / seek / wander vectors).

Runtime loop

sequenceDiagram
  participant Mgr as BFAIMgr / ZTAIMgr
  participant Cog as BFAICognitiveComponent
  participant Sen as BFAISensor
  participant TT as BFAITaskThinker
  participant Beh as BFBehExecTask -> BFBehavior
  participant Steer as BFSteeringMgr + BFLocomotionMgr
  Mgr->>Cog: tick on ThinkerInterval
  Cog->>Sen: perceive (targets, biome, needs)
  Sen-->>TT: candidate subjects/targets
  TT->>TT: score BFAITaskTemplates (BFAIEvalData)
  TT->>TT: reserve target (BFAIToken)
  TT->>Beh: execute chosen task
  Beh->>Steer: request movement
  Steer-->>Beh: arrived / blocked
  Beh-->>TT: BFAICompletionData / BFAIFailureData

Managers

BFAIMgr < BFAIComponentList (game: ZTAIMgr) owns the AI world. Per-entity-type cognition managers derive from BFAIEntityMgr: ZTAIGuestMgr, ZTAIStaffMgr, ZTAIAmbientsMgr. Specialized managers: BFAIRelationshipMgr, BFAIShowMgr (ZTAIShowMgr), BFAITrickMgr (ZTAITrickMgr), BFAICognitiveMgr, ZTAIStaffWaterCleaningMgr, ZTAITrickPopularityMgr.

Shows, tricks, tours

Shows are a scheduled state machine (ZTAIShowMgr/ZTAIShowScheduler/ZTAIShow/ ZTAIShowComponent/ZTAIShowEvent):

stateDiagram-v2
  [*] --> BETWEENSHOWS
  BETWEENSHOWS --> PRESHOW
  PRESHOW --> CONDUCTING
  CONDUCTING --> POSTSHOW
  POSTSHOW --> BETWEENSHOWS

Show runtime fields: ZTAIShowMgr holds show_songs, score_table (ShowScoreBand), show_size_table, effect_sets; a ShowSong is song_name/sound, a ShowScoreBand is min_tricks/min_score/show_score. ZTAIShow carries show_token_name, state : ShowState, animal_data, guests_invited, ran_to_completion; ZTAIShowScheduler holds queued_shows, between_shows_time_block, pre_show_time_seconds, post_show_time_seconds. Staff: ZTAIStaffMgr adds job_safe_distance, steal_job_threshold, time_category_duration_seconds; staff roles are interned as StaffRoleTypeHandle (role/type_token/runtime_handle).

Tricks: ZTAITrickComponent/Data/Level/Mgr/TargetComponent/PopularityMgr. Tours: ZTAITourTaker/Data/TourTaskThinker/ZTAISharedTourTaker. Guest viewing and donations are behavior-driven (ZTBehViewAnimals, ZTBehViewEvent, process_guest_animal_donation_candidates, the edDonate functions).

Guest viewing and donation

The guest donation/education loop is reconstructed — and recovers some of the donation formula the open contracts flagged:

classDiagram
  class ZTGuestDonationCandidate {
    +target_entity; +target_species; +view_key
    +education_value; +donation_value; +max_tour_view_value
  }
  class ZTGuestDonationScoreFactors {
    +base_donation_amount
    +max_species_donation_factor
    +preferred_animal_view_factor; +preferred_animal_donate_factor
    +view_species_discount; +view_species_discount_cap
  }
  class ZTGuestViewedSpeciesMemory { +guest_entity; +scores; +preferred_animal; +view_species_discount }
  class ZTEdDonateTask { +view_key; +ed_value; +ed_donate; +view_radius; +target_type }
  ZTGuestViewedSpeciesMemory ..> ZTGuestDonationCandidate : scores
  ZTGuestDonationScoreFactors ..> ZTGuestDonationCandidate : weights

A guest accumulates ZTGuestViewedSpeciesMemory (per-species view scores + a preferred_animal); a ZTGuestDonationCandidate weighs education_value/ donation_value/max_tour_view_value; ZTGuestDonationScoreFactors carries the weighting constants (base_donation_amount, max_species_donation_factor, preferred_animal_*_factor, repeat-view view_species_discount/cap). ZTEdDonateTask is the education-donate behavior (ed_value/ed_donate/view_radius). Behaviours ZTBehViewAnimals/ZTBehViewEvent drive it.

Message surface

102 registered BFAI_*/ZTAI_* tokens form the AI query/command/event vocabulary: the BFAI_EVENT root; queries (BFAI_GET_CRITICAL, …GET_ARRIVAL, …GET_RELATED_ENTITIES, ZTAI_GET_SHOW_STAR_RATING, ZTAI_GET_TRICK_SCORE, ZTAI_GET_DONATION_POINTS, ...); tests (BFAI_IS_ENTITY_CONTAINED, …IN_HABITAT, …ON_BIOME, BFAI_HAS_TOKEN); commands (BFAI_CREATE_ENTITY, BFAI_REGISTER_ENTITY, BFAI_ADD_RELATIONSHIP, BFAI_SET_TOKEN_TARGET, BFAI_REMOVE_TOKEN); attribute-changed notifications (BFAI_ATTRIBUTE_CHANGED_BOOL/FLOAT/POINT3/STRING); and the BEH_EVENT_ROOT/ LOCO_EVENT_ROOT/STEER_EVENT_ROOT per-layer roots.

show relationship model

classDiagram
  BFAITrickMgr <|-- ZTAITrickMgr
  ShowDomain "1" --> ZTAIShowMgr : show_manager
  ShowDomain "1" --> BFAITrickMgr : bf_trick_manager
  ShowDomain "1" --> ZTAITrickMgr : trick_manager
  ShowDomain "1" --> ZTAITrickPopularityMgr : popularity_manager
  ShowDomain "1" --> ZTShowMixerManager : mixer_manager
  ShowDomain "1" --> ZTShowTimerManager : timer_manager
  ShowDomain "*" --> ZTAIShow : active_shows
  ShowDomain "*" --> ZTShowMixerEvent : mixer_events
  ShowDomain "*" --> ZTShowSchedulerEvent : scheduler_events
  ShowDomain "1" --> ZTShowSelectionState : show_selection
  ShowEffectSet "*" --> ShowEffect : effects
  ZTAITrickTrainingRequest "0..1" --> ZTAITrickLevel : selected_level
classDiagram
  ZTAITrickData "0..1" --> ZTAITrickPrerequisite : prerequisite
  ZTAITrickData "0..1" --> ZTAITrickTargetData : target
  ZTAITrickData "*" --> ZTAITrickLevel : levels
  ZTAITrickData "1" --> ZTAITrickResultTokens : result_tokens
  ZTShowMix "*" --> ShowEffect : effects
  ZTShowMixerManager "*" --> ZTShowMixerIcon : icons
  ZTShowMixerManager "0..1" --> ZTShowMixerHighlightColor : highlight_color
  ZTShowMixerManager "*" --> ZTShowMix : mixes
  ZTShowMixerManager "*" --> ZTShowMixerChannel : channels
  ZTShowTimerManager "*" --> ZTShowTimer : timers
  ZTShowTimerManager "*" --> ZTShowTimerState : active_timers

ai relationship model

classDiagram
  BFAIEntityData <|-- BFAIEntityDataShared
  AiDomain "1" --> BFAITaskCatalog : task_catalog
  AiDomain "1" --> BFBehaviorMgr : behavior_mgr
  AiDomain "1" --> BFLocomotionMgr : locomotion_mgr
  AiDomain "*" --> BFAIEntityDataShared : entity_shared_data
  AiDomain "*" --> BFAIEntityData : entity_data
  AiDomain "*" --> ZTBehaviorType : behavior_types
  AiDomain "*" --> BFAIToken : tokens
  AiDomain "*" --> ZTAISensor : sensors
  AiDomain "*" --> BFAISensorSelf : self_sensors
  AiDomain "*" --> ZTAISensorPath : path_sensors
  AiDomain "*" --> ZTAISensorTA : ta_sensors
  AiDomain "*" --> ZTAISensorVA : va_sensors
  AiDomain "*" --> BFAINoPerceive : no_perceive_rules
  AiDomain "*" --> BFAIScriptData : script_data
  AiDomain "*" --> ZTAIInfluenceWatcher : influence_watchers
  AiDomain "*" --> BFGInfluenceController : influence_controllers
  AiDomain "*" --> BFGPhysAnimController : phys_anim_controllers
  AiDomain "*" --> ZTBeh : active_behaviors
  AiDomain "*" --> ZTAIStateThinker : zt_state_thinkers
  AiDomain "*" --> ZTAITaskThinker : zt_task_thinkers
  AiDomain "*" --> ZTAIViewData : view_data
  AiDomain "*" --> ZTAITourTaker : tour_takers
  AiDomain "*" --> ZTAIViewAnimals : view_animals
classDiagram
  BFAIMultiDataController "*" --> BFAIDataController : controllers
  BFAIBehaviorSetDocument "*" --> BFAIBehaviorSetRecord : behavior_sets
  BFAIBehaviorSetRecord "1" --> BFAIBehaviorSet : behavior_set
  BFAIBehaviorSetRecord "*" --> BFAITaskSection : sections
  BFAIExecutionData "1" --> BFAIBehaviorSet : behavior_set
  BFAIExecutionData "*" --> BFAITaskSection : sections
  BFAIEvaluator "0..1" --> BFAIEvaluatorKind : kind
  BFAIBiomeMapEval "1" --> BFAIBiomeMap : map
  BFAITargetSelector "1" --> BFAISelector : selector
  BFAITargetSelector "0..1" --> BFAITargetData : target_data
  BFAIObjectSelector "1" --> BFAISelector : selector
  BFAIBehaviorSet "*" --> BFBehavior : behaviors
  BFAIBehaviorSet "1" --> BFAIBehaviorSequence : sequence
classDiagram
  BFAISensor <|-- ZTAISensorPath
  BFAISensor <|-- ZTAISensorTA
  BFAISensor <|-- ZTAISensorVA
  BFAICogShared "*" --> BFAIStateVar : shared_state_vars
  BFAIFadeController "1" --> BFAIFadeHoldData : fade_hold
  ZTAISensorPath "1" --> BFAISensor : sensor
  ZTAISensorTA "1" --> BFAISensor : sensor
  ZTAISensorVA "1" --> BFAISensor : sensor
  ZTAISensorVA "*" --> ZTAIViewData : view_data
  ZTAIInfluenceWatcher "*" --> ZTAIInfluenceEffectData : effects
  ZTAIViewComponent "*" --> ViewedSpeciesScore : viewed_species
  ZTAIVisibleAnimalTarget "0..1" --> ZTAIViewpointCandidate : traversable_viewpoint
  ZTBehAnimateForViewFromTransport "1" --> ZTBehaviorInstance : instance
  ZTBehChangeWaterDirtiness "1" --> ZTBehaviorInstance : instance
classDiagram
  ZTBehFollowBase <|-- ZTBehFollowCable
  ZTBehFollowBase <|-- ZTBehFollowTrack
  ZTBehClimbLadder "1" --> ZTBehaviorInstance : instance
  ZTBehDigArtifact "1" --> ZTBehaviorInstance : instance
  ZTBehDockFence "1" --> ZTBehaviorInstance : instance
  ZTBehDockWater "1" --> ZTBehaviorInstance : instance
  ZTBehEconomy "1" --> ZTBehaviorInstance : instance
  ZTBehFeedback "1" --> ZTBehaviorInstance : instance
  ZTBehFindArtifact "1" --> ZTBehaviorInstance : instance
  ZTBehFollowBase "1" --> ZTBehaviorInstance : instance
  ZTBehFollowCable "1" --> ZTBehaviorInstance : instance
  ZTBehFollowTrack "1" --> ZTBehaviorInstance : instance
  ZTBehKickOffRider "1" --> ZTBehaviorInstance : instance
  ZTBehMorph "1" --> ZTBehaviorInstance : instance
  ZTBehPlaceTarget "1" --> ZTBehaviorInstance : instance
  ZTBehReplaceTrickObject "1" --> ZTBehaviorInstance : instance
  ZTBehRideVehicle "1" --> ZTBehaviorInstance : instance
  ZTBehShowEvent "1" --> ZTBehaviorInstance : instance
  ZTBehSplashGuest "1" --> ZTBehaviorInstance : instance
classDiagram
  ZTBehStaffTrainAnimal "1" --> ZTBehaviorInstance : instance
  ZTBehTargetFence "1" --> ZTBehaviorInstance : instance
  ZTBehTeleportToLoc "1" --> ZTBehaviorInstance : instance
  ZTBehTestTargetPos "1" --> ZTBehaviorInstance : instance
  ZTBehTour "1" --> ZTBehaviorInstance : instance
  ZTBehUseTransport "1" --> ZTBehaviorInstance : instance
  ZTBehWatchShow "1" --> ZTBehaviorInstance : instance
  ZTGuestDonationMemory "*" --> ZTGuestDonationCandidate : candidates
  ZTGuestDonationMemory "0..1" --> ZTAIDonationTaskState : active_task
  ZTGuestDonationMemory "1" --> ZTGuestViewedSpeciesMemory : viewed_species
  ZTGuestDonationMemory "1" --> ZTGuestDonationPruning : pruning
  ZTPAPTBFAIEntityDataInstance "*" --> ZTPredicate : predicates
  ZTPAPTBFPhysObj "*" --> ZTQUERY : position_queries

staff relationship model

classDiagram
  StaffDomain "1" --> ZTAIStaffMgr : manager
  StaffDomain "*" --> ZTStaffRequestData : requests
  StaffDomain "*" --> ZTAIStaffAssignment : assignments
  StaffDomain "*" --> ZTAIStaffAssignmentComponent : assignment_components
  StaffDomain "*" --> ZTStaffTimeCategory : time_categories
  StaffDomain "1" --> ZTStaffAssignmentUi : assignment_ui
  StaffDomain "1" --> ZTAIStaffCandidateSet : candidate_cache
  StaffDomain "*" --> ZTUserStaffAction : user_actions
  ZTAIStaffRequestController "*" --> ZTStaffRequestData : pending
  ZTAIStaffRequestController "*" --> ZTStaffRequestData : accepted
  ZTAIStaffRequestController "*" --> ZTAIStaffRequestEvaluation : rejected
  ZTAIStaffRequestController "*" --> ZTAIStaffBadEntityRecord : bad_entities
  ZTAIStaffJobQueue "*" --> ZTAIStaffJob : pending_jobs
  ZTAIStaffJobQueue "*" --> ZTAIStaffJob : active_jobs
  ZTAIStaffJobQueue "*" --> ZTAIStaffJob : completed_jobs
  ZTAIStaffJobQueue "*" --> ZTAIStaffJob : failed_jobs
  ZTAIStaffJobQueue "*" --> ZTStaffTimeCategory : time_categories
  ZTAIStaffJob "0..1" --> ZTStaffTimeCategory : time_category
  ZTAIStaffJob "1" --> ZTAIStaffJobStatus : status
  ZTAIStaffAssignmentComponent "*" --> ZTAIStaffAssignment : assignments
  ZTAIBadEntityCleanupQueue "*" --> ZTAIStaffBadEntityRecord : bad_entities
  ZTAIStaffRequestEvaluation "0..1" --> ZTStaffRequestData : request
  ZTAIStaffRequestEvaluation "*" --> ZTAIStaffCandidate : candidates
  ZTAIStaffCandidateSet "*" --> ZTAIStaffCandidate : candidates
  ZTAIStaffCandidate "0..1" --> StaffRole : role
classDiagram
  ZTDinoRecoveryTargetSet "*" --> ZTDinoRecoveryTarget : active_targets
  ZTStaffAssignmentUi "1" --> ZTStaffAssignmentCursor : cursor
  ZTStaffAssignmentUi "*" --> ZTStaffAssignmentPanel : panels
  ZTStaffAssignmentUi "1" --> ZTStaffAssignmentTargetSelector : target_selector
  ZTStaffAssignmentPanel "0..1" --> StaffRole : role
  ZTStaffRoleTypeIntern "*" --> StaffRoleTypeHandle : registered_roles
  ZTStaffTaskTokenBinding "0..1" --> StaffRole : staff_role
  ZTStaffTokenConfig "1" --> BFAITokenList : tokens
  ZTUserStaffAction "0..1" --> ZTStaffRequestData : request

Open contracts (AI)

World, Terrain, Placement, Fences, Paths, and Tanks

The world is five cooperating systems: a terrain heightfield + biome paint, a placement grid of tiles, collision/traversability/pathfinding over that grid, linear-structure systems (fences, tanks, paths, transport) that occupy it, and an editing-mode + transaction/undo front end. All world objects are BFComponent subtypes; editing tools are ZTMode subtypes; mutations are BFGTransactions that the undo stack can reverse.

Terrain and biome

classDiagram
  BFComponent <|-- BFTerrain
  BFComponent <|-- BFTerrainBiome
  BFTerrainBiome <|-- BFGBiome
  BFComponent <|-- BFWorldEnvironment
  BFComponent <|-- BFWaterfall
  BFPhysComponent <|-- BFTerrainPaintComponent
  BFNISceneGraphComponent <|-- BFTerrainDecalComponent
  BFDecalComponent <|-- BFTerrainShadowComponent
  BFWorldFittingSurface <|-- BFTerrainFittingSurface
  BFTypedObj <|-- BFWorldFittingSurface
  class BFGBiome { autoplacement variation masks; weighted object lists }

BFGBiome (< BFTerrainBiome) carries autoplacement data; it updates the variation-type mask and reads a weighted object list to scatter foliage/rocks per biome. BFWorldFittingSurface (and BFTerrain/BFGEntity fitting-surface variants) is the query interface entities use to sit on the ground (see ground-fit below).

Placement grid

classDiagram
  BFComponent <|-- BFGPlacementGrid
  BFComponent <|-- BFGPlacementData
  BFGPlacementData <|-- ZTPlacementData
  BFTypedObj <|-- BFGPlacementTile
  BFGPlacementTile <|-- BFGElevatedPlacementTile
  BFComponent <|-- BFGElevatedSupportTracker
  BFXMLObj <|-- ZTPlacementInfo
  class BFGPlacementGrid { tile grid; occupancy }
  class BFGElevatedSupportTracker { elevated path/track support }

BFGPlacementGrid owns the tile grid; BFGPlacementData/ZTPlacementData is the per-object footprint authored data; elevated structures add BFGElevatedPlacementTile + BFGElevatedSupportTracker (support columns) with BFGElevatedTileData/Serializer persistence.

Collision, traversability, pathfinding

classDiagram
  BFTraversabilityMgr <|-- BFGTraversabilityMgr
  BFComponent <|-- BFGTraversableArea
  BFComponent <|-- BFGCollisionMgr
  BFComponent <|-- BFGCollisionHandler
  BFComponent <|-- BFGCollisionTester
  BFComponent <|-- BFGCollisionData
  BFPhysComponent <|-- BFGridCollisionComponent
  BFComponent <|-- BFGPathFinderMgr
  BFComponent <|-- BFGRampageMgr

BFGTraversabilityMgr answers the placement predicates and the OUT_OF_ANIMAL_TRAVERS_AREA check; BFGPathFinderMgr routes movers; BFGRampageMgr handles escaped-animal rampage over the same grid, driven by BFGRampageConfig (the formula): update_interval_seconds, max_good_points/max_bad_points, base_rampage_chance/max_rampage_chance, rampaging_animal_factor, rampage_timeout_seconds.

Linear structures: fences, tanks, gates, paths, transport

The fence system is the base for aquatic tanks — ZTTankSegment is a ZTFence. Gates generalize across tanks and transport. Transport is circuits + tracks + stations + gates.

classDiagram
  BFComponent <|-- ZTFence
  ZTFence <|-- ZTTankSegment
  ZTTankSegment <|-- ZTTankGateSegment
  BFComponent <|-- ZTFenceSegmentInfo
  BFGEntity <|-- ZTFenceEntity
  BFComponent <|-- ZTGate
  ZTGate <|-- ZTTankPortal
  ZTGate <|-- ZTTransportCrossingGate
  ZTGate <|-- ZTTransportVehicleGate
  BFComponent <|-- ZTPathBase
  ZTPathBase <|-- ZTPath
  ZTPathBase <|-- ZTPathElevated
  BFComponent <|-- ZTTank
  BFComponent <|-- ZTTankMgr
  ZTExpandoComponent <|-- ZTTankSupport
classDiagram
  BFGTransportationMgr <|-- ZTTransportationMgr
  BFComponent <|-- ZTTransportCircuitPrivateBase
  ZTTransportCircuitPrivateBase <|-- ZTTransportCircuitBase
  ZTTransportCircuitBase <|-- ZTTransportGroundCircuit
  ZTTransportCircuitBase <|-- ZTTransportSkyCircuit
  BFComponent <|-- ZTTransportTrack
  ZTTransportTrack <|-- ZTTransportGroundTrack
  ZTTransportTrack <|-- ZTTransportSkyTrack
  BFComponent <|-- ZTTransportStationBase
  ZTTransportStationBase <|-- ZTTransportStationGround
  ZTTransportStationBase <|-- ZTTransportStationSky

Reconstructed field detail (transport)

Modeled fields: ZTTransportationMgr holds circuits : Vec~ZTTransportCircuit~, route_direction, paused_circuits, selected_vehicle_type; BFGTransportationMgr holds stations/vehicles/tracks. A ZTTransportCircuit links station_ids/track_ids/vehicle_ids with a closed flag — the runtime ride loop. A ZTTransportVehicle has entity_type, seat_count/occupied_seats, route_token; ZTTransportStation has station_kind, capacity/occupancy; ZTTransportTrack has track_kind + endpoints.

Reconstructed field detail (terrain / placement / tank / fence)

Modeled fields:

classDiagram
  class BFTerrain {
    +grid_width / grid_height
    +height_map : AssetPath
    +terrain_biomes : Vec~BFTerrainBiome~
    +vertices : Vec~BFTerrainVertex~
    +triangles : Vec~BFTerrainTriangle~
  }
  class ZTPlacementData {
    +mode_name; +cursor_xml; +footprint_xml
    +validation_messages[]; +failure_catalog
  }
  class ZTFootprintPreview { +footprint_xml; +grid_cells[]; +blocked_cells[] }
  class ZTTankMgr {
    +water_height_offset; +floor_height_offset
    +minimum_water_depth; +minimum_show_tank_depth
    +selected_tank; +pending_height_commands[]
  }
  class ZTFence { +fence_id; +fence_type; +entities : Vec~ZTFenceEntity~ }
  class ZTFenceEntity { +entity_id; +segment_info; +health }
  class ZTFenceType { +entity_type; +segment_entity; +gate_entities[]; +cost }
  ZTFence "1" *-- "*" ZTFenceEntity
  ZTFenceType ..> ZTFence : authors
  ZTPlacementData *-- ZTFootprintPreview

ZTFenceType is the authored fence definition (segment/gate entities, cost); ZTTankMgr adds water/floor depth tuning and pending height commands over the fence base. ZTPlacementData carries the cursor/footprint assets and a ZTPlacementFailureCatalog (messages : Vec~ZTPlacementFailureMessage~) that maps each place_*/too_steep/CANNOT_AFFORD/UNRESEARCHED result token to its UI message.

Editing modes (tool layer)

The ZTMode base (ZTModeRuntimeFields) is an XML-configured interaction handler: cursor, ui_layout, active, state_token, config_fields, layout_guis, hotkeys/inline_hotkeys, event_blocks : Vec~ZTModeEventBlock~, and message_handlers : Vec~ZTModeMessageHandler~. The reconstruction also models the native surface explicitly — ZTModeClassSurface { runtime, type_cache, vtable, input_state }.

World editing is driven by ZTMode subtypes (a shared interaction-mode base used across the game). The placement/world tools are ZTPlacementMode (< ZTEntityMovementMode), ZTFenceMode, ZTPathMode, ZTElevatedPathMode, ZTElevatedCurbMode, ZTBiomeMode (< ZTEntityMovementMode), ZTGroundTrackMode, ZTTankCommandReader, ZTTerrainCommandReader. (The full ZTMode catalog also covers camera/file/game/photo/gesture/training/overhead/main interaction modes.)

Placement transaction flow

sequenceDiagram
  participant Mode as ZTPlacementMode
  participant Val as validators
  participant Grid as BFGPlacementGrid + BFGTraversabilityMgr
  participant Tx as BFGTransaction / ZTTransaction
  participant Undo as BFGUndoMgr / ZTUndoMgr
  Mode->>Val: preview at cursor tile
  Val->>Grid: footprint + traversability + slope test
  Val->>Val: money (CANNOT_AFFORD) + research (UNRESEARCHED)
  Val-->>Mode: place_yes | place_no + reason (too_steep, place_fence_overlap, no_headroom_path, OUT_OF_ANIMAL_TRAVERS_AREA)
  Mode->>Tx: commit (charge, mutate grid, attach entity)
  Tx->>Undo: push BFUndoTransactionData
  Tx->>Grid: refresh collision/traversability/pathfinding queries

Result tokens are native string constants emitted by the validators/modes: place_yes/place_no, place_fence/place_fence_overlap, place_path/ no_headroom_path, place_track, place_tree/place_plant/place_rock, place_vehicle_ground/place_vehicle_sky, place_animal_entity, plus too_steep, CANNOT_AFFORD, UNRESEARCHED, OUT_OF_ANIMAL_TRAVERS_AREA.

Transactions and undo

classDiagram
  BFComponent <|-- BFGTransaction
  BFGTransaction <|-- ZTTransaction
  BFComponent <|-- BFGTransactionTracker
  BFComponent <|-- BFUndoMgr
  BFUndoMgr <|-- BF3DUndoMgr
  BF3DUndoMgr <|-- BFGUndoMgr
  BFGUndoMgr <|-- ZTUndoMgr
  BFXMLObj <|-- BFUndoTransactionData
  BFXMLObj <|-- BFGEconomyTransactionData

Ground-fit (entities sitting on the world)

BFGroundFitComponent and its specializations (BF2LegsGroundFitComponent, BF4LegsGroundFitComponent, BFBirdGroundFitComponent, BFHoverGroundFitComponent, BFWaterGroundFitComponent, BFAboveGroundFitComponent, BFMultiGroundFitComponent, BFLegFitComponent, ZTFPSCameraGroundFitComponent, ZTUnderwaterFloatGroundFitComponent) query a BFWorldFittingSurface to place an entity's height/tilt/contact. Hydrated keys: heightOffset, maxTilt, fitRadius, fitLowest, tiltGain, groundFitSatisfied, autoHeightOffset, floatOnWater, waterOffset. The fit algorithm is native.

transport relationship model

classDiagram
  TransportDomain "1" --> ZTTransportationMgr : manager
  TransportDomain "1" --> ZTTourData : tour_data
  TransportDomain "1" --> ZTTourRecorderData : recorder
  TransportDomain "*" --> ZTTransportCircuit : circuits
  TransportDomain "*" --> ZTTransportGroundCircuit : ground_circuits
  TransportDomain "*" --> ZTTransportSkyCircuit : sky_circuits
  TransportDomain "*" --> ZTTransportVehicle : vehicles
  TransportDomain "*" --> ZTTransportStation : stations
  TransportDomain "1" --> ZTTransportQuerySet : queries
  ZTChangeCircuitDirectionCommand "0..1" --> RouteDirection : requested_direction
  ZTTourData "*" --> ZTTourDataAttr : tours
  ZTTourData "*" --> ZTTourDataFeedback : feedback
  ZTTourRecorderData "*" --> ZTTourWaypoint : waypoints
classDiagram
  ZTTransportQuerySet "1" --> ZTGetCircuitQuery : circuit_query
  ZTTransportQuerySet "1" --> ZTClosedCircuitQuery : closed_circuit_query
  ZTTransportQuerySet "1" --> ZTConnectedSkyPieceQuery : connected_sky_piece_query
  ZTTransportQuerySet "1" --> ZTTransportPassengerQuery : passenger_query
  ZTTransportQuerySet "1" --> ZTTourStarRatingQuery : tour_star_rating_query
  ZTVehicleGround "1" --> ZTTransportVehicle : vehicle
  ZTVehicleSky "1" --> ZTTransportVehicle : vehicle

fence relationship model

classDiagram
  FenceDomain "*" --> ZTFenceType : fence_types
  FenceDomain "*" --> ZTFence : fences
  FenceDomain "*" --> ZTFenceSegmentInfo : segments
  FenceDomain "*" --> ZTGate : gates
  FenceDomain "*" --> ZTTankPortalSegment : tank_portals
  FenceDomain "1" --> FencePlacementShape : current_shape
  FenceDomain "1" --> ZTFenceModeState : placement_mode
  FenceDomain "*" --> ZTFenceTopologyEvent : topology_events
  ZTFenceModeState "1" --> FencePlacementShape : shape
  ZTFenceModeState "0..1" --> ZTFenceModeRotation : last_rotation
  ZTFenceModeCommandDecision "0..1" --> FencePlacementShape : shape
  ZTFenceModeCommandDecision "0..1" --> FencePlacementShape : previous_shape
  ZTFenceModeCommandDecision "0..1" --> ZTFenceModeRotation : rotation
  ZTFenceModeCommandDecision "0..1" --> ZTFenceModeUndoAction : undo_action
  ZTFenceModeUndoAction "0..1" --> ZTFenceModeRubberBandUndo : rubber_band_restore
  ZTFenceModeUndoAction "0..1" --> ZTFenceModeGateUndo : gate_restore
  ZTFenceModeGateUndo "1" --> FencePlacementShape : restored_shape
  ZTFenceModeRotation "1" --> FencePlacementShape : shape

world relationship model

classDiagram
  BFCameraComponent <|-- BFFPSCameraComponent
  AutoPlacementVariation "1" --> ObjectTypeMask : object_mask
  AutoPlacementVariation "*" --> WeightedObject : weighted_objects
  BFBoundedObjectComponent "1" --> BFEntityComponentCommon : common
  BFBoundedObjectComponent "0..1" --> GridRect : bounds
  BFCollisionComponent "1" --> BFEntityComponentCommon : common
  BFCollisionComponent "1" --> BFGCollisionData : collision_data
  BFCollisionComponent "0..1" --> BFGCollisionTest : last_test
  BFDebugComponent "1" --> BFEntityComponentCommon : common
  BFDockingComponent "1" --> BFEntityComponentCommon : common
  BFEntityComponentCommon "*" --> BFComponentProperty : properties
  BFEnvMapSwapComponent "1" --> BFEntityComponentCommon : common
  BFFPSCameraComponent "1" --> BFCameraComponent : base
  BFFallComponent "1" --> BFMovingComponent : base
  BFForceUpdateWhenVisibleComponent "1" --> BFEntityComponentCommon : common
classDiagram
  BFGEntityContainerSlot <|-- BFGEntityContainerSlotHeavy
  BFGEntityContainerSlot <|-- BFGEntityContainerSlotLight
  BFGPlacementTile <|-- BFGTerrainPlacementTile
  BFForwardMovingComponent "1" --> BFMovingComponent : base
  BFGEntityContainerSlot "1" --> EntityContainerSlotClass : slot_class
  BFGEntityContainerSlotLight "1" --> BFGEntityContainerSlot : base
  BFGEntityContainerSlotHeavy "1" --> BFGEntityContainerSlot : base
  BFGEventRoot "*" --> BFGEventRecord : events
  BFGFittingSurfaceComponent "0..1" --> BFWorldFittingSurface : fitting_surface
  BFGGame "*" --> BFGWorld : worlds
  BFGGame "1" --> BFGEventRoot : event_root
  BFGRemoveEntityBatch "*" --> BFGRemoveEntityBatchEntry : entries
  BFGTerrainPlacementTile "1" --> BFGPlacementTile : base
classDiagram
  BFGWorld "*" --> BFGEntity : entities
  BFGWorld "1" --> BFGPlacementGrid : placement_grid
  BFGWorld "1" --> BFGWorldMutationQueue : mutation_queue
  BFGWorld "1" --> BFGGameAttachment : attached_game
  BFGWorld "1" --> BFGWorldAttachment : attached_world
  BFGWorld "1" --> BFGEntityTypeIndex : entity_type_index
  BFGWorld "1" --> BFGEventRoot : event_root
  BFGWorldMutationQueue "*" --> BFGSpawnEntityRequest : spawn_requests
  BFGWorldMutationQueue "*" --> BFGRemoveEntityBatch : remove_batches
  BFGWorldMutationQueue "*" --> BFGEntityColorCommand : color_commands
  BFGWorldMutationQueue "*" --> BFGComponentLookup : component_lookups
  BFGWorldMutationQueue "*" --> BFGEntityBatchActionEvent : batch_events
  BFGestureSplineComponent "1" --> BFEntityComponentCommon : common
  BFHasParticleComponent "1" --> BFEntityComponentCommon : common
  BFHelpComponent "1" --> BFEntityComponentCommon : common
  BFManipSensorComponent "1" --> BFEntityComponentCommon : common
classDiagram
  BFCameraComponent <|-- BFOverheadCameraComponent
  BFMovingComponent "1" --> BFEntityComponentCommon : common
  BFOverheadCameraComponent "1" --> BFCameraComponent : base
  BFOverheadCameraComponent "0..1" --> BFOverheadCameraFrustum : frustum
  BFOverheadCameraComponent "0..1" --> GridRect : pan_bounds
  BFOverheadCameraUDVComponent "1" --> BFEntityComponentCommon : common
  BFOverheadCameraUDVComponent "*" --> BFOverheadCameraZoomSpeedMod : zoom_speed_mod
  BFPhysObj "1" --> BFPhysicsComponent : physics
  BFPhysObj "0..1" --> BFOverheadCameraComponent : overhead_camera
  BFPhysObj "0..1" --> BFOverheadCameraUDVComponent : overhead_camera_udv
  BFPhysObj "0..1" --> BFBoundedObjectComponent : bounded_object
  BFSpineBendComponent "1" --> BFEntityComponentCommon : common
  BFStaticBlobShadowComponent "1" --> BFEntityComponentCommon : common
  BFSuicideComponent "1" --> BFEntityComponentCommon : common
  BFSwimComponent "1" --> BFMovingComponent : base
  BFTextTagMacrosComponent "1" --> BFEntityComponentCommon : common
  BFTextTagMacrosComponent "*" --> BFTextTagMacro : macros
  BFTravAnimPathComponent "1" --> BFEntityComponentCommon : common
classDiagram
  BFTriggeredEventsComponent "1" --> BFEntityComponentCommon : common
  BFTriggeredEventsComponent "*" --> BFTriggeredEvent : triggers
  BFUserDrivenVehicleComponent "1" --> BFEntityComponentCommon : common
  BFWindowComponent "1" --> BFEntityComponentCommon : common
  BFWindowComponent "0..1" --> GridRect : region
  BiomeDefinition "0..1" --> WaterDefinition : water
  BiomeDefinition "*" --> WeightedObjectList : detail_objects
  BiomeDefinition "*" --> WeightedObjectList : decorative_detail_objects
  BiomeDefinition "*" --> AutoPlacementVariation : auto_placement
  EntityContainerSchema "*" --> EntityContainerSlotSchema : slots
  EntityContainerSlotSchema "1" --> EntityContainerSlotClass : slot_class
  PlacementPredicateInput "1" --> PlacementMode : mode
  PlacementPredicateInput "1" --> GridRect : bounds
  PlacementPredicateInput "1" --> ObjectPlacementFlags : object_flags
classDiagram
  TraversabilityConfig "1" --> ViewingConfig : viewing
  TraversabilityConfig "*" --> TraversalEntityConfig : entities
  TraversabilityConfig "*" --> CollisionTesterConfig : collision_testers
  WeightedObjectList "*" --> WeightedObject : objects
  WorldDomain "1" --> BFGGame : game
  WorldDomain "0..1" --> BFGWorld : active_world
  WorldDomain "1" --> BFGPlacementGrid : placement_grid
  WorldDomain "1" --> BFGCollisionMgr : collision_mgr
  WorldDomain "*" --> ZTZooSurveyAdjustment : zoo_survey_adjustments
  ZTDevComponent "1" --> BFEntityComponentCommon : common
  ZTDevComponent "0..1" --> ZTComponentLock : profile_lock
  ZTDevComponent "0..1" --> ZTComponentLock : game_lock
  ZTDevComponent "0..1" --> ZTEyedropperState : eyedropper
classDiagram
  BFTriggeredEventsComponent <|-- ZTTriggeredEventsComponent
  ZTFeedbackComponent "1" --> BFEntityComponentCommon : common
  ZTFeedbackComponent "0..1" --> ZTMessageInfo : current_message
  ZTFeedbackComponent "0..1" --> ZTThoughtInfo : current_thought
  ZTFeedbackComponent "0..1" --> ZTEmoticonInfo : current_emoticon
  ZTFeedbackComponent "0..1" --> ZTFeedbackClickTarget : click_target
  ZTOverviewComponent "1" --> BFEntityComponentCommon : common
  ZTOverviewComponent "*" --> ZTOverviewLayer : layers
  ZTOverviewComponent "1" --> ZTOverviewExport : export
  ZTTriggeredEventsComponent "1" --> BFTriggeredEventsComponent : base
  ZTTriggeredEventsComponent "*" --> ZTTriggeredEventRecord : pending_events

terrain relationship model

classDiagram
  BFTerrainEvent "*" --> ZTChangedTriangle : changed_triangles
  BFTerrainEvent "0..1" --> BFTerrainChargeCommand : charge
  BFTerrainMeshPatch "*" --> BFTerrainVertex : vertices
  BFTerrainMeshPatch "*" --> BFTerrainTriangle : triangles
  BFTerrainUndoData "*" --> BFTerrainUndoRecord : records
  BFTerrainUndoData "0..1" --> BFTerrainChargeCommand : final_charge
  BFTerrainUndoData "*" --> BFTerrainUndoBoundary : boundaries
  BFTerrainUndoRecord "0..1" --> BFTerrainMeshPatch : before_patch
  BFTerrainUndoRecord "0..1" --> BFTerrainMeshPatch : after_patch
  BiomeOptions "*" --> BiomeBrushSet : brush_sets
  MapsConfig "*" --> MapConfigEntry : entries
  TerrDeformationUI "*" --> TerrDeformationCursorTexture : cursor_textures
  TerrDeformationUI "*" --> TerrainBrush : brushes
  TerrPaintUI "*" --> TerrainBrush : biome_brushes
classDiagram
  TerrainDomain "1" --> ZTTerrainGrid : grid
  TerrainDomain "1" --> BFTerrain : bf_terrain
  TerrainDomain "*" --> BFTerrainMeshPatch : mesh_patches
  TerrainDomain "1" --> BFTerrainUndoData : undo_data
  TerrainDomain "*" --> BFTerrainChargeCommand : charge_queue
  TerrainDomain "1" --> BiomeOptions : biome_options
  TerrainDomain "1" --> TerrDeformationUI : deformation_ui
  TerrainDomain "1" --> TerrPaintUI : paint_ui
  TerrainDomain "1" --> MapsConfig : maps
  TerrainDomain "*" --> BFGBiome : biomes
  TerrainDomain "1" --> ZTAutoPlacementController : autoplacement
  TerrainDomain "1" --> ZTBiomeModeState : biome_mode
  TerrainDomain "1" --> ZTTerrainModeState : terrain_mode
  TerrainDomain "0..1" --> ZTTerrainCommandReader : active_command_reader
  TerrainDomain "*" --> ZTChangedTriangle : changed_triangles
  TerrainDomain "*" --> ZTBiomeObjectEvent : biome_events
  TerrainDomain "*" --> BFTerrainEvent : events
  TerrainDomain "1" --> ZTTerrainBrushPreview : brush_preview
  TerrainDomain "*" --> BFTerrainWaterEdit : water_edits
  TerrainDomain "*" --> ZTBiomeUndoDeleteFlattening : flattening_deletions
  TerrainDomain "0..1" --> BFTerrainWorldSurface : loaded_world_surface
classDiagram
  ZTAutoPlacementController "*" --> ZTAutoPlacementVariation : variations
  ZTAutoPlacementController "*" --> ZTAutoPlacementObjectSpawn : pending_spawns
  ZTAutoPlacementController "*" --> ZTAutoPlacementObjectSpawn : pending_removals
  ZTAutoPlacementVariation "1" --> ZTAutoPlacementObjectMask : object_mask
  ZTAutoPlacementVariation "*" --> ZTAutoPlacementWeightedObject : weighted_objects
  ZTBiomeModeState "0..1" --> BiomeBrushSet : brush_set
  ZTBiomeModeState "*" --> ZTAutoPlacementObjectSpawn : added_objects
  ZTBiomeModeState "*" --> ZTAutoPlacementObjectSpawn : removed_objects
  ZTBiomeModeState "*" --> ZTBiomeCommand : commands
  ZTTerrainCommandRecord "1" --> ZTTerrainCommand : command
  ZTTerrainCommandRecord "0..1" --> BFTerrainUndoRecord : undo_record
  ZTTerrainCommandRecord "0..1" --> BFTerrainChargeCommand : charge
  ZTTerrainModeState "0..1" --> TerrainBrush : active_brush
  ZTTerrainModeState "0..1" --> ZTTerrainCommandReader : command_reader
  ZTTerrainModeState "0..1" --> ZTTerrainCommandRecord : last_command
  ZTTerrainModeState "0..1" --> BFTerrainMeshPatch : preview_patch

tank relationship model

classDiagram
  TankDomain "1" --> ZTTankMgr : manager
  TankDomain "*" --> ZTTank : tanks
  TankDomain "1" --> ZTTankTopology : topology
  TankDomain "*" --> ZTTankWallSegment : wall_segments
  TankDomain "*" --> ZTTankWallGlassMaterialSelector : glass_material_selectors
  TankDomain "*" --> ZTTankGateSegment : gates
  TankDomain "*" --> ZTTankPortal : portals
  TankDomain "*" --> ZTTankSupport : supports
  TankDomain "*" --> ZTTankLinkDetachRecord : link_detach_records
  TankDomain "1" --> ZTTankCommandQueue : commands
  TankDomain "1" --> ZTTankCommandReader : command_reader
  TankDomain "1" --> ZTTankQuerySet : queries
  ZTTankAlternateLink "0..1" --> ZTTankLink : link
  ZTTankCommandQueue "*" --> ZTTankCommand : pending
  ZTTankCommandQueue "*" --> ZTTankCommand : completed
  ZTTankManipulationUi "*" --> ZTTankManipulationCursorTexture : cursor_textures
classDiagram
  ZTTankSegment <|-- ZTTankGateSegment
  ZTTankPrimaryLink "0..1" --> ZTTankLink : link
  ZTTankQuerySet "1" --> ZTIsTankInWorldQuery : world_query
  ZTTankQuerySet "1" --> ZTTankFloorHeightQuery : floor_height_query
  ZTTankQuerySet "1" --> ZTTankWaterHeightQuery : water_height_query
  ZTTankTopology "*" --> ZTTankSegment : segments
  ZTTankTopology "*" --> ZTTankGateSegment : gates
  ZTTankTopology "*" --> ZTTankPortal : portals
  ZTTankTopology "*" --> ZTTankLink : links
  ZTTankTopology "*" --> ZTTankTopologyChange : pending_changes
  ZTTankWallSegment "0..1" --> ZTTankWallGlassMaterialSelector : tankwallglass_selector
  ZTTankWallGlassMaterialSelector "1" --> ZTTankWallGlassSelectorGeometry : geometry
  ZTTankWallGlassSelectorGeometry "*" --> ZTTankWallGlassSelectorVertex : vertices
  ZTTankWallGlassSelectorSweep "*" --> ZTTankWallGlassMaterialSelector : selectors

placement relationship model

classDiagram
  PlacementDomain "1" --> ZTPlacementData : placement_data
  PlacementDomain "0..1" --> ZTPlaceEntityComponent : active_entity
  PlacementDomain "*" --> ZTSpawnEntityComponent : spawned_entities
  PlacementDomain "0..1" --> ZTPlacementConfirmation : pending_confirmation
  PlacementDomain "1" --> ZTPlacementPreview : preview
  PlacementDomain "1" --> ZTPlacementCursor : cursor
  PlacementDomain "*" --> ZTPlacementFailure : failure_history
  PlacementDomain "1" --> ZTPlacementRuleSet : rules
  PlacementDomain "1" --> ZTPlacementCommandQueue : commands
  PlacementDomain "1" --> ZTToolCommandQueue : tool_commands
  PlacementDomain "1" --> ZTUserDraggingState : user_dragging
  PlacementDomain "1" --> ZTClickableObjectSelection : clickable_object
  ZTPlaceEntityComponent "1" --> ZTPlacementFlags : placement_flags
  ZTPlacementCommandQueue "*" --> ZTPlacementCommand : pending
  ZTPlacementCommandQueue "*" --> ZTPlacementCommand : completed
  ZTPlacementCommand "0..1" --> FencePlacementShape : fence_shape
  ZTPlacementCommand "0..1" --> ZTFenceModeUndoAction : fence_undo_action
  ZTPlacementPreview "0..1" --> ZTFootprintPreview : footprint
classDiagram
  ZTPlacementRuleSet "0..1" --> ZTPlacementAffordabilityRule : affordability
  ZTPlacementRuleSet "0..1" --> ZTPlacementResearchRule : research
  ZTPlacementRuleSet "0..1" --> ZTPlacementFootprintRule : footprint
  ZTPlacementRuleSet "0..1" --> ZTPlacementTerrainRule : terrain
  ZTPlacementRuleSet "0..1" --> ZTPlacementFenceRule : fence
  ZTPlacementRuleSet "0..1" --> ZTPlacementPathRule : path
  ZTPlacementRuleSet "0..1" --> ZTTankPlacementRule : tank
  ZTPlacementRuleSet "0..1" --> ZTElevatedPathPlacementRule : elevated_path
  ZTToolCommandQueue "*" --> ZTToolCommand : pending
  ZTToolCommandQueue "*" --> ZTToolCommand : completed

path relationship model

classDiagram
  PathDomain "*" --> ZTPath : paths
  PathDomain "*" --> ZTPathElevated : elevated_paths
  PathDomain "*" --> ZTPathPlacementCommand : placement_commands
  PathDomain "*" --> ZTElevatedPathCommand : elevated_commands
  PathDomain "*" --> ZTConnectedPathQuery : connected_queries
  ZTElevatedPathSegment "1" --> ZTPathSegment : path
  ZTElevatedPathSegment "0..1" --> ZTElevatedCurbPlacement : curb_mode
  ZTPathPlacementCommand "0..1" --> ZTPathValidation : validation

Consumers and open contracts (World)

Consumers: ZTWorldMgr, BFGManager, ZTAIMgr (pathing/rampage), the economy (charges), and the renderer (terrain/decal/shadow projection).

Modes (Interaction Tools)

classDiagram
  class ZTMode { cursor; ui_layout; event_blocks; message_handlers; hotkeys }
  ZTMode <|-- ZTEntityMovementMode
  ZTEntityMovementMode <|-- ZTPlacementMode
  ZTEntityMovementMode <|-- ZTBiomeMode
  ZTMode <|-- ZTSelectionMode
  ZTMode <|-- ZTFPActionModeBase
  ZTFPActionModeBase <|-- ZTCureDiseaseMode
  ZTFPActionModeBase <|-- ZTTranquilizeMode
  ZTFPActionModeBase <|-- ZTFPTrainingMode
  ZTMode <|-- ZTFossilFindingMode
  ZTMode <|-- ZTGestureTraceModeBase
  ZTGestureTraceModeBase <|-- ZTCloningGestureMode
  ZTMode <|-- ZTGfxOptionsMode
  ZTMode <|-- ZTFileMode
  ZTFileMode <|-- ZTSaveMode
  ZTFileMode <|-- ZTLoadMode
  ZTMode <|-- ZTCameraCommandReader
  ZTMode <|-- ZTTerrainCommandReader
  ZTMode <|-- ZTTankCommandReader

First-person and gameplay modes

classDiagram
  class ZTFPTrainingMode {
    +training_area; +animal_entity; +trick_token
    +time_to_reward_animal_seconds
    +time_out_for_teleporting_animals_seconds
  }
  class ZTTranquilizeMode { +target_entity; +charge; +range; +user_prompt }
  class ZTFossilFindingMode { +sonar_beep; +sonar_graphic; +artifact_marker; +user_prompt }
  class ZTCloningGestureMode { +cloning_center_entity; +goo_level; +countdown_seconds; +score }
  class ZTSelectionMode {
    +default_cursor; +pickup_cursor; +rotate_cursor; +selection_texture
    +info_panel_update_seconds; +mouse_over_check_seconds
  }
  class ZTGfxOptionsModeState {
    +graphics : ZTGraphicsOptions; +audio : ZTAudioOptions; +vince : ZTVinceOptions
    +settings_document; +pending_confirmation; +selected_detail_level
  }

ZTFPTrainingMode runs trick training (reward/teleport timers); ZTTranquilizeMode darts an animal (charge/range); ZTFossilFindingMode is the dig-site sonar tool; ZTCloningGestureMode is the cloning-center minigame (goo_level/countdown/score); ZTSelectionMode is the default pick/move/rotate cursor handler; ZTGfxOptionsMode edits graphics/audio/VINCE options with confirmation. World-editing modes (ZTPlacementMode, ZTFenceMode, ZTPathMode, ZTBiomeMode, ZTTankCommandReader, ZTTerrainCommandReader) and camera (ZTCameraCommandReader) are detailed in the World and Renderer sections.

Gesture system (cloning / training minigames)

ZTGestureMgr (cross-cutting manager) owns the gesture minigame used by ZTCloningGestureMode and training. Authored ZTGestureDefinitions describe the target shape; the player's live ZTGestureTrace is matched against them to produce a score :

classDiagram
  class ZTGestureMgr { +gestures; +committed_traces; +definitions; +tracer_visuals; +editing_directory }
  class ZTGestureDefinition {
    +gesture_type; +parent_obj; +parent_node
    +camera_pos; +plane_normal; +bounding_box_scale
  }
  class ZTGestureTrace { +gesture_type_hint; +strokes : Vec~ZTGestureStroke~; +source_mode; +subject_entity }
  class ZTGestureMatch { +gesture_type; +event_count; +trace_score; +score }
  class ZTGestureComponent { +gesture_type; +subject_entity; +target_entity; +dispatched_trace_events }
  ZTGestureMgr "1" *-- "*" ZTGestureDefinition
  ZTGestureMgr "1" *-- "*" ZTGestureTrace
  ZTGestureTrace ..> ZTGestureMatch : scored against definition
  ZTGestureComponent ..> ZTGestureTrace : produces

A ZTGestureDefinition fixes the gesture plane (camera_pos/plane_normal) and a bounding_box_scale; the live ZTGestureTrace is a set of ZTGestureStrokes; matching samples observed-vs-expected points (ZTGestureTraceSample) into a ZTGestureMatch score. ZTGestureComponent attaches the minigame to an entity and dispatches ZTGestureTraceEvents at score thresholds.

Reconstructed mode-state records

Remaining mode structs (state/native-contract/config records), fields per type:

gesture relationship model

classDiagram
  GestureDomain "1" --> ZTGestureMgr : manager
  GestureDomain "*" --> GesturesDocument : documents
  GestureDomain "1" --> ZTGestureRecognizer : recognizer
  GestureDomain "1" --> ZTGestureSplineEditor : editor
  GestureDomain "0..1" --> ZTGestureComponent : active_gesture
  GestureDomain "0..1" --> ZTGestureTrace : active_trace
  GestureDomain "*" --> ZTGestureEventFail : failed_events
  GesturesDocument "*" --> ZTGestureDefinition : definitions
  GesturesDocument "0..1" --> ZTGestureEditingConfig : editing
  GesturesDocument "0..1" --> ZTGestureEventFail : failed_event
  ZTGestureComponentNativeContract "1" --> ZTGestureProjectionFrame : projection_frame
  ZTGestureComponentNativeContract "*" --> ZTGestureTraceEventTextureBinding : event_textures
  ZTGestureRecognizer "*" --> ZTGestureDefinition : definitions
  ZTGestureRecognizer "0..1" --> ZTGestureMatch : last_match
  ZTGestureSplineEditor "0..1" --> ZTEditableGestureSpline : active_spline
  ZTGestureSplineEditor "*" --> ZTGestureSplineCommand : commands
classDiagram
  ZTGestureTraceEventVisual "1" --> ZTGesturePoint : expected
  ZTGestureTraceEventVisual "1" --> ZTGestureProjectionFrame : projection_frame
  ZTGestureTraceEventVisual "1" --> ZTGestureTraceEventMarkerSurface : marker_surface
  ZTGestureTraceEventAssetDispatch "1" --> ZTGestureTraceEvent : event
  ZTGestureTraceAdvance "*" --> ZTGestureTraceEventPoint : due_events
  ZTGestureTraceAdvance "*" --> ZTGestureTraceEventPoint : expired_events
  ZTGestureTraceScore "1" --> ZTGestureTraceScoreBand : band
  ZTGestureTraceEventPoint "1" --> ZTGestureTraceEvent : event
  ZTGestureTraceEventPoint "1" --> ZTGesturePoint : expected
  ZTGestureTracerNativeVisualContract "1" --> ZTGestureTraceEventTexture : event_textures
  ZTGestureTracerEntitySurface "1" --> ZTGestureTracerEntityBinding : tracer
  ZTGestureTracerEntitySurface "1" --> ZTGestureTracerEntityBinding : pointer_pointer
  ZTGestureTracerEntityBinding "*" --> ZTGestureTracerBinderBinding : binders

modes relationship model

classDiagram
  ModesDomain "0..1" --> ZTModeKind : current_mode
  ModesDomain "0..1" --> ZTModeToken : current_shell_mode
  ModesDomain "*" --> ZTModeToken : current_shell_mode_path
  ModesDomain "*" --> ZTModeToken : shell_mode_history
  ModesDomain "1" --> ZTShellModeCatalogue : shell_modes
  ModesDomain "1" --> ZTModeHotKeyRegistry : shell_hotkeys
  ModesDomain "*" --> ZTModeConfigDocument : mode_config_documents
  ModesDomain "*" --> UiHotKeyBinding : active_hotkeys
  ModesDomain "*" --> ZTModeKind : stack
  ModesDomain "*" --> ZTModeRequest : requests
  ModesDomain "*" --> ZTModeDescriptor : registered_modes
  ModesDomain "1" --> ZTModeClassRegistry : mode_classes
  ModesDomain "1" --> ZTDeleteModeState : delete_mode
  ModesDomain "1" --> ZTDownloadModeState : download_mode
  ModesDomain "1" --> ZTFileModeState : file_mode
  ModesDomain "1" --> ZTGfxOptionsModeState : gfx_options_mode
  ModesDomain "1" --> ZTGroundTrackModeState : ground_track_mode
  ModesDomain "1" --> ZTGuestViewModeState : guest_view_mode
  ModesDomain "1" --> ZTOverviewModeState : overview_mode
  ModesDomain "1" --> ZTElevatedCurbModeState : elevated_curb_mode
  ModesDomain "1" --> ZTFirstPersonModeState : first_person_state
  ModesDomain "1" --> ZTFossilFindingModeState : fossil_finding_state
  ModesDomain "1" --> ZTFPTrainingModeState : fp_training_state
  ModesDomain "1" --> ZTTranquilizeModeState : tranquilize_state
  ModesDomain "1" --> ZTCloningGestureModeState : cloning_gesture_state
  ModesDomain "1" --> ZTSuperStaffModeState : super_staff_state
  ModesDomain "1" --> ZTBiomeModeState : biome_mode_state
  ModesDomain "*" --> ZTModeCommand : commands
  ModesDomain "*" --> ZTKeyboardAction : keyboard_actions
classDiagram
  ZTDownloadIndex "*" --> ZTDownloadItem : items
  ZTFPClimbLadderModeNativeState "*" --> ZTFPClimbLadderDurationRequest : duration_requests
  ZTFileInfoList "*" --> FileInfo : rows
  ZTFirstPersonResourceUpdate "1" --> ZTFirstPersonResourceValue : value
  ZTFirstPersonMovementEvent "1" --> ZTFirstPersonMovementAxis : axis
  ZTFirstPersonModeState "0..1" --> ZTModeKind : entered_from_mode
  ZTGestureCreationMode "1" --> ZTModeClassSurface : surface
  ZTGestureCreationMode "1" --> ZTGestureCreationBounds : trick_bounds
  ZTGestureTraceModeBaseNativeState "0..1" --> ZTGestureTraceScore : last_trace_score
classDiagram
  ZTGfxOptionsBackRevert "1" --> ZTGfxOptionsModeSnapshot : restored
  ZTGfxOptionsBackRevert "*" --> ZTGfxOptionsFloatMessage : dispatched_float_messages
  ZTGfxOptionsSafeGraphicsRestore "1" --> ZTGraphicsSafeMode : restored
  ZTGfxOptionsSettingsDocument "*" --> ZTOptionsSettingDefinition : settings
  ZTMainMode "1" --> ZTModeClassSurface : surface
  ZTModeColorBinding "1" --> ZTModeColor : color
  ZTModeConfigDocument "1" --> ZTModeConfigNode : root
  ZTModeHotKeyRegistry "*" --> ZTModeHotKeyDocument : documents
  ZTModeHotKeyDocument "*" --> ZTModeHotKeyNode : nodes
  ZTModeHotKeyNode "*" --> UiHotKeyBinding : hotkeys
classDiagram
  ZTModeVTable "0..1" --> ZTModeAddressRange : table_range
  ZTModeVTable "0..1" --> ZTModeAddressRange : descriptor_subtable
  ZTModeVTable "*" --> ZTModeVirtualSlot : virtual_slots
  ZTOptionsSettingDefinition "*" --> ZTOptionsSettingChoice : choices
  ZTOptionsSettingChoice "*" --> ZTOptionsTypedValue : values
  ZTOptionsValueWrite "1" --> ZTOptionsValueType : value_type
  ZTShellModeCatalogue "0..1" --> ZTModeRecord : root
  ZTShellModeCatalogue "*" --> ZTModeRecord : standalone_modes
  ZTToolsetMode "1" --> ZTModeClassSurface : surface
  ZTToolsetMode "0..1" --> ZTToolsetModeDocument : config_document
  ZTToolsetModeDocument "1" --> ZTModeRecord : mode_record

Open contracts (Modes)

Economy, Fame, Research, Disease, and Status

The progression systems share one shape: a manager (a BFComponent or BFScriptComponent) owns persisted state, registers named value-handlers that the UI binds to (make_<x>_value produces, accept_<x>_value consumes), and responds to ZT_* messages. Eligibility everywhere is decided by the shared ZTPredicate family.

Economy

classDiagram
  class ZTEconomyMgr {
    +context_configs : Vec~ZTEconomyContextConfig~
    +configs : Vec~EconomyConfig~
    +components : Vec~ZTEconomyComponent~
    +zt_transactions : Vec~ZTTransaction~
    +bfg_components : Vec~BFGEconomyComponent~
    +transaction_tracker : BFGTransactionTracker
    +money_events : Vec~MoneyEvent~
    +ui_price_selections : Vec~ZTPriceIndexSelection~
    +from_root() / read_config_xml_node()
    +process_transaction(name)
    +set_price_index(...) / process_fame_update(fame)
  }
  class ZTEconomyComponent {
    +name; +category; +no_binder; +active
    +transactions : Vec~TransactionConfig~
    +read_xml_node()/write_xml_node()
    +find_transaction_by_name(name)
  }
  class ZTTransaction {
    +name; +config; +subject_entity; +target_entity; +applied_amount
    +apply(); +evaluate_cost(); +set_cost_clamped(cost)
  }
  class ZTEconomyComponentBase {
    +component_name; +owner_entity; +active
    +activate()/deactivate()
  }
  class ZTEconomyComponentGuest { +guest_entity; +donation_multiplier; +score_donation(target) }
  ZTEconomyMgr "1" *-- "*" ZTEconomyComponent
  ZTEconomyMgr "1" *-- "*" ZTTransaction
  ZTEconomyMgr *-- BFGTransactionTracker
  BFGEconomyComponent <|-- ZTEconomyComponentBase
  ZTEconomyComponentBase <|-- ZTEconomyComponentGuest
  ZTEconomyComponentBase <|-- ZTEconomyComponentStub
  ZTEconomyComponentBase <|-- ZTEconomyComponentHistoryBase

ZTEconomyMgr owns cash via per-context ZTEconomyContextConfig (initial_cash, saveable, config_data), aggregates ZTEconomyComponents (each a named set of TransactionConfigs), and runs ZTTransactions — evaluate_cost/set_cost_clamped compute the charge, apply commits it, and BFGTransactionTracker holds pending/completed. ZTEconomyComponentGuest.score_donation scores guest donations; ZTEconomyComponentHistoryBase keeps FameHistoryEntry history feeding fame.

Open (from todo!()): process_transaction aggregation, set_price_index admission

Economy cluster relationships

Relationship model (composition/aggregation with cardinality + field role, inheritance) for the full cluster, generated from the reconstruction field types:

classDiagram
  BFGEconomyComponent <|-- ZTEconomyComponentBase
  BFGTransaction <|-- ZTTransaction
  ZTEconomyComponentBase <|-- ZTEconomyComponentGuest
  ZTEconomyComponentBase <|-- ZTEconomyComponentHistoryBase
  ZTEconomyComponentBase <|-- ZTEconomyComponentStub
  ZTEconomyComponentHistoryBase <|-- ZTEconomyComponent
  ZTEconomyMgr "*" --> ZTEconomyContextConfig : context_configs
  ZTEconomyMgr "0..1" --> EconomyConfig : config
  ZTEconomyMgr "*" --> EconomyConfig : configs
  ZTEconomyMgr "*" --> ZTEconomyComponent : components
  ZTEconomyMgr "*" --> ZTTransaction : zt_transactions
  ZTEconomyMgr "*" --> BFGEconomyComponent : bfg_components
  ZTEconomyMgr "1" --> BFGTransactionTracker : transaction_tracker
  ZTEconomyMgr "*" --> MoneyEvent : money_events
  ZTEconomyMgr "*" --> ZTPriceIndexSelection : ui_price_selections
  ZTEconomyComponent "*" --> TransactionConfig : transactions
  ZTTransaction "0..1" --> TransactionConfig : config
  ZTEconomyComponentGuest "1" --> ZTEconomyComponentBase : base
  ZTEconomyComponentStub "1" --> ZTEconomyComponentBase : base
  ZTEconomyComponentHistoryBase "1" --> ZTEconomyComponentBase : base
  ZTEconomyComponentHistoryBase "*" --> FameHistoryEntry : history
  BFGEconomyComponent "1" --> BFGEconomyData : data
  BFGEconomyComponent "*" --> BFGTransaction : transactions
  BFGTransactionTracker "*" --> BFGTransaction : pending
  BFGTransactionTracker "*" --> BFGTransaction : completed
  EconomyConfig "0..1" --> EconomyComponentConfig : general_component
  EconomyConfig "*" --> EconomyComponentConfig : components
  EconomyConfig "*" --> CostFactor : cost_factors
  TransactionConfig "0..1" --> TransactionFrequency : frequency
  TransactionConfig "0..1" --> TransactionType : transaction_type
  TransactionConfig "0..1" --> TransactionPeriod : period
  TransactionConfig "0..1" --> CostType : cost_type
  TransactionConfig "0..1" --> CostChoice : cost_choice
  MoneyEvent "1" --> MoneyEventKind : kind

coupling, and process_fame_update hand-off to ZTFameData.

Fame: a value-handler registry

ZTFameData (< BFXMLObj) is the clearest instance of the value-handler pattern — it exposes dozens of computed status values and persists them:

Research

classDiagram
  class ZTResearchMgr {
    +items : Vec~ZTResearchItem~
    +buttons : Vec~ZTUIResearchButton~
    +unlocked_entities[]; +unlocked_fences[]
    +active_research[]; +completed_research[]
  }
  class ZTResearchItem {
    +item_id; +entity_type; +fence_type
    +loc_id; +button_template; +unlocked
  }
  class ZTResearchUnlock { +entity_type; +fence_type; +fame_requirement }
  BFScriptComponent <|-- ZTResearchMgr
  ZTResearchMgr "1" *-- "*" ZTResearchItem

ZTResearchMgr tracks unlock state; ZTResearchItem is a research entry. Gating messages: ZT_RESEARCH_IS_UNLOCKED, ZT_RESEARCH_UNLOCK_ENTITY_KIND. Placement validation consults research (the UNRESEARCHED token in the World section).

Disease

Fields carry their XML-attribute provenance; todo!() in the code marks behaviour still open.

classDiagram
  class ZTDiseaseMgr {
    +half_star_minimum  : halfStarMinimum
    +disease_check_interval_seconds : diseaseCheckInterval
    +update_interval_seconds : updateInterval
    +cure_timeout_seconds : cureTimeout
    +diseases : Vec~ZTDisease~
    +from_root(root)
    +read_config_xml_node(doc)
    +update()  TODO
    +force_disease(name, target)  TODO
  }
  class ZTDisease {
    +name, name_loc_id, token, cure_token
    +clear_tokens[], target_types[]
    +chance, chance_multiplier
    +single_qualifier, search_for_targets
    +research_loc_id_base, base_reward, reward_delta, force_only
    +qualifier, cause, cure
  }
  class ZTDiseaseClue { +types[]; +hint; +product }
  class ZTDiseaseCase {
    +disease_name; +target_entity
    +cause_entity; +cure_entity; +research_state
  }
  ZTDiseaseMgr "1" *-- "*" ZTDisease
  ZTDisease *-- ZTDiseaseQualifier
  ZTDisease *-- ZTDiseaseClue : cause / cure
  ZTDiseaseQualifier *-- ZTDiseaseZooTest
  ZTDiseaseQualifier *-- ZTDiseaseAnimalFilter

ZTDiseaseMgr (< BFComponent) hydrates from config/diseasemgr.xml and holds the ZTDisease records; each ZTDisease carries cause/cure ZTDiseaseClues (types/hint/product) and a ZTDiseaseQualifier. Qualifiers combine zoo tests (ZTEntityTypePredicate, ZTZooFamePredicate) and animal filters (ZTAnimalAttributeFilter attribute/boolValue/stringValue, ZTAnimalProximityFilter type/distance/closer) — these are the predicate family shared with scenario/AI. A live infection is a ZTDiseaseCase whose research progresses through a state machine:

stateDiagram-v2
  [*] --> Unknown
  Unknown --> Unsampled
  Unsampled --> Sampled
  Sampled --> CauseKnown
  CauseKnown --> CureKnown
  CureKnown --> Cured
  Cured --> [*]

ZTCureDiseaseMode (< ZTFPActionModeBase) drives sampling/curing with fields analysis_duration_seconds, indicator_duration_seconds, sample_distance, ignored_sample_types, active_target; behaviours ZTBehCureDisease/ ZTBehAddSubjectAsDiseaseTarget carry it out; query ZT_DISEASE_CURE_QUERY.

Open (from todo!()): the disease check/update interval target-search loop (ZTDiseaseMgr::update), forced-disease application (force_disease), and the sample→cure scoring inside ZTCureDiseaseMode.

Predicate system (cross-cutting eligibility)

classDiagram
  BFXMLObj <|-- ZTPredicate
  ZTPredicate <|-- ZTEntityTypePredicate
  ZTPredicate <|-- ZTZooFamePredicate
  ZTPredicate <|-- ZTAnimalFilter
  ZTAnimalFilter <|-- ZTAnimalAttributeFilter
  ZTAnimalFilter <|-- ZTAnimalProximityFilter
  ZTAnimalFilter <|-- ZTTAEntityFilter
  ZTAnimalFilter <|-- ZTTAPerimeterFilter

ZTPredicate objects are authored eligibility tests reused by disease targeting, scenario rules, adoption filters, and AI selection.

Status, Zoopedia, awards, adoption

ZTStatus (< BFScriptComponent) is the zoo status aggregate. Its UI surface is a set of native widget subclasses under the UI framework: ZTZooStatusComponent/ZTZoopediaComponent (< UILayout), ZTZoopediaTOC/ ZTZooSurveyComponent (< UIListBox); ZTZooMessageData carries zoo messages. ZTAdoptionMgr (< BFComponent) → ZTAdoptionSlotMgr, with ZTAdoptionSlot entries, owns the buy/adopt panel; ZTAwardMgr grants awards.

Message surface and data flow

sequenceDiagram
  participant Src as gameplay (sale, birth, view)
  participant Eco as ZTEconomyMgr / ZTFameData / ZTStatus
  participant Bus as ZT_ECONOMY_EVENT / value handlers
  participant UI as bound UI value
  Src->>Eco: ZT_ADD_INCOME / ZT_ADD_EXPENSE / fame delta
  Eco->>Eco: update state, run make_*_value
  Eco->>Bus: emit ZT_ECONOMY_EVENT / refresh handler
  Bus-->>UI: ZT_GET_ZOO_CASH / FAME / PROFIT / ...

Tokens: ZT_GET_ZOO_CASH/FAME/OPEN/NAME/INCOME/PROFIT, ZT_SET_ZOO_CASH, ZT_ADD_INCOME/ZT_ADD_EXPENSE, ZT_ECONOMY_EVENT, ZT_RESEARCH_IS_UNLOCKED/ UNLOCK_ENTITY_KIND, ZT_DISEASE_CURE_QUERY.

research relationship model

classDiagram
  ResearchDomain "1" --> ZTResearchMgr : manager
  ZTResearchMgr "*" --> ZTResearchItem : items
  ZTResearchMgr "*" --> ZTResearchUnlock : config_unlocks
  ZTResearchMgr "*" --> ZTUIResearchButton : buttons
  ZTResearchMgr "*" --> ZTResearchActiveRecord : active_research
  ZTResearchMgr "*" --> ZTResearchCompletedRecord : completed_research
  ZTResearchActiveRecord "1" --> ZTResearchProgressionRef : progression
  ZTResearchCompletedRecord "1" --> ZTResearchProgressionRef : progression

donation relationship model

classDiagram
  DonationDomain "*" --> DonationAcceptor : acceptors
  DonationDomain "1" --> ZTDonationStatus : totals
  ZTDonationStatus "*" --> ZTDonationBucket : by_animal_type
  ZTDonationStatus "*" --> ZTDonationBucket : by_endangerment

disease relationship model

classDiagram
  DiseaseDomain "1" --> ZTDiseaseMgr : manager
  DiseaseDomain "*" --> ZTDiseaseCase : cases
  DiseaseDomain "*" --> ZTDiseaseUiCommand : ui_commands

economy relationship model

classDiagram
  DonationTotals "*" --> DonationByAnimalType : by_animal_type
  DonationTotals "*" --> DonationByEndangerment : by_endangerment
  FameStatus "*" --> FameHistoryEntry : fame_history
  ZTStatusConfig "1" --> ZTStatusHappyFactors : happy_factors

Open contracts (Progression)

Profile, Campaign, Scenario, Tutorial, and Scripts

A scenario is a tree of rules that fire actions; actions run script through the BFScriptComponent/Lua runtime; the BFS_* message family is the scripting API the rules and Lua use to read and mutate game state. Campaign/tutorial/challenge are scenario variants over the same machinery.

Scenario rule tree

classDiagram
  BFComponent <|-- BFScenarioRule
  BFScenarioRule <|-- BFScenarioGroup
  BFScenarioGroup <|-- BFScenarioMgr
  BFScenarioMgr <|-- ZTScenarioMgr
  BFScriptComponent <|-- BFScenarioAction
  BFScenarioAction <|-- BFScenarioScriptAction
  BFXMLObj <|-- BFScenarioAltTextData
  BFScenarioRule "1" *-- "*" BFScenarioRule : nested rules
  BFScenarioRule ..> BFScenarioAction : fires

Because BFScenarioMgr is a BFScenarioGroup is a BFScenarioRule, the whole scenario is one recursive rule structure. Rules carry state (visible/hidden, set/reset) queried and mutated by the BFS_* API; BFScenarioScriptAction runs a script when a rule triggers; BFScenarioAltTextData supplies alternate overview/help text.

Script runtime

BFScriptComponent (< BFComponent) is the root of every scriptable component (AI, economy, status, research all descend from it). Lua sits behind a generic script context:

classDiagram
  BFComponent <|-- BFScriptComponent
  BFComponent <|-- BFScriptContextMgr
  BFXMLObj <|-- BFScriptContext
  BFScriptContext <|-- BFLuaContext
  BFTypedObj <|-- BFLuaStack
  BFXMLObj <|-- BFLuaArgs
  BFEvent <|-- BFLuaResponse
  BFEvent <|-- BFScriptComponentArgs

BFScriptContextMgr owns script contexts; BFLuaContext is the Lua binding, exchanging BFLuaArgs/BFLuaStack in and BFLuaResponse out. ZT_RUN_SCRIPT/ZT_RUN_LOP invoke scripts.

Scenario scripting API (BFS_*)

The BFS_* tokens are the contract between rules/Lua and native state, grouped by role:

Reconstructed field detail (scenario / scripts)

Modeled fields:

classDiagram
  class ZTScenarioMgr {
    +scenario_groups : Vec~BFScenarioGroup~
    +campaign_documents : Vec~BFCampaign~
    +campaign_state : ZTCampaignState
    +event_root : BFScenarioEventRoot
    +pending_script_actions
  }
  class BFScenarioMgr { +groups[]; +rules_by_name : Vec~BFScenarioRuleState~; +active_challenge }
  class Campaign { +campaign_id; +xpack; +display_name; +scenarios : Vec~BFScenarioMapEntry~ }
  class BFScriptContextMgr {
    +config_path; +cache_scripts
    +loaded_contexts : Vec~BFScriptContext~
    +context_records[]
  }
  class BFScriptContext {
    +context_name; +script : AssetPath
    +exported_functions[]; +function_bindings[]; +actions[]; +loaded
  }
  class BFScriptFunctionBinding { +function_name; +command_name; +argument_signature[]; +return_signature[] }
  ZTScenarioMgr *-- BFScenarioMgr
  ZTScenarioMgr *-- Campaign
  BFScriptContextMgr "1" *-- "*" BFScriptContext
  BFScriptContext *-- BFScriptFunctionBinding

BFScriptFunctionBinding is the concrete BFS_* API surface: each exported Lua function maps to a command_name with typed argument_signature/return_signature. Campaigns (BFCampaign/Campaign) carry unlock_rules and a current_scenario over the rule tree.

Campaign, maps, photo challenges, profile

ZTMapData (< BFComponent) holds map/campaign list data; ZTGameMode (< ZTMode) is the in-game interaction mode; ZTGoalPanel (< UIListBox) shows goals. Photo challenges are their own cluster: ZTPhotoChallenge, ZTPhotoChallengeSet, ZTPhotoChallengeMgr, ZTPhotoChallengesComponent (< BFScriptComponent). Photo capture: ZTPhotoManager holds active_album, abstractions (ZTPhotoAbstraction: matched_subjects, subject_bounds, score), pending_photo, and options; ZTPhotoSubjectBounds records entity_id/screen_rect/percent_seen for challenge scoring. Player profile is owned by BFUserProfileMgr (< BFComponent).

Lifecycle and data flow

sequenceDiagram
  participant Menu as main menu / ZTGameMode
  participant Mgr as ZTScenarioMgr
  participant Rule as BFScenarioRule tree
  participant Act as BFScenarioScriptAction
  participant Lua as BFLuaContext
  Menu->>Mgr: ZT_LOADGAME / select scenario
  Mgr->>Rule: evaluate rule states
  Rule->>Act: trigger fires action
  Act->>Lua: ZT_RUN_SCRIPT
  Lua->>Mgr: BFS_SETRULESTATE / BFS_SETGLOBALVAR / BFS_GETLOCID
  Mgr-->>Menu: goal/status updates (ZTGoalPanel)

Game-lifecycle tokens: ZT_LOADGAME, ZT_SAVEGAME, ZT_SETMODE, ZT_SCENARIO_SELECTION_CHANGED, ZT_LOAD_AFTER_SAVE, ZT_SAVE_SCREENSHOT.

scenario relationship model

classDiagram
  BFScenarioChallengeState "*" --> BFScenarioChallenge : challenges
  BFScenarioCommand "1" --> BFScenarioCommandKind : kind
  BFScenarioCommand "0..1" --> BFScenarioTypedCommand : typed
  BFScenarioCommandResult "1" --> BFScenarioCommandStatus : status
  BFScenarioGlobalVars "*" --> BFScenarioVar : values
  BFScenarioScriptActionPendingRecords "*" --> BFScenarioScriptActionPendingRecord : records
  BFScenarioScriptActionPendingRecord "1" --> BFScenarioScriptAction : action
  BFScenarioUserVars "*" --> BFScenarioVar : values
classDiagram
  ScenarioDomain "1" --> ZTScenarioMgr : manager
  ZTScenarioMgr "1" --> BFScenarioMgr : bf_manager
  ZTScenarioMgr "*" --> BFScenarioGroup : scenario_groups
  ZTScenarioMgr "*" --> BFCampaign : campaign_documents
  ZTScenarioMgr "1" --> ZTCampaignState : campaign_state
  ZTScenarioMgr "1" --> ZTScenarioRuntimeState : runtime
  ZTScenarioMgr "*" --> BFScenarioAction : pending_actions
  ZTScenarioMgr "1" --> BFScenarioEventRoot : event_root
  ZTScenarioMgr "1" --> BFScenarioChallengeState : challenge_state
  ZTScenarioRuntimeState "0..1" --> BFScenarioRuntimeRef : active_scenario
  ZTScenarioRuntimeState "*" --> BFScenarioObjectiveProgress : objective_progress

scripting relationship model

classDiagram
  BFScriptContext <|-- BFLuaContext
  BFResourceCacheFlush "*" --> BFResourceCacheRecord : copied_records
  BFScriptCache "*" --> BFScriptCacheEntry : entries
  BFScriptContextVector "*" --> BFScriptContextRecord : records
  ScriptingDomain "1" --> BFScriptContextMgr : context_mgr
  ScriptingDomain "*" --> BFScriptContext : contexts
  ScriptingDomain "*" --> BFLuaContext : lua_contexts
  ScriptingDomain "1" --> BFScriptCache : cache
  ScriptingDomain "1" --> BFResourceCacheFlush : resource_cache_flush

photo relationship model

classDiagram
  PhotoDomain "1" --> ZTPhotoManager : manager
  PhotoDomain "1" --> ZTPhotoChallengeMgr : challenge_mgr
  PhotoDomain "*" --> ZTPhotoAlbumComponent : albums
  PhotoDomain "*" --> ZTPhotoAnalysisComponent : analysis_components
  PhotoDomain "*" --> ZTPAParseTree : parse_trees
  PhotoDomain "1" --> ZTPhotoModeState : mode
  PhotoDomain "*" --> ZTPhotoEventCommand : event_commands
  ZTPAPTPhotoAnalysisComponent "*" --> ZTPAParseTree : queries
  ZTPAParseTree "*" --> ZTPAParseNode : nodes
  ZTPAParseTree "*" --> ZTPAGetterBinding : getters
  ZTPAParseNode "0..1" --> ZTPAGetterBinding : getter
  ZTPAGetterBinding "1" --> ZTPAGetterTarget : target
  ZTPhotoAlbumComponent "*" --> ZTPhotoInfo : photos
  ZTPhotoAnalysisComponent "0..1" --> ZTPAParseTree : parse_tree
  ZTPhotoAnalysisComponent "*" --> ZTPhotoAbstraction : abstractions
  ZTPhotoAnalysisComponent "*" --> ZTPhotoAnalysisResult : results
  ZTPhotoAnalysisContext "*" --> ZTPhotoAnalysisEntity : entities
  ZTPhotoAnalysisContext "*" --> ZTPhotoAbstraction : abstractions
  ZTPhotoAnalysisEntity "*" --> ZTPhotoAnalysisProperty : properties
classDiagram
  ZTPhotoEventCommand "1" --> ZTPhotoEvent : event
  ZTPhotoOptions "0..1" --> ZTPhotoCaptionScript : caption_script

menu profile campaign scenario relationship model

classDiagram
  MenuProfileCampaignScenarioDomain "*" --> ZTMapData : maps
  MenuProfileCampaignScenarioDomain "1" --> ZTCampaignIndex : campaign_index
  MenuProfileCampaignScenarioDomain "1" --> ZTCampaignSelectionState : campaign_state
  MenuProfileCampaignScenarioDomain "1" --> ZTGlobe : globe
  MenuProfileCampaignScenarioDomain "*" --> ZTUserProfile : profiles
  MenuProfileCampaignScenarioDomain "1" --> ZTMovieList : movies
  MenuProfileCampaignScenarioDomain "*" --> ZTMenuPopulationRequest : population_requests
  MenuProfileCampaignScenarioDomain "1" --> ZTMenuPopulatedLists : populated_lists
  ZTCampaignIndex "*" --> ZTCampaignIndexEntry : campaigns
  ZTCampaignSelectionState "0..1" --> ZTMenuCachedMapData : cached_map_data
  ZTGlobe "*" --> ZTGlobeDot : visible_dots
  ZTMenuPopulatedLists "*" --> ZTMenuMapListEntry : map_entries
  ZTMenuPopulatedLists "*" --> ZTMenuCampaignListEntry : campaign_entries
  ZTMenuPopulatedLists "*" --> ZTMenuCampaignScenarioListEntry : campaign_scenario_entries
  ZTMovieList "*" --> ZTMovieInfo : movies

Open contracts (Scenario/Scripts)

Renderer, Materials, Models, Animation, Camera, Audio

The projection/output layer consumes domain state (entities, world, UI) and renders/sounds it behind the preservation boundary. The original backend is Gamebryo/NetImmerse (the BFNi* classes) over Direct3D plus a sound engine; a modern host may replace those mechanics while preserving the component inputs below.

Scene graph and render components

classDiagram
  BFPhysComponent <|-- BFSceneGraphComponent
  BFSceneGraphComponent <|-- BFRSceneGraphComponent
  BFRSceneGraphComponent <|-- BFRActorComponent
  BFNISceneGraphComponent <|-- BFCameraComponent
  BFNISceneGraphComponent <|-- BFDecalComponent
  BFNISceneGraphComponent <|-- BFNiBoneLODComponent
  BFDecalComponent <|-- BFTerrainShadowComponent
  BFPhysComponent <|-- BFDecalTextureCycleComponent
  BFPhysComponent <|-- BFRealPhysicsComponent
  BFPhysComponent <|-- BFRotYawMovingComponent
  BFComponent <|-- BFRenderer
  BFComponent <|-- BFResourceMgr
  BFComponent <|-- BFParticleDictionary

An entity attaches into the scene through BFSceneGraphComponentBFRSceneGraphComponentBFRActorComponent (its renderable). BFNISceneGraphComponent is the Gamebryo node base used by camera, decals, and bone-LOD. BFRenderer drives the frame; BFResourceMgr owns GPU resources.

Materials and textures

Materials are authored .bfmat/.fx source consumed by the renderer (the class BFRMaterialManager is evidenced only by its ::load log string — no standalone type). Texture animation/variation is native data: BFGSetTextureData, BFTextureSwapInfo, BFSharedRandomTextureInfo, BFDecalTextureCycleComponent, ZTTransportGroundTrackTextureData.

Animation

classDiagram
  BFTypedObj <|-- BFAnimController
  BFComponent <|-- BFAnimGraph
  BFComponent <|-- BFAnimManager
  BFComponent <|-- BFAnimTable
  BFXMLObj <|-- BFAnimRequestData
  BFPhysComponent <|-- BFAnimatedObjectControllerComponent

BFAnimController selects animations from a BFAnimTable/BFAnimGraph driven by BFAnimRequestData; BFAnimManager coordinates. AI's BFLocoAnimate and BFAITextureController feed this layer. The animation graph is a node/transition machine:

classDiagram
  class BFAnimGraph { +graph_name; +nodes : Vec~BFAnimGraphNode~; +transitions : Vec~BFAnimGraphTransition~ }
  class BFAnimGraphNode { +node_name; +animation_name; +looped; +blend_seconds }
  class BFAnimGraphTransition { +from; +to; +condition }
  class BFAnimationSequence { +sequence_name; +current_node; +elapsed_seconds }
  BFAnimGraph "1" *-- "*" BFAnimGraphNode
  BFAnimGraph "1" *-- "*" BFAnimGraphTransition
  BFAnimGraph ..> BFAnimationSequence : plays

BFAnimController holds a BFAnimTable + current_animation and steps the graph; transitions fire on condition, blending over blend_seconds.

Sprites and UI rendering

classDiagram
  BFUIRenderer <|-- BFSpriteMgr
  BFSpriteMgr <|-- BFNISpriteMgr

BFSpriteMgr is part of the UI renderer (< BFUIRenderer); BFNISpriteMgr is the Gamebryo-backed implementation. It bridges the retained UI tree and the screen.

Camera

BFCameraComponent (< BFNISceneGraphComponent) is the camera node; ZTCameraCommandReader (< ZTMode) is the input mode. Camera commands travel as messages: ZT_CAMERA, ZT_CAMERA_ZOOM, ZT_CAMERA_ROTATE, ZT_CAMERA_PAN, ZT_CAMERA_POSITION, ZT_CAMERA_MOVED. ZT_BLIT requests a frame blit.

Camera detail

Modeled fields: ZTCameraCommandReader binds input to camera commands via command_state_bindings (ZTCameraCommandStateBinding: trigger/code/char_value/ ctrl_state/allow_repeat) producing command_state_events; active_command_states holds the live set, providing the concrete backing for the ZT_CAMERA_* messages.

Audio

classDiagram
  BFSnd <|-- BF2DSnd
  BFSnd <|-- BF3DSnd
  BFComponent <|-- BF2DSndFactory
  BFComponent <|-- BF3DSndFactory
  BFComponent <|-- BFSoundMgr
  BFComponent <|-- BFSoundStage
  BFComponent <|-- BFSoundStageMgr
  BFComponent <|-- BFSoundtag
  BFComponent <|-- BFWorld3DSndMgr

BFSoundMgr/BFSoundStageMgr own playback; BF2DSndFactory/BF3DSndFactory mint 2D/3D sound instances (BF2DSnd/BF3DSnd < BFSnd); BFWorld3DSndMgr places world sound; BFSoundtag names a cue; BFSndCrossFader blends. Audio is fully message-driven (BFSND_EVENT/BFSND_CMD):

Reconstructed field detail (renderer / audio)

Modeled fields:

classDiagram
  class BFDX9Renderer {
    +init_config : BFDX9RendererConfig
    +capability_report : BFRendererCapabilityReport
    +texture_memory_kib / vertex_buffer_kib / index_buffer_kib
  }
  class BFDX9RendererConfig {
    +minimal_graphics; +graphics_detail
    +screen_width; +screen_height
  }
  class BFRendererCapabilityReport {
    +video_ram_mib; +max_texture_width
    +vertex_shader_version; +overall_graphic_detail
  }
  class BFSoundMgr {
    +categories : Vec~SoundCategory~
    +options : BFSoundOptions
    +sound_tags; +pending_events
  }
  class BFSoundOptions { +want_sound; +sample_rate; +bits; +channels; +mixer_channels }
  BFDX9Renderer *-- BFDX9RendererConfig
  BFDX9Renderer *-- BFRendererCapabilityReport
  BFSoundMgr *-- BFSoundOptions

BFDX9Renderer is the concrete Direct3D 9 backend (the replaceable mechanism behind BFRenderer); its config/capability fields are the projection inputs a host adapter must satisfy. BFSoundMgr carries mixer BFSoundOptions and per-tag sound dirs.

Reconstructed model / effect / particle detail

Modeled fields:

classDiagram
  class BFRModelResource {
    +path; +source_document
    +subclass_kind; +nodes : Vec~BFRModelNode~; +meshes : Vec~BFRModelMesh~
  }
  class BFRNetImmerseNifModel { +nif geometry/skin/controllers }
  class BFRMaterialResource { +effect; +parameters; +textures }
  class BFREffectResource { +emitters }
  class BFREffectEmitter { +particle emit params }
  class BFParticleDictionary { +dictionaries[]; +entries : Vec~BFParticleDictionaryEntry~ }
  class ZTSunLayer { +texture; +base_models[]; +sun_models[]; +sun_position_model }
  BFRModelResource <|-- BFRNetImmerseNifModel : NIF backend
  BFRModelResource *-- BFRModelMesh
  BFREffectResource "1" *-- "*" BFREffectEmitter

BFRModelResource is the model loader (nodes/meshes); BFRNetImmerseNifModel is the concrete Gamebryo .nif backing. Materials (BFRMaterialResource) bind an effect + parameters + textures (authored .bfmat/.fx). Effects/particles (BFREffectResource/BFREffectEmitter/BFRParticleEmitter, indexed by BFParticleDictionary) drive VFX; ZTSunLayer renders the sky/sun; BFWaterGroup groups water surfaces. Vertex formats (BFRVertexFormatElement, BFRVertexPND*) are the GPU layouts the host adapter must reproduce.

Adapter boundary

flowchart LR
  Domain["entities / world / UI / status (native domain state)"]
  Render["BFRenderer + BFSpriteMgr + BFAnim* + BFSoundMgr"]
  Backend["Gamebryo/NetImmerse + D3D + sound engine (REPLACEABLE)"]
  Domain -->|component inputs| Render -->|adapter| Backend

The reconstruction may swap Backend entirely; it must preserve the component inputs (BFRActorComponent transforms, BFAnimController selections, BFSpriteMgr UI projection, BFSND_* cues) that Render consumes.

camera relationship model

classDiagram
  CameraDomain "1" --> ZTCameraCommandReader : command_reader
  CameraDomain "1" --> ZTUserCameraData : user_camera
  CameraDomain "0..1" --> BFPhysObj : startup_phys_obj
  CameraDomain "*" --> ZTRailCam : rail_cams
  CameraDomain "1" --> ZTCameraActiveCommands : active_commands
  CameraDomain "*" --> ZTCameraCommandEvent : command_events
  CameraDomain "1" --> ZTFollowCameraState : follow_camera
  ZTCameraActiveCommands "*" --> ZTCameraActiveCommandState : states
  ZTCameraActiveCommandState "1" --> ZTCameraCommandKind : kind
  ZTCameraCommandReaderNativeState "*" --> ZTCameraFreeMouseLookRequest : free_mouse_look_requests
  ZTCameraCommandReaderNativeState "*" --> ZTCameraCrouchRequest : crouch_requests
  ZTCameraCommandReaderNativeState "*" --> ZTCameraOutputCommandState : output_command_states
  ZTCameraCommandEvent "1" --> ZTCameraCommandKind : kind
  ZTCameraOutputCommandState "1" --> ZTCameraOutputCommand : command

audio relationship model

classDiagram
  AmbientAllowedDocument "*" --> AmbientAllowedEntry : entries
  AmbientBiomeDocument "*" --> AmbientBiomeBinding : bindings
  AmbientSoundDocument "*" --> AmbientSoundSet : sets
  AmbientSoundSet "*" --> AmbientSoundCue : cues
  AudioAmbientDocuments "*" --> AmbientSoundDocument : ambient
  AudioAmbientDocuments "*" --> AmbientBiomeDocument : ambient_biomes
  AudioAmbientDocuments "*" --> AmbientAllowedDocument : ambients_allowed
classDiagram
  AudioDomain "1" --> BFSoundMgr : sound_mgr
  AudioDomain "1" --> BFSoundStageMgr : sound_stage_mgr
  AudioDomain "1" --> ZTWorldSndMgr : world_sound_mgr
  AudioDomain "1" --> ZTAIAmbientsMgr : ambients_mgr
  AudioDomain "1" --> SoundTags : sound_tags
  AudioDomain "*" --> SoundTagsDocument : sound_tag_documents
  AudioDomain "1" --> AudioAmbientDocuments : ambient_documents
  AudioDomain "*" --> BFSoundtag : bf_soundtags
  AudioDomain "1" --> BF2DSndFactory : two_d_factory
  AudioDomain "1" --> BF3DSndFactory : three_d_factory
  AudioDomain "1" --> BFAmbient2DSndFactory : ambient_two_d_factory
  AudioDomain "1" --> BFAmbient3DSndFactory : ambient_three_d_factory
  AudioDomain "*" --> BFSoundEvent : sound_events
  BFAmbient3DSndFactory "*" --> BFAmbient3DSndGenerator : generators
  BFAmbient3DSndGenerator "0..1" --> BF3DSnd : active_sound
classDiagram
  SoundTag "0..1" --> BF2DSndFactory : two_d_factory
  SoundTag "*" --> SoundTagVariant : variants
  SoundTag "1" --> SoundTagPlaybackPolicy : playback
  SoundTag "1" --> SoundTagDistancePolicy : distance
  SoundTag "1" --> SoundTagRandomPolicy : random
  SoundTagGroup "*" --> SoundTag : tags
  SoundTags "*" --> SoundTag : tags
  SoundTags "*" --> SoundTagAlias : aliases
  SoundTags "*" --> SoundTagGroup : groups
  SoundTagsDocument "1" --> SoundTags : root
  ZTWaterEnvSizes "1" --> ZTWaterSoundStages : natural
  ZTWaterEnvSizes "1" --> ZTWaterSoundStages : tanks
  ZTWorldSndMgrContextConfig "*" --> BFContextComponent : children

renderer relationship model

classDiagram
  AmbientBiomesConfig "*" --> AmbientBiomeEntry : entries
  AmbientConfig "*" --> AmbientWeight : day_weights
  AmbientConfig "*" --> AmbientWeight : night_weights
  BFBinderResourceEntry "1" --> BFResourceEntry : entry
  BFDirectoryResourceEntry "1" --> BFResourceEntry : entry
  BFLODComponent "0..1" --> BFLODPixelData : pixel_data
  BFPosInterpolateComponent "1" --> BFPosInterpolate : interpolation
  BFRD3DStateBlock "*" --> BFRRenderState : render_states
  BFRD3DStateBlock "*" --> BFRRenderState : texture_stage_states
  BFRD3DStateBlock "*" --> BFRShaderConstant : shader_constants
  BFREffectManager "1" --> BFRResourceManager : base
  BFREffectManager "*" --> BFREffectResource : effects
classDiagram
  BFREffectIncludeManager "1" --> BFRResourceManager : base
  BFREffectIncludeManager "*" --> BFREffectIncludeRecord : include_records
  BFRMaterialMode "*" --> BFRRenderState : render_states
  BFRMaterialMode "*" --> BFRMaterialParam : params
  BFRMaterialParam "1" --> BFRMaterialParamType : param_type
  BFRMaterialParam "1" --> BFRMaterialParamValue : value
  BFRMaterialParam "0..1" --> BFRMaterialAnimation : animated
  BFRMaterialAnimation "*" --> BFRMaterialAnimationTrack : tracks
  BFRMaterialAnimationTrack "0..1" --> BFRMaterialAnimationChannel : channel
  BFRMaterialAnimationTrack "*" --> BFRMaterialKeyFrame : keys
  BFRMaterialSelector "*" --> BFRMaterialResource : variants
  BFRMaterialSelector "0..1" --> BFRSelectorBounds : bounds
classDiagram
  BFRModelManager "1" --> BFRResourceManager : base
  BFRModelManager "*" --> BFRModelResource : models
  BFRModelManager "*" --> BFRModelPathParts : path_parts
  BFRModelManager "*" --> BFRModelFactoryDispatch : factory_dispatches
  BFRModelFactoryDispatch "0..1" --> BFRModelSubclassKind : product_kind
  BFRModelFactoryProduct "0..1" --> BFRModelSubclassKind : kind
  BFRModelFactoryProduct "0..1" --> BFRModelResource : resource
  BFRModelGeometryCollection "*" --> BFRModelGeometryRecord : records
  BFRModelGeometryCollection "*" --> BFRModelGeometryChildRecord : child_records
  BFRModelGeometryCollection "0..1" --> BFRBoundingSphere : bounds
  BFRModelGeometryRecord "1" --> BFRModelGeometryRecordFlags : record_flags
  BFRModelGeometryRecord "0..1" --> BFRModelGeometryStream : stream
  BFRModelGeometryExtendedRecord "1" --> BFRModelGeometryRecord : base
  BFRModelGeometryChildRecord "1" --> BFRModelGeometryRecord : record
  BFRModelGeometryStream "0..1" --> BFRModelVertexFormatDescriptor : format
  BFRModelGeometryStream "*" --> BFRVertexFormatElement : format_elements
  BFRModelGeometryStream "*" --> BFRVertex : vertices
  BFRModelGeometryStream "*" --> BFRModelGeometryStreamRecord : stream_records
classDiagram
  BFRNetImmerseNifBlock "1" --> BFRNetImmerseNifBlockPayload : payload
  BFRParticleManager "1" --> BFRResourceManager : base
  BFRParticleManager "*" --> BFRParticleSystem : systems
  BFRParticleSystem "0..1" --> BFRParticleEmitter : emitter
  BFRParticleSystem "*" --> BFRParticleModifier : modifiers
  BFRParticleSystem "0..1" --> BFRParticleDefinition : default_particle
  BFRParticleModifier "*" --> BFRParticleParam : params
  BFRResourceManager "1" --> BFRResourceCache : cache
  BFRResourceCache "*" --> BFRResourceHandle : handles
  BFRShaderConstant "1" --> BFRMaterialParamValue : value
  BFRTextureResourceCache "*" --> BFRResourceHandle : resident_textures
  BFRTextureManager "1" --> BFRResourceManager : base
  BFRTextureManager "*" --> BFRTextureResource : textures
  BFRTextureManager "1" --> BFRTextureResourceCache : texture_cache
  BFRTextureResource "0..1" --> BFRTextureFormat : format
  BFResourceEntryLifecycle "*" --> BFRResourceHandle : retained_handles
classDiagram
  BFResourceImportRequest "*" --> BFResourceArchiveVariant : variants
  BFResourceImportRequest "0..1" --> BFResourceZipPrefixImport : zip_prefix
  BFResourceOpenRequest "1" --> BFResourceOpenMode : mode
  BFResourceOpenRequest "0..1" --> BFResourcePathNormalization : normalized
  BFResourceOpenResult "1" --> BFResourceEntryKind : entry_kind
  BFResourceQueryResult "1" --> BFResourceEntryKind : entry_kind
  BFResourceTree "*" --> BFResourceTreeNode : nodes
  BFUITextRenderOptions "1" --> BFUITextRenderSetting : shadows
  BFUITextRenderOptions "1" --> BFUITextRenderSetting : textures
  BFZ2FResourceEntry "1" --> BFResourceEntry : entry
  BFZ2SResourceEntry "1" --> BFResourceEntry : entry
  BFZipResourceEntry "1" --> BFResourceEntry : entry
classDiagram
  Bink "0..1" --> BinkFrameCopy : last_copy
  BinkVideoRuntime "*" --> Bink : videos
  BinkVideoRuntime "*" --> BinkFrameCopy : pending_frames
  CrowdConfig "*" --> Graph : density_curves
  CrowdDocument "*" --> CrowdDensityBand : density_bands
  CrowdDocument "*" --> Graph : graphs
  CurveMap "*" --> CurvePoint : points
  FogDocument "*" --> FogLayer : layers
  FogDocument "*" --> FogTimeSlice : time_slices
  FogLayer "*" --> FogKeyFrame : keyframes
classDiagram
  GamebryoRuntime "1" --> NiMain : main
  GamebryoRuntime "1" --> NiSystem : system
  GamebryoRuntime "1" --> NiD3D : d3d
  GamebryoRuntime "1" --> NiDX9 : dx9
  GamebryoRuntime "1" --> NiDX9Renderer : renderer
  GamebryoRuntime "*" --> NiNode : root_nodes
  GamebryoRuntime "*" --> NiParticles : particles
  GamebryoRuntime "*" --> NiParticlesData : particle_data
  GamebryoRuntime "*" --> NiParticleModifier : particle_modifiers
  GamebryoRuntime "*" --> NiColorData : color_data
  GamebryoRuntime "*" --> NiFloatData : float_data
  GamebryoRuntime "*" --> NiCamera : cameras
  GamebryoRuntime "*" --> NiTriShape : tri_shapes
  GamebryoRuntime "*" --> NiSourceTexture : source_textures
  GamebryoRuntime "*" --> NiRenderedTexture : rendered_textures
  GamebryoRuntime "*" --> NiZBufferProperty : z_buffer_properties
  GamebryoRuntime "*" --> NiVertexColorProperty : vertex_color_properties
  GamebryoRuntime "*" --> NiStringExtraData : string_extra_data
  GamebryoRuntime "*" --> NiMaterialProperty : material_properties
  GamebryoRuntime "*" --> NiTexturingProperty : texturing_properties
  GamebryoRuntime "*" --> NiAlphaProperty : alpha_properties
  GamebryoRuntime "*" --> NiAlphaController : alpha_controllers
  GamebryoRuntime "*" --> NiControllerManager : controller_managers
  GamebryoRuntime "*" --> NiParticleSystemController : particle_controllers
  GamebryoRuntime "*" --> NiCollisionObject : collision_objects
  GamebryoRuntime "1" --> NiAccumulatorSet : accumulators
classDiagram
  LightRig "*" --> LightConfig : lights
  LightRig "*" --> LightKeyFrame : keyframes
  LightsConfig "*" --> LightConfig : lights
  LightsDocument "*" --> LightRig : rigs
  LodDistances "*" --> LodDistanceLevel : levels
  LodDistancesDocument "*" --> LodDistanceLevel : levels
  NiAVObject "1" --> NiObjectNET : object
  NiAVObject "1" --> NiTransform : local_transform
  NiAVObject "1" --> NiTransform : world_transform
  NiAVObject "*" --> NiPropertyRef : properties
  NiAVObject "0..1" --> NiCollisionObject : collision
  NiAVObject "0..1" --> NiObjectRef : collision_ref
  NiAccumulatorSet "1" --> NiAlphaAccumulator : alpha
  NiAccumulatorSet "1" --> NiTextureAccumulator : texture
  NiAlphaAccumulator "*" --> NiObjectRef : sorted_objects
  NiAlphaAccumulator "*" --> NiAlphaProperty : alpha_properties
classDiagram
  NiAlphaController "1" --> NiObjectNET : object
  NiAlphaController "0..1" --> NiControllerRef : next_controller
  NiAlphaController "0..1" --> NiObjectRef : target
  NiAlphaController "0..1" --> NiObjectRef : data
  NiAlphaProperty "1" --> NiObjectNET : object
  NiAnimation "*" --> NiControllerRef : controllers
  NiAnimation "0..1" --> NiTextKeyExtraData : text_keys
  NiCamera "1" --> NiAVObject : av_object
  NiCamera "1" --> NiCameraFrustum : frustum
  NiCamera "1" --> NiViewport : viewport
  NiCollision "0..1" --> NiObjectRef : subject
  NiCollision "0..1" --> NiObjectRef : target
  NiCollisionObject "1" --> NiObjectNET : object
  NiCollisionObject "0..1" --> NiObjectRef : target
  NiCollisionObject "0..1" --> NiCollisionData : data
  NiColorData "1" --> NiObjectRef : ref_id
  NiColorData "1" --> NiColorKeyGroup : keys
  NiColorKeyGroup "*" --> NiColorKey : keys
  NiControllerManager "1" --> NiObjectNET : object
  NiControllerManager "*" --> NiAnimation : sequences
classDiagram
  NiD3DShaderInterface "*" --> NiShaderConstant : constants
  NiDX9 "1" --> NiD3D : d3d
  NiDX9 "0..1" --> NiDX9Renderer : renderer
  NiDX9 "0..1" --> NiD3DShaderInterface : shader_interface
  NiDX9Renderer "*" --> NiRenderedTexture : render_targets
  NiDX9Renderer "1" --> NiTextureAccumulator : texture_accumulator
  NiDX9Renderer "1" --> NiAlphaAccumulator : alpha_accumulator
  NiFloatData "1" --> NiObjectRef : ref_id
  NiFloatData "1" --> NiFloatKeyGroup : keys
  NiFloatKeyGroup "*" --> NiFloatKey : keys
  NiGeometry "1" --> NiAVObject : av_object
  NiGeometry "0..1" --> NiObjectRef : data
  NiGeometry "0..1" --> NiObjectRef : skin_instance
  NiGeometry "0..1" --> NiGeometryShader : shader
  NiMain "*" --> NiObjectRef : object_roots
  NiMaterialProperty "1" --> NiObjectNET : object
classDiagram
  NiNode "1" --> NiAVObject : av_object
  NiNode "*" --> NiObjectRef : children
  NiNode "*" --> NiObjectRef : effects
  NiObjectNET "1" --> NiObjectRef : ref_id
  NiObjectNET "*" --> NiExtraDataRef : extra_data
  NiObjectNET "0..1" --> NiControllerRef : controller
  NiParticleModifier "1" --> NiObjectNET : object
  NiParticleModifier "1" --> NiParticleModifierKind : kind
  NiParticleModifier "0..1" --> NiObjectRef : next_modifier
  NiParticleModifier "0..1" --> NiObjectRef : controller
  NiParticleModifier "0..1" --> NiObjectRef : color_data
  NiParticleSystemController "1" --> NiObjectNET : object
  NiParticleSystemController "0..1" --> NiControllerRef : next_controller
  NiParticleSystemController "0..1" --> NiObjectRef : target
  NiParticleSystemController "0..1" --> NiObjectRef : emitter
  NiParticleSystemController "*" --> NiParticleInfo : particles
  NiParticleSystemController "0..1" --> NiObjectRef : particle_extra
  NiParticleSystemController "0..1" --> NiObjectRef : unknown_link
  NiParticleSystemController "0..1" --> NiObjectRef : unknown_link_2
  NiParticles "1" --> NiGeometry : geometry
  NiParticlesData "1" --> NiObjectRef : ref_id
  NiParticlesData "1" --> NiGeometryData : geometry
  NiRenderedTexture "1" --> NiObjectNET : object
  NiShaderTextureSlot "0..1" --> NiTextureSlot : texture
classDiagram
  NiSkinBone "1" --> NiTransform : transform
  NiSkinBone "*" --> NiSkinWeight : weights
  NiSkinData "*" --> NiSkinBone : bones
  NiSkinData "1" --> NiTransform : bind_transform
  NiSourceTexture "1" --> NiObjectNET : object
  NiSourceTexture "0..1" --> NiObjectRef : pixel_data
  NiStringExtraData "1" --> NiObjectRef : ref_id
  NiTextKeyExtraData "*" --> NiTextKey : keys
  NiTextureAccumulator "*" --> NiSourceTexture : queued_textures
  NiTextureSlot "0..1" --> NiObjectRef : source
  NiTexturingProperty "1" --> NiObjectNET : object
  NiTexturingProperty "0..1" --> NiTextureSlot : base_texture
  NiTexturingProperty "0..1" --> NiTextureSlot : dark_texture
  NiTexturingProperty "0..1" --> NiTextureSlot : detail_texture
  NiTexturingProperty "0..1" --> NiTextureSlot : gloss_texture
  NiTexturingProperty "0..1" --> NiTextureSlot : glow_texture
  NiTexturingProperty "0..1" --> NiTextureSlot : bump_map_texture
  NiTexturingProperty "0..1" --> NiTextureSlot : decal_0_texture
  NiTexturingProperty "*" --> NiShaderTextureSlot : shader_textures
  NiTriShape "1" --> NiAVObject : av_object
  NiTriShape "0..1" --> NiTriShapeData : data
  NiTriShape "0..1" --> NiSkinData : skin
  NiVertexColorProperty "1" --> NiObjectNET : object
classDiagram
  NiZBufferProperty "1" --> NiObjectNET : object
  RenderEnvironmentDocumentSet "*" --> FogDocument : fog
  RenderEnvironmentDocumentSet "*" --> LightsDocument : lights
  RenderEnvironmentDocumentSet "*" --> SkyLayersDocument : sky_layers
  RenderEnvironmentDocumentSet "*" --> WaterDocument : water
  RenderEnvironmentDocumentSet "*" --> CrowdDocument : crowd
  RenderEnvironmentDocumentSet "*" --> SuspenseDocument : suspense
  RenderEnvironmentDocumentSet "*" --> LodDistancesDocument : lod_distances
classDiagram
  RenderEnvironmentDocuments "1" --> AmbientConfig : ambient
  RenderEnvironmentDocuments "1" --> AmbientBiomesConfig : ambient_biomes
  RenderEnvironmentDocuments "1" --> AmbientsAllowedConfig : ambients_allowed
  RenderEnvironmentDocuments "1" --> CrowdConfig : crowd
  RenderEnvironmentDocuments "1" --> FogConfig : fog
  RenderEnvironmentDocuments "1" --> LightsConfig : lights
  RenderEnvironmentDocuments "1" --> LodDistances : lod_distances
  RenderEnvironmentDocuments "1" --> SkyLayersConfig : sky_layers
  RenderEnvironmentDocuments "1" --> SuspenseConfig : suspense
  RenderEnvironmentDocuments "1" --> WaterRenderConfig : water
  RenderEnvironmentDocuments "1" --> RenderEnvironmentDocumentSet : authored_roots
classDiagram
  RendererDomain "0..1" --> BFDX9Renderer : dx9_renderer
  RendererDomain "0..1" --> BFUIRenderer : ui_renderer
  RendererDomain "1" --> BFRResourceCache : resource_cache
  RendererDomain "1" --> BFRD3DStateBlock : d3d_state
  RendererDomain "1" --> BFRTextureManager : texture_manager
  RendererDomain "1" --> BFRMaterialManager : material_manager
  RendererDomain "1" --> BFREffectManager : effect_manager
  RendererDomain "1" --> BFREffectIncludeManager : effect_include_manager
  RendererDomain "1" --> BFRModelManager : model_manager
  RendererDomain "1" --> BFRParticleManager : particle_manager
  RendererDomain "1" --> BFParticleDictionary : particle_dictionary
  RendererDomain "*" --> BFParticleDefinition : particle_definitions
  RendererDomain "1" --> BFRSceneGraph : scene_graph
  RendererDomain "1" --> RenderEnvironmentDocuments : environment_documents
  RendererDomain "*" --> ZTVista : vistas
  RendererDomain "*" --> ZTSunLayer : sun_layers
  RendererDomain "*" --> BFWaterGroup : water_groups
  RendererDomain "*" --> BFWaterfall : waterfalls
  RendererDomain "*" --> BFRModeVisualEffectRequest : mode_visual_effects
  RendererDomain "1" --> GamebryoRuntime : gamebryo
  RendererDomain "1" --> BinkVideoRuntime : bink
classDiagram
  BFFPSUDVComponent <|-- ZTFPSUDVComponent
  SkyLayersConfig "*" --> ZTSunLayer : layers
  SkyLayersDocument "*" --> SkyLayerDocumentEntry : layers
  SkyLayersDocument "0..1" --> TimeOfDayUpdateInterval : update_interval
  SuspenseConfig "*" --> Graph : mix_graphs
  SuspenseDocument "*" --> SuspenseCue : cues
  SuspenseDocument "*" --> Graph : graphs
  WaterDocument "*" --> WaterLayer : layers
  WaterDocument "*" --> WaterScroll : scroll
  ZTFPSUDVComponent "1" --> BFFPSUDVComponent : base

model relationship model

classDiagram
  NetImmerseColorKeyGroup "*" --> NetImmerseColorKey : keys
  NetImmerseFloatKeyGroup "*" --> NetImmerseFloatKey : keys
  NetImmerseNiAlphaController "1" --> NetImmerseNiTimeController : controller
  NetImmerseNiAlphaProperty "1" --> NetImmerseNiObjectNet : object
  NetImmerseNiAvObject "1" --> NetImmerseNiObjectNet : object
  NetImmerseNiColorData "1" --> NetImmerseColorKeyGroup : data
  NetImmerseNiFloatData "1" --> NetImmerseFloatKeyGroup : data
  NetImmerseNiGeometry "1" --> NetImmerseNiAvObject : av_object
  NetImmerseNiGeometry "0..1" --> NetImmerseNiGeometryShader : shader
  NetImmerseNiMaterialProperty "1" --> NetImmerseNiObjectNet : object
  NetImmerseNiNode "1" --> NetImmerseNiAvObject : av_object
  NetImmerseNiParticleColorModifier "1" --> NetImmerseNiParticleModifier : modifier
  NetImmerseNiParticleGrowFade "1" --> NetImmerseNiParticleModifier : modifier
classDiagram
  NetImmerseNiParticleRotation "1" --> NetImmerseNiParticleModifier : modifier
  NetImmerseNiParticleSystemController "1" --> NetImmerseNiTimeController : controller
  NetImmerseNiParticleSystemController "*" --> NetImmerseNiParticleInfo : particles
  NetImmerseNiParticles "1" --> NetImmerseNiGeometry : geometry
  NetImmerseNiParticlesData "1" --> NetImmerseNiGeometryData : geometry
  NetImmerseNiSourceTexture "1" --> NetImmerseNiObjectNet : object
  NetImmerseNiTexturingProperty "1" --> NetImmerseNiObjectNet : object
  NetImmerseNiTexturingProperty "0..1" --> NetImmerseTextureSlot : base_texture
  NetImmerseNiTexturingProperty "0..1" --> NetImmerseTextureSlot : dark_texture
  NetImmerseNiTexturingProperty "0..1" --> NetImmerseTextureSlot : detail_texture
  NetImmerseNiTexturingProperty "0..1" --> NetImmerseTextureSlot : gloss_texture
  NetImmerseNiTexturingProperty "0..1" --> NetImmerseTextureSlot : glow_texture
  NetImmerseNiTexturingProperty "0..1" --> NetImmerseTextureSlot : bump_map_texture
  NetImmerseNiTexturingProperty "0..1" --> NetImmerseTextureSlot : decal_0_texture
  NetImmerseNiTexturingProperty "*" --> NetImmerseShaderTextureSlot : shader_textures
  NetImmerseNiVertexColorProperty "1" --> NetImmerseNiObjectNet : object
  NetImmerseNiZBufferProperty "1" --> NetImmerseNiObjectNet : object
classDiagram
  NetImmerseNifDocument "1" --> NetImmerseNifHeader : header
  NetImmerseNifDocument "1" --> NetImmerseNifFooter : footer
  NetImmerseNifDocument "*" --> ModelBlockRecord : block_records
  NetImmerseNifDocument "*" --> ModelBlockTypeCount : block_type_counts
  NetImmerseNifDocument "*" --> NetImmerseNifBlock : block_payloads
  NetImmerseShaderTextureSlot "0..1" --> NetImmerseTextureSlot : texture

Open contracts (Renderer/Audio)

Persistence

Persistence reuses the BFXMLObj read_xml_node/write_xml_node contract that every component already implements. A save is the serialized component/entity tree written into a .z2s container; load replays it back into the same binders and components. Save and load are file-mode tools.

classDiagram
  ZTMode <|-- ZTFileMode
  ZTFileMode <|-- ZTSaveMode
  ZTFileMode <|-- ZTLoadMode
  ZTMode <|-- ZTDownloadMode
  BFComponent <|-- BFUserProfileMgr
  BFComponent <|-- BFGElevatedTileSerializer
  BFXMLObj <|-- BFUndoTransactionData
  class BFUserProfileMgr { profile id; saveDirectory; tempDirectory; options.xml }

What is persisted

The save captures the source-defined zoo: profile/options (BFUserProfileMgr, options.xml), selected map/scenario/campaign, zoo session (cash/economy history, fame, research unlocks, status), the world (terrain/biome, fences/tanks, paths, transport, placement grid + elevated support via BFGElevatedTileSerializer), entity instances and their component state, AI tokens and task-relevant state, scenario/tutorial rule state, disease/cure state, adoption slots, and photos/challenges.

Reconstructed: a ZTSavedGame row carries name, path, preview thumbnail, file_time_low/high, and scenario_name; ZTSaveRequest/ZTLoadModeState drive the file-mode flow.

Save/load flow

sequenceDiagram
  participant UI as menu
  participant Mode as ZTSaveMode / ZTLoadMode
  participant Tree as binder + component tree
  participant File as .z2s container
  UI->>Mode: ZT_SAVEGAME / ZT_LOADGAME
  Mode->>Tree: walk roots
  Tree->>File: write_xml_node() per component (save)
  File->>Tree: read_xml_node() per component (load)
  Mode-->>UI: ZT_SAVE_SCREENSHOT / ZT_LOAD_AFTER_SAVE

handle_saveEntityFile_command shows the same path for single entity-file export; ZT_SAVE_SCREENSHOT attaches the save thumbnail.

save relationship model

classDiagram
  SaveDomain "1" --> ZTLoadModeState : load_mode
  SaveDomain "1" --> ZTSaveModeState : save_mode
  SaveDomain "0..1" --> ZTSavedGame : current_game
  SaveDomain "0..1" --> ZTLoadRequest : pending_load_request
  SaveDomain "0..1" --> ZTSaveRequest : pending_save
  SaveDomain "0..1" --> ZTDeleteGameRequest : pending_delete
  SaveDomain "*" --> BFUserProfileEvent : profile_events
  SaveDomain "0..1" --> ZTLoadAfterSave : load_after_save
  ZTSaveModeState "*" --> ZTSaveLoadAlert : alerts

Open contracts (Persistence)

Reconstructed Type Reference (Appendix)

Field coverage for reconstructed flat config/state/helper records.

ai.rs

animal.rs

app.rs

audio.rs

camera.rs

catalog.rs

disease.rs

economy.rs

entity_info.rs

fence.rs

gesture.rs

managers.rs

menu_profile_campaign_scenario.rs

modes.rs

photo.rs

placement.rs

renderer.rs

research.rs

runtime_support.rs

scenario.rs

scripting.rs

show.rs

staff.rs

tank.rs

terrain.rs

transport.rs

ui_binding.rs

ui_contract.rs

world.rs

Registered Class Roster (node-level)

Thin registered subtypes/records (behaviour in base + message vocabulary), with parent:

Message Token Registry

All 1084 registered message/event tokens (no fields/methods) by family.

Open Contract Register

Open contracts mark native surfaces that remain explicit until established from source data and authored content. Cross-cutting unknowns:

Surface What is unrecovered Owning section
Source schemas full entity shared-data schema, profile/save/.z2s and scenario field layouts, descriptor-table shapes Source Object Model, Persistence
Vtable behavior widget/manager vtable method bodies (UI_*/BFAI_* handlers); only message sets + inheritance modeled UI, AI, Managers
AI/sim policy task scoring/tie-break, ThinkerInterval cadence, token lifetime, steering blend weights AI
World placement grid units, footprint schema, slope thresholds, elevated topology rules, terrain visual mechanism World
Economy/fame/disease half-star/admission/donation formulae, disease spread/cure cadence, research tree schema Economy
Renderer/audio .bfmat/.fx parameter+animation syntax, material slot binding, anim blend/transition, mixing categories Renderer
Scenario/scripts rule evaluation order, Lua arg/stack marshalling, compiled .bin/.lop + VINCE telemetry Scenario
Manager runtime construction/update order per tick, BFTimeKeeper fan-out, which managers persist Managers
Host adapters Win32 pump/dialog/IME edges, registry/profile mapping, network/download/MOTD Renderer, Persistence (adapter boundary)

Unresolved methods, globals, payloads, and formulae stay attached to the nearest original class or manager.

Binary Perimeter

The binary's function/global perimeter, library boundaries, vtable enumeration, and identification coverage live in the Binary Perimeter (perimeter.html) as red-team analysis artifacts. They stay separate from the product-domain contract to preserve the clean-room boundary between binary analysis and specification.