Ejemplo n.º 1
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var entityType = GetArchetypeChunkEntityType();

        JobHandle playerHandle;
        var       playerEntity = playerGroup.ToEntityArray(Allocator.TempJob, out playerHandle);

        var updateJob = new UpdateJob
        {
            snapshotFromEntity = GetBufferFromEntity <ShipSnapshotData>(),
            targetTick         = NetworkTimeSystem.interpolateTargetTick
        };

        inputDeps = updateJob.Schedule(this, inputDeps);
        var destroyJob = new DestroyJob
        {
            commandBuffer         = m_Barrier.CreateCommandBuffer().ToConcurrent(),
            entityType            = entityType,
            playerEntity          = playerEntity,
            playerStateFromEntity = GetComponentDataFromEntity <PlayerStateComponentData>()
        };

        inputDeps = destroyJob.Schedule(destroyGroup, JobHandle.CombineDependencies(inputDeps, playerHandle));
        m_Barrier.AddJobHandleForProducer(inputDeps);
        return(inputDeps);
    }
Ejemplo n.º 2
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var settings = GetSingleton <SettingsComponent>();

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

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

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

            var destroyJob = new DestroyJob
            {
                CachedEntities    = cachedEntities,
                CommandBuffer     = _commandBuffer.CreateCommandBuffer(),
                ClickedComponents = _clickedQuery.ToComponentDataArray <ClickedComponent>(Allocator.TempJob),
                InGroup           = GetComponentDataFromEntity <InGroupComponent>(true),
                Helper            = helper,
                MinGroupSize      = settings.MinGroupSize
            };

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

            jobHandle = destroyJob.Schedule(jobHandle);

            _commandBuffer.AddJobHandleForProducer(jobHandle);

            return(jobHandle);
        }
Ejemplo n.º 3
0
    protected override void OnUpdate()
    {
        var entityType = GetEntityTypeHandle();

        var playerEntity            = GetSingletonEntity <NetworkIdComponent>();
        var commandTargetFromEntity = GetComponentDataFromEntity <CommandTargetComponent>();

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

        Entities.WithNone <GhostShipState>().WithAll <ShipTagComponentData, PredictedGhostComponent>().ForEach((Entity entity) => {
            var state          = commandTargetFromEntity[playerEntity];
            state.targetEntity = entity;
            commandTargetFromEntity[playerEntity] = state;
            commandBuffer.AddComponent(0, entity, new GhostShipState());
        }).Schedule();

        var destroyJob = new DestroyJob
        {
            commandBuffer           = commandBuffer,
            entityType              = entityType,
            playerEntity            = playerEntity,
            commandTargetFromEntity = GetComponentDataFromEntity <CommandTargetComponent>()
        };
        var inputDeps = destroyJob.Schedule(m_DestroyGroup, Dependency);

        m_Barrier.AddJobHandleForProducer(inputDeps);
        Dependency = inputDeps;
    }
Ejemplo n.º 4
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        endSimulationBuffer = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();
        DestroyJob job       = new DestroyJob(endSimulationBuffer.CreateCommandBuffer());
        JobHandle  jobHandle = job.Schedule(this, inputDeps);

        endSimulationBuffer.AddJobHandleForProducer(jobHandle);
        return(jobHandle);
    }
Ejemplo n.º 5
0
    public static void ScheduleDestroyJob(Entity entityToDestroy)
    {
        var job = new DestroyJob()
        {
            cmdBuffer       = Bootstrap.entityCommandBuffer,
            entityToDestroy = entityToDestroy
        }.Schedule();

        job.Complete();
    }
Ejemplo n.º 6
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        DestroyJob destroyJob = new DestroyJob
        {
            entityCommandBuffer = endSimulationEntityCommandBuffer.CreateCommandBuffer().ToConcurrent()
        };

        JobHandle jobHandle = destroyJob.Schedule(this, inputDeps);

        endSimulationEntityCommandBuffer.AddJobHandleForProducer(jobHandle);
        return(jobHandle);
    }
    // OnUpdate runs on the main thread.
    protected override JobHandle OnUpdate(JobHandle inputDependencies)
    {
        var commandBuffer = m_Barrier.CreateCommandBuffer().ToConcurrent();

        var job = new DestroyJob
        {
            CommandBuffer = commandBuffer,
        }.Schedule(this, inputDependencies);

        m_Barrier.AddJobHandleForProducer(job);

        return(job);
    }
Ejemplo n.º 8
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        var job = new DestroyJob()
        {
            limit         = GameDataManager.instance.AsteroidCount,
            CommandBuffer = endSimCommandBufferSystem.CreateCommandBuffer().ToConcurrent()
        };

        var jobHandle = job.Schedule(this, inputDeps);

        endSimCommandBufferSystem.AddJobHandleForProducer(jobHandle);
        return(jobHandle);
    }
Ejemplo n.º 9
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var handle = inputDeps;

            handle = new DestroyJob()
            {
                CommandBuffer = _entityCommandBufferSystem.CreateCommandBuffer().ToConcurrent(),
                DeltaTime     = Time.DeltaTime,
            }.Schedule(this, handle);

            _entityCommandBufferSystem.AddJobHandleForProducer(handle);
            return(handle);
        }
Ejemplo n.º 10
0
        protected override JobHandle OnUpdate(JobHandle handle)
        {
            var commandBuffer = commandBufferSystem.CreateCommandBuffer();

            var destroyJob = new DestroyJob {
                CommandBuffer = commandBuffer,
            };

            handle = HandleMessage(handle, commandBuffer);
            handle = destroyJob.Schedule(this, handle);
            commandBufferSystem.AddJobHandleForProducer(handle);

            return(handle);
        }
Ejemplo n.º 11
0
        protected override void OnUpdate()
        {
            EndSimulationEntityCommandBufferSystem endSimECBSystem = World.GetOrCreateSystem <EndSimulationEntityCommandBufferSystem>();

            DestroyJob job = new DestroyJob
            {
                EntityType            = GetEntityTypeHandle(),
                InfoType              = GetComponentTypeHandle <TTweenInfo>(true),
                TweenBufferFromEntity = GetBufferFromEntity <TweenState>(),
                ParallelWriter        = endSimECBSystem.CreateCommandBuffer().AsParallelWriter(),
            };

            Dependency = job.ScheduleParallel(TweenInfoQuery, Dependency);
            endSimECBSystem.AddJobHandleForProducer(Dependency);
        }
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            DestroyJob lifetimeJob = new DestroyJob
            {
                Entities      = _destroyGroup.Entities,
                ToDestroy     = _destroyGroup.ToDestroy,
                CommandBuffer = _jobBarrier.CreateCommandBuffer().ToConcurrent()
            };

            var jobHandle = lifetimeJob.Schedule(_destroyGroup.Length, 500, inputDeps);

            jobHandle.Complete();

            return(jobHandle);
        }
Ejemplo n.º 13
0
        protected override JobHandle OnUpdate(JobHandle inputDeps)
        {
            var commandBufferSystem = World.GetExistingManager <BeginSimulationEntityCommandBufferSystem>();

            inputDeps = new ProcessJob
            {
                DestroyQueue = m_DestroyQueue.ToConcurrent(),
                DeltaTime    = Time.deltaTime
            }.Schedule(this, inputDeps);

            inputDeps = new DestroyJob
            {
                DestroyQueue  = m_DestroyQueue,
                CommandBuffer = commandBufferSystem.CreateCommandBuffer(),
            }.Schedule(inputDeps);

            commandBufferSystem.AddJobHandleForProducer(inputDeps);

            return(inputDeps);
        }
Ejemplo n.º 14
0
    protected override JobHandle OnUpdate(JobHandle inputDeps)
    {
        inputDeps = base.OnUpdate(inputDeps);

        var entityType = GetArchetypeChunkEntityType();

        JobHandle playerHandle;
        var       playerEntity = m_PlayerGroup.ToEntityArray(Allocator.TempJob, out playerHandle);

        var destroyJob = new DestroyJob
        {
            commandBuffer           = m_Barrier.CreateCommandBuffer().ToConcurrent(),
            entityType              = entityType,
            playerEntity            = playerEntity,
            commandTargetFromEntity = GetComponentDataFromEntity <CommandTargetComponent>()
        };

        inputDeps = destroyJob.Schedule(m_DestroyGroup, JobHandle.CombineDependencies(inputDeps, playerHandle));
        m_Barrier.AddJobHandleForProducer(inputDeps);
        return(inputDeps);
    }
Ejemplo n.º 15
0
 public static InputTask BulldozeFactory()
 {
     return(new InputTask(InputMode.Area, (cells, selected) => {
         foreach (Cell cell in cells)
         {
             if (cell.Floor != null)
             {
                 DestroyJob job = new DestroyJob(cell, cell.Floor);
                 cell.World.JobManager.AddJob(job);
             }
             else if (cell.Structure != null)
             {
                 DestroyJob job = new DestroyJob(cell, cell.Structure);
                 cell.World.JobManager.AddJob(job);
             }
         }
     }, (cell, spriteBatch) => {
         Blueprint preview = new Blueprint(cell.World, new Floor(cell, FloorType.Concrete));
         preview.Draw(spriteBatch, cell.X, cell.Y, Blueprint.BlueprintState.Invalid);
     }));
 }