mirror of
https://github.com/Heretek-AI/game-engine.git
synced 2026-11-07 10:55:58 -10:00
3.9 KiB
3.9 KiB
Milestone 2: The Illusion Compiler (Roslyn Source Generators & 100ms Hot-Reload)
- Timeline: Months 3–4
- Verification Gate: Edit a C# gameplay script (
IComponent), pressCtrl+S, and observe100,000active entities update their behavior in< 100\text{ ms}without losing world state or pausing the engine.
GitHub Issues Breakdown
Issue M2-01: Ergonomic IComponent, Entity, and Phase Attributes API
- Labels:
area:roslyn-illusion - Description: Design the user-facing C# scripting surface in
Engine.Runtimeso developers write intuitive per-entity methods without touching pointers or ECS queries. - Acceptance Criteria:
- Define
public interface IComponent,readonly record struct Entity(ulong Id), and[UpdateInPhase(Phase)]attributes. - Provide blittable collection & string types (
FixedString64,TempList<T>backed by the nativeLinearFrameAllocator,AssetRef<T>). - Expose SIMD-accelerated math types (
float3,float4,quaternion,float4x4) mapped directly toSystem.Numerics/System.Runtime.Intrinsics.
- Define
Issue M2-02: Roslyn IIncrementalGenerator (IComponent to Native Chunk Job)
- Labels:
area:roslyn-illusion,priority:critical - Description: Build the Roslyn Source Generator in
Engine.Analyzersthat intercepts anypartial struct : IComponentwith aTick(...)method and compiles it into a zero-copy native chunk runner. - Acceptance Criteria:
- Parse
ref(read-write) andin(read-only) component parameters on userTick()methods. - Emit auto-registration code that registers the struct size, alignment (
sizeof(T)), and component dependencies with Flecs viaNativeApi.EcsRegisterComponentandNativeApi.EcsRegisterSystem. - Emit an
[UnmanagedCallersOnly]static method that unpacksEcsChunkView*intoSpan<T>/ReadOnlySpan<T>slices and executes a tight, bounds-check-eliminated loop.
- Parse
Issue M2-03: Compile-Time Performance & Memory Safety Roslyn Analyzers
- Labels:
area:roslyn-illusion - Description: Prevent GC spikes and memory corruption at compile time by flagging illegal C# patterns inside hot ECS systems as the user types in their IDE.
- Acceptance Criteria:
ENG0001(Heap Allocation in Hot Path): Flagnewclass allocations, string interpolations, LINQ queries, and lambda closures inside[UpdateInPhase]methods. Provide a Roslyn CodeFix to replacenew List<T>()withTempList<T>.ENG0002(Non-Blittable Component Field): Forbid managed reference types (string,class,interface, arrays) inside any struct implementingIComponent.ENG0003(Blocking Async/Wait): Forbid.Wait(),.Result, orThread.Sleep()on engine threads.
Issue M2-04: Stateless Collectible AssemblyLoadContext 100ms Hot-Reload
- Labels:
area:abi-bridge,area:roslyn-illusion,priority:critical - Description: Implement indestructible live code reloading by isolating user gameplay scripts inside a collectible
AssemblyLoadContextwhile keeping 100% of component data in native C++ Flecs memory. - Acceptance Criteria:
- Implement
ScriptHostManagerinEngine.RuntimeloadingGameScripts.dllfrom an in-memory stream (preventing OS file locks on.dll/.pdbfiles). - At the frame sync barrier, unbind old
ManagedSystemCallbackpointers in Flecs, unload the oldAssemblyLoadContext, load the newly compiled assembly, and re-bind the updated[UnmanagedCallersOnly]callbacks. - Support schema evolution: if a user adds or removes a field on an
IComponentstruct during hot-reload, automatically invoke Flecs component table migration so existing entity values remain intact. - Wrap managed system invocations in a native/managed fault barrier: if a user script throws an exception, log the stack trace, disable that system, and keep the engine/editor running without crashing.
- Implement