Exemplo n.º 1
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            PlayerInputSystem.ClickData clickData = _entityManager.GetComponentData <PlayerInputSystem.ClickData>(_clickDataEntity);

            var job = new CursorSpawnJob
            {
                m_ClickData   = clickData,
                CommandBuffer = _entityCommandBufferSystem.CreateCommandBuffer()
            }.ScheduleSingle(this, inputDeps);

            _entityCommandBufferSystem.AddJobHandleForProducer(job);

            return(job);
        }
Exemplo n.º 2
0
        protected override JobHandle OnUpdate(JobHandle handle)
        {
            var commandBuffer = commandBufferSystem.CreateCommandBuffer();

            var despawnJob = new DespawnJob {
                CommandBuffer = commandBuffer,
                DeltaTime     = Time.deltaTime,
            };

            handle = despawnJob.Schedule(this, handle);
            commandBufferSystem.AddJobHandleForProducer(handle);

            return(handle);
        }
Exemplo n.º 3
0
    protected override void OnUpdate()
    {
        Entity grid;

        using (var tmp = mGridQuery.ToEntityArray(Allocator.TempJob))
            grid = tmp.Length > 0 ? tmp[0] : Entity.Null;

        Debug.Assert(grid != Entity.Null);

        var cellSize      = EntityManager.GetComponentData <CGridCellSize>(grid).Value;
        var cellCount     = EntityManager.GetComponentData <CGridCellCount>(grid).Value;
        var gridPos       = EntityManager.GetComponentData <CGridPos>(grid).Value;
        var stackHeights  = EntityManager.GetBuffer <BStackHeights>(grid);
        var floorStart    = -Settings.Instance.FieldSize.y * 0.5f;
        var resourcesSize = Settings.Instance.ResourceSize;

        var ecb = mCommandBufferSystem.CreateCommandBuffer().AsParallelWriter();

        Entities
        .WithAll <TResource>()
        .WithNone <CHeldBy, CStackHeight>()
        .ForEach((Entity e, int entityInQueryIndex, ref Translation translation, ref CVelocity velocity, in CGridIndex idx) =>
        {
            var cellStackIdx = idx.Value.y * cellCount.x + idx.Value.x;
            var stackHeight  = stackHeights[cellStackIdx].Value;
            var floorHeight  = floorStart + (stackHeight + 0.5f) * resourcesSize;

            if (translation.Value.y < floorHeight)
            {
                if (floorHeight + resourcesSize < -floorStart)
                {
                    translation.Value = new float3(translation.Value.xz, floorHeight).xzy;
                    velocity.Value    = float3.zero;
                    ecb.AddComponent(entityInQueryIndex, e, new CStackHeight {
                        Value = stackHeight++
                    });
                    stackHeights[cellStackIdx] = new BStackHeights {
                        Value = stackHeight
                    };
                }
                else
                {
                    ecb.DestroyEntity(entityInQueryIndex, e);
                }
            }
        })
        .Schedule();
        mCommandBufferSystem.AddJobHandleForProducer(Dependency);
    }
Exemplo n.º 4
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            inputDeps = new TickJob()
            {
                DeltaTime = Time.DeltaTime
            }.Schedule(this, inputDeps);

            inputDeps = Tick(inputDeps);

            inputDeps = new TickResetJob {
            }.Schedule(this, inputDeps);

            m_EntityCommandBuffer.AddJobHandleForProducer(inputDeps);
            return(inputDeps);
        }
Exemplo n.º 5
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            JobHandle jobHandle = new TriggerCollisonCheckJob
            {
                Enemies              = GetComponentDataFromEntity <UnitEnemy>(true),
                Projectiles          = GetComponentDataFromEntity <ProjectileData>(true),
                AllSystemsHealthData = GetComponentDataFromEntity <HealthData>(),

                EntityCommandBuffer = _commandBufferSystem.CreateCommandBuffer()
            }.Schedule(_stepPhysicsWorldSystem.Simulation, ref _buildPhysicsWorldSystem.PhysicsWorld, inputDeps);

            _commandBufferSystem.AddJobHandleForProducer(jobHandle);

            return(jobHandle);
        }
        protected override void OnUpdate( )
        {
            EntityCommandBuffer.ParallelWriter ecbp = becb.CreateCommandBuffer().AsParallelWriter();

            Entities.WithName("InitializePathNodeAsJob")
            .WithAll <PathNodeTag> ()
            .WithNone <PathNodeElevationComponent> ()
            .ForEach((Entity nodeEntity, int entityInQueryIndex) =>
            {
                ecbp.AddComponent <PathNodeElevationComponent> (entityInQueryIndex, nodeEntity);
                ecbp.AddBuffer <PathNodeLinksBuffer> (entityInQueryIndex, nodeEntity);
            }).ScheduleParallel();

            becb.AddJobHandleForProducer(Dependency);
        }
Exemplo n.º 7
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var playerEntity = _navAgentEntityQuery.GetSingletonEntity();
            var navAgent     = _entityManager.GetComponentData <NavAgent>(playerEntity);

            JobHandle job = new ProjectileSpawnRequestJob {
                CommandBuffer = _entityCommandBufferSystem.CreateCommandBuffer(),
                Owner         = playerEntity,
                StartPosition = navAgent.Position
            }.Schedule(this, inputDeps);

            _entityCommandBufferSystem.AddJobHandleForProducer(job);

            return(job);
        }
Exemplo n.º 8
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var commandBuffer = _entityCommandBufferSystem.CreateCommandBuffer().ToConcurrent();

            var handle = inputDeps;
            var job    = new MyJob {
                CommandBuffer = commandBuffer,
                Time          = UTJ.Time.GetCurrent(),
            };

            handle = job.Schedule(this, dependsOn: handle);
            _entityCommandBufferSystem.AddJobHandleForProducer(handle);

            return(handle);
        }
Exemplo n.º 9
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var throwingArmsComponentArray = m_ArmDataQuery.ToComponentDataArray <ThrowingArmsSharedDataComponent>(Allocator.TempJob);

        var job = new TinCanInitJob {
            CommandBuffer  = m_EntityCommandBufferSystem.CreateCommandBuffer().ToConcurrent(),
            Rand           = new Unity.Mathematics.Random(43255),
            TotalArmsWidth = throwingArmsComponentArray[0].ConveyorWidth
        }.Schedule(this, inputDeps);

        m_EntityCommandBufferSystem.AddJobHandleForProducer(job);
        throwingArmsComponentArray.Dispose();

        return(job);
    }
Exemplo n.º 10
0
    protected override void OnUpdate()
    {
        var ecb = mCommandBufferSystem.CreateCommandBuffer().AsParallelWriter();

        Entities
        .WithAll <TDeath>()
        .ForEach((Entity e, int entityInQueryIndex) =>
        {
            ecb.DestroyEntity(entityInQueryIndex, e);
        })
        .WithName("RemoveDead")
        .ScheduleParallel();

        mCommandBufferSystem.AddJobHandleForProducer(Dependency);
    }
Exemplo n.º 11
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var job = new SetInitialHeadingJob
        {
            CommandBuffer = m_EntityCommandBufferSystem.CreateCommandBuffer(),
            Random        = new Random(0xabcdef)
        };
        //this needs ti be single or else it will error out
        var handle = job.ScheduleSingle(this, inputDeps);

        // SpawnJob runs in parallel with no sync point until the barrier system executes.
        // When the barrier system executes we want to complete the SpawnJob and then play back the commands (Creating the entities and placing them).
        // We need to tell the barrier system which job it needs to complete before it can play back the commands.
        m_EntityCommandBufferSystem.AddJobHandleForProducer(handle);
        return(handle);
    }
Exemplo n.º 12
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var projectileSpawner = _entityManager.GetComponentData <ProjectileSpawnerComponent>(
                _spawnerEntityQuery.GetSingletonEntity()
                );

            JobHandle job = new ProjectileSpawnJob
            {
                CommandBuffer = _entityCommandBufferSystem.CreateCommandBuffer(),
                Prefab        = projectileSpawner.Prefab
            }.Schedule(this, inputDeps);

            _entityCommandBufferSystem.AddJobHandleForProducer(job);

            return(job);
        }
    protected override JobHandle OnUpdate(JobHandle inputDependencies)
    {
        var playersScore = m_Group.ToComponentDataArray <PlayerScoreData>(Allocator.TempJob);
        var job          = new BallGoalCheckSystemJob()
        {
            CommandBuffer = m_EntityCommandBufferSystem.CreateCommandBuffer().ToConcurrent(),
            PlayersScore  = playersScore
        };

        inputDependencies = job.Run(this, inputDependencies);
        m_EntityCommandBufferSystem.AddJobHandleForProducer(inputDependencies);
        inputDependencies.Complete();
        playersScore.Dispose();

        return(inputDependencies);
    }
        public JobHandle ProcessSpawnProjectileJob(EntityQuery query, BeginInitializationEntityCommandBufferSystem buffer, JobHandle inputDependencies = default(JobHandle))
        {
            SpawnProjectileJob job = new SpawnProjectileJob
            {
                LastSystemVersion = this.LastSystemVersion,
                WeaponType        = GetArchetypeChunkComponentType <Weapon>(true),
                RotationType      = GetArchetypeChunkComponentType <Rotation>(true),
                TranslationType   = GetArchetypeChunkComponentType <Translation>(true),
                CommandBuffer     = buffer.CreateCommandBuffer()
            };

            JobHandle handle = job.Schedule(query, inputDependencies);

            buffer.AddJobHandleForProducer(handle);

            return(handle);
        }
    protected override void OnUpdate()
    {
        var commandBuffer = bufferSystem.CreateCommandBuffer().AsParallelWriter();

        var random    = UnityEngine.Random.Range(0, Mathf.Infinity);
        var rnd       = Unity.Mathematics.Random.CreateFromIndex((uint)random);
        var deltaTime = Time.DeltaTime;

        Entities
        .WithName("MadShotSpawnerSystem")
        .WithBurst(Unity.Burst.FloatMode.Default, Unity.Burst.FloatPrecision.Standard, true)
        .ForEach((Entity entity, int entityInQueryIndex, ref WeaponComponent weapon, ref MadShotPowerUpComponent madshot, ref Rotation rotation, ref Translation translation, in MadShotSpawnerComponent spawner) =>
        {
            madshot.timeLeft -= deltaTime;
            if (madshot.timeLeft > 0)
            {
                if (weapon.shooting)
                {
                    for (int i = 0; i < 10; i++)
                    {
                        var instance = commandBuffer.Instantiate(entityInQueryIndex, spawner.prefab);

                        float3 fwd = math.forward(rotation.Value) * i;
                        commandBuffer.SetComponent(entityInQueryIndex, instance, new Translation
                        {
                            Value = translation.Value + fwd * 2
                        });

                        commandBuffer.SetComponent(entityInQueryIndex, instance, new MoverComponent
                        {
                            speed     = 5,
                            direction = fwd
                        });
                        commandBuffer.AddComponent(entityInQueryIndex, instance, new DestroyOnNewWorldTag());
                        commandBuffer.AddComponent(entityInQueryIndex, instance, new MadShotPowerUpComponent());
                    }
                }
            }
            else
            {
                commandBuffer.RemoveComponent <MadShotPowerUpComponent>(entityInQueryIndex, entity);
            }
        }).ScheduleParallel();

        bufferSystem.AddJobHandleForProducer(Dependency);
    }
    protected override void OnUpdate()
    {
        float deltaTime     = Time.DeltaTime;
        var   commandBuffer = bufferSystem.CreateCommandBuffer().AsParallelWriter();

        Entities
        .ForEach((Entity entity, int entityInQueryIndex, ref SelfDestroyComponent destroyComponent) =>
        {
            destroyComponent.currentLifeTime += deltaTime;
            if (destroyComponent.currentLifeTime >= destroyComponent.lifeSpan)
            {
                commandBuffer.DestroyEntity(entityInQueryIndex, entity);
            }
        }).ScheduleParallel();

        bufferSystem.AddJobHandleForProducer(Dependency);
    }
Exemplo n.º 17
0
        protected override void OnUpdate()
        {
            var   ecbPackage = m_ecbSystem.CreateCommandBuffer();
            var   ecb        = ecbPackage.ToConcurrent();
            float dt         = Time.DeltaTime;

            Entities.ForEach((Entity entity, int entityInQueryIndex, ref TimeToLive timeToLive) =>
            {
                timeToLive.timeToLive -= dt;
                if (timeToLive.timeToLive < 0f)
                {
                    ecb.DestroyEntity(entityInQueryIndex, entity);
                }
            }).ScheduleParallel();

            m_ecbSystem.AddJobHandleForProducer(Dependency);
        }
Exemplo n.º 18
0
    protected override void OnUpdate()
    {
        var ecb = ecbSystem.CreateCommandBuffer().AsParallelWriter();

        var networkIdLookup   = GetComponentDataFromEntity <NetworkIdComponent>();
        var movableCubeLookup = GetComponentDataFromEntity <MovableCube>();

        var ghostPrefabBufferLookup = GetBufferFromEntity <GhostPrefabBuffer>();

        var ghostPrefabCollectionSingleton = GetSingletonEntity <GhostPrefabCollectionComponent>();

        Entities
        .WithReadOnly(networkIdLookup)
        .WithReadOnly(movableCubeLookup)

        .WithReadOnly(ghostPrefabBufferLookup)

        .WithNone <SendRpcCommandRequestComponent>()
        .ForEach((Entity reqEnt, int entityInQueryIndex, ref GoInGameRequest req, ref ReceiveRpcCommandRequestComponent reqSrc) => {
            ecb.AddComponent <NetworkStreamInGame>(entityInQueryIndex, reqSrc.SourceConnection);
            UnityEngine.Debug.Log(string.Format("Server setting connection {0} to in game", networkIdLookup[reqSrc.SourceConnection].Value));
            var prefab  = Entity.Null;
            var prefabs = ghostPrefabBufferLookup[ghostPrefabCollectionSingleton];
            for (int ghostId = 0; ghostId < prefabs.Length; ++ghostId)
            {
                if (movableCubeLookup.HasComponent(prefabs[ghostId].Value))
                {
                    prefab = prefabs[ghostId].Value;
                }
            }
            var player = ecb.Instantiate(entityInQueryIndex, prefab);
            ecb.SetComponent(entityInQueryIndex, player, new GhostOwnerComponent {
                NetworkId = networkIdLookup[reqSrc.SourceConnection].Value
            });
            ecb.AddBuffer <CubeInput>(entityInQueryIndex, player);

            ecb.SetComponent(entityInQueryIndex, reqSrc.SourceConnection, new CommandTargetComponent {
                targetEntity = player
            });

            ecb.DestroyEntity(entityInQueryIndex, reqEnt);
        })
        .ScheduleParallel();

        ecbSystem.AddJobHandleForProducer(Dependency);
    }
Exemplo n.º 19
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        translationTypeFromEntity = GetComponentDataFromEntity <Translation>(true);
        scaleTypeFromEntity       = GetComponentDataFromEntity <Scale>(true);

        var reachingJob = new ReachingArmJob()
        {
            translationsFromEntity = translationTypeFromEntity,
            scalesFromEntity       = scaleTypeFromEntity,
            ecb       = ecbSystem.CreateCommandBuffer().ToConcurrent(),
            deltaTime = Time.deltaTime
        };
        var handle = reachingJob.Schedule(this, inputDeps);

        ecbSystem.AddJobHandleForProducer(handle);
        return(handle);
    }
Exemplo n.º 20
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var settings        = GetSingleton <SettingsComponent>();
            var singletonEntity = GetSingletonEntity <SettingsComponent>();

            if (_positionsQuery.CalculateEntityCount() == settings.Width * settings.Height)
            {
                return(inputDeps);
            }

            var helper = new ArrayHelper(settings.Width, settings.Height);

            var cachedEntities = new NativeArray <Entity>(settings.Width * settings.Height, Allocator.TempJob);
            var randomValues   = new NativeArray <int>(settings.Width * settings.Height, Allocator.TempJob);

            for (var i = 0; i < settings.Width * settings.Height; ++i)
            {
                randomValues[i] = Random.Range(0, settings.SetSize);
            }

            var cacheJob = new CacheJob
            {
                CachedEntities = cachedEntities,
                Entities       = _positionsQuery.ToEntityArray(Allocator.TempJob),
                Positions      = _positionsQuery.ToComponentDataArray <PositionComponent>(Allocator.TempJob),
                Helper         = helper
            };

            var spawnJob = new SpawnJob
            {
                CachedEntities  = cachedEntities,
                RandomValues    = randomValues,
                GemSet          = GetBufferFromEntity <GemSet>(true),
                CommandBuffer   = _commandBuffer.CreateCommandBuffer(),
                SingletonEntity = singletonEntity,
                Helper          = helper
            };

            var spawnHandler = cacheJob.Schedule(_positionsQuery.CalculateEntityCount(), 32, inputDeps);

            spawnHandler = spawnJob.Schedule(spawnHandler);

            _commandBuffer.AddJobHandleForProducer(spawnHandler);

            return(spawnHandler);
        }
Exemplo n.º 21
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var generateBURSTJob = new GenerateChunkBURSTJob
        {
            ChunkSize = ChunkMarkGenerateJS.ChunkSize,
            cbd       = GetBufferFromEntity <ChunkBufferData>()
        };
        var handle = generateBURSTJob.Schedule(this, inputDeps);

        var generateJob = new GenerateChunkJob
        {
            commandBuffer = ecbSystem.CreateCommandBuffer().ToConcurrent(),
        };

        handle = generateJob.Schedule(this, handle);
        ecbSystem.AddJobHandleForProducer(handle);
        return(handle);
    }
Exemplo n.º 22
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var cleanClicksJob = new CleanClicksJob
            {
                CommandBuffer = _commandBuffer.CreateCommandBuffer(),
                Entities      = _clickedQuery.ToEntityArray(Allocator.TempJob)
            };

            var clicksJobHandle = cleanClicksJob.Schedule(inputDeps);

            var cleanInGroupsJob = new CleanInGroupsJob();

            var cleanInGroupsJobHandle = cleanInGroupsJob.Schedule(this, inputDeps);

            _commandBuffer.AddJobHandleForProducer(clicksJobHandle);

            return(JobHandle.CombineDependencies(clicksJobHandle, cleanInGroupsJobHandle));
        }
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        //Instead of performing structural changes directly, a Job can add a command to an EntityCommandBuffer to perform such changes on the main thread after the Job has finished.
        //Command buffers allow you to perform any, potentially costly, calculations on a worker thread, while queuing up the actual insertions and deletions for later.

        // Schedule the job that will add Instantiate commands to the EntityCommandBuffer.
        var job = new SpawnJob
        {
            CommandBuffer = m_EntityCommandBufferSystem.CreateCommandBuffer()
        }.ScheduleSingle(this, inputDeps);

        // SpawnJob runs in parallel with no sync point until the barrier system executes.
        // When the barrier system executes we want to complete the SpawnJob and then play back the commands (Creating the entities and placing them).
        // We need to tell the barrier system which job it needs to complete before it can play back the commands.
        m_EntityCommandBufferSystem.AddJobHandleForProducer(job);

        return(job);
    }
Exemplo n.º 24
0
    /// <summary>
    /// 如果有新地图,则启动任务
    /// </summary>
    /// <param name="inputDeps">依赖</param>
    /// <returns>任务句柄</returns>
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var job = new CalculateJob
        {
            CommandBuffer = m_EntityCommandBufferSystem.CreateCommandBuffer().ToConcurrent(),
        }.Schedule(m_CellGroup, inputDeps);

        m_EntityCommandBufferSystem.AddJobHandleForProducer(job);
        job.Complete();

        if (job.IsCompleted)
        {
            Debug.Log("CalculateJob IsCompleted:" + job.IsCompleted);
            MainWorld.Instance.RenderMesh();
        }

        return(job);
    }
Exemplo n.º 25
0
        protected override JobHandle OnUpdate(JobHandle handle)
        {
            var job = new Job {
                Forward       = UnityEngine.Input.GetKey("w") ? ButtonState.Pressed : ButtonState.Released,
                Backward      = UnityEngine.Input.GetKey("s") ? ButtonState.Pressed : ButtonState.Released,
                Left          = UnityEngine.Input.GetKey("a") ? ButtonState.Pressed : ButtonState.Released,
                Right         = UnityEngine.Input.GetKey("d") ? ButtonState.Pressed : ButtonState.Released,
                Fire          = UnityEngine.Input.GetKey(KeyCode.Return) ? ButtonState.Pressed : ButtonState.Released,
                Special       = UnityEngine.Input.GetKey(KeyCode.Space) ? ButtonState.Pressed : ButtonState.Released,
                DeltaTime     = Time.deltaTime,
                CommandBuffer = commandBufferSystem.CreateCommandBuffer()
            };

            handle = job.Schedule(this, handle);
            commandBufferSystem.AddJobHandleForProducer(handle);

            return(handle);
        }
Exemplo n.º 26
0
    protected override void OnUpdate()
    {
        var ecb = ecbSystem.CreateCommandBuffer().AsParallelWriter();

        Entities
        .WithNone <NetworkStreamInGame>()
        .ForEach((Entity ent, int entityInQueryIndex, ref NetworkIdComponent id) => {
            ecb.AddComponent <NetworkStreamInGame>(entityInQueryIndex, ent);
            var req = ecb.CreateEntity(entityInQueryIndex);
            ecb.AddComponent <GoInGameRequest>(entityInQueryIndex, req);
            ecb.AddComponent(entityInQueryIndex, req, new SendRpcCommandRequestComponent {
                TargetConnection = ent
            });
        })
        .ScheduleParallel();

        ecbSystem.AddJobHandleForProducer(Dependency);
    }
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var   tinCansArray         = m_TinCanQuery.ToEntityArray(Allocator.TempJob);
        var   tinCanPositionsArray = m_TinCanQuery.ToComponentDataArray <Translation>(Allocator.TempJob);
        var   ecb       = m_EntityCommandBufferSystem.CreateCommandBuffer().ToConcurrent();
        float deltaTime = Time.deltaTime;
        var   jobHandle = inputDeps;

        jobHandle = Entities
                    .WithName("CheckHitCanSystem")
                    .WithAll <RockComponent, InFlightTag>()
                    .WithDeallocateOnJobCompletion(tinCansArray)
                    .WithDeallocateOnJobCompletion(tinCanPositionsArray)
                    .ForEach(
            (int entityInQueryIndex, Entity e, ref Translation pos, ref RigidBodyComponent rigidBody) =>
        {
            int index = 0;
            while (index < tinCansArray.Length)
            {
                Translation tcpos = tinCanPositionsArray[index];
                if (math.distance(pos.Value, tcpos.Value) < 0.25f)
                {
                    var tce = tinCansArray[index];
                    ecb.RemoveComponent <ConveyorComponent>(entityInQueryIndex, tce);
                    ecb.AddComponent(entityInQueryIndex, tce, new InFlightTag());

                    Unity.Mathematics.Random rand      = new Unity.Mathematics.Random((uint)index + 1);
                    RigidBodyComponent tinCanRigidBody = new RigidBodyComponent {
                        Gravity = 20f
                    };
                    tinCanRigidBody.Velocity        = rigidBody.Velocity;
                    tinCanRigidBody.AngularVelocity = math.radians(math.normalize(rand.NextFloat3()) * math.length(rigidBody.Velocity) * 40f);
                    ecb.SetComponent(entityInQueryIndex, tce, tinCanRigidBody);
                    break;
                }
                index++;
            }
        })
                    .Schedule(jobHandle);

        m_EntityCommandBufferSystem.AddJobHandleForProducer(jobHandle);

        return(jobHandle);
    }
Exemplo n.º 28
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        Entities
        .WithAll <RecalcTag>()
        .WithStructuralChanges()
        .ForEach((Entity entity, ref OJO_RequestRecalculationData recalc) =>
        {
            if (recalc.requestState == MyCode.RequestState.InitializeRequest)
            {
                var commandBuffer = m_EntityCommandBufferSystem.CreateCommandBuffer();     //.ToConcurrent();

                AppManager.instance.requestNewPath(entity);

                commandBuffer.RemoveComponent <RecalcTag>(entity);
            }
        }).Run();

        m_EntityCommandBufferSystem.AddJobHandleForProducer(inputDeps);
        return(default);
Exemplo n.º 29
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        rockHeldCompTypeFromEntity = GetComponentDataFromEntity <RockHeldComponent>(true);
        translationTypeFromEntity  = GetComponentDataFromEntity <Translation>(true);

        var job = new HoldingArmJob()
        {
            translationsFromEntity  = translationTypeFromEntity,
            EntitiesBucketedByIndex = BucketSystems.TinCanEntitiesBucketedByIndex,
            rockHeldCompsFromEntity = rockHeldCompTypeFromEntity,
            deltaTime = Time.deltaTime,
            ecb       = ecbSystem.CreateCommandBuffer().ToConcurrent(),
        };
        var handle = job.Schedule(this, inputDeps);

        World.GetOrCreateSystem <UnbucketSystems>().AddJobHandle(handle);
        ecbSystem.AddJobHandleForProducer(handle);
        return(handle);
    }
Exemplo n.º 30
0
    protected override void OnUpdate()
    {
        var commandBuffer = bufferSystem.CreateCommandBuffer().AsParallelWriter();

        Entities
        .WithAll <EnemyDestroyedTag>()
        .ForEach((Entity entity, int entityInQueryIndex, ref PowerUpSpawnerComponent spawner, ref Translation translation) =>
        {
            var instance = commandBuffer.Instantiate(entityInQueryIndex, spawner.powerUp);
            commandBuffer.SetComponent(entityInQueryIndex, instance, new Translation
            {
                Value = translation.Value
            });
            commandBuffer.AddComponent(entityInQueryIndex, instance, new DestroyOnNewWorldTag());
            commandBuffer.DestroyEntity(entityInQueryIndex, entity);
        }).ScheduleParallel();

        bufferSystem.AddJobHandleForProducer(Dependency);
    }