4.0 KiB
gregCore - Agent Guide
Welcome to the gregCore repository. This document outlines the project architecture, commands, conventions, and constraints to help AI agents work effectively in this codebase.
1. Project Overview
gregCore is a modding framework for the game "Data Center". It acts as a bridge between the game (running on Unity IL2CPP with MelonLoader) and various modding languages (C#, Lua, JS, Rust, Go).
Critical Constraint: All runtime/gameplay-facing components MUST remain compatible with .NET 6.0. Do not upgrade the target framework beyond net6.0, as it will break Unity IL2CPP + MelonLoader compatibility.
2. Essential Commands & Scripts
The project uses PowerShell scripts for most build and deployment tasks. You can find them in the scripts/ directory.
- Build Release:
pwsh scripts/Build-Release.ps1- This builds
src/gregCore.csprojin Release configuration and packages it intopublish/gregCore-vX.Y.Z.zip.
- This builds
- Manual Build:
dotnet build src/gregCore.csproj -c Release - Hooks Generation:
pwsh scripts/Generate-GregHooksFromIl2CppDump.ps1 - Workshop Deployment:
pwsh scripts/Deploy-Release-ToWorkshop.ps1
When CI=true is set, the project uses stub DLLs from ci-stubs/ instead of actual MelonLoader references.
3. Architecture & Layers
The framework is strictly layered (as detailed in modding_core_architecture_summary.md):
- Unity Game Layer: Game types/methods patched via Harmony (
src/GameLayer/Patches/). - Core Layer (gregCore):
src/GameLayer/Bootstrap/gregCoreLoader.cs(MelonMod entry point)- FFI Bridge (
Win32FfiBridge.cs) and API Table (GameApiTable.cs) - Event Dispatching (
GregEventBus,NativeEventHooks.cs)
- Plugin Layer: Plugin registry and dependency resolver (
src/Infrastructure/Plugins/). - Language Bridges: Hosts for script isolation (
src/Infrastructure/Scripting/Lua,Js). - Mod Layer: User-created mods (C#, native DLLs, or scripts).
Event / Hooking Pipeline
HarmonyPatchesintercept Unity methods (Prefix/Postfix).- Data is extracted into primitive/struct DTOs.
- Dispatched via
GregEventBususing canonical hook names:greg.<Domain>.<Event>. - Mappings are defined in
assets/greg_hooks.jsonandNativeEventHooks.cs.
4. Conventions and Rules
- Language: Respond in technical German when summarizing intent before code changes, unless a file or repository policy explicitly requires English.
- ABI & FFI Boundaries:
- Struct order/types are ABI-critical. Always use
[StructLayout(LayoutKind.Sequential)]. - Pass stable primitive types (
int,uint,float,byte[],IntPtr) across the bridge. - No implicit Unity/IL2CPP object references in public Bridge DTOs.
- Struct order/types are ABI-critical. Always use
- Error Handling: Every boundary (FFI, JSON parse, network) must be wrapped in
try/catch+ logging. Failure in a mod must remain isolated and not crash the core loop. MISSING.mdRule: If a required API abstraction is missing during extension work, you MUST create aMISSING.mdfile in the relevant module folder. It must include a.gitignoreheader (!MISSING.md). (Seedocs/MODDING_MelonLoader_gregCore.mdfor the template).- Wiki Currency Check: At the end of every change request, you MUST verify whether relevant wiki pages in
docs/are up to date and list them if updates are required.
5. Directory Structure
src/Core/: Core interfaces, exceptions, and models.src/GameLayer/: Harmony patches and bootstrap/entry point logic.src/PublicApi/: Public SDK used by C# mods (Attributes, Mod base classes).src/Infrastructure/: Implementations for Networking (MCP, Sync), FFI, UI, Config, Scripting (MoonSharp Lua, JS), Automation, and Performance Governors.scripts/: PowerShell automation for builds, packaging, and hook generation.assets/: Containsgreg_hooks.json.docs/: Extensive project documentation (Tutorials, Hooks Catalog, Architecture).lib/: Third-party dependencies and references (e.g., MoonSharp, MelonLoader stubs).