Exemplo n.º 1
0
    protected override void OnCreate()
    {
        m_Barrier    = World.Active.GetOrCreateSystem <LbSimulationBarrier>();
        m_BoardQuery = GetEntityQuery(typeof(LbBoard), typeof(LbCatMap));

        m_Queue = new NativeQueue <Entity>(Allocator.Persistent);
    }
Exemplo n.º 2
0
    protected override void OnCreate()
    {
        m_EntityCommandBufferSystem = World.GetOrCreateSystem <EntityCommandBufferSystem>();

        var queryDesc = new EntityQueryDesc
        {
            None = new ComponentType[] { typeof(C_Target), ComponentType.ReadOnly <Tag_IsDead>(), ComponentType.ReadOnly <Tag_IsDying>(), ComponentType.ReadOnly <C_Holding>() },
            All  = new ComponentType[] { ComponentType.ReadOnly <Tag_Bee>(), ComponentType.ReadOnly <C_Shared_Team>(), typeof(C_Random) }
        };

        var targetQueryDesc = new EntityQueryDesc
        {
            None = new ComponentType[] { ComponentType.ReadOnly <Tag_IsDead>(), ComponentType.ReadOnly <Tag_IsDying>(), ComponentType.ReadOnly <Tag_Bee_Init>() },
            All  = new ComponentType[] { ComponentType.ReadOnly <Tag_Bee>(), ComponentType.ReadOnly <C_Shared_Team>() }
        };

        var resourceQueryDesc = new EntityQueryDesc
        {
            None = new ComponentType[] { ComponentType.ReadOnly <Tag_IsHeld>() },
            All  = new ComponentType[] { ComponentType.ReadOnly <Tag_Resource>(), ComponentType.ReadOnly <C_GridIndex>(), ComponentType.ReadOnly <C_Stack>() }
        };

        m_yellowGroup     = GetEntityQuery(queryDesc);
        m_purpleGroup     = GetEntityQuery(queryDesc);
        m_YellowTargets   = GetEntityQuery(targetQueryDesc);
        m_PurpleTargets   = GetEntityQuery(targetQueryDesc);
        m_resourceTargets = GetEntityQuery(resourceQueryDesc);
    }
Exemplo n.º 3
0
 protected override void OnCreate()
 {
     base.OnCreate();
     m_CommandBuffer  = World.GetOrCreateSystem <BeginInitializationEntityCommandBufferSystem>();
     m_RandomArray    = new NativeArray <Random>(1, Allocator.Persistent);
     m_RandomArray[0] = new Random(1);
 }
Exemplo n.º 4
0
        protected override void OnCreate()
        {
            EntityQueryDesc allyQueryDesc = new EntityQueryDesc()
            {
                All = new ComponentType[]
                {
                    ComponentType.ReadOnly <AgentTag>(),
                    ComponentType.ReadOnly <AllyTeamComponent>(),
                    ComponentType.ReadOnly <AttackTargetComponent>(),
                }
            };

            m_AllyGroup = GetEntityQuery(allyQueryDesc);

            EntityQueryDesc enemyQueryDesc = new EntityQueryDesc()
            {
                All = new ComponentType[]
                {
                    ComponentType.ReadOnly <AgentTag>(),
                    ComponentType.ReadOnly <EnemyTeamComponent>(),
                    ComponentType.ReadOnly <AttackTargetComponent>(),
                }
            };

            m_EnemyGroup = GetEntityQuery(enemyQueryDesc);

            m_Barrier = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();
        }
Exemplo n.º 5
0
        protected override void OnCreateManager()
        {
#if UNITY_EDITOR
            if (!EditorApplication.isPlayingOrWillChangePlaymode)
            {
                AdditiveScene = SceneManager.GetSceneByName("AdditiveLightPoolScene");
            }
            else
#endif
            {
                AdditiveScene = SceneManager.CreateScene("AdditiveLightPoolScenePlaymode");
            }

            LightPool.Prefabs         = new List <GameObject>();
            LightPool.AvailableStacks = new List <Stack <GameObject> >();

            ClosestLights = new NativeArray <EntityDist>(PoolSize, Allocator.Persistent);
            CullingPlanes = new NativeArray <float4>(6, Allocator.Persistent);

            m_NewSharedLights = GetComponentGroup
                                (
                ComponentType.ReadOnly <SharedLight>(),
                ComponentType.Exclude <LightPoolCreatedTag>()
                                );

            m_ActiveLightProxies = GetComponentGroup
                                   (
                ComponentType.ReadWrite <LightPoolIndex>(),
                ComponentType.ReadOnly <Translation>()
                                   );

            m_CommandBufferSystem = World.GetOrCreateManager <EndSimulationEntityCommandBufferSystem>();
        }
        protected override void OnCreate()
        {
            var world = World.DefaultGameObjectInjectionWorld;

            commandBufferSystem = world.GetOrCreateSystem <EndInitializationEntityCommandBufferSystem>();
            entityManager       = world.EntityManager;
        }
        protected override void OnCreate()
        {
            glyphQuery = GetEntityQuery(new EntityQueryDesc {
                All = new [] {
                    ComponentType.ReadOnly <GlyphElement>(),
                    ComponentType.ReadOnly <FontID>()
                }
            });

            textQuery = GetEntityQuery(new EntityQueryDesc {
                All = new [] {
                    ComponentType.ReadWrite <LocalVertexData>(),
                    ComponentType.ReadWrite <LocalTriangleIndexElement>(),
                    ComponentType.ReadOnly <CharElement>(),
                    ComponentType.ReadOnly <TextOptions>(),
                    ComponentType.ReadOnly <BuildUIElementTag>()
                },

                Options = EntityQueryOptions.IncludeDisabled
            });

            RequireForUpdate(textQuery);

            cmdBufferSystem = World.GetOrCreateSystem <BeginPresentationEntityCommandBufferSystem>();
        }
Exemplo n.º 8
0
    protected override void OnCreate()
    {
        // Entities with GeneralPurposeComponentA but not StateComponentB
        m_newEntities = GetEntityQuery(new EntityQueryDesc()
        {
            All  = new ComponentType[] { ComponentType.ReadOnly <GeneralPurposeComponentA>() },
            None = new ComponentType[] { ComponentType.ReadWrite <StateComponentB>() }
        });

        // Entities with both GeneralPurposeComponentA and StateComponentB
        m_activeEntities = GetEntityQuery(new EntityQueryDesc()
        {
            All = new ComponentType[]
            {
                ComponentType.ReadWrite <GeneralPurposeComponentA>(),
                ComponentType.ReadOnly <StateComponentB>()
            }
        });

        // Entities with StateComponentB but not GeneralPurposeComponentA
        m_destroyedEntities = GetEntityQuery(new EntityQueryDesc()
        {
            All  = new ComponentType[] { ComponentType.ReadWrite <StateComponentB>() },
            None = new ComponentType[] { ComponentType.ReadOnly <GeneralPurposeComponentA>() }
        });

        m_ECBSource = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();
    }
Exemplo n.º 9
0
        protected override void OnCreate()
        {
            base.OnCreate();
            ecbSystem         = World.GetOrCreateSystem <BeginSimulationEntityCommandBufferSystem>();
            marchingTablesPtr = MarchingTables.CreateBlobAssetReference();
            var disabledDirtyChunks = new EntityQueryDesc
            {
                All = new ComponentType[]
                {
                    ComponentType.ReadOnly <MarchingChunk>(),
                    ComponentType.ReadOnly <DirtyChunkTag>(),
                    ComponentType.ReadOnly <Disabled>()
                }
            };

            var enabledDirtyChunks = new EntityQueryDesc
            {
                All = new ComponentType[]
                {
                    ComponentType.ReadOnly <MarchingChunk>(),
                    ComponentType.ReadOnly <DirtyChunkTag>(),
                },
                None = new ComponentType[] { ComponentType.ReadOnly <Disabled>() }
            };

            query = GetEntityQuery(disabledDirtyChunks, enabledDirtyChunks);
        }
Exemplo n.º 10
0
 protected override void OnCreate()
 {
     base.OnCreate();
     commandBufferSystem = World.GetOrCreateSystem <EndInitializationEntityCommandBufferSystem>();
     entityQuery         = GetEntityQuery(ComponentType.ReadOnly <KeepTag>(),
                                          ComponentType.ReadOnly <LinkedEntityGroup>());
 }
Exemplo n.º 11
0
        protected override void OnCreate()
        {
            base.OnCreate();

            commandBufferSystem = World.DefaultGameObjectInjectionWorld
                                  .GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();
        }
Exemplo n.º 12
0
 protected override void OnCreate()
 {
     base.OnCreate();
     m_EndFramePhysicsSystem = World.GetOrCreateSystem <EndFramePhysicsSystem>();
     m_BuildPhysicsWorld     = World.GetOrCreateSystem <BuildPhysicsWorld>();
     m_EndSimulationSystem   = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();
 }
Exemplo n.º 13
0
 protected override void OnCreate()
 {
     commandBuffer   = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();
     DamageMap       = new NativeMultiHashMap <Entity, float>(0, Allocator.Persistent);
     damageableUnits = GetEntityQuery(ComponentType.ReadOnly <HealthComponent>());
     base.OnCreate();
 }
Exemplo n.º 14
0
 protected override void OnCreate()
 {
     base.OnCreate();
     commandBufferSystem = World.GetOrCreateSystem <PostTriggerEventServerSystem>();
     buildPhysicsWorld   = World.GetOrCreateSystem <BuildPhysicsWorld>();
     stepPhysicsWorld    = World.GetOrCreateSystem <StepPhysicsWorld>();
 }
        protected override void OnCreate()
        {
            base.OnCreate();
            ecbSystem = World.GetOrCreateSystem <BeginInitializationEntityCommandBufferSystem>();

            var enabledChunksQueryDesc = new EntityQueryDesc
            {
                All  = new ComponentType[] { ComponentType.ReadOnly <MarchingChunk>() },
                None = new ComponentType[]
                {
                    ComponentType.ReadOnly <Disabled>(),
                    ComponentType.ReadOnly <DirtyChunkTag>()
                }
            };
            var inProcessChunksQueryDesc = new EntityQueryDesc
            {
                All = new ComponentType[]
                {
                    ComponentType.ReadOnly <MarchingChunk>(),
                    ComponentType.ReadOnly <Disabled>(),
                    ComponentType.ReadOnly <DirtyChunkTag>()
                }
            };

            chunksQuery         = GetEntityQuery(enabledChunksQueryDesc, inProcessChunksQueryDesc);
            disabledChunksQuery = GetEntityQuery(ComponentType.ReadOnly <MarchingChunk>(),
                                                 ComponentType.ReadOnly <Disabled>(), ComponentType.Exclude <DirtyChunkTag>());
        }
Exemplo n.º 16
0
        protected override void OnCreate()
        {
            _updateQuery = GetEntityQuery(
                new EntityQueryDesc
            {
                All = new[]
                {
                    ComponentType.ReadOnly <AIAgent>(), ComponentType.ReadOnly <RaycastResult>()
                },
                None = new[] { ComponentType.ReadWrite <RaycastResultState>() }
            }
                );

            _updateQueryNoState = GetEntityQuery(
                new EntityQueryDesc
            {
                All = new[]
                {
                    ComponentType.ReadOnly <AIAgent>(), ComponentType.ReadOnly <RaycastResult>(), ComponentType.ReadWrite <RaycastResultState>(),
                },
            }
                );

            _cleanupQuery = GetEntityQuery(ComponentType.ReadOnly <RaycastResultState>(),
                                           ComponentType.Exclude <AIAgent>());

            _commandBufferSystem = World.GetExistingSystem <EndSimulationEntityCommandBufferSystem>();
        }
Exemplo n.º 17
0
 protected override void OnCreate()
 {
     MainGroup = GetEntityQuery(
         ComponentType.ReadOnly <SpawnProjectile>(),
         ComponentType.ReadWrite <LocalToWorld>());
     barrier = World.Active.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();
 }
    protected override void OnCreate()
    {
        m_Query      = GetEntityQuery(ComponentType.ReadOnly <LbArrowPrefab>(), typeof(LbMovementTarget), typeof(LbDistanceToTarget));
        m_BoardQuery = GetEntityQuery(ComponentType.ReadOnly <LbBoard>());

        m_Barrier = World.GetOrCreateSystem <LbSimulationBarrier>();
    }
Exemplo n.º 19
0
        protected override void OnCreate()
        {
            base.OnCreate();

            _ecbSystem         = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();
            _translationSystem = World.GetOrCreateSystem <FolowPathTaskTranslationSystem>();
        }
    protected override void OnCreate()
    {
        endFrameBuffer = World.GetOrCreateSystem <EntityCommandBufferSystem>();

        playerGroup  = GetEntityQuery(ComponentType.ReadOnly <Translation>(), typeof(Dat_MovementData));
        mapTileGroup = GetEntityQuery(ComponentType.ReadOnly <Dat_MapTileData>());
    }
Exemplo n.º 21
0
    protected override void OnCreate()
    {
        m_entityCommandBufferSystem = World.GetOrCreateSystem <EntityCommandBufferSystem>();

        m_StripDyingHoldingQuery = GetEntityQuery(ComponentType.ReadOnly <Tag_IsDying>(), ComponentType.ReadOnly <C_Holding>());
        m_StripDyingTargetQuery  = GetEntityQuery(ComponentType.ReadOnly <Tag_IsDying>(), ComponentType.ReadOnly <C_Target>());
    }
Exemplo n.º 22
0
 protected override void OnCreate()
 {
     ecbs = World.GetOrCreateSystem <EntityCommandBufferSystem>();
     //The Filter
     pokemonMoveDataQuery      = GetEntityQuery(typeof(PokemonMoveDataEntity), typeof(PokemonMoveEntity), typeof(EntityParent));
     pokemonMoveFinishEntities = GetEntityQuery(typeof(PokemonMoveEntityRemoveRequest), typeof(PokemonMoveDataEntity));
 }
Exemplo n.º 23
0
    protected override void OnCreate()
    {
        m_EntityCommandBufferSystem = World.GetOrCreateSystem <EntityCommandBufferSystem>();

        m_bloodQuery = GetEntityQuery(ComponentType.ReadOnly <C_Velocity>(), ComponentType.ReadOnly <RenderMesh>(), ComponentType.ReadOnly <Tag_Particle_Init>());
        m_smokeQuery = GetEntityQuery(ComponentType.ReadOnly <C_Velocity>(), ComponentType.ReadOnly <RenderMesh>(), ComponentType.ReadOnly <Tag_Particle_Init>());
    }
Exemplo n.º 24
0
    protected override void OnCreate()
    {
        w = World.DefaultGameObjectInjectionWorld;
        //ecbSource = World.GetExistingSystem<EndSimulationEntityCommandBufferSystem>();
        ecbSource = w.GetExistingSystem <EndSimulationEntityCommandBufferSystem>();

        // Create some test entities
        // This runs on the main thread, but it is still faster to use a command buffer
        EntityCommandBuffer creationBuffer = new EntityCommandBuffer(Allocator.Temp);
        EntityArchetype     archetype      = EntityManager.CreateArchetype(typeof(GeneralPurposeComponentData));

        for (int i = 0; i < 10000; i++)
        {
            Entity newEntity = creationBuffer.CreateEntity(archetype);
            creationBuffer.SetComponent <GeneralPurposeComponentData>
            (
                newEntity,
                new GeneralPurposeComponentData()
            {
                Lifetime = i
            }
            );
        }
        //Execute the command buffer

        /*
         * 使用playback的效率,比使用EntityManager要快.
         *
         * https://docs.unity3d.com/Packages/[email protected]/manual/sync_points.html
         * Even on the main thread, it is typically faster to record commands in an ECB and then play back those commands, than it is to make the structural changes one-by-one using the EntityManager class itself.
         *
         */
        creationBuffer.Playback(EntityManager);
    }
Exemplo n.º 25
0
 protected override void OnCreate()
 {
     mapBodyQuery              = GetEntityQuery(typeof(MapBody), typeof(MapElement));
     conversionQuery           = GetEntityQuery(typeof(PointToMapBody));
     entityCommandBufferSystem = World.GetExistingSystem <EndSimulationEntityCommandBufferSystem>();
     RequireForUpdate(conversionQuery);
 }
Exemplo n.º 26
0
    protected override void OnCreate()
    {
        bufferSystem = World.GetOrCreateSystem <BeginPresentationEntityCommandBufferSystem> ();
        //待添加质量组件
        EntityQueryDesc addMass = new EntityQueryDesc();

        addMass.All  = new ComponentType[] { typeof(Joiner_C) };
        addMass.None = new ComponentType[] { typeof(MassPoint_C) };
        nonMassQuery = GetEntityQuery(addMass);
        //待添加缩放组件
        EntityQueryDesc addScale = new EntityQueryDesc();

        addScale.All  = new ComponentType[] { typeof(Joiner_C) };
        addScale.None = new ComponentType[] { typeof(NonUniformScale) };
        nonScaleQuery = GetEntityQuery(addScale);
        // 待添加颜色组件
        //待添加移动组件
        EntityQueryDesc addMover = new EntityQueryDesc();

        addMover.All  = new ComponentType[] { typeof(Joiner_C) };
        addMover.None = new ComponentType[] { typeof(Mover_C) };
        nonMoverQuery = GetEntityQuery(addMover);
        ////待添加View组件
        //EntityQueryDesc addView = new EntityQueryDesc ();
        //addView.All = new ComponentType[] { typeof (Joiner_C), typeof (MassPoint_C), typeof (NonUniformScale),typeof(RenderMesh) };
        ////addView.None = new ComponentType[] { typeof(JoinerView_C) };
        //nonViewQuery = GetEntityQuery (addView);
    }
    // private EntityQuery playerGameStatus;
    protected override void OnCreate()
    {
        // 创建用于存储游戏状态的实体 并进行数据初始化
        var entity = EntityManager.CreateEntity(typeof(LeoGameStatus));

        EntityManager.SetComponentData(entity, new LeoGameStatus
        {
            theGameStatus = TheGameStatus.NoReady
        });

        // 进行请求限制
        EntityQueryDesc entityQueryDesc = new EntityQueryDesc
        {
            All  = new ComponentType[] { typeof(LeoPlayerGameStatus), typeof(ReceiveRpcCommandRequestComponent) },
            None = new ComponentType[] { typeof(SendRpcCommandRequestComponent) }
        };

        entityQueryReceive = GetEntityQuery(entityQueryDesc);

        RequireForUpdate(entityQueryReceive); // 需要有才执行

        CommandBufferSystem = World.GetExistingSystem <EndInitializationEntityCommandBufferSystem>();

        /*EntityQueryDesc playerQueryDesc = new EntityQueryDesc
         * {
         *  All = new ComponentType[] { typeof(LeoPlayerGameStatus) },
         *  None=new ComponentType[] { typeof(SendRpcCommandRequestComponent),typeof(ReceiveRpcCommandRequestComponent) }
         * };
         * playerGameStatus= GetEntityQuery(playerQueryDesc);*/
    }
        public void TestAdd()
        {
            var e    = EntityManager.CreateEntity();
            var item = new Item {
                Center = new float3(50.5F), Size = new float3(1.1F)
            };

            EntityManager.AddComponentData(e, item);

            EntityCommandBufferSystem barrier = World.CreateSystem <BeginInitializationEntityCommandBufferSystem>();
            var system = World.CreateSystem <SystemTest>();

            system.Barrier = barrier;

            system.Update();
            EntityManager.CompleteAllJobs();
            barrier.Update();
            EntityManager.CompleteAllJobs();

            Assert.IsTrue(EntityManager.HasComponent(e, ComponentType.ReadOnly(typeof(ItemMirror))));
            Assert.AreEqual(1, EntityManager.GetComponentData <ItemMirror>(e).GetItemID);

            var sh = system.SpatialHash;

            Assert.AreEqual(1, sh.ItemCount);
            Assert.AreEqual(3 * 3 * 3, sh.BucketItemCount);

            var results = new NativeList <Item>(5, Allocator.TempJob);
            var bounds  = new Bounds(item.GetCenter(), item.GetSize());

            sh.CalculStartEndIteration(bounds, out var start, out var end);

            var hashPosition = new int3(0F);

            for (int x = start.x; x < end.x; ++x)
            {
                hashPosition.x = x;

                for (int y = start.y; y < end.y; ++y)
                {
                    hashPosition.y = y;

                    for (int z = start.z; z < end.z; ++z)
                    {
                        hashPosition.z = z;

                        var querryBound = new Bounds(sh.GetPositionVoxel(hashPosition, true), sh.CellSize * 0.99F);

                        results.Clear();
                        sh.Query(querryBound, results);

                        Assert.AreEqual(1, results.Length);
                        Assert.AreEqual(item, results[0]);
                    }
                }
            }

            results.Dispose();
        }
Exemplo n.º 29
0
        protected override void OnCreate()
        {
            base.OnCreate();

            this.cmdSystem = this.World.GetExistingSystem <BeginInitializationEntityCommandBufferSystem>();

            this.structureHitHolderSystem = this.World.GetExistingSystem <StructureHitMessageHolderAllocationSystem>();
        }
    protected override void OnCreate()
    {
        _finish = false;
        _raycastCurrentCount = 0;
        _raycastBatchSize    = 10;

        _barrier = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();
    }