Пример #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));
        }
Пример #2
0
 public EntityId NewSystem(CharPtr id, SystemKind kind, string sig, SystemActionDelegate action) => ecs.new_system(this, id, kind, sig, action);
Пример #3
0
        public static EntityId ECS_SYSTEM <T1, T2, T3>(World world, SystemAction <T1, T2, T3> systemImpl, SystemKind kind)
            where T1 : unmanaged where T2 : unmanaged where T3 : unmanaged
        {
            SystemActionDelegate del = delegate(ref Rows rows)
            {
                var set1 = (T1 *)_ecs.column(ref rows, Heap.SizeOf <T1>(), 1);
                var set2 = (T2 *)_ecs.column(ref rows, Heap.SizeOf <T2>(), 2);
                var set3 = (T3 *)_ecs.column(ref rows, Heap.SizeOf <T3>(), 3);
                systemImpl(ref rows, new Span <T1>(set1, (int)rows.count), new Span <T2>(set2, (int)rows.count), new Span <T3>(set3, (int)rows.count));
            };

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

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

            return(ecs.new_system(world, systemNamePtr, kind, $"{typeof(T1).Name}, {typeof(T2).Name}, {typeof(T3).Name}", del));
        }
Пример #4
0
        public static EntityId ECS_SYSTEM <T1, T2, T3>(World world, SystemAction <T1, T2, T3> systemImpl, SystemKind kind, SystemSignatureBuilder signatureBuilder)
            where T1 : unmanaged where T2 : unmanaged where T3 : unmanaged
        {
            SystemActionDelegate del = delegate(ref Rows rows)
            {
                var set1 = (T1 *)_ecs.column(ref rows, Heap.SizeOf <T1>(), 1);
                var set2 = (T2 *)_ecs.column(ref rows, Heap.SizeOf <T2>(), 2);
                var set3 = (T3 *)_ecs.column(ref rows, Heap.SizeOf <T3>(), 3);
                systemImpl(ref rows, new Span <T1>(set1, (int)rows.count), new Span <T2>(set2, (int)rows.count), new Span <T3>(set3, (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));
        }