EditorController
TheEditorController class (EditorController.cs) is the central orchestrator. It:
- Manages all editor state (blocks, items, enemies, balls, sections)
- Handles user input (keyboard, mouse)
- Coordinates between menus, pools, and property panels
- Implements
ILevelReferencefor gameplay integration - Maintains the
LuaScriptsCollectionandMessagesManager
Key Responsibilities
EditorLevelSection
Each section is anEditorLevelSection instance containing:
SectionId— Unique identifierBlocks—BlockNetgrid of blocksBalls— List of balls in this sectionEnemies— List of enemies in this sectionThemeModel— Visual themeMusic— Background music trackDarkMode— Dark mode flagSkyboxGrid— Skybox grid flagLavaPool— Lava pool configuration
Pool System
Element pools (EditorBlocksPool, EditorItemsPool, etc.) inherit from EditorElementSelector<T>:
- Display a grid of templates from the current theme
- Handle selection and deselection
- Support keyboard navigation
- Auto-close after selection
- Store element property backups for template copying
Menu System
The editor uses a singleton menu pattern — only one menu can be active at a time:- Camera input is disabled
- The menu panel is activated
- UI elements are focused for keyboard navigation
- Camera input is restored (unless another menu opens)
- The menu panel is deactivated
Event System
Menus communicate through C# events:OnMainMenuSelectChoice— Main menu button clicksOnElementPropertiesOpenTemplateSelector— Template selection requestsOnElementPropertiesOnDirectionChange— Direction changesOnBallStyleSelectorAction— Ball style selection- Various
OnBackButtonPressedevents for navigation
Input Handling
Input is processed in two phases:UIInputs()
Handles menu shortcuts and escape key. Runs every frame but is blocked when a menu is active.BlocksInputs()
Handles block manipulation (WASD/EQ movement, clicks, space, backspace, tab). Only runs when no menu is active. Both phases checkLoadingEnabled and IsAnyMenuActive before processing.
Score Calculation
Score is calculated lazily:_scoreInfoDeprecatedis set totruewhen elements changeUpdateScoreInfo()runs inUpdate()when the flag is set- Iterates all sections, blocks, items, and enemies
- Updates the
ScoreInfoDatastruct - The HUD reads the struct for display
Section Management
Sections are stored in:_mainSection— The default section (always exists)_sections— Dictionary of additional sections
SetCurrentSection()updates_currentSectionReloadEditor()rebuilds the viewport- Theme and music are reloaded for the new section
Persistence Layer
EditorPersistentState is a static class that stores:
- Camera transform (position, rotation)
- Block selector position
- Level data (full level state)
- Level path
- Best editor time
Creation Modes
Elements are created with aCreationMode flag:
This flag affects template callbacks and initialization behavior.