protected override JobHandle OnUpdate(JobHandle inputDeps) { var settings = SnakeBootstrap.Settings; if (settings == null) { return(inputDeps); } if (m_Players.Length <= 0) { return(inputDeps); } if (m_Foods.Length <= 0) { return(inputDeps); } var playersVsEnemies = new CollisionJob { Foods = m_Foods.Food, FoodPositions = m_Foods.Position, CollisionRadiusSquared = settings.enemyCollisionRadius * settings.enemyCollisionRadius, Health = m_Players.Health, Positions = m_Players.Position, }.Schedule(m_Players.Length, 1, inputDeps); return(playersVsEnemies); }
void Start() { m_ParticleSystem = GetComponent <ParticleSystem>(); var main = m_ParticleSystem.main; var collision = m_ParticleSystem.collision; int maxParticleCount = main.maxParticles; m_SortKeys = new NativeArray <SortKey>(maxParticleCount, Allocator.Persistent); m_Collisions = new NativeQueue <Collision>(Allocator.Persistent); m_CacheJob = new CacheJob { sortKeys = m_SortKeys, }; m_SortJob = new SortJob { sortKeys = m_SortKeys }; m_CollisionJob = new CollisionJob { sortKeys = m_SortKeys, collisions = m_Collisions.AsParallelWriter(), bounce = collision.bounceMultiplier, radiusScale = collision.radiusScale, maxDiameter = main.startSize.constantMax * collision.radiusScale // TODO - handle different size curve modes and size over life if needed }; m_ApplyCollisionsJob = new ApplyCollisionsJob { collisions = m_Collisions }; }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var player = GetSingletonEntity <Player>(); CollisionJob job = new CollisionJob(GetComponentDataFromEntity <Ground>(false), player); return(job.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorld.PhysicsWorld, inputDeps)); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var settings = TwoStickBootstrap.Settings; if (settings == null) { return(inputDeps); } var enemiesVsPlayers = new CollisionJob { ShotPositions = m_EnemyShots.Position, Shots = m_EnemyShots.Shot, CollisionRadiusSquared = settings.playerCollisionRadius * settings.playerCollisionRadius, Health = m_Players.Health, Positions = m_Players.Position, }.Schedule(m_Players.Length, 1, inputDeps); var playersVsEnemies = new CollisionJob { ShotPositions = m_PlayerShots.Position, Shots = m_PlayerShots.Shot, CollisionRadiusSquared = settings.enemyCollisionRadius * settings.enemyCollisionRadius, Health = m_Enemies.Health, Positions = m_Enemies.Position, }.Schedule(m_Enemies.Length, 1, enemiesVsPlayers); return(playersVsEnemies); }
// ============================================================================================================= protected override JobHandle OnUpdate(JobHandle inputDependencies) { float enemyRadius = GameSettings.Instance.EnemyCollisionRadius; float playerRadius = GameSettings.Instance.PlayerCollisionRadius; //A job for our enemies against all bullets var jobEvB = new CollisionJob() { radius = enemyRadius * enemyRadius, transToTestAgainst = bulletGroup.ToComponentDataArray <Translation>(Allocator.TempJob) }; //Add it to our job schedule JobHandle jobEvBHandle = jobEvB.Schedule(enemyGroup, inputDependencies); //If player is already dead, return our handle, do nothing. if (GameSettings.Instance.IsPlayerDead) { return(jobEvBHandle); } //A job for our player against all enemies var jobPvE = new CollisionJob() { radius = playerRadius * playerRadius, transToTestAgainst = enemyGroup.ToComponentDataArray <Translation>(Allocator.TempJob) }; //Add it to our job schedule return(jobPvE.Schedule(playerGroup, jobEvBHandle)); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { float distance = Time.deltaTime * this.boardConfig.BulletSpeed; float[] distances = new float[this.spearcasters.Length]; for (int i = 0; i < distances.Length; i++) { distances[i] = distance; } NativeArray <float> distanceArray = new NativeArray <float>(distances, Allocator.TempJob); var collisionJob = new CollisionJob { Distance = distanceArray, RoundedCorners = this.roundedCorners, SquaredRoundedCornerThreshold = this.boardConfig.RoundedCornerThreshold * this.boardConfig.RoundedCornerThreshold, SpearcastData = this.spearcasters.SpearcastData, SpearcasterPosition = this.spearcasters.Position, SpearcasterHeading = this.spearcasters.Heading, CollidableEntities = this.collisionTargets.Entities, Collidable = this.collisionTargets.Collidable, CollidablePosition = this.collisionTargets.Position, }.Schedule(this.spearcasters.Length, 1, inputDeps); distanceArray.Dispose(); return(collisionJob); }
protected override JobHandle OnUpdate(JobHandle inputDependencies) { var healthType = GetArchetypeChunkComponentType <HealthComponent>(false); var translationType = GetArchetypeChunkComponentType <Translation>(true); float enemyRadius = 1; float playerRadius = 1; var jobEvB = new CollisionJob() { radius = enemyRadius * enemyRadius, healthType = healthType, translationType = translationType, transToTestAgainst = playerGroup.ToComponentDataArray <Translation>(Allocator.TempJob) }; JobHandle jobHandle = jobEvB.Schedule(enemyGroup, inputDependencies); var jobPvE = new CollisionJob() { radius = playerRadius * playerRadius, healthType = healthType, translationType = translationType, transToTestAgainst = enemyGroup.ToComponentDataArray <Translation>(Allocator.TempJob) }; return(jobPvE.Schedule(playerGroup, jobHandle)); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var copyBarrier = Setup(inputDeps); var collisionJob = new CollisionJob { Positions = _positionsCopy, Sizes = _sizeCopy, Entities = _entitiesCopy, CommandBuffer = _barrierSystem.CreateCommandBuffer().ToConcurrent(), MaxPlayerSize = Bootstrap.Settings.PlayerMaxSize, Grid = _gridSystem.Grid, CellSize = Bootstrap.Settings.CellSize }; var collisionJobHandle = collisionJob.Schedule(_mSpatialData.Length, 64, copyBarrier); var copySizesBackJob = new CopyArrayToComponentData <Size> { Source = _sizeCopy, Results = _mSpatialData.Size }; return(copySizesBackJob.Schedule(_mSpatialData.Length, 64, collisionJobHandle)); }
protected override JobHandle OnUpdate(JobHandle inputDependencies) { var healthType = GetComponentTypeHandle <Health>(false); var translationType = GetComponentTypeHandle <Translation>(true); float enemyRadius = Settings.EnemyCollisionRadius; float playerRadius = Settings.PlayerCollisionRadius; var jobEvB = new CollisionJob() { radius = enemyRadius * enemyRadius, healthType = healthType, translationType = translationType, transToTestAgainst = bulletGroup.ToComponentDataArray <Translation>(Allocator.TempJob) }; JobHandle jobHandle = jobEvB.Schedule(enemyGroup, inputDependencies); if (Settings.IsPlayerDead()) { return(jobHandle); } var jobPvE = new CollisionJob() { radius = playerRadius * playerRadius, healthType = healthType, translationType = translationType, transToTestAgainst = enemyGroup.ToComponentDataArray <Translation>(Allocator.TempJob) }; return(jobPvE.Schedule(playerGroup, jobHandle)); }
protected override JobHandle OnUpdate(JobHandle inputDependencies) { var healthType = GetArchetypeChunkComponentType <Health>(false); var translationType = GetArchetypeChunkComponentType <Translation>(true); float enemyRadius = Boot.Settings.EnemyRadius; // TODO - Set this up as an array of the radii float playerRadius = Boot.Settings.PlayerRadius; var jobEvB = new CollisionJob() { radius = enemyRadius * enemyRadius, healthType = healthType, translationType = translationType, transToTestAgainst = bulletGroup.ToComponentDataArray <Translation>(Allocator.TempJob) }; JobHandle jobHandle = jobEvB.Schedule(enemyGroup, inputDependencies); // if (Settings.IsPlayerDead()) // return jobHandle; var jobPvE = new CollisionJob() { radius = playerRadius * playerRadius, healthType = healthType, translationType = translationType, transToTestAgainst = enemyGroup.ToComponentDataArray <Translation>(Allocator.TempJob) }; return(jobPvE.Schedule(playerGroup, jobHandle)); }
// ============================================================================================================= protected override JobHandle OnUpdate(JobHandle inputDependencies) { //1. We first need to get the archetype chunk type we will be using var healthType = GetArchetypeChunkComponentType <Health>(false); var translationType = GetArchetypeChunkComponentType <Translation>(true); float enemyRadius = GameSettings.Instance.EnemyCollisionRadius; float playerRadius = GameSettings.Instance.PlayerCollisionRadius; //2. We pass it to the Job var jobEvB = new CollisionJob() { radius = enemyRadius * enemyRadius, healthType = healthType, translationType = translationType, transToTestAgainst = bulletGroup.ToComponentDataArray <Translation>(Allocator.TempJob) }; JobHandle jobHandle = jobEvB.Schedule(enemyGroup, inputDependencies); if (GameSettings.Instance.IsPlayerDead) { return(jobHandle); } var jobPvE = new CollisionJob() { radius = playerRadius * playerRadius, healthType = healthType, translationType = translationType, transToTestAgainst = enemyGroup.ToComponentDataArray <Translation>(Allocator.TempJob) }; return(jobPvE.Schedule(playerGroup, jobHandle)); }
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(); }
// ============================================================================================================= /// <summary> /// Our Job Handle can get info from our MonoBehaviour objects. /// After we get the info, we send to our selected group in our query. /// </summary> /// <param name="inputDependencies"></param> /// <returns></returns> protected override JobHandle OnUpdate(JobHandle inputDependencies) { var jobEvP = new CollisionJob(); jobEvP.radius = GameSettings.Instance.EnemyCollisionRadius; jobEvP.playerPosition = GameSettings.Instance.PlayerPosition; return(jobEvP.Schedule(enemyGroup, inputDependencies)); }
// ============================================================================================================= protected override JobHandle OnUpdate(JobHandle inputDependencies) { var jobEvB = new CollisionJob(); jobEvB.radius = GameSettings.Instance.EnemyCollisionRadius; //Allocator.TempJob - This changes how the memory is managed for that Array. //Prepares it to be used in jobs. jobEvB.transToTestAgainst = enemyGroup.ToComponentDataArray <Translation>(Allocator.TempJob); return(jobEvB.Schedule(playerGroup, inputDependencies)); //change here to enemyGroup and see what happens ;) }
protected override JobHandle OnUpdate(JobHandle inputDeps) { CollisionJob job = new CollisionJob() { bulletsGroup = GetComponentDataFromEntity <BulletComponent>(), airplanesGroup = GetComponentDataFromEntity <AirplaneComponent>() }; return(job.Schedule(_stepPhysicsWorld.Simulation, ref _buildPhysicsWorld.PhysicsWorld, inputDeps)); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var job = new CollisionJob { projectiles = GetComponentDataFromEntity <Projectile>(true), queuedActions = ProjectileImpactManager.queuedProjectileEvents.AsParallelWriter(), World = buildPhysicsWorldSystem.PhysicsWorld, }.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorldSystem.PhysicsWorld, inputDeps); job.Complete(); return(job); }
protected override JobHandle OnUpdate(JobHandle inputDependencies) { var jobPvE = new CollisionJob() { currentBuffer = endFrameBuffer.CreateCommandBuffer().ToConcurrent(), tileDataToTestAgainst = mapTileGroup.ToComponentDataArray <Dat_MapTileData>(Allocator.TempJob), playerDataToTestAgainst = playerGroup.ToComponentDataArray <Translation>(Allocator.TempJob), }; return(jobPvE.Schedule(this, inputDependencies)); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var healthType = GetArchetypeChunkComponentType <Health>(false); var translationType = GetArchetypeChunkComponentType <Translation>(true); var scrapType = GetArchetypeChunkComponentType <ScrapTag>(false); float enemyRadius = 1f; float playerRadius = 2.5f; float scrapRadius = 1f; var jobEvB = new CollisionJob() { radiusSquared = enemyRadius * enemyRadius, healthType = healthType, translationType = translationType, translationsToTestAgainst = bulletGroup.ToComponentDataArray <Translation>(Allocator.TempJob) }; JobHandle jobHandle = jobEvB.Schedule(enemyGroup, inputDeps); // Handle player death if (GameManager.IsPlayerDead()) { return(jobHandle); } var jobPvE = new CollisionJob() { radiusSquared = playerRadius * playerRadius, healthType = healthType, translationType = translationType, translationsToTestAgainst = enemyGroup.ToComponentDataArray <Translation>(Allocator.TempJob) }; var playerVersusEnemiesHandle = jobPvE.Schedule(playerGroup, jobHandle); var jobScrapOnPlayer = new CollisionWithScrapJob() { radiusSquared = scrapRadius * scrapRadius, scrapType = scrapType, translationType = translationType, translationsToTestAgainst = playerGroup.ToComponentDataArray <Translation>(Allocator.TempJob) }; return(jobScrapOnPlayer.Schedule(scrapGroup, playerVersusEnemiesHandle)); //var enemyBulletsCollisionJob = new NewCollisionJob() //{ // bulletGroup = GetComponentDataFromEntity<TimeToLive>(), // enemyGroup = GetComponentDataFromEntity<Health>() //}; //return enemyBulletsCollisionJob.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorld.PhysicsWorld, inputDeps); }
protected override JobHandle OnUpdate(JobHandle inputDependencies) { var healthType = GetArchetypeChunkComponentType <Health>(false); var timeToLiveType = GetArchetypeChunkComponentType <TimeToLive>(false); var translationType = GetArchetypeChunkComponentType <Translation>(true); float enemyRadius = Settings.EnemyCollisionRadius; float playerRadius = Settings.PlayerCollisionRadius; var time_to_lives = bulletGroup.ToComponentDataArray <TimeToLive>(Allocator.TempJob); for (int i = 0; i < time_to_lives.Length; i++) { var time_to_live = time_to_lives[i]; time_to_live.Value = 0; time_to_lives[i] = time_to_live; } time_to_lives.Dispose(); var jobEvB = new CollisionJob() { radius = enemyRadius * enemyRadius, doTimeToLive = true, healthType = healthType, timeToLiveType = timeToLiveType, translationType = translationType, transToTestAgainst = bulletGroup.ToComponentDataArray <Translation>(Allocator.TempJob), bullerChucks = bulletGroup.CreateArchetypeChunkArray(Allocator.TempJob) }; JobHandle jobHandle = jobEvB.Schedule(enemyGroup, inputDependencies); if (Settings.IsPlayerDead()) { return(jobHandle); } var jobPvE = new CollisionJob() { radius = playerRadius * playerRadius, doTimeToLive = false, healthType = healthType, timeToLiveType = timeToLiveType, translationType = translationType, transToTestAgainst = enemyGroup.ToComponentDataArray <Translation>(Allocator.TempJob), bullerChucks = bulletGroup.CreateArchetypeChunkArray(Allocator.TempJob) }; return(jobPvE.Schedule(playerGroup, jobHandle)); }
protected override void OnUpdate() { CollisionJob triggerJob = new CollisionJob { damageData = GetComponentDataFromEntity <DamageData>(), takeDamage = GetComponentDataFromEntity <TakeDamageData>(), destroyData = GetComponentDataFromEntity <DestroyData>(), colorData = GetComponentDataFromEntity <ColorData>(), EM = EntityManager }; JobHandle job = triggerJob.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorld.PhysicsWorld, Dependency); job.Complete(); }
protected override void OnUpdate() { if (EntityManager.CreateEntityQuery(typeof(Brick)).CalculateEntityCount() == 0) { return; } Dependency = new CollisionJob() { brickHealths = GetComponentDataFromEntity <HealthInt>() }.Schedule(m_StepPhysicsWorldSystem.Simulation, ref m_BuildPhysicsWorldSystem.PhysicsWorld, Dependency); Dependency.Complete(); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var collisionJob = new CollisionJob() { damageApplyerGroup = GetComponentDataFromEntity <DamageApplyer>(), hpGroup = GetComponentDataFromEntity <HPComponent>(), teamMemberGroup = GetComponentDataFromEntity <TeamMemberComponent>(), }; var jobHandle = collisionJob.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorld.PhysicsWorld, inputDeps); jobHandle.Complete(); return(jobHandle); }
protected override JobHandle OnUpdate(JobHandle inputDependencies) { inputDependencies = JobHandle.CombineDependencies(inputDependencies, buildPhysicsWorldSystem.FinalJobHandle); var physicsWorld = buildPhysicsWorldSystem.PhysicsWorld; var collisionJob = new CollisionJob { enemiesGroup = GetComponentDataFromEntity <AIData>(), translationsGroup = GetComponentDataFromEntity <Translation>() }; JobHandle collisionHandle = collisionJob.Schedule(stepPhysicsWorldSystem.Simulation, ref physicsWorld, inputDependencies); return(collisionHandle); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var consumedObjectIndex = GetComponentDataFromEntity <ConsumableObject>(); var collisionJob = new CollisionJob { physicsWorld = _physicsWorldSystem.PhysicsWorld, commandBuffer = _commandBufferSystem.CreateCommandBuffer().ToConcurrent(), consumedObjectIndex = consumedObjectIndex }; var jobHandle = collisionJob.Schedule(this, inputDeps); _commandBufferSystem.AddJobHandleForProducer(jobHandle); return(jobHandle); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { CollisionJob colJob = new CollisionJob { cmd = buffer.CreateCommandBuffer().ToConcurrent(), Length = bData.Length, playerPosition = pData.position, playerLength = pData.Length, bulletPosition = bData.position, bulletRadius = bData.radius }; JobHandle colHandle = colJob.Schedule(this, inputDeps); return(colHandle); }
protected override JobHandle OnUpdate(JobHandle inputDependencies) { var healthType = GetArchetypeChunkComponentType <Health>(false); var translationType = GetArchetypeChunkComponentType <Translation>(true); float enemyRadius = GameSettings.EnemyCollisionRadius; float towerRadius = GameSettings.TowerCollisionRadius; var jobEvB = new CollisionJob() { radius = enemyRadius * enemyRadius, healthType = healthType, translationType = translationType, transToTestAgainst = projectileGroup.ToComponentDataArray <Translation>(Allocator.TempJob) }; //Debug.Log("jobEvB.radius : " + jobEvB.radius); //Debug.Log("jobEvB.healthType : " + jobEvB.healthType); //Debug.Log("jobEvB.translationType : " + jobEvB.translationType); //Debug.Log("jobEvB.transToTestAgainst : " + jobEvB.transToTestAgainst); JobHandle jobHandle = jobEvB.Schedule(enemyGroup, inputDependencies); if (GameSettings.IsTowerDown()) { //Debug.Log("Tower is down"); return(jobHandle); } var jobPvE = new CollisionJob() { radius = towerRadius * towerRadius, healthType = healthType, translationType = translationType, transToTestAgainst = enemyGroup.ToComponentDataArray <Translation>(Allocator.TempJob) }; //Debug.Log("jobPvE.radius : " + jobPvE.radius ); //Debug.Log("jobPvE.healthType : "+ jobPvE.healthType); //Debug.Log("jobPvE.translationType : "+ jobPvE.translationType); //Debug.Log("jobPvE.transToTestAgainst : "+ jobPvE.transToTestAgainst); return(jobPvE.Schedule(mainTowerGroup, jobHandle)); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var job = new CollisionJob(); job.deathTriggerGroup = GetComponentDataFromEntity <DeathTriggerTag>(true); job.enemyBulletGroup = GetComponentDataFromEntity <EnemyBulletTag>(true); job.playerBulletGroup = GetComponentDataFromEntity <PlayerBulletTag>(true); job.enemyGroup = GetComponentDataFromEntity <EnemyTag>(true); job.playerGroup = GetComponentDataFromEntity <PlayerTag>(true); job.commandBuffer = commandBufferSystem.CreateCommandBuffer(); job.sceneIndex = sceneIndex; JobHandle jobHandle = job.Schedule(stepPhysicsWorld.Simulation, ref buildPhysicsWorld.PhysicsWorld, inputDeps); commandBufferSystem.AddJobHandleForProducer(jobHandle); return(jobHandle); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var combineDependencies = JobHandle.CombineDependencies(inputDeps, m_BuildPhysicsWorld.FinalJobHandle, m_StepPhysicsWorld.FinalSimulationJobHandle); var collisionJob = new CollisionJob { PhysicsWorld = m_BuildPhysicsWorld.PhysicsWorld, CollisionEvents = m_StepPhysicsWorld.Simulation.TriggerEvents, PhysicsVelocityData = GetComponentDataFromEntity <PhysicsVelocity>(), EntityCommandBuffer = m_EndSimulationEntityCommandBufferSystem.CreateCommandBuffer(), CollisionInfoBuffer = GetBufferFromEntity <CollisionInfoElement>() }; var collisionJobHandle = collisionJob.Schedule(combineDependencies); return(collisionJobHandle); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { if (m_BoardQuery.CalculateEntityCount() <= 0) { return(inputDeps); } var boardEntity = m_BoardQuery.GetSingletonEntity(); var board = m_BoardQuery.GetSingleton <LbBoard>(); var bufferLookup = GetBufferFromEntity <LbCatMap>(); var buffer = bufferLookup[boardEntity]; var bufferArray = buffer.AsNativeArray(); var handle = new MemsetNativeArray <LbCatMap>() { Source = bufferArray, Value = new LbCatMap() }.Schedule(bufferArray.Length, 32, inputDeps); handle = new CatMapJob { Size = board.SizeY, Buffer = bufferArray, Translations = m_CatQuery.ToComponentDataArray <Translation>(Allocator.TempJob) }.Schedule(handle); handle = new CollisionJob { Size = board.SizeY, CatLocationBuffer = bufferArray, Queue = m_Queue.AsParallelWriter(), }.Schedule(this, handle); handle = new CollisionCleanJob { Queue = m_Queue, CommandBuffer = m_Barrier.CreateCommandBuffer(), }.Schedule(handle); m_Barrier.AddJobHandleForProducer(handle); return(handle); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var mapEntityArray = mapGroup.ToEntityArray(Allocator.TempJob); Map map = EntityManager.GetSharedComponentData <Map>(mapEntityArray[0]); var mapArray = new NativeArray <int>(map.mapArray, Allocator.TempJob); var objArray = objGroup.ToComponentDataArray <PhysicsObject>(Allocator.TempJob); var job = new CollisionJob { rows = map.rows, cols = map.cols, mapArray = mapArray, objArray = objArray }; mapEntityArray.Dispose(); return(job.Schedule(this, inputDeps)); }