Luban Game Configuration Tool

repository·main·Indexed 26 days ago

https://github.com/focus-creative-games/luban

A high-performance game configuration tool that converts source files such as Excel, JSON, XML, YAML, and Lua into optimized, type-safe code and data formats. It supports multiple export formats (binary, JSON, BSON, XML, Lua, YAML) and provides built-in code generation for C#, Java, Go, C++, Lua, Python, JavaScript, TypeScript, Rust, PHP, Erlang, and Godot. Luban features advanced data modeling with OOP type inheritance, data validation, and compatibility with Unity, Unreal, Cocos2x, and Godot.

Tokens
997
Snippets
0
Records
6
Agent score
39%

What's inside Luban

  1. Overview of Luban Game Configuration Solution

    main

    Luban is a powerful, stable, and elegant game configuration solution designed to handle workflows ranging from small to ultra-large game projects. It standardizes the game configuration development process to improve efficiency between designers and programmers.

    Key Capabilities:

    • Diverse Source Formats: Supports Excel family (csv, xls, xlsx, xlsm), JSON, XML, YAML, and Lua.
    • Multiple Export Formats: Generates binary, JSON, BSON, XML, Lua, and YAML.
    • Advanced Data Modeling: Supports complex nested structures (lists, sub-structures, nested lists) and OOP type inheritance for modeling complex gameplay data like behavior trees, skills, or dungeons.
    • Multi-Language Support: Built-in code generation for C#, Java, Go, C++, Lua, Python, JavaScript, TypeScript, Rust, PHP, Erlang, and Godot. It also supports other languages via Protobuf or Flatbuffers.
    • Data Validation: Includes reference checking (ref), resource path validation, and range checks.
    • Engine & Platform Compatibility: Supports Unity, Unreal, Cocos2x, Godot, and WeChat Mini Games across Windows, Linux, and Mac.
    • Hot-Update Friendly: Compatible with HybridCLR, ILRuntime, Lua (various flavors), and Puerts.
    • Obfuscation Friendly: Generated code avoids reflection, making it compatible with tools like Obfuz, Obfuscator, Confuser, and .NET Refactor.
  2. Get Started with Luban

    main

    To begin using Luban, you can refer to the official documentation and example projects to understand the configuration pipeline and code generation process.

  3. Use DartCommonTemplateExtension in Scriban templates

    main

    The DartCommonTemplateExtension class provides helper functions for generating Dart code from Luban definitions within Scriban templates. These functions handle common tasks such as generating class modifiers, managing imports, and formatting type names.

    Key capabilities include:

    • Class & Method Modifiers: Automatically adding abstract or @override based on the definition structure.
    • Import Management: Generating import statements based on a provided RootFolder path and the definition's full name.
    • Type Name Resolution: Determining declaring type names, nullable type names, and collection reference names.
    • Field & Constructor Logic: Checking if a constructor is needed or if a field belongs to a superclass.
  4. Generate Dart imports using DeclaringImportName

    main

    When writing Scriban templates for Dart, use DeclaringImportName to generate the appropriate import statement for a given TType. This function handles Enums, Beans, and Collections (including Maps) by resolving their underlying types and formatting them into a file path relative to the RootFolder.

    Parameters:

    • type: The TType to generate an import for.
    • RootFolder: The base directory string used to construct the import path.

    Behavior:

    • For TEnum, it imports the file containing the DefEnum.
    • For TBean, it imports the file containing the DefBean.
    • For collections, it recursively resolves the element type (or both key and value types for TMap).