Exemplo n.º 1
0
        public static EntityId ECS_SYSTEM(World world, SystemActionDelegate method, SystemKind kind, string expr)
        {
            var systemNamePtr = Caches.AddUnmanagedString(method.Method.Name);

            Caches.AddSystemAction(world, method);
            return(ecs.new_system(world, systemNamePtr, kind, expr, method));
        }
Exemplo n.º 2
0
        public static EntityId ECS_SYSTEM <T1>(World world, SystemAction <T1> systemImpl, SystemKind kind, SystemSignatureBuilder signatureBuilder) where T1 : unmanaged
        {
            SystemActionDelegate del = delegate(ref Rows rows)
            {
                var set1 = (T1 *)_ecs.column(ref rows, Heap.SizeOf <T1>(), 1);
                systemImpl(ref rows, new Span <T1>(set1, (int)rows.count), ecs.get_delta_time(world));
            };

            // ensure our system doesnt get GCd and that our Component is registered
            Caches.AddSystemAction(world, del);

            var systemNamePtr = Caches.AddUnmanagedString(systemImpl.Target.GetType().FullName);

            return(ecs.new_system(world, systemNamePtr, kind, signatureBuilder.Build(), del));
        }
Exemplo n.º 3
0
        public static EntityId ECS_SYSTEM <T1>(World world, SystemAction <T1> systemImpl, SystemKind kind) where T1 : unmanaged
        {
            SystemActionDelegate del = delegate(ref Rows rows)
            {
                var set1 = (T1 *)_ecs.column(ref rows, Heap.SizeOf <T1>(), 1);
                systemImpl(ref rows, new Span <T1>(set1, (int)rows.count));
            };

            // ensure our system doesnt get GCd and that our Component is registered
            Caches.AddSystemAction(world, del);
            Caches.GetComponentTypeId <T1>(world);

            var systemNamePtr = Caches.AddUnmanagedString(systemImpl.Method.Name);

            return(ecs.new_system(world, systemNamePtr, kind, typeof(T1).Name, del));
        }
Exemplo n.º 4
0
 public EntityId NewSystem(CharPtr id, SystemKind kind, string sig, SystemActionDelegate action) => ecs.new_system(this, id, kind, sig, action);
Exemplo n.º 5
0
 public static void AddSystemAction(World world, SystemActionDelegate del) => systemActions[world].Add(del);