From c575046a61620434e7ee01679ce86bf0beb0f700 Mon Sep 17 00:00:00 2001 From: copygirl Date: Sat, 13 May 2023 20:59:54 +0200 Subject: [PATCH] Minimal world init, remove args constructor --- src/gaemstone.ECS/World+Bare.cs | 13 ++++--------- src/gaemstone.ECS/World.cs | 7 +++++-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/gaemstone.ECS/World+Bare.cs b/src/gaemstone.ECS/World+Bare.cs index c1eb0ca..50addc8 100644 --- a/src/gaemstone.ECS/World+Bare.cs +++ b/src/gaemstone.ECS/World+Bare.cs @@ -17,7 +17,9 @@ public unsafe struct World public World(ecs_world_t* handle) => Handle = handle; - public World(params string[] args) + /// Initializes a new Flecs world. + /// If true, doesn't automatically import built-in modules. + public World(bool minimal = false) { [UnmanagedCallersOnly] static void Abort() => throw new FlecsAbortException(); @@ -27,14 +29,7 @@ public unsafe struct World api.abort_ = new FnPtr_Void { Pointer = &Abort }; ecs_os_set_api(&api); - if (args?.Length > 0) { - var ptr = Runtime.CStrings.CStringArray(args); - Handle = ecs_init_w_args(args.Length, ptr); - for (var i = 0; i < args.Length; i++) - Marshal.FreeHGlobal(ptr[i]); - } else { - Handle = ecs_init(); - } + Handle = minimal ? ecs_mini() : ecs_init(); } public bool Progress(TimeSpan delta) diff --git a/src/gaemstone.ECS/World.cs b/src/gaemstone.ECS/World.cs index 9689a2b..3cdc8b1 100644 --- a/src/gaemstone.ECS/World.cs +++ b/src/gaemstone.ECS/World.cs @@ -15,8 +15,11 @@ public unsafe struct World public World(World value) => Value = value; - public World(params string[] args) - : this(new World(args)) { } + + /// Initializes a new Flecs world. + /// If true, doesn't automatically import built-in modules. + public World(bool minimal = false) + : this(new World(minimal)) { } public bool Progress(TimeSpan delta) => Value.Progress(delta); public void Quit() => Value.Quit();