diff --git a/src/Flecs.NET.Codegen/Generators/Observer.cs b/src/Flecs.NET.Codegen/Generators/Observer.cs index 0438f3cf..553212c3 100644 --- a/src/Flecs.NET.Codegen/Generators/Observer.cs +++ b/src/Flecs.NET.Codegen/Generators/Observer.cs @@ -19,6 +19,7 @@ public override void Generate() private static string GenerateObserver(int i) { + string typeName = Generator.GetTypeName(Type.Observer, i); return $$""" #nullable enable @@ -31,7 +32,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 16 type arguments. /// /// {{Generator.XmlTypeParameters[i]}} - public unsafe partial struct {{Generator.GetTypeName(Type.Observer, i)}} : IEquatable<{{Generator.GetTypeName(Type.Observer, i)}}>, IDisposable + public unsafe partial struct {{typeName}} : IDisposable, IEquatable<{{typeName}}>, IEntity<{{typeName}}> { private Observer _observer; @@ -74,22 +75,46 @@ public void Dispose() _observer.Dispose(); } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) { - _observer.Ctx(ctx); + _observer.Ctx(ref value); } - - /// - public void* Ctx() + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) { - return _observer.Ctx(); + _observer.Ctx(ref value, callback); } - + + /// + public void Ctx(T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _observer.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + /// - public T* Ctx() where T : unmanaged + public ref T Ctx() { - return _observer.Ctx(); + return ref _observer.Ctx(); } /// @@ -99,43 +124,43 @@ public void Ctx(void* ctx) } /// - public static implicit operator ulong({{Generator.GetTypeName(Type.Observer, i)}} observer) + public static implicit operator ulong({{typeName}} observer) { return ToUInt64(observer); } /// - public static implicit operator Id({{Generator.GetTypeName(Type.Observer, i)}} observer) + public static implicit operator Id({{typeName}} observer) { return ToId(observer); } /// - public static implicit operator Entity({{Generator.GetTypeName(Type.Observer, i)}} observer) + public static implicit operator Entity({{typeName}} observer) { return ToEntity(observer); } /// - public static ulong ToUInt64({{Generator.GetTypeName(Type.Observer, i)}} observer) + public static ulong ToUInt64({{typeName}} observer) { return observer.Entity; } /// - public static Id ToId({{Generator.GetTypeName(Type.Observer, i)}} observer) + public static Id ToId({{typeName}} observer) { return observer.Id; } /// - public static Entity ToEntity({{Generator.GetTypeName(Type.Observer, i)}} observer) + public static Entity ToEntity({{typeName}} observer) { return observer.Entity; } /// - public bool Equals({{Generator.GetTypeName(Type.Observer, i)}} other) + public bool Equals({{typeName}} other) { return _observer == other._observer; } @@ -143,7 +168,7 @@ public bool Equals({{Generator.GetTypeName(Type.Observer, i)}} other) /// public override bool Equals(object? obj) { - return obj is {{Generator.GetTypeName(Type.Observer, i)}} other && Equals(other); + return obj is {{typeName}} other && Equals(other); } /// @@ -153,13 +178,13 @@ public override int GetHashCode() } /// - public static bool operator ==({{Generator.GetTypeName(Type.Observer, i)}} left, {{Generator.GetTypeName(Type.Observer, i)}} right) + public static bool operator ==({{typeName}} left, {{typeName}} right) { return left.Equals(right); } /// - public static bool operator !=({{Generator.GetTypeName(Type.Observer, i)}} left, {{Generator.GetTypeName(Type.Observer, i)}} right) + public static bool operator !=({{typeName}} left, {{typeName}} right) { return !(left == right); } diff --git a/src/Flecs.NET.Codegen/Generators/ObserverBuilder.cs b/src/Flecs.NET.Codegen/Generators/ObserverBuilder.cs index 3e9de08b..31ad9bc2 100644 --- a/src/Flecs.NET.Codegen/Generators/ObserverBuilder.cs +++ b/src/Flecs.NET.Codegen/Generators/ObserverBuilder.cs @@ -96,10 +96,45 @@ public void Dispose() return ref this; } - /// - public ref {{Generator.GetTypeName(Type.ObserverBuilder, i)}} Ctx(void* data) + /// + public ref {{Generator.GetTypeName(Type.ObserverBuilder, i)}} Ctx(T value) { - _observerBuilder.Ctx(data); + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref {{Generator.GetTypeName(Type.ObserverBuilder, i)}} Ctx(T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref {{Generator.GetTypeName(Type.ObserverBuilder, i)}} Ctx(T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref {{Generator.GetTypeName(Type.ObserverBuilder, i)}} Ctx(ref T value) + { + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref {{Generator.GetTypeName(Type.ObserverBuilder, i)}} Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref {{Generator.GetTypeName(Type.ObserverBuilder, i)}} Ctx(ref T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET.Codegen/Generators/SystemBuilder.cs b/src/Flecs.NET.Codegen/Generators/SystemBuilder.cs index ff0b25f5..8e35e7d0 100644 --- a/src/Flecs.NET.Codegen/Generators/SystemBuilder.cs +++ b/src/Flecs.NET.Codegen/Generators/SystemBuilder.cs @@ -145,10 +145,45 @@ public void Dispose() return ref this; } - /// - public ref {{Generator.GetTypeName(Type.SystemBuilder, i)}} Ctx(void* ctx) + /// + public ref {{Generator.GetTypeName(Type.SystemBuilder, i)}} Ctx(T value) { - _systemBuilder.Ctx(ctx); + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref {{Generator.GetTypeName(Type.SystemBuilder, i)}} Ctx(T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref {{Generator.GetTypeName(Type.SystemBuilder, i)}} Ctx(T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref {{Generator.GetTypeName(Type.SystemBuilder, i)}} Ctx(ref T value) + { + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref {{Generator.GetTypeName(Type.SystemBuilder, i)}} Ctx(ref T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref {{Generator.GetTypeName(Type.SystemBuilder, i)}} Ctx(ref T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET.Codegen/Generators/System_.cs b/src/Flecs.NET.Codegen/Generators/System_.cs index 517819d8..6ee16ce9 100644 --- a/src/Flecs.NET.Codegen/Generators/System_.cs +++ b/src/Flecs.NET.Codegen/Generators/System_.cs @@ -36,7 +36,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes {{i + 1}} type arguments. /// /// {{Generator.XmlTypeParameters[i]}} - public unsafe partial struct {{systemTypeName}} : IEquatable<{{systemTypeName}}>, IEntity<{{systemTypeName}}> + public unsafe partial struct {{systemTypeName}} : IDisposable, IEquatable<{{systemTypeName}}>, IEntity<{{systemTypeName}}> { private System_ _system; @@ -72,17 +72,53 @@ public System(Entity entity) {{Generator.GetTypeName(Type.TypeHelper, i)}}.AssertNoTags(); _system = new System_(entity); } + + /// + public void Dispose() + { + _system.Dispose(); + } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(T value, delegate* callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) { - _system.Ctx(ctx); + _system.Ctx(ref value, callback); } - /// - public void* Ctx() + /// + public ref T Ctx() { - return _system.Ctx(); + return ref _system.Ctx(); } /// diff --git a/src/Flecs.NET.Examples/Systems/SystemCtx.cs b/src/Flecs.NET.Examples/Systems/SystemCtx.cs index ce1e5b89..546b51d3 100644 --- a/src/Flecs.NET.Examples/Systems/SystemCtx.cs +++ b/src/Flecs.NET.Examples/Systems/SystemCtx.cs @@ -18,7 +18,7 @@ public static void Main() using Query qCollide = world.Query(); System system = world.System("Collide") - .Ctx(&qCollide) + .Ctx(qCollide) .Each((Iter it, int i, ref Position p, ref Radius r) => { ref Query q = ref it.Ctx>(); diff --git a/src/Flecs.NET.Tests/CSharp/Core/MiscTests.cs b/src/Flecs.NET.Tests/CSharp/Core/MiscTests.cs new file mode 100644 index 00000000..0cfa7b78 --- /dev/null +++ b/src/Flecs.NET.Tests/CSharp/Core/MiscTests.cs @@ -0,0 +1,27 @@ +using Flecs.NET.Core; +using Xunit; + +namespace Flecs.NET.Tests.CSharp.Core; + +public class MiscTests +{ + [Fact] + private void AppInit() + { + using World world = World.Create(); + + world.System() + .Each(static (Iter it, int _) => + { + Assert.Equal("TestString", it.World().Get()); + }); + + world.App() + .Init(static (World world) => + { + world.Set("TestString"); + }) + .Frames(1) + .Run(); + } +} diff --git a/src/Flecs.NET.Tests/CSharp/Core/ObserverTests.cs b/src/Flecs.NET.Tests/CSharp/Core/ObserverTests.cs index c6244edb..d488f7f1 100644 --- a/src/Flecs.NET.Tests/CSharp/Core/ObserverTests.cs +++ b/src/Flecs.NET.Tests/CSharp/Core/ObserverTests.cs @@ -2667,4 +2667,46 @@ static void Callback(Iter it, int i, Position* p, Velocity* v) p->Y += v->Y; } } + + [Fact] + private void Ctx() + { + using World world = World.Create(); + + Observer observer = world.Observer() + .Event(Ecs.OnAdd) + .With() + .Ctx(new UnmanagedStruct(10)) + .Each(static (Iter it, int _) => + { + it.Ctx().Value = 20; + }); + + Assert.Equal(10, observer.Ctx().Value); + world.Entity().Add(); + Assert.Equal(20, observer.Ctx().Value); + } + + [Fact] + private void CtxWithCallback() + { + using World world = World.Create(); + + Observer observer = world.Observer() + .Event(Ecs.OnAdd) + .With() + .Ctx(new UnmanagedStruct(10),static (ref UnmanagedStruct ctx) => + { + Assert.Equal(30, ctx.Value); + }) + .Each(static (Iter it, int _) => + { + it.Ctx().Value = 20; + }); + + Assert.Equal(10, observer.Ctx().Value); + world.Entity().Add(); + Assert.Equal(20, observer.Ctx().Value); + observer.Ctx().Value = 30; + } } diff --git a/src/Flecs.NET.Tests/CSharp/Core/SystemTests.cs b/src/Flecs.NET.Tests/CSharp/Core/SystemTests.cs index 6a443019..6192fe3c 100644 --- a/src/Flecs.NET.Tests/CSharp/Core/SystemTests.cs +++ b/src/Flecs.NET.Tests/CSharp/Core/SystemTests.cs @@ -2593,4 +2593,42 @@ static void Callback(Iter it, int i, Position* p, Velocity* v) p->Y += v->Y; } } + + [Fact] + private void Ctx() + { + using World world = World.Create(); + + System_ system = world.System() + .Ctx(new UnmanagedStruct(10)) + .Each(static (Iter it, int _) => + { + it.Ctx().Value = 20; + }); + + Assert.Equal(10, system.Ctx().Value); + system.Run(); + Assert.Equal(20, system.Ctx().Value); + } + + [Fact] + private void CtxWithCallback() + { + using World world = World.Create(); + + System_ system = world.System() + .Ctx(new UnmanagedStruct(10), static (ref UnmanagedStruct ctx) => + { + Assert.Equal(30, ctx.Value); + }) + .Each(static (Iter it, int _) => + { + it.Ctx().Value = 20; + }); + + Assert.Equal(10, system.Ctx().Value); + system.Run(); + Assert.Equal(20, system.Ctx().Value); + system.Ctx().Value = 30; + } } diff --git a/src/Flecs.NET.Tests/Helpers.cs b/src/Flecs.NET.Tests/Helpers.cs index a2186011..fb08ee21 100644 --- a/src/Flecs.NET.Tests/Helpers.cs +++ b/src/Flecs.NET.Tests/Helpers.cs @@ -51,6 +51,8 @@ public record struct SharedComponent(int Value); public record struct SparseComponent(int Value); +public record struct UnmanagedStruct(int Value); + public record struct ManagedStruct(int Value) { public object Dummy = null!; diff --git a/src/Flecs.NET/Core/AppBuilder.cs b/src/Flecs.NET/Core/AppBuilder.cs index 977c96de..71fb4ed5 100644 --- a/src/Flecs.NET/Core/AppBuilder.cs +++ b/src/Flecs.NET/Core/AppBuilder.cs @@ -1,5 +1,5 @@ using System; -using System.Runtime.InteropServices; +using Flecs.NET.Core.BindingContext; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -10,14 +10,13 @@ namespace Flecs.NET.Core; /// public unsafe struct AppBuilder : IDisposable, IEquatable { - private ecs_world_t* _world; + private World _world; private ecs_app_desc_t _desc; - private GCHandle _initHandle; /// /// Reference to world. /// - public ref ecs_world_t* World => ref _world; + public ref World World => ref _world; /// /// Reference to app description. @@ -28,11 +27,10 @@ public unsafe struct AppBuilder : IDisposable, IEquatable /// Creates an app builder for world. /// /// - public AppBuilder(ecs_world_t* world) + public AppBuilder(World world) { _world = world; _desc = default; - _initHandle = default; ecs_world_info_t* stats = ecs_get_world_info(world); Desc.target_fps = stats->target_fps; @@ -46,8 +44,7 @@ public AppBuilder(ecs_world_t* world) /// public void Dispose() { - Managed.FreeGcHandle(_initHandle); - _initHandle = default; + this = default; } /// @@ -120,25 +117,24 @@ public ref AppBuilder EnableStats(bool value = true) /// /// Sets a callback to be run before starting the main loop. /// - /// + /// The callback. /// - public ref AppBuilder Init(Ecs.AppInitAction value) + public ref AppBuilder Init(Ecs.AppInitCallback callback) { - Managed.FreeGcHandle(_initHandle); - _initHandle = GCHandle.Alloc(value); - - Desc.init = Marshal.GetFunctionPointerForDelegate(value); + World.WorldContext.AppInit.Set(callback, Pointers.AppInitCallbackDelegate); + Desc.init = Pointers.AppInitCallback; return ref this; } /// - /// Context for storing custom data. + /// Sets a callback to be run before starting the main loop. /// - /// + /// The callback. /// - public ref AppBuilder Ctx(void* value) + public ref AppBuilder Init(delegate* callback) { - Desc.ctx = value; + World.WorldContext.AppInit.Set((int)callback, Pointers.AppInitCallbackPointer); + Desc.init = Pointers.AppInitCallback; return ref this; } diff --git a/src/Flecs.NET/Core/BindingContext/SystemContext.cs b/src/Flecs.NET/Core/BindingContext/AppContext.cs similarity index 51% rename from src/Flecs.NET/Core/BindingContext/SystemContext.cs rename to src/Flecs.NET/Core/BindingContext/AppContext.cs index 89be70df..53f825d2 100644 --- a/src/Flecs.NET/Core/BindingContext/SystemContext.cs +++ b/src/Flecs.NET/Core/BindingContext/AppContext.cs @@ -3,16 +3,16 @@ namespace Flecs.NET.Core.BindingContext; -internal unsafe struct SystemContext : IDisposable +internal unsafe struct AppContext : IDisposable { - public UserContext UserContext; + public Callback Init; public void Dispose() { - UserContext.Dispose(); + Init.Dispose(); } - public static void Free(SystemContext* context) + public static void Free(AppContext* context) { if (context == null) return; @@ -20,9 +20,9 @@ public static void Free(SystemContext* context) Memory.Free(context); } - public static void Free(ref SystemContext context) + public static void Free(ref AppContext context) { - fixed (SystemContext* ptr = &context) + fixed (AppContext* ptr = &context) Free(ptr); } } diff --git a/src/Flecs.NET/Core/BindingContext/Functions.cs b/src/Flecs.NET/Core/BindingContext/Functions.cs index 0656a51d..0d420849 100644 --- a/src/Flecs.NET/Core/BindingContext/Functions.cs +++ b/src/Flecs.NET/Core/BindingContext/Functions.cs @@ -45,21 +45,15 @@ internal static void GroupByContextFree(GroupByContext* context) } [UnmanagedCallersOnly] - internal static void SystemContextFree(SystemContext* context) + internal static void TypeHooksContextFree(TypeHooksContext* context) { - SystemContext.Free(context); + TypeHooksContext.Free(context); } [UnmanagedCallersOnly] - internal static void ObserverContextFree(ObserverContext* context) + internal static void UserContextFree(UserContext* context) { - ObserverContext.Free(context); - } - - [UnmanagedCallersOnly] - internal static void TypeHooksContextFree(TypeHooksContext* context) - { - TypeHooksContext.Free(context); + UserContext.Free(context); } internal static void UserContextFinishDelegate(ref UserContext context) @@ -381,7 +375,7 @@ internal static void PostFrameCallbackPointer(ecs_world_t* world, void* ctx) #endregion - #region World Finish Callback + #region World Finish Callbacks [UnmanagedCallersOnly] internal static void WorldFinishCallback(ecs_world_t* world, void* ctx) @@ -404,6 +398,28 @@ internal static void WorldFinishCallbackPointer(ecs_world_t* world, void* ctx) #endregion + #region App Init Callbacks + + [UnmanagedCallersOnly] + internal static int AppInitCallback(ecs_world_t* world) + { + WorldContext* context = new World(world).GetBindingContext(); + ((delegate*)context->AppInit.Invoker)(world, context); + return 0; + } + + internal static void AppInitCallbackDelegate(World world, WorldContext* context) + { + ((Ecs.AppInitCallback)context->AppInit.Delegate.Target!)(world); + } + + internal static void AppInitCallbackPointer(World world, WorldContext* context) + { + ((delegate*)context->AppInit.Pointer)(world); + } + + #endregion + #region Os Api Callbacks [UnmanagedCallersOnly] diff --git a/src/Flecs.NET/Core/BindingContext/ObserverContext.cs b/src/Flecs.NET/Core/BindingContext/ObserverContext.cs deleted file mode 100644 index 7e4742d6..00000000 --- a/src/Flecs.NET/Core/BindingContext/ObserverContext.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using Flecs.NET.Utilities; - -namespace Flecs.NET.Core.BindingContext; - -internal unsafe struct ObserverContext : IDisposable -{ - public UserContext UserContext; - - public void Dispose() - { - UserContext.Dispose(); - } - - public static void Free(ObserverContext* context) - { - if (context == null) - return; - context->Dispose(); - Memory.Free(context); - } - - public static void Free(ref ObserverContext context) - { - fixed (ObserverContext* ptr = &context) - Free(ptr); - } -} diff --git a/src/Flecs.NET/Core/BindingContext/Pointers.cs b/src/Flecs.NET/Core/BindingContext/Pointers.cs index 85f692c7..f02ba74c 100644 --- a/src/Flecs.NET/Core/BindingContext/Pointers.cs +++ b/src/Flecs.NET/Core/BindingContext/Pointers.cs @@ -33,9 +33,8 @@ static Pointers() internal static readonly nint RunContextFree = (nint)(delegate* unmanaged)&Functions.RunContextFree; internal static readonly nint QueryContextFree = (nint)(delegate* unmanaged)&Functions.QueryContextFree; internal static readonly nint GroupByContextFree = (nint)(delegate* unmanaged)&Functions.GroupByContextFree; - internal static readonly nint SystemContextFree = (nint)(delegate* unmanaged)&Functions.SystemContextFree; - internal static readonly nint ObserverContextFree = (nint)(delegate* unmanaged)&Functions.ObserverContextFree; internal static readonly nint TypeHooksContextFree = (nint)(delegate* unmanaged)&Functions.TypeHooksContextFree; + internal static readonly nint UserContextFree = (nint)(delegate* unmanaged)&Functions.UserContextFree; #endregion @@ -103,6 +102,14 @@ static Pointers() #endregion + #region App Init Callbacks + + internal static readonly nint AppInitCallback = (nint)(delegate* unmanaged)&Functions.AppInitCallback; + internal static readonly nint AppInitCallbackDelegate = (nint)(delegate*)&Functions.AppInitCallbackDelegate; + internal static readonly nint AppInitCallbackPointer = (nint)(delegate*)&Functions.AppInitCallbackPointer; + + #endregion + #region Os Api Callbacks internal static readonly nint AbortCallback = (nint)(delegate* unmanaged)&Functions.AbortCallback; diff --git a/src/Flecs.NET/Core/BindingContext/UserContext.cs b/src/Flecs.NET/Core/BindingContext/UserContext.cs index 56ae14a5..736ea9d6 100644 --- a/src/Flecs.NET/Core/BindingContext/UserContext.cs +++ b/src/Flecs.NET/Core/BindingContext/UserContext.cs @@ -74,6 +74,20 @@ public void Set(T value, delegate* callback) return Alloc(ref value); } + public static void Free(UserContext* context) + { + if (context == null) + return; + context->Dispose(); + Memory.Free(context); + } + + public static void Free(ref UserContext context) + { + fixed (UserContext* ptr = &context) + Free(ptr); + } + public bool Equals(UserContext other) { return Object.Equals(other.Object); diff --git a/src/Flecs.NET/Core/BindingContext/WorldContext.cs b/src/Flecs.NET/Core/BindingContext/WorldContext.cs index 4c108cf8..71ac4375 100644 --- a/src/Flecs.NET/Core/BindingContext/WorldContext.cs +++ b/src/Flecs.NET/Core/BindingContext/WorldContext.cs @@ -9,6 +9,7 @@ internal unsafe struct WorldContext : IDisposable public UserContext UserContext; public Callback UserContextFree; + public Callback AppInit; public NativeList TypeCache; public NativeList RunPostFrameContexts; // Stores PostFrameContext* @@ -18,6 +19,7 @@ public void Dispose() { UserContext.Dispose(); UserContextFree.Dispose(); + AppInit.Dispose(); TypeCache.Dispose(); foreach (nint ptr in RunPostFrameContexts) diff --git a/src/Flecs.NET/Core/Ecs/Delegates.cs b/src/Flecs.NET/Core/Ecs/Delegates.cs index 02bba31b..ed0445d8 100644 --- a/src/Flecs.NET/Core/Ecs/Delegates.cs +++ b/src/Flecs.NET/Core/Ecs/Delegates.cs @@ -6,9 +6,9 @@ namespace Flecs.NET.Core; public static unsafe partial class Ecs { /// - /// App init action. + /// App init callback. /// - public delegate int AppInitAction(ecs_world_t* world); + public delegate void AppInitCallback(World world); /// /// Callback to be run before a user context object is released by flecs. diff --git a/src/Flecs.NET/Core/Iter.cs b/src/Flecs.NET/Core/Iter.cs index f444b73d..d3ff898c 100644 --- a/src/Flecs.NET/Core/Iter.cs +++ b/src/Flecs.NET/Core/Iter.cs @@ -4,6 +4,7 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.CompilerServices; +using Flecs.NET.Core.BindingContext; using Flecs.NET.Utilities; using static Flecs.NET.Bindings.flecs; @@ -164,9 +165,10 @@ public Table Range() /// /// /// - public ref T Ctx() where T : unmanaged + public ref T Ctx() { - return ref *CtxPtr(); + UserContext* context = (UserContext*)Handle->ctx; + return ref context->Get(); } /// diff --git a/src/Flecs.NET/Core/Observer.cs b/src/Flecs.NET/Core/Observer.cs index c626fa7f..c5cd91d7 100644 --- a/src/Flecs.NET/Core/Observer.cs +++ b/src/Flecs.NET/Core/Observer.cs @@ -1,4 +1,5 @@ using System; +using Flecs.NET.Core.BindingContext; using static Flecs.NET.Bindings.flecs; namespace Flecs.NET.Core; @@ -49,38 +50,103 @@ public Observer(Entity entity) /// public void Dispose() { - Destruct(); + Entity.Destruct(); } /// - /// Sets the observer context. + /// Sets the observer user context object. /// - /// - public void Ctx(void* ctx) + /// The user context object. + /// The user context type. + /// + public void Ctx(T value) + { + new ObserverBuilder(World, Entity) + .Ctx(ref value) + .Build(); + } + + /// + /// Sets the observer user context object. The provided callback will be run before the + /// user context object is released by flecs. + /// + /// The user context object. + /// The callback. + /// The user context type. + /// + public void Ctx(T value, Ecs.UserContextFinish callback) + { + new ObserverBuilder(World, Entity) + .Ctx(ref value, callback) + .Build(); + } + + /// + /// Sets the observer user context object. The provided callback will be run before the + /// user context object is released by flecs. + /// + /// The user context object. + /// The callback. + /// The user context type. + /// + public void Ctx(T value, delegate* callback) + { + new ObserverBuilder(World, Entity) + .Ctx(ref value, callback) + .Build(); + } + + /// + /// Sets the observer user context object. + /// + /// The user context object. + /// The user context type. + /// + public void Ctx(ref T value) + { + new ObserverBuilder(World, Entity) + .Ctx(ref value) + .Build(); + } + + /// + /// Sets the observer user context object. The provided callback will be run before the + /// user context object is released by flecs. + /// + /// The user context object. + /// The callback. + /// The user context type. + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) { - ecs_observer_desc_t desc = default; - desc.entity = Entity; - desc.ctx = ctx; - ecs_observer_init(World, &desc); + new ObserverBuilder(World, Entity) + .Ctx(ref value, callback) + .Build(); } /// - /// Gets the observer context. + /// Sets the observer user context object. The provided callback will be run before the + /// user context object is released by flecs. /// + /// The user context object. + /// The callback. + /// The user context type. /// - public void* Ctx() + public void Ctx(ref T value, delegate* callback) { - return ecs_observer_get(World, Entity)->ctx; + new ObserverBuilder(World, Entity) + .Ctx(ref value, callback) + .Build(); } /// - /// Gets the observer context. + /// Returns the context for the system. /// - /// /// - public T* Ctx() where T : unmanaged + public ref T Ctx() { - return (T*)Ctx(); + UserContext* context = (UserContext*)ecs_observer_get(World, Entity)->ctx; + return ref context->Get(); } /// diff --git a/src/Flecs.NET/Core/ObserverBuilder.cs b/src/Flecs.NET/Core/ObserverBuilder.cs index 27e962f7..59d12bce 100644 --- a/src/Flecs.NET/Core/ObserverBuilder.cs +++ b/src/Flecs.NET/Core/ObserverBuilder.cs @@ -15,6 +15,10 @@ public unsafe partial struct ObserverBuilder : IDisposable, IEquatable ref *EnsureUserContext(); + internal ref IteratorContext IteratorContext => ref *EnsureIteratorContext(); + internal ref RunContext RunContext => ref *EnsureRunContext(); + /// /// A reference to the world. /// @@ -30,10 +34,6 @@ public unsafe partial struct ObserverBuilder : IDisposable, IEquatable public ref QueryBuilder QueryBuilder => ref _queryBuilder; - internal ref ObserverContext ObserverContext => ref *EnsureObserverContext(); - internal ref IteratorContext IteratorContext => ref *EnsureIteratorContext(); - internal ref RunContext RunContext => ref *EnsureRunContext(); - /// /// Creates an observer builder for the provided world. /// @@ -63,6 +63,19 @@ public ObserverBuilder(ecs_world_t* world, string name) : this(world) Desc.entity = ecs_entity_init(world, &entityDesc); } + /// + /// Creates an observer builder for the provided world. + /// + /// The world. + /// The observer entity. + public ObserverBuilder(ecs_world_t* world, ulong entity) : this(world) + { + ecs_entity_desc_t entityDesc = default; + entityDesc.id = entity; + + Desc.entity = ecs_entity_init(world, &entityDesc); + } + /// /// Disposes the observer builder. This should be called if the observer builder /// will be discarded and .Iter()/.Each()/.Run() isn't called. @@ -70,7 +83,7 @@ public ObserverBuilder(ecs_world_t* world, string name) : this(world) public void Dispose() { QueryBuilder.Dispose(); - ObserverContext.Free(ref ObserverContext); + UserContext.Free(ref UserContext); IteratorContext.Free(ref IteratorContext); RunContext.Free(ref RunContext); this = default; @@ -123,13 +136,82 @@ public ref ObserverBuilder ObserverFlags(uint flags) } /// - /// Set observer context. + /// Sets the observer user context object. + /// + /// The user context object. + /// The user context type. + /// + public ref ObserverBuilder Ctx(T value) + { + UserContext.Set(ref value); + return ref this; + } + + /// + /// Sets the observer user context object. The provided callback will be run before the + /// user context object is released by flecs. /// - /// + /// The user context object. + /// The callback. + /// The user context type. + /// + public ref ObserverBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + UserContext.Set(ref value, callback); + return ref this; + } + + /// + /// Sets the observer user context object. The provided callback will be run before the + /// user context object is released by flecs. + /// + /// The user context object. + /// The callback. + /// The user context type. + /// + public ref ObserverBuilder Ctx(T value, delegate* callback) + { + UserContext.Set(ref value, callback); + return ref this; + } + + /// + /// Sets the observer user context object. + /// + /// The user context object. + /// The user context type. + /// + public ref ObserverBuilder Ctx(ref T value) + { + UserContext.Set(ref value); + return ref this; + } + + /// + /// Sets the observer user context object. The provided callback will be run before the + /// user context object is released by flecs. + /// + /// The user context object. + /// The callback. + /// The user context type. + /// + public ref ObserverBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + UserContext.Set(ref value, callback); + return ref this; + } + + /// + /// Sets the observer user context object. The provided callback will be run before the + /// user context object is released by flecs. + /// + /// The user context object. + /// The callback. + /// The user context type. /// - public ref ObserverBuilder Ctx(void* data) + public ref ObserverBuilder Ctx(ref T value, delegate* callback) { - Desc.ctx = data; + UserContext.Set(ref value, callback); return ref this; } @@ -354,14 +436,14 @@ Observer IQueryBuilder.Build() return Build(); } - private ObserverContext* EnsureObserverContext() + private UserContext* EnsureUserContext() { if (Desc.ctx != null) - return (ObserverContext*)Desc.ctx; + return (UserContext*)Desc.ctx; - Desc.ctx = Memory.AllocZeroed(1); - Desc.ctx_free = Pointers.ObserverContextFree; - return (ObserverContext*)Desc.ctx; + Desc.ctx = Memory.AllocZeroed(1); + Desc.ctx_free = Pointers.UserContextFree; + return (UserContext*)Desc.ctx; } private IteratorContext* EnsureIteratorContext() diff --git a/src/Flecs.NET/Core/SystemBuilder.cs b/src/Flecs.NET/Core/SystemBuilder.cs index 21f44c1c..99b3ce9f 100644 --- a/src/Flecs.NET/Core/SystemBuilder.cs +++ b/src/Flecs.NET/Core/SystemBuilder.cs @@ -14,6 +14,10 @@ public unsafe partial struct SystemBuilder : IDisposable, IEquatable ref *EnsureUserContext(); + internal ref IteratorContext IteratorContext => ref *EnsureIteratorContext(); + internal ref RunContext RunContext => ref *EnsureRunContext(); + /// /// A reference to the world. /// @@ -29,10 +33,6 @@ public unsafe partial struct SystemBuilder : IDisposable, IEquatable public ref QueryBuilder QueryBuilder => ref _queryBuilder; - internal ref SystemContext SystemContext => ref *EnsureSystemContext(); - internal ref IteratorContext IteratorContext => ref *EnsureIteratorContext(); - internal ref RunContext RunContext => ref *EnsureRunContext(); - /// /// Creates a system builder for the provided world. /// @@ -68,6 +68,33 @@ public SystemBuilder(ecs_world_t* world, string name) entityDesc.root_sep = Pointers.DefaultSeparator; Desc.entity = ecs_entity_init(world, &entityDesc); + + if (ecs_has_id(world, Desc.entity, Ecs.Pair(EcsDependsOn, EcsWildcard)) == Utils.True) + return; + + ecs_add_id(world, Desc.entity, Ecs.Pair(EcsDependsOn, EcsOnUpdate)); + ecs_add_id(world, Desc.entity, EcsOnUpdate); + } + + /// + /// Creates a system builder for the provided world. + /// + /// The world. + /// The system entity. + public SystemBuilder(ecs_world_t* world, ulong entity) + { + _world = world; + _desc = default; + _queryBuilder = new QueryBuilder(world); + + ecs_entity_desc_t entityDesc = default; + entityDesc.id = entity; + + Desc.entity = ecs_entity_init(world, &entityDesc); + + if (ecs_has_id(world, Desc.entity, Ecs.Pair(EcsDependsOn, EcsWildcard)) == Utils.True) + return; + ecs_add_id(world, Desc.entity, Ecs.Pair(EcsDependsOn, EcsOnUpdate)); ecs_add_id(world, Desc.entity, EcsOnUpdate); } @@ -79,7 +106,7 @@ public SystemBuilder(ecs_world_t* world, string name) public void Dispose() { QueryBuilder.Dispose(); - SystemContext.Free(ref SystemContext); + UserContext.Free(ref UserContext); IteratorContext.Free(ref IteratorContext); RunContext.Free(ref RunContext); this = default; @@ -210,13 +237,82 @@ public ref SystemBuilder TickSource() } /// - /// Set system context. + /// Sets the system user context object. + /// + /// The user context object. + /// The user context type. + /// + public ref SystemBuilder Ctx(T value) + { + UserContext.Set(ref value); + return ref this; + } + + /// + /// Sets the system user context object. The provided callback will be run before the + /// user context object is released by flecs. /// - /// + /// The user context object. + /// The callback. + /// The user context type. + /// + public ref SystemBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + UserContext.Set(ref value, callback); + return ref this; + } + + /// + /// Sets the system user context object. The provided callback will be run before the + /// user context object is released by flecs. + /// + /// The user context object. + /// The callback. + /// The user context type. + /// + public ref SystemBuilder Ctx(T value, delegate* callback) + { + UserContext.Set(ref value, callback); + return ref this; + } + + /// + /// Sets the system user context object. + /// + /// The user context object. + /// The user context type. + /// + public ref SystemBuilder Ctx(ref T value) + { + UserContext.Set(ref value); + return ref this; + } + + /// + /// Sets the system user context object. The provided callback will be run before the + /// user context object is released by flecs. + /// + /// The user context object. + /// The callback. + /// The user context type. + /// + public ref SystemBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + UserContext.Set(ref value, callback); + return ref this; + } + + /// + /// Sets the system user context object. The provided callback will be run before the + /// user context object is released by flecs. + /// + /// The user context object. + /// The callback. + /// The user context type. /// - public ref SystemBuilder Ctx(void* ctx) + public ref SystemBuilder Ctx(ref T value, delegate* callback) { - Desc.ctx = ctx; + UserContext.Set(ref value, callback); return ref this; } @@ -437,14 +533,14 @@ System_ IQueryBuilder.Build() return Build(); } - private SystemContext* EnsureSystemContext() + private UserContext* EnsureUserContext() { if (Desc.ctx != null) - return (SystemContext*)Desc.ctx; + return (UserContext*)Desc.ctx; - Desc.ctx = Memory.AllocZeroed(1); - Desc.ctx_free = Pointers.SystemContextFree; - return (SystemContext*)Desc.ctx; + Desc.ctx = Memory.AllocZeroed(1); + Desc.ctx_free = Pointers.UserContextFree; + return (UserContext*)Desc.ctx; } private IteratorContext* EnsureIteratorContext() diff --git a/src/Flecs.NET/Core/System_.cs b/src/Flecs.NET/Core/System_.cs index eca72840..16242170 100644 --- a/src/Flecs.NET/Core/System_.cs +++ b/src/Flecs.NET/Core/System_.cs @@ -1,5 +1,6 @@ using System; using System.Diagnostics.CodeAnalysis; +using Flecs.NET.Core.BindingContext; using static Flecs.NET.Bindings.flecs; namespace Flecs.NET.Core; @@ -9,7 +10,7 @@ namespace Flecs.NET.Core; /// [SuppressMessage("ReSharper", "InconsistentNaming")] [SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores")] -public unsafe partial struct System_ : IEquatable +public unsafe partial struct System_ : IDisposable, IEquatable, IEntity { private Entity _entity; @@ -48,24 +49,107 @@ public System_(Entity entity) } /// - /// Sets the context for the system. + /// Disposes this system. /// - /// - public void Ctx(void* ctx) + public void Dispose() { - ecs_system_desc_t desc = default; - desc.entity = Entity; - desc.ctx = ctx; - ecs_system_init(World, &desc); + Entity.Destruct(); + } + + /// + /// Sets the system user context object. + /// + /// The user context object. + /// The user context type. + /// + public void Ctx(T value) + { + new SystemBuilder(World, Entity) + .Ctx(ref value) + .Build(); + } + + /// + /// Sets the system user context object. The provided callback will be run before the + /// user context object is released by flecs. + /// + /// The user context object. + /// The callback. + /// The user context type. + /// + public void Ctx(T value, Ecs.UserContextFinish callback) + { + new SystemBuilder(World, Entity) + .Ctx(ref value, callback) + .Build(); + } + + /// + /// Sets the system user context object. The provided callback will be run before the + /// user context object is released by flecs. + /// + /// The user context object. + /// The callback. + /// The user context type. + /// + public void Ctx(T value, delegate* callback) + { + new SystemBuilder(World, Entity) + .Ctx(ref value, callback) + .Build(); + } + + /// + /// Sets the system user context object. + /// + /// The user context object. + /// The user context type. + /// + public void Ctx(ref T value) + { + new SystemBuilder(World, Entity) + .Ctx(ref value) + .Build(); + } + + /// + /// Sets the system user context object. The provided callback will be run before the + /// user context object is released by flecs. + /// + /// The user context object. + /// The callback. + /// The user context type. + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + new SystemBuilder(World, Entity) + .Ctx(ref value, callback) + .Build(); + } + + /// + /// Sets the system user context object. The provided callback will be run before the + /// user context object is released by flecs. + /// + /// The user context object. + /// The callback. + /// The user context type. + /// + public void Ctx(ref T value, delegate* callback) + { + new SystemBuilder(World, Entity) + .Ctx(ref value, callback) + .Build(); } /// /// Returns the context for the system. /// /// - public void* Ctx() + public ref T Ctx() { - return ecs_system_get(World, Entity)->ctx; + UserContext* context = (UserContext*)ecs_system_get(World, Entity)->ctx; + return ref context->Get(); } /// diff --git a/src/Flecs.NET/Core/World.cs b/src/Flecs.NET/Core/World.cs index 6530276a..1dd7c16e 100644 --- a/src/Flecs.NET/Core/World.cs +++ b/src/Flecs.NET/Core/World.cs @@ -14,7 +14,7 @@ public unsafe partial struct World : IDisposable, IEquatable { private ecs_world_t* _handle; - private ref WorldContext WorldContext => ref *EnsureBindingContext(); + internal ref WorldContext WorldContext => ref *EnsureBindingContext(); /// /// The handle to the C world. @@ -3859,6 +3859,11 @@ public void InitBuiltinComponents() Import(); } + internal WorldContext* GetBindingContext() + { + return (WorldContext*)ecs_get_binding_ctx_fast(Handle); + } + private WorldContext* EnsureBindingContext() { WorldContext* ptr = (WorldContext*)ecs_get_binding_ctx_fast(Handle); diff --git a/src/Flecs.NET/Generated/Observer/Observer/T1.g.cs b/src/Flecs.NET/Generated/Observer/Observer/T1.g.cs index aea1da02..5711f73b 100644 --- a/src/Flecs.NET/Generated/Observer/Observer/T1.g.cs +++ b/src/Flecs.NET/Generated/Observer/Observer/T1.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 16 type arguments. /// /// The T0 component type. -public unsafe partial struct Observer : IEquatable>, IDisposable +public unsafe partial struct Observer : IDisposable, IEquatable>, IEntity> { private Observer _observer; @@ -54,22 +54,46 @@ public void Dispose() _observer.Dispose(); } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) { - _observer.Ctx(ctx); + _observer.Ctx(ref value); } - - /// - public void* Ctx() + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) { - return _observer.Ctx(); + _observer.Ctx(ref value, callback); } - + + /// + public void Ctx(T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _observer.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + /// - public T* Ctx() where T : unmanaged + public ref T Ctx() { - return _observer.Ctx(); + return ref _observer.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/Observer/Observer/T10.g.cs b/src/Flecs.NET/Generated/Observer/Observer/T10.g.cs index 39dc59ba..6e6cc778 100644 --- a/src/Flecs.NET/Generated/Observer/Observer/T10.g.cs +++ b/src/Flecs.NET/Generated/Observer/Observer/T10.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 16 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. The T6 component type. The T7 component type. The T8 component type. The T9 component type. -public unsafe partial struct Observer : IEquatable>, IDisposable +public unsafe partial struct Observer : IDisposable, IEquatable>, IEntity> { private Observer _observer; @@ -54,22 +54,46 @@ public void Dispose() _observer.Dispose(); } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) { - _observer.Ctx(ctx); + _observer.Ctx(ref value); } - - /// - public void* Ctx() + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) { - return _observer.Ctx(); + _observer.Ctx(ref value, callback); } - + + /// + public void Ctx(T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _observer.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + /// - public T* Ctx() where T : unmanaged + public ref T Ctx() { - return _observer.Ctx(); + return ref _observer.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/Observer/Observer/T11.g.cs b/src/Flecs.NET/Generated/Observer/Observer/T11.g.cs index d5cc2bba..7dd01e43 100644 --- a/src/Flecs.NET/Generated/Observer/Observer/T11.g.cs +++ b/src/Flecs.NET/Generated/Observer/Observer/T11.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 16 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. The T6 component type. The T7 component type. The T8 component type. The T9 component type. The T10 component type. -public unsafe partial struct Observer : IEquatable>, IDisposable +public unsafe partial struct Observer : IDisposable, IEquatable>, IEntity> { private Observer _observer; @@ -54,22 +54,46 @@ public void Dispose() _observer.Dispose(); } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) { - _observer.Ctx(ctx); + _observer.Ctx(ref value); } - - /// - public void* Ctx() + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) { - return _observer.Ctx(); + _observer.Ctx(ref value, callback); } - + + /// + public void Ctx(T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _observer.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + /// - public T* Ctx() where T : unmanaged + public ref T Ctx() { - return _observer.Ctx(); + return ref _observer.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/Observer/Observer/T12.g.cs b/src/Flecs.NET/Generated/Observer/Observer/T12.g.cs index 4a063278..eaa931ad 100644 --- a/src/Flecs.NET/Generated/Observer/Observer/T12.g.cs +++ b/src/Flecs.NET/Generated/Observer/Observer/T12.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 16 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. The T6 component type. The T7 component type. The T8 component type. The T9 component type. The T10 component type. The T11 component type. -public unsafe partial struct Observer : IEquatable>, IDisposable +public unsafe partial struct Observer : IDisposable, IEquatable>, IEntity> { private Observer _observer; @@ -54,22 +54,46 @@ public void Dispose() _observer.Dispose(); } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) { - _observer.Ctx(ctx); + _observer.Ctx(ref value); } - - /// - public void* Ctx() + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) { - return _observer.Ctx(); + _observer.Ctx(ref value, callback); } - + + /// + public void Ctx(T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _observer.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + /// - public T* Ctx() where T : unmanaged + public ref T Ctx() { - return _observer.Ctx(); + return ref _observer.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/Observer/Observer/T13.g.cs b/src/Flecs.NET/Generated/Observer/Observer/T13.g.cs index 70da8b85..a8143bd8 100644 --- a/src/Flecs.NET/Generated/Observer/Observer/T13.g.cs +++ b/src/Flecs.NET/Generated/Observer/Observer/T13.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 16 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. The T6 component type. The T7 component type. The T8 component type. The T9 component type. The T10 component type. The T11 component type. The T12 component type. -public unsafe partial struct Observer : IEquatable>, IDisposable +public unsafe partial struct Observer : IDisposable, IEquatable>, IEntity> { private Observer _observer; @@ -54,22 +54,46 @@ public void Dispose() _observer.Dispose(); } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) { - _observer.Ctx(ctx); + _observer.Ctx(ref value); } - - /// - public void* Ctx() + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) { - return _observer.Ctx(); + _observer.Ctx(ref value, callback); } - + + /// + public void Ctx(T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _observer.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + /// - public T* Ctx() where T : unmanaged + public ref T Ctx() { - return _observer.Ctx(); + return ref _observer.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/Observer/Observer/T14.g.cs b/src/Flecs.NET/Generated/Observer/Observer/T14.g.cs index a87a30e1..a281a28a 100644 --- a/src/Flecs.NET/Generated/Observer/Observer/T14.g.cs +++ b/src/Flecs.NET/Generated/Observer/Observer/T14.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 16 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. The T6 component type. The T7 component type. The T8 component type. The T9 component type. The T10 component type. The T11 component type. The T12 component type. The T13 component type. -public unsafe partial struct Observer : IEquatable>, IDisposable +public unsafe partial struct Observer : IDisposable, IEquatable>, IEntity> { private Observer _observer; @@ -54,22 +54,46 @@ public void Dispose() _observer.Dispose(); } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) { - _observer.Ctx(ctx); + _observer.Ctx(ref value); } - - /// - public void* Ctx() + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) { - return _observer.Ctx(); + _observer.Ctx(ref value, callback); } - + + /// + public void Ctx(T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _observer.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + /// - public T* Ctx() where T : unmanaged + public ref T Ctx() { - return _observer.Ctx(); + return ref _observer.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/Observer/Observer/T15.g.cs b/src/Flecs.NET/Generated/Observer/Observer/T15.g.cs index 47e20bb3..e896c817 100644 --- a/src/Flecs.NET/Generated/Observer/Observer/T15.g.cs +++ b/src/Flecs.NET/Generated/Observer/Observer/T15.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 16 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. The T6 component type. The T7 component type. The T8 component type. The T9 component type. The T10 component type. The T11 component type. The T12 component type. The T13 component type. The T14 component type. -public unsafe partial struct Observer : IEquatable>, IDisposable +public unsafe partial struct Observer : IDisposable, IEquatable>, IEntity> { private Observer _observer; @@ -54,22 +54,46 @@ public void Dispose() _observer.Dispose(); } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) { - _observer.Ctx(ctx); + _observer.Ctx(ref value); } - - /// - public void* Ctx() + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) { - return _observer.Ctx(); + _observer.Ctx(ref value, callback); } - + + /// + public void Ctx(T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _observer.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + /// - public T* Ctx() where T : unmanaged + public ref T Ctx() { - return _observer.Ctx(); + return ref _observer.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/Observer/Observer/T16.g.cs b/src/Flecs.NET/Generated/Observer/Observer/T16.g.cs index a642314f..04c71688 100644 --- a/src/Flecs.NET/Generated/Observer/Observer/T16.g.cs +++ b/src/Flecs.NET/Generated/Observer/Observer/T16.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 16 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. The T6 component type. The T7 component type. The T8 component type. The T9 component type. The T10 component type. The T11 component type. The T12 component type. The T13 component type. The T14 component type. The T15 component type. -public unsafe partial struct Observer : IEquatable>, IDisposable +public unsafe partial struct Observer : IDisposable, IEquatable>, IEntity> { private Observer _observer; @@ -54,22 +54,46 @@ public void Dispose() _observer.Dispose(); } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) { - _observer.Ctx(ctx); + _observer.Ctx(ref value); } - - /// - public void* Ctx() + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) { - return _observer.Ctx(); + _observer.Ctx(ref value, callback); } - + + /// + public void Ctx(T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _observer.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + /// - public T* Ctx() where T : unmanaged + public ref T Ctx() { - return _observer.Ctx(); + return ref _observer.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/Observer/Observer/T2.g.cs b/src/Flecs.NET/Generated/Observer/Observer/T2.g.cs index c0586ce4..7f39f017 100644 --- a/src/Flecs.NET/Generated/Observer/Observer/T2.g.cs +++ b/src/Flecs.NET/Generated/Observer/Observer/T2.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 16 type arguments. /// /// The T0 component type. The T1 component type. -public unsafe partial struct Observer : IEquatable>, IDisposable +public unsafe partial struct Observer : IDisposable, IEquatable>, IEntity> { private Observer _observer; @@ -54,22 +54,46 @@ public void Dispose() _observer.Dispose(); } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) { - _observer.Ctx(ctx); + _observer.Ctx(ref value); } - - /// - public void* Ctx() + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) { - return _observer.Ctx(); + _observer.Ctx(ref value, callback); } - + + /// + public void Ctx(T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _observer.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + /// - public T* Ctx() where T : unmanaged + public ref T Ctx() { - return _observer.Ctx(); + return ref _observer.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/Observer/Observer/T3.g.cs b/src/Flecs.NET/Generated/Observer/Observer/T3.g.cs index ac772570..36f7e991 100644 --- a/src/Flecs.NET/Generated/Observer/Observer/T3.g.cs +++ b/src/Flecs.NET/Generated/Observer/Observer/T3.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 16 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. -public unsafe partial struct Observer : IEquatable>, IDisposable +public unsafe partial struct Observer : IDisposable, IEquatable>, IEntity> { private Observer _observer; @@ -54,22 +54,46 @@ public void Dispose() _observer.Dispose(); } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) { - _observer.Ctx(ctx); + _observer.Ctx(ref value); } - - /// - public void* Ctx() + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) { - return _observer.Ctx(); + _observer.Ctx(ref value, callback); } - + + /// + public void Ctx(T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _observer.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + /// - public T* Ctx() where T : unmanaged + public ref T Ctx() { - return _observer.Ctx(); + return ref _observer.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/Observer/Observer/T4.g.cs b/src/Flecs.NET/Generated/Observer/Observer/T4.g.cs index 074470a6..f624b9a0 100644 --- a/src/Flecs.NET/Generated/Observer/Observer/T4.g.cs +++ b/src/Flecs.NET/Generated/Observer/Observer/T4.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 16 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. -public unsafe partial struct Observer : IEquatable>, IDisposable +public unsafe partial struct Observer : IDisposable, IEquatable>, IEntity> { private Observer _observer; @@ -54,22 +54,46 @@ public void Dispose() _observer.Dispose(); } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) { - _observer.Ctx(ctx); + _observer.Ctx(ref value); } - - /// - public void* Ctx() + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) { - return _observer.Ctx(); + _observer.Ctx(ref value, callback); } - + + /// + public void Ctx(T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _observer.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + /// - public T* Ctx() where T : unmanaged + public ref T Ctx() { - return _observer.Ctx(); + return ref _observer.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/Observer/Observer/T5.g.cs b/src/Flecs.NET/Generated/Observer/Observer/T5.g.cs index a17b4fb5..9c95aefa 100644 --- a/src/Flecs.NET/Generated/Observer/Observer/T5.g.cs +++ b/src/Flecs.NET/Generated/Observer/Observer/T5.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 16 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. -public unsafe partial struct Observer : IEquatable>, IDisposable +public unsafe partial struct Observer : IDisposable, IEquatable>, IEntity> { private Observer _observer; @@ -54,22 +54,46 @@ public void Dispose() _observer.Dispose(); } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) { - _observer.Ctx(ctx); + _observer.Ctx(ref value); } - - /// - public void* Ctx() + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) { - return _observer.Ctx(); + _observer.Ctx(ref value, callback); } - + + /// + public void Ctx(T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _observer.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + /// - public T* Ctx() where T : unmanaged + public ref T Ctx() { - return _observer.Ctx(); + return ref _observer.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/Observer/Observer/T6.g.cs b/src/Flecs.NET/Generated/Observer/Observer/T6.g.cs index 9499ed03..dbf19249 100644 --- a/src/Flecs.NET/Generated/Observer/Observer/T6.g.cs +++ b/src/Flecs.NET/Generated/Observer/Observer/T6.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 16 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. -public unsafe partial struct Observer : IEquatable>, IDisposable +public unsafe partial struct Observer : IDisposable, IEquatable>, IEntity> { private Observer _observer; @@ -54,22 +54,46 @@ public void Dispose() _observer.Dispose(); } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) { - _observer.Ctx(ctx); + _observer.Ctx(ref value); } - - /// - public void* Ctx() + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) { - return _observer.Ctx(); + _observer.Ctx(ref value, callback); } - + + /// + public void Ctx(T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _observer.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + /// - public T* Ctx() where T : unmanaged + public ref T Ctx() { - return _observer.Ctx(); + return ref _observer.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/Observer/Observer/T7.g.cs b/src/Flecs.NET/Generated/Observer/Observer/T7.g.cs index d061dc26..53498948 100644 --- a/src/Flecs.NET/Generated/Observer/Observer/T7.g.cs +++ b/src/Flecs.NET/Generated/Observer/Observer/T7.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 16 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. The T6 component type. -public unsafe partial struct Observer : IEquatable>, IDisposable +public unsafe partial struct Observer : IDisposable, IEquatable>, IEntity> { private Observer _observer; @@ -54,22 +54,46 @@ public void Dispose() _observer.Dispose(); } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) { - _observer.Ctx(ctx); + _observer.Ctx(ref value); } - - /// - public void* Ctx() + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) { - return _observer.Ctx(); + _observer.Ctx(ref value, callback); } - + + /// + public void Ctx(T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _observer.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + /// - public T* Ctx() where T : unmanaged + public ref T Ctx() { - return _observer.Ctx(); + return ref _observer.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/Observer/Observer/T8.g.cs b/src/Flecs.NET/Generated/Observer/Observer/T8.g.cs index a846b285..3ce362f7 100644 --- a/src/Flecs.NET/Generated/Observer/Observer/T8.g.cs +++ b/src/Flecs.NET/Generated/Observer/Observer/T8.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 16 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. The T6 component type. The T7 component type. -public unsafe partial struct Observer : IEquatable>, IDisposable +public unsafe partial struct Observer : IDisposable, IEquatable>, IEntity> { private Observer _observer; @@ -54,22 +54,46 @@ public void Dispose() _observer.Dispose(); } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) { - _observer.Ctx(ctx); + _observer.Ctx(ref value); } - - /// - public void* Ctx() + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) { - return _observer.Ctx(); + _observer.Ctx(ref value, callback); } - + + /// + public void Ctx(T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _observer.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + /// - public T* Ctx() where T : unmanaged + public ref T Ctx() { - return _observer.Ctx(); + return ref _observer.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/Observer/Observer/T9.g.cs b/src/Flecs.NET/Generated/Observer/Observer/T9.g.cs index 7c6928a6..93cb0008 100644 --- a/src/Flecs.NET/Generated/Observer/Observer/T9.g.cs +++ b/src/Flecs.NET/Generated/Observer/Observer/T9.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 16 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. The T6 component type. The T7 component type. The T8 component type. -public unsafe partial struct Observer : IEquatable>, IDisposable +public unsafe partial struct Observer : IDisposable, IEquatable>, IEntity> { private Observer _observer; @@ -54,22 +54,46 @@ public void Dispose() _observer.Dispose(); } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) { - _observer.Ctx(ctx); + _observer.Ctx(ref value); } - - /// - public void* Ctx() + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) { - return _observer.Ctx(); + _observer.Ctx(ref value, callback); } - + + /// + public void Ctx(T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _observer.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observer.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) + { + _observer.Ctx(ref value, callback); + } + /// - public T* Ctx() where T : unmanaged + public ref T Ctx() { - return _observer.Ctx(); + return ref _observer.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T1.g.cs b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T1.g.cs index 3473d4b4..87002de5 100644 --- a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T1.g.cs +++ b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T1.g.cs @@ -75,10 +75,45 @@ public ref ObserverBuilder YieldExisting(bool value = true) return ref this; } - /// - public ref ObserverBuilder Ctx(void* data) + /// + public ref ObserverBuilder Ctx(T value) { - _observerBuilder.Ctx(data); + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value) + { + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T10.g.cs b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T10.g.cs index 3fb65877..f1c73a55 100644 --- a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T10.g.cs +++ b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T10.g.cs @@ -75,10 +75,45 @@ public ref ObserverBuilder YieldExisting return ref this; } - /// - public ref ObserverBuilder Ctx(void* data) + /// + public ref ObserverBuilder Ctx(T value) { - _observerBuilder.Ctx(data); + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value) + { + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T11.g.cs b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T11.g.cs index dc27fe35..6f66fcec 100644 --- a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T11.g.cs +++ b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T11.g.cs @@ -75,10 +75,45 @@ public ref ObserverBuilder YieldExi return ref this; } - /// - public ref ObserverBuilder Ctx(void* data) + /// + public ref ObserverBuilder Ctx(T value) { - _observerBuilder.Ctx(data); + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value) + { + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T12.g.cs b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T12.g.cs index 2d354b87..aaa3133d 100644 --- a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T12.g.cs +++ b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T12.g.cs @@ -75,10 +75,45 @@ public ref ObserverBuilder Yie return ref this; } - /// - public ref ObserverBuilder Ctx(void* data) + /// + public ref ObserverBuilder Ctx(T value) { - _observerBuilder.Ctx(data); + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value) + { + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T13.g.cs b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T13.g.cs index b471cff2..bfebe5b3 100644 --- a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T13.g.cs +++ b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T13.g.cs @@ -75,10 +75,45 @@ public ref ObserverBuilder Ctx(void* data) + /// + public ref ObserverBuilder Ctx(T value) { - _observerBuilder.Ctx(data); + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value) + { + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T14.g.cs b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T14.g.cs index 0dc01a18..af1f2bd8 100644 --- a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T14.g.cs +++ b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T14.g.cs @@ -75,10 +75,45 @@ public ref ObserverBuilder Ctx(void* data) + /// + public ref ObserverBuilder Ctx(T value) { - _observerBuilder.Ctx(data); + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value) + { + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T15.g.cs b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T15.g.cs index d45bf583..fdf0e2e3 100644 --- a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T15.g.cs +++ b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T15.g.cs @@ -75,10 +75,45 @@ public ref ObserverBuilder Ctx(void* data) + /// + public ref ObserverBuilder Ctx(T value) { - _observerBuilder.Ctx(data); + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value) + { + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T16.g.cs b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T16.g.cs index faed0729..30a22790 100644 --- a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T16.g.cs +++ b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T16.g.cs @@ -75,10 +75,45 @@ public ref ObserverBuilder Ctx(void* data) + /// + public ref ObserverBuilder Ctx(T value) { - _observerBuilder.Ctx(data); + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value) + { + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T2.g.cs b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T2.g.cs index 0361fe17..bb1c391a 100644 --- a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T2.g.cs +++ b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T2.g.cs @@ -75,10 +75,45 @@ public ref ObserverBuilder YieldExisting(bool value = true) return ref this; } - /// - public ref ObserverBuilder Ctx(void* data) + /// + public ref ObserverBuilder Ctx(T value) { - _observerBuilder.Ctx(data); + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value) + { + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T3.g.cs b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T3.g.cs index 08db4199..8dcfad36 100644 --- a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T3.g.cs +++ b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T3.g.cs @@ -75,10 +75,45 @@ public ref ObserverBuilder YieldExisting(bool value = true) return ref this; } - /// - public ref ObserverBuilder Ctx(void* data) + /// + public ref ObserverBuilder Ctx(T value) { - _observerBuilder.Ctx(data); + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value) + { + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T4.g.cs b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T4.g.cs index a7ed9953..fde3d929 100644 --- a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T4.g.cs +++ b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T4.g.cs @@ -75,10 +75,45 @@ public ref ObserverBuilder YieldExisting(bool value = true) return ref this; } - /// - public ref ObserverBuilder Ctx(void* data) + /// + public ref ObserverBuilder Ctx(T value) { - _observerBuilder.Ctx(data); + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value) + { + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T5.g.cs b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T5.g.cs index ae54ba03..825d06e1 100644 --- a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T5.g.cs +++ b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T5.g.cs @@ -75,10 +75,45 @@ public ref ObserverBuilder YieldExisting(bool value = true) return ref this; } - /// - public ref ObserverBuilder Ctx(void* data) + /// + public ref ObserverBuilder Ctx(T value) { - _observerBuilder.Ctx(data); + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value) + { + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T6.g.cs b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T6.g.cs index fcbd466c..f4f23e63 100644 --- a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T6.g.cs +++ b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T6.g.cs @@ -75,10 +75,45 @@ public ref ObserverBuilder YieldExisting(bool value = tr return ref this; } - /// - public ref ObserverBuilder Ctx(void* data) + /// + public ref ObserverBuilder Ctx(T value) { - _observerBuilder.Ctx(data); + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value) + { + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T7.g.cs b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T7.g.cs index 89dd69d2..9a7c048d 100644 --- a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T7.g.cs +++ b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T7.g.cs @@ -75,10 +75,45 @@ public ref ObserverBuilder YieldExisting(bool value return ref this; } - /// - public ref ObserverBuilder Ctx(void* data) + /// + public ref ObserverBuilder Ctx(T value) { - _observerBuilder.Ctx(data); + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value) + { + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T8.g.cs b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T8.g.cs index 257e8311..0692c71f 100644 --- a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T8.g.cs +++ b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T8.g.cs @@ -75,10 +75,45 @@ public ref ObserverBuilder YieldExisting(bool va return ref this; } - /// - public ref ObserverBuilder Ctx(void* data) + /// + public ref ObserverBuilder Ctx(T value) { - _observerBuilder.Ctx(data); + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value) + { + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T9.g.cs b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T9.g.cs index 1898a6f4..bc45f8d9 100644 --- a/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T9.g.cs +++ b/src/Flecs.NET/Generated/ObserverBuilder/ObserverBuilder/T9.g.cs @@ -75,10 +75,45 @@ public ref ObserverBuilder YieldExisting(boo return ref this; } - /// - public ref ObserverBuilder Ctx(void* data) + /// + public ref ObserverBuilder Ctx(T value) { - _observerBuilder.Ctx(data); + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value) + { + _observerBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _observerBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref ObserverBuilder Ctx(ref T value, delegate* callback) + { + _observerBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T1.g.cs b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T1.g.cs index 41c912fa..df0fd66f 100644 --- a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T1.g.cs +++ b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T1.g.cs @@ -124,10 +124,45 @@ public ref SystemBuilder TickSource() return ref this; } - /// - public ref SystemBuilder Ctx(void* ctx) + /// + public ref SystemBuilder Ctx(T value) { - _systemBuilder.Ctx(ctx); + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value) + { + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T10.g.cs b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T10.g.cs index 9c2979c1..03d34aa7 100644 --- a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T10.g.cs +++ b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T10.g.cs @@ -124,10 +124,45 @@ public ref SystemBuilder TickSource() return ref this; } - /// - public ref SystemBuilder Ctx(void* ctx) + /// + public ref SystemBuilder Ctx(T value) { - _systemBuilder.Ctx(ctx); + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value) + { + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T11.g.cs b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T11.g.cs index 795b2790..6fb4e423 100644 --- a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T11.g.cs +++ b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T11.g.cs @@ -124,10 +124,45 @@ public ref SystemBuilder TickSource return ref this; } - /// - public ref SystemBuilder Ctx(void* ctx) + /// + public ref SystemBuilder Ctx(T value) { - _systemBuilder.Ctx(ctx); + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value) + { + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T12.g.cs b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T12.g.cs index ba7687f3..6283cd66 100644 --- a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T12.g.cs +++ b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T12.g.cs @@ -124,10 +124,45 @@ public ref SystemBuilder TickS return ref this; } - /// - public ref SystemBuilder Ctx(void* ctx) + /// + public ref SystemBuilder Ctx(T value) { - _systemBuilder.Ctx(ctx); + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value) + { + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T13.g.cs b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T13.g.cs index fb0a2593..0d2de624 100644 --- a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T13.g.cs +++ b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T13.g.cs @@ -124,10 +124,45 @@ public ref SystemBuilder return ref this; } - /// - public ref SystemBuilder Ctx(void* ctx) + /// + public ref SystemBuilder Ctx(T value) { - _systemBuilder.Ctx(ctx); + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value) + { + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T14.g.cs b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T14.g.cs index db4f6a97..54af2fad 100644 --- a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T14.g.cs +++ b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T14.g.cs @@ -124,10 +124,45 @@ public ref SystemBuilder - public ref SystemBuilder Ctx(void* ctx) + /// + public ref SystemBuilder Ctx(T value) { - _systemBuilder.Ctx(ctx); + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value) + { + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T15.g.cs b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T15.g.cs index 2d6923d6..3872589c 100644 --- a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T15.g.cs +++ b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T15.g.cs @@ -124,10 +124,45 @@ public ref SystemBuilder - public ref SystemBuilder Ctx(void* ctx) + /// + public ref SystemBuilder Ctx(T value) { - _systemBuilder.Ctx(ctx); + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value) + { + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T16.g.cs b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T16.g.cs index ebb3adc0..7b3cc924 100644 --- a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T16.g.cs +++ b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T16.g.cs @@ -124,10 +124,45 @@ public ref SystemBuilder - public ref SystemBuilder Ctx(void* ctx) + /// + public ref SystemBuilder Ctx(T value) { - _systemBuilder.Ctx(ctx); + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value) + { + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T2.g.cs b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T2.g.cs index 922982f7..ed5b11ad 100644 --- a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T2.g.cs +++ b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T2.g.cs @@ -124,10 +124,45 @@ public ref SystemBuilder TickSource() return ref this; } - /// - public ref SystemBuilder Ctx(void* ctx) + /// + public ref SystemBuilder Ctx(T value) { - _systemBuilder.Ctx(ctx); + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value) + { + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T3.g.cs b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T3.g.cs index 592a915d..68ae98ab 100644 --- a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T3.g.cs +++ b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T3.g.cs @@ -124,10 +124,45 @@ public ref SystemBuilder TickSource() return ref this; } - /// - public ref SystemBuilder Ctx(void* ctx) + /// + public ref SystemBuilder Ctx(T value) { - _systemBuilder.Ctx(ctx); + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value) + { + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T4.g.cs b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T4.g.cs index af737afb..8c3f91fd 100644 --- a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T4.g.cs +++ b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T4.g.cs @@ -124,10 +124,45 @@ public ref SystemBuilder TickSource() return ref this; } - /// - public ref SystemBuilder Ctx(void* ctx) + /// + public ref SystemBuilder Ctx(T value) { - _systemBuilder.Ctx(ctx); + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value) + { + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T5.g.cs b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T5.g.cs index 5d2eddef..51579944 100644 --- a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T5.g.cs +++ b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T5.g.cs @@ -124,10 +124,45 @@ public ref SystemBuilder TickSource() return ref this; } - /// - public ref SystemBuilder Ctx(void* ctx) + /// + public ref SystemBuilder Ctx(T value) { - _systemBuilder.Ctx(ctx); + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value) + { + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T6.g.cs b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T6.g.cs index cde6c694..7e04995f 100644 --- a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T6.g.cs +++ b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T6.g.cs @@ -124,10 +124,45 @@ public ref SystemBuilder TickSource() return ref this; } - /// - public ref SystemBuilder Ctx(void* ctx) + /// + public ref SystemBuilder Ctx(T value) { - _systemBuilder.Ctx(ctx); + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value) + { + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T7.g.cs b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T7.g.cs index b3c644eb..b0bdf2a6 100644 --- a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T7.g.cs +++ b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T7.g.cs @@ -124,10 +124,45 @@ public ref SystemBuilder TickSource() return ref this; } - /// - public ref SystemBuilder Ctx(void* ctx) + /// + public ref SystemBuilder Ctx(T value) { - _systemBuilder.Ctx(ctx); + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value) + { + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T8.g.cs b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T8.g.cs index 9e51ff18..3434bb98 100644 --- a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T8.g.cs +++ b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T8.g.cs @@ -124,10 +124,45 @@ public ref SystemBuilder TickSource() return ref this; } - /// - public ref SystemBuilder Ctx(void* ctx) + /// + public ref SystemBuilder Ctx(T value) { - _systemBuilder.Ctx(ctx); + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value) + { + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T9.g.cs b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T9.g.cs index 3e73c53a..62a5ff86 100644 --- a/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T9.g.cs +++ b/src/Flecs.NET/Generated/SystemBuilder/SystemBuilder/T9.g.cs @@ -124,10 +124,45 @@ public ref SystemBuilder TickSource() return ref this; } - /// - public ref SystemBuilder Ctx(void* ctx) + /// + public ref SystemBuilder Ctx(T value) { - _systemBuilder.Ctx(ctx); + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value) + { + _systemBuilder.Ctx(ref value); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, Ecs.UserContextFinish callback) + { + _systemBuilder.Ctx(ref value, callback); + return ref this; + } + + /// + public ref SystemBuilder Ctx(ref T value, delegate* callback) + { + _systemBuilder.Ctx(ref value, callback); return ref this; } diff --git a/src/Flecs.NET/Generated/System_/System/T1.g.cs b/src/Flecs.NET/Generated/System_/System/T1.g.cs index b636302c..82fd3854 100644 --- a/src/Flecs.NET/Generated/System_/System/T1.g.cs +++ b/src/Flecs.NET/Generated/System_/System/T1.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 1 type arguments. /// /// The T0 component type. -public unsafe partial struct System : IEquatable>, IEntity> +public unsafe partial struct System : IDisposable, IEquatable>, IEntity> { private System_ _system; @@ -47,17 +47,53 @@ public System(Entity entity) TypeHelper.AssertNoTags(); _system = new System_(entity); } + + /// + public void Dispose() + { + _system.Dispose(); + } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(T value, delegate* callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) { - _system.Ctx(ctx); + _system.Ctx(ref value, callback); } - /// - public void* Ctx() + /// + public ref T Ctx() { - return _system.Ctx(); + return ref _system.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/System_/System/T10.g.cs b/src/Flecs.NET/Generated/System_/System/T10.g.cs index 4a62afbe..cb58c21b 100644 --- a/src/Flecs.NET/Generated/System_/System/T10.g.cs +++ b/src/Flecs.NET/Generated/System_/System/T10.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 10 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. The T6 component type. The T7 component type. The T8 component type. The T9 component type. -public unsafe partial struct System : IEquatable>, IEntity> +public unsafe partial struct System : IDisposable, IEquatable>, IEntity> { private System_ _system; @@ -47,17 +47,53 @@ public System(Entity entity) TypeHelper.AssertNoTags(); _system = new System_(entity); } + + /// + public void Dispose() + { + _system.Dispose(); + } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(T value, delegate* callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) { - _system.Ctx(ctx); + _system.Ctx(ref value, callback); } - /// - public void* Ctx() + /// + public ref T Ctx() { - return _system.Ctx(); + return ref _system.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/System_/System/T11.g.cs b/src/Flecs.NET/Generated/System_/System/T11.g.cs index b0e54f62..fb250680 100644 --- a/src/Flecs.NET/Generated/System_/System/T11.g.cs +++ b/src/Flecs.NET/Generated/System_/System/T11.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 11 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. The T6 component type. The T7 component type. The T8 component type. The T9 component type. The T10 component type. -public unsafe partial struct System : IEquatable>, IEntity> +public unsafe partial struct System : IDisposable, IEquatable>, IEntity> { private System_ _system; @@ -47,17 +47,53 @@ public System(Entity entity) TypeHelper.AssertNoTags(); _system = new System_(entity); } + + /// + public void Dispose() + { + _system.Dispose(); + } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(T value, delegate* callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) { - _system.Ctx(ctx); + _system.Ctx(ref value, callback); } - /// - public void* Ctx() + /// + public ref T Ctx() { - return _system.Ctx(); + return ref _system.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/System_/System/T12.g.cs b/src/Flecs.NET/Generated/System_/System/T12.g.cs index dd14a703..b3898769 100644 --- a/src/Flecs.NET/Generated/System_/System/T12.g.cs +++ b/src/Flecs.NET/Generated/System_/System/T12.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 12 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. The T6 component type. The T7 component type. The T8 component type. The T9 component type. The T10 component type. The T11 component type. -public unsafe partial struct System : IEquatable>, IEntity> +public unsafe partial struct System : IDisposable, IEquatable>, IEntity> { private System_ _system; @@ -47,17 +47,53 @@ public System(Entity entity) TypeHelper.AssertNoTags(); _system = new System_(entity); } + + /// + public void Dispose() + { + _system.Dispose(); + } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(T value, delegate* callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) { - _system.Ctx(ctx); + _system.Ctx(ref value, callback); } - /// - public void* Ctx() + /// + public ref T Ctx() { - return _system.Ctx(); + return ref _system.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/System_/System/T13.g.cs b/src/Flecs.NET/Generated/System_/System/T13.g.cs index 1492175e..be3db027 100644 --- a/src/Flecs.NET/Generated/System_/System/T13.g.cs +++ b/src/Flecs.NET/Generated/System_/System/T13.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 13 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. The T6 component type. The T7 component type. The T8 component type. The T9 component type. The T10 component type. The T11 component type. The T12 component type. -public unsafe partial struct System : IEquatable>, IEntity> +public unsafe partial struct System : IDisposable, IEquatable>, IEntity> { private System_ _system; @@ -47,17 +47,53 @@ public System(Entity entity) TypeHelper.AssertNoTags(); _system = new System_(entity); } + + /// + public void Dispose() + { + _system.Dispose(); + } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(T value, delegate* callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) { - _system.Ctx(ctx); + _system.Ctx(ref value, callback); } - /// - public void* Ctx() + /// + public ref T Ctx() { - return _system.Ctx(); + return ref _system.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/System_/System/T14.g.cs b/src/Flecs.NET/Generated/System_/System/T14.g.cs index b1e5f9e4..07ca999a 100644 --- a/src/Flecs.NET/Generated/System_/System/T14.g.cs +++ b/src/Flecs.NET/Generated/System_/System/T14.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 14 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. The T6 component type. The T7 component type. The T8 component type. The T9 component type. The T10 component type. The T11 component type. The T12 component type. The T13 component type. -public unsafe partial struct System : IEquatable>, IEntity> +public unsafe partial struct System : IDisposable, IEquatable>, IEntity> { private System_ _system; @@ -47,17 +47,53 @@ public System(Entity entity) TypeHelper.AssertNoTags(); _system = new System_(entity); } + + /// + public void Dispose() + { + _system.Dispose(); + } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(T value, delegate* callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) { - _system.Ctx(ctx); + _system.Ctx(ref value, callback); } - /// - public void* Ctx() + /// + public ref T Ctx() { - return _system.Ctx(); + return ref _system.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/System_/System/T15.g.cs b/src/Flecs.NET/Generated/System_/System/T15.g.cs index caf278bc..4e462fbc 100644 --- a/src/Flecs.NET/Generated/System_/System/T15.g.cs +++ b/src/Flecs.NET/Generated/System_/System/T15.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 15 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. The T6 component type. The T7 component type. The T8 component type. The T9 component type. The T10 component type. The T11 component type. The T12 component type. The T13 component type. The T14 component type. -public unsafe partial struct System : IEquatable>, IEntity> +public unsafe partial struct System : IDisposable, IEquatable>, IEntity> { private System_ _system; @@ -47,17 +47,53 @@ public System(Entity entity) TypeHelper.AssertNoTags(); _system = new System_(entity); } + + /// + public void Dispose() + { + _system.Dispose(); + } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(T value, delegate* callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) { - _system.Ctx(ctx); + _system.Ctx(ref value, callback); } - /// - public void* Ctx() + /// + public ref T Ctx() { - return _system.Ctx(); + return ref _system.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/System_/System/T16.g.cs b/src/Flecs.NET/Generated/System_/System/T16.g.cs index 360358d4..648d0d7f 100644 --- a/src/Flecs.NET/Generated/System_/System/T16.g.cs +++ b/src/Flecs.NET/Generated/System_/System/T16.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 16 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. The T6 component type. The T7 component type. The T8 component type. The T9 component type. The T10 component type. The T11 component type. The T12 component type. The T13 component type. The T14 component type. The T15 component type. -public unsafe partial struct System : IEquatable>, IEntity> +public unsafe partial struct System : IDisposable, IEquatable>, IEntity> { private System_ _system; @@ -47,17 +47,53 @@ public System(Entity entity) TypeHelper.AssertNoTags(); _system = new System_(entity); } + + /// + public void Dispose() + { + _system.Dispose(); + } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(T value, delegate* callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) { - _system.Ctx(ctx); + _system.Ctx(ref value, callback); } - /// - public void* Ctx() + /// + public ref T Ctx() { - return _system.Ctx(); + return ref _system.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/System_/System/T2.g.cs b/src/Flecs.NET/Generated/System_/System/T2.g.cs index 0bbee443..9ea6aa6f 100644 --- a/src/Flecs.NET/Generated/System_/System/T2.g.cs +++ b/src/Flecs.NET/Generated/System_/System/T2.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 2 type arguments. /// /// The T0 component type. The T1 component type. -public unsafe partial struct System : IEquatable>, IEntity> +public unsafe partial struct System : IDisposable, IEquatable>, IEntity> { private System_ _system; @@ -47,17 +47,53 @@ public System(Entity entity) TypeHelper.AssertNoTags(); _system = new System_(entity); } + + /// + public void Dispose() + { + _system.Dispose(); + } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(T value, delegate* callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) { - _system.Ctx(ctx); + _system.Ctx(ref value, callback); } - /// - public void* Ctx() + /// + public ref T Ctx() { - return _system.Ctx(); + return ref _system.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/System_/System/T3.g.cs b/src/Flecs.NET/Generated/System_/System/T3.g.cs index fdeb4028..e1c7c232 100644 --- a/src/Flecs.NET/Generated/System_/System/T3.g.cs +++ b/src/Flecs.NET/Generated/System_/System/T3.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 3 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. -public unsafe partial struct System : IEquatable>, IEntity> +public unsafe partial struct System : IDisposable, IEquatable>, IEntity> { private System_ _system; @@ -47,17 +47,53 @@ public System(Entity entity) TypeHelper.AssertNoTags(); _system = new System_(entity); } + + /// + public void Dispose() + { + _system.Dispose(); + } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(T value, delegate* callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) { - _system.Ctx(ctx); + _system.Ctx(ref value, callback); } - /// - public void* Ctx() + /// + public ref T Ctx() { - return _system.Ctx(); + return ref _system.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/System_/System/T4.g.cs b/src/Flecs.NET/Generated/System_/System/T4.g.cs index 95f00c96..740bbfd0 100644 --- a/src/Flecs.NET/Generated/System_/System/T4.g.cs +++ b/src/Flecs.NET/Generated/System_/System/T4.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 4 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. -public unsafe partial struct System : IEquatable>, IEntity> +public unsafe partial struct System : IDisposable, IEquatable>, IEntity> { private System_ _system; @@ -47,17 +47,53 @@ public System(Entity entity) TypeHelper.AssertNoTags(); _system = new System_(entity); } + + /// + public void Dispose() + { + _system.Dispose(); + } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(T value, delegate* callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) { - _system.Ctx(ctx); + _system.Ctx(ref value, callback); } - /// - public void* Ctx() + /// + public ref T Ctx() { - return _system.Ctx(); + return ref _system.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/System_/System/T5.g.cs b/src/Flecs.NET/Generated/System_/System/T5.g.cs index 441e0ba5..5b84c3ab 100644 --- a/src/Flecs.NET/Generated/System_/System/T5.g.cs +++ b/src/Flecs.NET/Generated/System_/System/T5.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 5 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. -public unsafe partial struct System : IEquatable>, IEntity> +public unsafe partial struct System : IDisposable, IEquatable>, IEntity> { private System_ _system; @@ -47,17 +47,53 @@ public System(Entity entity) TypeHelper.AssertNoTags(); _system = new System_(entity); } + + /// + public void Dispose() + { + _system.Dispose(); + } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(T value, delegate* callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) { - _system.Ctx(ctx); + _system.Ctx(ref value, callback); } - /// - public void* Ctx() + /// + public ref T Ctx() { - return _system.Ctx(); + return ref _system.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/System_/System/T6.g.cs b/src/Flecs.NET/Generated/System_/System/T6.g.cs index 345a76fd..3a0726ca 100644 --- a/src/Flecs.NET/Generated/System_/System/T6.g.cs +++ b/src/Flecs.NET/Generated/System_/System/T6.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 6 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. -public unsafe partial struct System : IEquatable>, IEntity> +public unsafe partial struct System : IDisposable, IEquatable>, IEntity> { private System_ _system; @@ -47,17 +47,53 @@ public System(Entity entity) TypeHelper.AssertNoTags(); _system = new System_(entity); } + + /// + public void Dispose() + { + _system.Dispose(); + } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(T value, delegate* callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) { - _system.Ctx(ctx); + _system.Ctx(ref value, callback); } - /// - public void* Ctx() + /// + public ref T Ctx() { - return _system.Ctx(); + return ref _system.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/System_/System/T7.g.cs b/src/Flecs.NET/Generated/System_/System/T7.g.cs index 8a8e33d9..deeef16a 100644 --- a/src/Flecs.NET/Generated/System_/System/T7.g.cs +++ b/src/Flecs.NET/Generated/System_/System/T7.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 7 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. The T6 component type. -public unsafe partial struct System : IEquatable>, IEntity> +public unsafe partial struct System : IDisposable, IEquatable>, IEntity> { private System_ _system; @@ -47,17 +47,53 @@ public System(Entity entity) TypeHelper.AssertNoTags(); _system = new System_(entity); } + + /// + public void Dispose() + { + _system.Dispose(); + } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(T value, delegate* callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) { - _system.Ctx(ctx); + _system.Ctx(ref value, callback); } - /// - public void* Ctx() + /// + public ref T Ctx() { - return _system.Ctx(); + return ref _system.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/System_/System/T8.g.cs b/src/Flecs.NET/Generated/System_/System/T8.g.cs index b7f4e617..4c368b61 100644 --- a/src/Flecs.NET/Generated/System_/System/T8.g.cs +++ b/src/Flecs.NET/Generated/System_/System/T8.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 8 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. The T6 component type. The T7 component type. -public unsafe partial struct System : IEquatable>, IEntity> +public unsafe partial struct System : IDisposable, IEquatable>, IEntity> { private System_ _system; @@ -47,17 +47,53 @@ public System(Entity entity) TypeHelper.AssertNoTags(); _system = new System_(entity); } + + /// + public void Dispose() + { + _system.Dispose(); + } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(T value, delegate* callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) { - _system.Ctx(ctx); + _system.Ctx(ref value, callback); } - /// - public void* Ctx() + /// + public ref T Ctx() { - return _system.Ctx(); + return ref _system.Ctx(); } /// diff --git a/src/Flecs.NET/Generated/System_/System/T9.g.cs b/src/Flecs.NET/Generated/System_/System/T9.g.cs index d8eaf82d..a3c3b2fc 100644 --- a/src/Flecs.NET/Generated/System_/System/T9.g.cs +++ b/src/Flecs.NET/Generated/System_/System/T9.g.cs @@ -11,7 +11,7 @@ namespace Flecs.NET.Core; /// A type-safe wrapper around that takes 9 type arguments. /// /// The T0 component type. The T1 component type. The T2 component type. The T3 component type. The T4 component type. The T5 component type. The T6 component type. The T7 component type. The T8 component type. -public unsafe partial struct System : IEquatable>, IEntity> +public unsafe partial struct System : IDisposable, IEquatable>, IEntity> { private System_ _system; @@ -47,17 +47,53 @@ public System(Entity entity) TypeHelper.AssertNoTags(); _system = new System_(entity); } + + /// + public void Dispose() + { + _system.Dispose(); + } - /// - public void Ctx(void* ctx) + /// + public void Ctx(T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(T value, delegate* callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value) + { + _system.Ctx(ref value); + } + + /// + public void Ctx(ref T value, Ecs.UserContextFinish callback) + { + _system.Ctx(ref value, callback); + } + + /// + public void Ctx(ref T value, delegate* callback) { - _system.Ctx(ctx); + _system.Ctx(ref value, callback); } - /// - public void* Ctx() + /// + public ref T Ctx() { - return _system.Ctx(); + return ref _system.Ctx(); } ///