# brahma *Visual code + fsm editor for rust/bevy* Doc v0.3 ![Ludiq Bolt](https://i.imgur.com/axrdxaY.jpg) **Ludiq Bolt** Inspired by Ludiq Bolt. Brahma aims to provide a simple yet robust editor capable of authoring algorithm graph (function call graph) and state graph (state machine graph), which gets compiled into consumable rust code. It aims, - to reduce the barrier of entry for new comers, i.e. artists, designers and hobby programmers - to make higher level flow related content authoring easier, i.e. gamelogic, ux flow, ai fsm, animation fsm. General idea is, it is much easier to follow control flows visually than in code (especially for ECS). ## Feature Set - Search Palette UI: fuzzy search types like Events, Resources and Rust methods - Author custom functions visually using Brahma Algo Nodes - Interop with Bevy Resources - Call existing rust methods - Run Multiple FSM Instances - Hierarchical State Machine [TBD] - Local Events [TBD] *Note** *"Project" usually means end user game project and "libs" are the external libraries that people use in their game projects eg. std...etc* ## UI/UX Overview ### Widgets - Graph Breadcrumb Widget - displays where we are in the graph ### Viewports #### Graph Editor Depending on which node i.e. fsm or algo is opened, the graph editor will switch to one of the below views. - State Machine Editor View - Edit FSM graph - Algorithm Editor View - Edit Algorithm graph #### Inspector Inspectors allow you to edit certain properties of a node. Depending on the node selected, inspector panel will change. - State Node Inspector - Transistion Node Inspector - Algorithm Node Inspector ### Nodes There are two kinds of nodes, leaf nodes and branch nodes. Leaf cannot contain children i.e. these nodes cannot be expanded and modified inside the editor. Branch can have children and they can be edited inside the editor. There are different types of node, namely #### Method Node (Leaf Node) Public rust functions defined in the project/libs ##### Ports - Control - In, Out - Data - Set, Get #### Variable Node (Leaf Node) Nodes used to hold data can be. Returns a handle to the variable ##### Ports - Data - Get #### Event Node (Leaf Node) Bevy Event ##### Ports - Control - Out - Data - Get #### Algo Node Functions that are created inside brahma. ##### Ports - Control - In, Out - Data - Set, Get ##### Children - Nested Algo Node - Method Node - Variable Node #### State Node FSM State. Can connect only to Transistion Nodes ##### Ports - Control - In, Out ##### Children - Event Node - Algo Node - Method Node - Variable Node #### Transistion Node FSM Transition. When the condition is true fsm will transit to the linked State. Can connect only to State Node ##### Ports - Control - In, Out ##### Children - Algo Node - Method Node - Variable Node - Event Node [TBD] ### Ports Nodes are connected via ports. There are two types, control port and data port. Ports can only be connected to the same type. It is always an one to one connection i.e. one port can only be linked to one other port. #### Control Port Dictates the direction of flow i.e. sequence of execution. #### Data Port Data port is mainly to link return values to function parameter. ## Architecture Overview ![Overview](https://github.com/PradeepKumarRajamanickam/brahma/raw/master/brahma.jpg) **Editor Architecture Overview** ### Brahma Lang Server (brahma_lsp) Brahma maintains a look up file with information about project/libs public apis that the user wants to use as nodes. Fuzzy searching calls will use this data to quickly provide results. This data has to be rebuilt each time there is a change in the src code. User needs to explicitly configure this (via gui/cli wizard). ### Brahma Graph (brahma_graph) This is an intermediate representation that can be easily serialised to/from ron. ### Brahma Scribe (brahma_scribe) Consumes graph object to generate executable rust code. ### Brahma UI (brahma_ui) Provides API to easily setup ui widgets/viewport (graph editor, node inspector...etc) and sends ui event callbacks. ### Brahma (Root Module) Editor entry module which handles ui/ux logic, setups ui layout and viewports. This is the glue layer that communicates with all the sub modules. ## How To Tackle / The Plan Order in which I see things might happen - brahma_graph - brahma_scribe - brahma_yantra - brahma_lsp - brahma_ui (much later once bevy editor ui is stable and usable) - brahma **Time estimate: approx. 1 year of development* **Note this is just a rough plan, the final product and time frame might be very different.* Inspired By: [Ludiq Bolt](https://assetstore.unity.com/packages/tools/visual-scripting/bolt-163802)