コード例 #1
0
ファイル: InfectionSystem.cs プロジェクト: Beugeny/spreading
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var currentTime = UnityEngine.Time.time;
            var triggerJob  = new TriggerJob(GetComponentDataFromEntity <CreatureData>(), currentTime);

            return(triggerJob.Schedule(_stepPhysicsWorld.Simulation, ref _buildPhysicsWorld.PhysicsWorld, inputDeps));
        }
コード例 #2
0
    protected override void OnUpdate()
    {
        PhysicsWorld physicsWorld = World.GetOrCreateSystem <BuildPhysicsWorld>().PhysicsWorld;
        ISimulation  sim          = World.GetOrCreateSystem <StepPhysicsWorld>().Simulation;

        // Process all the collisions
        Entities.ForEach((DynamicBuffer <CollisionBuffer> collisions) =>
        {
            collisions.Clear();
        }).Run();

        var collisionJob = new CollisionJob()
        {
            m_collisions = GetBufferFromEntity <CollisionBuffer>(),
        };
        JobHandle collisionJobHandle = collisionJob.Schedule(sim, ref physicsWorld, Dependency);

        collisionJobHandle.Complete();

        // Process all the triggers
        Entities.ForEach((DynamicBuffer <TriggerBuffer> triggers) =>
        {
            triggers.Clear();
        }).Run();

        var triggerJob = new TriggerJob()
        {
            m_triggers = GetBufferFromEntity <TriggerBuffer>(),
        };
        JobHandle triggerJobHandle = triggerJob.Schedule(sim, ref physicsWorld, Dependency);

        triggerJobHandle.Complete();
    }
コード例 #3
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        TriggerJob triggerJob = new TriggerJob {
            physicsVelocityEntities = GetComponentDataFromEntity <PhysicsVelocity>()
        };

        return(triggerJob.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorld.PhysicsWorld, inputDeps));
    }
コード例 #4
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        TriggerJob triggerJob = new TriggerJob
        {
            speedEntities    = GetComponentDataFromEntity <SpeedData>(),
            entitiesToDelete = GetComponentDataFromEntity <DeleteTag>(),
            commandBuffer    = bufferSystem.CreateCommandBuffer()
        };

        return(triggerJob.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorld.PhysicsWorld, inputDeps));
    }
コード例 #5
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            TriggerJob triggerJob = new TriggerJob
            {
                goalEntities  = GetComponentDataFromEntity <GoalNetTag>(),
                laserEntities = GetComponentDataFromEntity <Speed_Laser_Component>(),
                commandBuffer = bufferSystem.CreateCommandBuffer()
            };

            return(triggerJob.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorld.PhysicsWorld, inputDeps));
        }
コード例 #6
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        float      yPos       = -GameManager.main.yBound + 2;
        TriggerJob triggerJob = new TriggerJob
        {
            yPos                = yPos,
            playerEntities      = GetComponentDataFromEntity <PlayerData>(),
            translationEntities = GetComponentDataFromEntity <Translation>()
        };

        return(triggerJob.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorld.PhysicsWorld, inputDeps));
    }
コード例 #7
0
 protected override void OnUpdate()
 {
     Dependency = new TriggerJob()
     {
         EffectBufferChunk   = GetArchetypeChunkBufferType <EFFECT_BUFFER>(true),
         SkillBufferChunk    = GetArchetypeChunkBufferType <SkillBuffer>(true),
         TargetChunk         = GetArchetypeChunkComponentType <Target>(true),
         ConsumerWriter      = _conusmerSystem.GetConsumerWriter(_query.CalculateChunkCount()),
         EffectContextWriter = GetContextWriter()
     }.ScheduleParallel(_query, Dependency);
     _conusmerSystem.RegisterTriggerDependency(Dependency);
 }
コード例 #8
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var destroyables = GetComponentDataFromEntity <DestroyableComponentData>();

            var job = new TriggerJob
            {
                m_destroyables = destroyables
            };

            var jobHandle = job.Schedule(m_stepPhysicsWorld.Simulation, ref m_physicsWorld.PhysicsWorld, inputDeps);

            jobHandle.Complete();
            return(jobHandle);
        }
コード例 #9
0
ファイル: PickupSystem.cs プロジェクト: denisrox/sneek
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        TriggerJob triggerJob = new TriggerJob
        {
            speedEntities    = GetComponentDataFromEntity <MoveComponent>(),
            entitiesToDelete = GetComponentDataFromEntity <DeleteTag>(),
            commandBuffer    = bufferSystem.CreateCommandBuffer()
        };

        JobHandle jobHandle =
            triggerJob.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorld.PhysicsWorld, inputDeps);

        jobHandle.Complete();
        //ХЗ зачем шедулер и зачем ему такие параметры
        return(default);
コード例 #10
0
ファイル: TriggerSystem.cs プロジェクト: july1997/Whales2
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var jobHandle = new TriggerJob
        {
            boidsEntities       = boidsGroup.ToEntityArray(Allocator.TempJob),
            playerEntities      = playerGroup.ToEntityArray(Allocator.TempJob),
            connectionEntities  = connectionGroup.ToEntityArray(Allocator.TempJob),
            connectionComponent = connectionGroup.ToComponentDataArray <CommandTargetComponent>(Allocator.TempJob),
            CommandBuffer       = _bufferSystem.CreateCommandBuffer()
        }.Schedule(_stepPhysicsWorldSystem.Simulation, ref _buildPhysicsWorldSystem.PhysicsWorld, inputDeps);

        _bufferSystem.AddJobHandleForProducer(jobHandle);

        return(jobHandle);
    }
コード例 #11
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        TriggerJob triggerJob = new TriggerJob {
            commandBuffer       = _ecb.CreateCommandBuffer(),
            damaeDealerEntities = GetComponentDataFromEntity <DamageDealerData>(true),
            planetEntities      = GetComponentDataFromEntity <PlanetTag>(true),
            healthEntities      = GetComponentDataFromEntity <HealthData>()
        };


        JobHandle triggerJobHandle = triggerJob.Schedule(_stepPhysicsWorld.Simulation, ref _buildPhysicsWorld.PhysicsWorld, inputDeps);

        _ecb.AddJobHandleForProducer(triggerJobHandle);

        return(triggerJobHandle);
    }
コード例 #12
0
    protected override void OnUpdate()
    {
        if (this.IsLevel())
        {
            //TODO:parallel?
            var jobHandle = new TriggerJob
            {
                PlayerDataGroup = GetComponentDataFromEntity <PlayerData>(),
                EnemyDataGroup  = GetComponentDataFromEntity <EnemyData>(),
                damageToPlayer  = GameDataManager.instance.EnemyDamage,
            }
            .Schedule(stepWorld.Simulation, ref physicsWorld.PhysicsWorld, Dependency);

            jobHandle.Complete();
        }
    }
コード例 #13
0
    protected override void OnUpdate()
    {
        TriggerJob triggerJob = new TriggerJob
        {
            playerEntity     = GetComponentDataFromEntity <PlayerTag>(),
            pickableEntity   = GetComponentDataFromEntity <CollectableTag>(),
            waitDeleteEntity = GetComponentDataFromEntity <DeleteTag>(),
            commandBuffer    = m_BufferSystem.CreateCommandBuffer()
        };

        // 由于TriggerJob涉及到Unity.Physics内的方法,需要传入物理系统的依赖,然TriggerJob执行在物理系统的基本逻辑之后
        Dependency = triggerJob.Schedule(m_StepPhysicsWorld.Simulation, ref m_BuildPhysicsWorld.PhysicsWorld, Dependency);
        // 当在Job的CommandBuffer执行了写的操作(比如AddComponent),就需要调用AddJobHandleForProducer(JobHandle)把当前System的JobHandle依赖加入缓存系统的依赖队列
        // 目前我们的Job集成自IJob,只是一个线程上运行,如果有集成自IJobParaller或者IJobChunk的,还要调用ToConcurrent(),具体调用方式可查阅官方文档
        // https://docs.unity3d.com/Packages/[email protected]/api/Unity.Entities.EntityCommandBufferSystem.html
        m_BufferSystem.AddJobHandleForProducer(Dependency);
    }
コード例 #14
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var job = new TriggerJob
        {
            cuterEntities   = GetComponentDataFromEntity <PlayerComponentData>(),
            cutableEntities = GetComponentDataFromEntity <Cutable>(),
            waitingToBeDestroyedEntities = GetComponentDataFromEntity <DestroyComponent>(),
            m_entityCommandBuffer        = m_endSimulationEntityCommandBufferSystem.CreateCommandBuffer()
        };

        var jobHandle = job.Schedule(m_physicsStep.Simulation, ref m_physicsWorld.PhysicsWorld, inputDeps);

        m_endSimulationEntityCommandBufferSystem.AddJobHandleForProducer(jobHandle);
        jobHandle.Complete();

        return(jobHandle);
    }
コード例 #15
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        float3 randomDir = new float3(
            UnityEngine.Random.Range(-10f, 10f),
            UnityEngine.Random.Range(2f, 10f),
            UnityEngine.Random.Range(-10f, 10f)
            );

        TriggerJob job = new TriggerJob
        {
            physicsVelocityEntities = GetComponentDataFromEntity <PhysicsVelocity>(),
            randomLinearVelocity    = randomDir
        };

        JobHandle handle = job.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorld.PhysicsWorld, inputDeps);

        return(handle);
    }
コード例 #16
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        EntityCommandBuffer EndSimECB = EndSimECBSystem.CreateCommandBuffer();

        var triggerJob = new TriggerJob
        {
            enemiesGroup     = GetComponentDataFromEntity <EnemyTag>(),
            playersGroup     = GetComponentDataFromEntity <PlayerTag>(),
            projectilesGroup = GetComponentDataFromEntity <ProjectileTag>(),
            ECB = EndSimECB,
        };
        var jobHandle = triggerJob.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorld.PhysicsWorld, inputDeps);

        EndSimECBSystem.AddJobHandleForProducer(jobHandle);
        EndFramePhysicsSystem.HandlesToWaitFor.Add(jobHandle);

        return(jobHandle);
    }
コード例 #17
0
    protected override void OnUpdate()
    {
        Entities
        .ForEach((ref FreeSpotData freeSpot) =>
        {
            freeSpot.Value = true;
        }).Schedule();
        TriggerJob triggerJob = new TriggerJob
        {
            damageData  = GetComponentDataFromEntity <DamageData>(),
            takeDamage  = GetComponentDataFromEntity <TakeDamageData>(),
            destroyData = GetComponentDataFromEntity <DestroyData>(),
            colorData   = GetComponentDataFromEntity <ColorData>(),
            freeSpot    = GetComponentDataFromEntity <FreeSpotData>()
        };
        JobHandle job = triggerJob.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorld.PhysicsWorld, Dependency);

        job.Complete();
    }
コード例 #18
0
    protected override void OnUpdate()
    {
        if (this.IsLevel())
        {
            var localCommandBuffer = commandBuffer.CreateCommandBuffer();

            var jobHandle = new TriggerJob
            {
                BulletDataGroup  = GetComponentDataFromEntity <BulletData>(),
                EnemyDataGroup   = GetComponentDataFromEntity <EnemyData>(),
                projectileDamage = GameDataManager.instance.BulletDamage,
                commandBuffer    = localCommandBuffer
            }
            .Schedule(stepWorld.Simulation, ref physicsWorld.PhysicsWorld, Dependency);

            commandBuffer.AddJobHandleForProducer(jobHandle);

            jobHandle.Complete();
        }
    }
コード例 #19
0
        protected override void OnUpdate()
        {
            // If the consumer won't run, there is no point in tirgerring the effects...
            // This also avoid the creation of a stream that would never be disposed of.
            if (!_conusmerSystem.ShouldRunSystem())
            {
                return;
            }

            Dependency = new TriggerJob()
            {
                EffectBufferChunk   = GetArchetypeChunkBufferType <EFFECT_BUFFER>(true),
                AbilityBufferChunk  = GetArchetypeChunkBufferType <AbilityBuffer>(true),
                TargetChunk         = GetArchetypeChunkComponentType <Target>(true),
                EntityChunk         = GetArchetypeChunkEntityType(),
                ConsumerWriter      = _conusmerSystem.CreateConsumerWriter(_query.CalculateChunkCount()),
                EffectContextWriter = GetContextWriter()
            }.ScheduleParallel(_query, Dependency);

            // Tell the consumer to wait for ths trigger job to finish before starting to consume the effects.
            _conusmerSystem.RegisterTriggerDependency(Dependency);
        }