示例#1
0
    protected override JobHandle OnUpdate(JobHandle inputDependencies)
    {
        var job = new CollisionEventSystemJob()
        {
            EntityCommandBuffer = m_EntityCommandBufferSystem.CreateCommandBuffer(),
            EntitiesToDestroy   = GetComponentDataFromEntity <DestroyOnCollideTag>(true),
            EntitiesToDisable   = GetComponentDataFromEntity <DisableOnCollideTag>(true)
        }.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorldSystem.PhysicsWorld,
                   inputDependencies);

        m_EntityCommandBufferSystem.AddJobHandleForProducer(job);
        return(job);
    }
    protected override JobHandle OnUpdate(JobHandle inputDependencies)
    {
        JobHandle job = new CollisionEventSystemJob()
        {
            EntitiesWithOnCollideEffectsOnOtherBuffer = GetBufferFromEntity <OnCollideEffectsOnOtherBuffer>(true),
            EntitiesWithOnCollideEffectsOnSelfBuffer  = GetBufferFromEntity <OnCollideEffectsOnSelfBuffer>(true),
            EffectCommandQueue = m_EffectBufferSystem.CreateCommandsQueue()
        }.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorldSystem.PhysicsWorld,
                   inputDependencies);

        AddJobHandleForConsumer(job);
        return(job);
    }
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var job = new CollisionEventSystemJob();

        job.bulletRef = GetComponentDataFromEntity <BulletComponent>(isReadOnly: false);
        job.healthRef = GetComponentDataFromEntity <HealthComponent>(isReadOnly: false);
        var jobResult = job.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorldSystem.PhysicsWorld, inputDeps);

        var commandBuffer = endSimulationCommandBuffer.CreateCommandBuffer().AsParallelWriter();
        var result        = Entities.ForEach((Entity entity, int entityInQueryIndex, ref BulletComponent bullet) => {
            if (bullet.destroyed)
            {
                commandBuffer.DestroyEntity(entityInQueryIndex, entity);
            }
        }).Schedule(jobResult);

        endSimulationCommandBuffer.AddJobHandleForProducer(result);
        return(result);
    }
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        // параллельная работа, которая проходит по всем триггерам;
        var job = new CollisionEventSystemJob();

        job.HealthRef    = GetComponentDataFromEntity <HealthComponent>(isReadOnly: false);
        job.MagicFireRef = GetComponentDataFromEntity <MagicFireComponent>(isReadOnly: false);
        var jobResult = job.Schedule(_step.Simulation, ref _world.PhysicsWorld, inputDeps);

        var commandBuffer = _endSimulationEntityCommandBufferSystem.CreateCommandBuffer().AsParallelWriter();

        // собираем команды на удаление Entity магических снарядов, которые были уничтожены;
        var result = Entities.ForEach((Entity entity, int entityInQueryIndex, ref MagicFireComponent magicFire) =>
        {
            if (magicFire.Destroyed)
            {
                commandBuffer.DestroyEntity(entityInQueryIndex, entity);
            }
        }).Schedule(jobResult);

        // настройка зависимостей;
        _endSimulationEntityCommandBufferSystem.AddJobHandleForProducer(result);
        return(result);
    }
示例#5
0
    protected override JobHandle OnUpdate(JobHandle inputDependencies)
    {
        var triggerStayRefsFromEntity = GetBufferFromEntity <TriggerStayRef>();

        var job1 = new ClearTriggers
        {
            TriggerStayRefsFromEntity = triggerStayRefsFromEntity
        }.Schedule(this, inputDependencies);

        inputDependencies = JobHandle.CombineDependencies(inputDependencies, job1, stepPhysicsWorld.FinalSimulationJobHandle);

        var job2 = new CollisionEventSystemJob()
        {
            TriggerStayRefsFromEntity = triggerStayRefsFromEntity,
            agentData       = GetComponentDataFromEntity <AgentData>(),
            translationData = GetComponentDataFromEntity <Translation>()
        }.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorldSystem.PhysicsWorld, inputDependencies);

        inputDependencies = JobHandle.CombineDependencies(inputDependencies, job2);

        endFramePhysicsSystem.HandlesToWaitFor.Add(inputDependencies);

        return(inputDependencies);
    }