protected override void OnUpdate() { if (IncommingProjectileGroup.CalculateLength() > 0) { HandleIncommingProjectiles(); } }
protected override void OnUpdate() { int cameraGroupLength = cameraGroup.CalculateLength(); int mapGroupLength = mapGroup.CalculateLength(); if ((cameraGroupLength == 0) || (cameraGroupLength != mapGroupLength)) { return; } var cameraEntities = cameraGroup.ToEntityArray(Allocator.TempJob); var mapEntities = mapGroup.ToEntityArray(Allocator.TempJob); Position position; for (int i = 0; i < cameraEntities.Length; i++) { Map map = EntityManager.GetSharedComponentData <Map>(mapEntities[i]); position.Value = new float3(map.cols / 2, map.rows / 2, -10f); EntityManager.SetComponentData <Position>(cameraEntities[i], position); EntityManager.RemoveComponent <Initializer>(cameraEntities[i]); } cameraEntities.Dispose(); mapEntities.Dispose(); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var positions = allPlanets.GetComponentDataArray <Position>(); var headings = allPlanets.GetComponentDataArray <Heading>(); var speeds = allPlanets.GetComponentDataArray <MoveSpeed>(); var sunPos = suns.GetComponentDataArray <Position>(); sunPositions = new NativeArray <Position>(sunPos.Length, Allocator.Persistent); for (int i = 0; i < sunPos.Length; i++) { sunPositions[i] = sunPos[i]; } var steerJob = new Steer { headings = headings, planetPositions = positions, speeds = speeds, sunPositions = sunPositions }; var steerJobHandle = steerJob.Schedule(allPlanets.CalculateLength(), 64); steerJobHandle.Complete(); sunPositions.Dispose(); inputDeps = steerJobHandle; return(inputDeps); }
protected override void OnUpdate() { if (_done) { return; } EntityManager.GetAllUniqueSharedComponentDatas(_sharedData1Array); EntityManager.GetAllUniqueSharedComponentDatas(_sharedData2Array); var sum = 0; foreach (var data1 in _sharedData1Array) { foreach (var data2 in _sharedData2Array) { _group.SetFilter(data1, data2); UnityEngine.Debug.Log( "Data1 = " + data1.Value + ", Data2 = " + data2.Value + ", Length = " + _group.CalculateLength() ); var dataArray = _group.GetComponentDataArray <Data>(); for (var i = 0; i < dataArray.Length; i++) { sum += dataArray[i].Value * data1.Value * data2.Value; } } } _done = sum > 0; }
protected override void OnUpdate() { //Si se han destruido todas las naves hija if (m_NavesHijas.CalculateLength() == 0) { //Eliminar todas las entidades ComponentGroup m_Jugador = GetComponentGroup(typeof(PlayerInputCMP_NV)); EntityManager.DestroyEntity(m_Jugador); ComponentGroup m_Proyectil = GetComponentGroup(typeof(ProyectilJugadorCMP_NV)); EntityManager.DestroyEntity(m_Proyectil); ComponentGroup m_Enemigos = GetComponentGroup(typeof(EnemigoActivoCMP_NV)); EntityManager.DestroyEntity(m_Enemigos); ComponentGroup m_Premios = GetComponentGroup(typeof(PremioCMP_NV)); EntityManager.DestroyEntity(m_Premios); ComponentGroup m_TiempoSpawn = GetComponentGroup(typeof(TiempoSpawnCMP_NV)); EntityManager.DestroyEntity(m_TiempoSpawn); ComponentGroup m_SonidoMoneda = GetComponentGroup(typeof(SonidoMonedaComponent)); EntityManager.DestroyEntity(m_SonidoMoneda); ComponentGroup m_Explosion = GetComponentGroup(typeof(ExplosionCMP_NV)); EntityManager.DestroyEntity(m_Explosion); EntityManager.DestroyEntity(m_Temporizador); EntityManager.DestroyEntity(m_NavesHijas); Bootstrap_NV.bootstrap_NV.StopMusic(); //parar musica de fondo Bootstrap_NV.bootstrap_NV.PlaySound(2); //reproducir sonido fin partida Bootstrap_NV.bootstrap_NV.FinJuego(); //Metodo que muestra el pop-up de fin de partida y elimina todas las entidades } }
protected override JobHandle OnUpdate(JobHandle inputDeps) { Debug.Log("Remove Octree Instance."); int i_groupLength = group.CalculateLength(); var removeInstanceJob = new RemoveInstanceJob { a_octreeEntities = group.GetEntityArray(), // Contains a list of instances to add, with its properties. removeInstanceBufferElement = GetBufferFromEntity <RemoveInstanceBufferElement> (), a_rootNodeData = GetComponentDataFromEntity <RootNodeData> (), nodeSparesBufferElement = GetBufferFromEntity <NodeSparesBufferElement> (), nodeBufferElement = GetBufferFromEntity <NodeBufferElement> (), nodeInstancesIndexBufferElement = GetBufferFromEntity <NodeInstancesIndexBufferElement> (), nodeChildrenBufferElement = GetBufferFromEntity <NodeChildrenBufferElement> (), instanceBufferElement = GetBufferFromEntity <InstanceBufferElement> (), instancesSpareIndexBufferElement = GetBufferFromEntity <InstancesSpareIndexBufferElement> () }.Schedule(i_groupLength, 8, inputDeps); var completeRemoveInstanceJob = new CompleteRemoveInstanceJob { ecb = barrier.CreateCommandBuffer().ToConcurrent(), a_octreeEntities = group.GetEntityArray() }.Schedule(i_groupLength, 8, removeInstanceJob); return(completeRemoveInstanceJob); }
protected override JobHandle OnUpdate(JobHandle deps) { EntityManager.GetAllUniqueSharedComponentDatas(_renderers); TJob job = new TJob(); for (var i = 0; i < _renderers.Count; i++) { var renderer = _renderers[i]; _group.SetFilter(renderer); var groupCount = _group.CalculateLength(); if (groupCount == 0) { continue; } job.Initialize( _group, renderer.Vertices, renderer.Normals, renderer.ConcurrentCounter ); deps = job.Schedule(groupCount, 8, deps); } _renderers.Clear(); return(deps); }
protected override void OnUpdate() { for (int index = 0; index < 1; index++) { scoreingGroup.SetFilter(new ScoringGroup() { GroupId = index }); if (scoreingGroup.CalculateLength() == 0) { return; } float valueToAdd = DoAddition(index); float valueToSubtract = DoSubtraction(index); if (valueToAdd + valueToSubtract == 0) { return; } var scoreKeepers = scoreingGroup.GetComponentDataArray <ScoreKeeper>(); for (int i = 0; i < scoreKeepers.Length; i++) { ScoreKeeper scoreKeeper = scoreKeepers[i]; scoreKeeper.Score += valueToAdd - valueToSubtract; scoreKeepers[i] = scoreKeeper; } ScoreText.text = defaultScoringText + scoreKeepers[index].Score.ToString("C2"); } }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var sumNoTag = CreateJob(_noTagEntities, _allocatedArrays[0]); var noTagHandler = sumNoTag.ScheduleBatch(_noTagEntities.CalculateLength(), sumNoTag.EntitiesInButch); var sumFirstTag = CreateJob(_firstTagEntities, _allocatedArrays[1]); var firstTagHandler = sumFirstTag.ScheduleBatch(_firstTagEntities.CalculateLength(), sumFirstTag.EntitiesInButch); var sumSecodTag = CreateJob(_secondTagEntities, _allocatedArrays[2]); var secondTagHandler = sumSecodTag.ScheduleBatch(_secondTagEntities.CalculateLength(), sumSecodTag.EntitiesInButch); var sumAll = CreateJob(_allRandomEntities, _allocatedArrays[3]); var handlerAll = sumAll.ScheduleBatch(_allRandomEntities.CalculateLength(), sumAll.EntitiesInButch); _jobHandler[0] = handlerAll; _jobHandler[1] = noTagHandler; _jobHandler[2] = firstTagHandler; _jobHandler[3] = secondTagHandler; JobHandle.CompleteAll(_jobHandler); double noTagsSum = CalcSum(sumNoTag.Sums); double firstTagSum = CalcSum(sumFirstTag.Sums); double secondTagSum = CalcSum(sumSecodTag.Sums); double totalSum = CalcSum(sumAll.Sums); InitializeChunkIterationWorld.LogSumResults(this, noTagsSum, firstTagSum, secondTagSum, totalSum); return(base.OnUpdate(inputDeps)); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var length = m_Group.CalculateLength(); var entityArray = new NativeArray <Entity>(length, Allocator.TempJob); var addArray = new NativeArray <@bool>(length, Allocator.TempJob); var removeArray = new NativeArray <@bool>(length, Allocator.TempJob); var commandBufferSystem = World.Active.GetExistingManager <BeginSimulationEntityCommandBufferSystem>(); inputDeps = new ProcessJob { EntityArray = entityArray, AddArray = addArray, RemoveArray = removeArray, TranslationFromEntity = GetComponentDataFromEntity <Translation>(true), FacingTargetFromEntity = GetComponentDataFromEntity <FacingTarget>(true) }.Schedule(this, inputDeps); inputDeps = new FacingTargetJob { CommandBuffer = commandBufferSystem.CreateCommandBuffer().ToConcurrent(), EntityArray = entityArray, AddArray = addArray, RemoveArray = removeArray }.Schedule(length, 64, inputDeps); commandBufferSystem.AddJobHandleForProducer(inputDeps); return(inputDeps); }
protected override void OnUpdate() { if (m_Group.CalculateLength() > 0) { EntityManager.RemoveComponent(m_Group, ComponentType.ReadWrite <DamagedDispatched>()); } new ProcessDamagedJob { DamagedQueue = m_DamagedQueue.ToConcurrent() }.Schedule(this).Complete(); while (m_DamagedQueue.TryDequeue(out var component)) { if (!(EntityManager.Exists(component.This) && EntityManager.Exists(component.Other))) { continue; } var damaged = PostUpdateCommands.CreateEntity(m_Archetype); PostUpdateCommands.SetComponent(damaged, component); PostUpdateCommands.AddComponent(component.This, new DamagedDispatched()); } }
protected override JobHandle OnUpdate(JobHandle deps) { EntityManager.GetAllUniqueSharedComponentDatas(_renderers); for (var i = 0; i < _renderers.Count; i++) { var renderer = _renderers[i]; if (renderer.WorkMesh == null) { continue; } renderer.Counter.Count = 0; _group.SetFilter(renderer); var job = new ReconstructionJob() { Disintegrators = _group.GetComponentDataArray <Disintegrator>(), Positions = _group.GetComponentDataArray <Position>(), Facets = _group.GetComponentDataArray <Facet>(), Vertices = renderer.Vertices, Normals = renderer.Normals, Counter = renderer.Counter }; deps = job.Schedule(_group.CalculateLength(), 16, deps); } _renderers.Clear(); return(deps); }
protected override JobHandle OnUpdate(JobHandle deps) { EntityManager.GetAllUniqueSharedComponentDatas(_renderers); for (var i = 0; i < _renderers.Count; i++) { var renderer = _renderers[i]; if (renderer.WorkMesh == null) { continue; } _group.SetFilter(renderer); // Reset the triangle counter. renderer.Counter.Count = 0; // Create a reconstruction job and add it to the job chain. var job = new ReconstructionJob() { Particles = _group.GetComponentDataArray <Particle>(), Positions = _group.GetComponentDataArray <Position>(), Triangles = _group.GetComponentDataArray <Triangle>(), Vertices = renderer.Vertices, Normals = renderer.Normals, Counter = renderer.Counter }; deps = job.Schedule(_group.CalculateLength(), 16, deps); } _renderers.Clear(); return(deps); }
protected override void OnUpdate(){ var t_entity = trail.GetEntityArray(); var t_trail = trail.GetComponentArray<TrailRenderer>(); for(int i = 0; i < trail.CalculateLength(); i++){ t_trail[i].enabled = false; } }
protected override void OnUpdate() { var i_entity = impact.GetEntityArray(); for (var i = 0; i < impact.CalculateLength(); i++) { PostUpdateCommands.RemoveComponent <CollidedWithPlayer>(i_entity[i]); } }
protected override JobHandle OnUpdate(JobHandle inputDeps) { if (m_ContactModifierGroup.CalculateLength() == 0) { return(inputDeps); } if (m_StepPhysicsWorld.Simulation.Type == SimulationType.NoPhysics) { return(inputDeps); } var modifiers = m_ContactModifierGroup.ToComponentDataArray <ModifyNarrowphaseContacts>(Allocator.TempJob); var surfaceNormal = modifiers[0].surfaceNormal; var surfaceRBIdx = m_BuildPhysicsWorld.PhysicsWorld.GetRigidBodyIndex(modifiers[0].surfaceEntity); SimulationCallbacks.Callback callback = (ref ISimulation simulation, JobHandle inDeps) => { inDeps.Complete(); // TODO: shouldn't be needed (jobify the below) SimulationData.Contacts.Iterator iterator = simulation.Contacts.GetIterator(); while (iterator.HasItemsLeft()) { ContactHeader manifold = iterator.GetNextContactHeader(); bool bUpdateNormal = (manifold.BodyPair.BodyAIndex == surfaceRBIdx) || (manifold.BodyPair.BodyBIndex == surfaceRBIdx); float distanceScale = 1; if (bUpdateNormal) { var newNormal = surfaceNormal; distanceScale = math.dot(newNormal, manifold.Normal); //<todo.eoin.hpi Feels pretty weird. //<todo.eoin.hp Need to make this work if user has read a contact iterator.SetManifoldNormal(newNormal); } for (int i = 0; i < manifold.NumContacts; i++) { ContactPoint cp = iterator.GetNextContact(); if (bUpdateNormal) { cp.Distance *= distanceScale; iterator.UpdatePreviousContact(cp); } } } return(inDeps); }; modifiers.Dispose(); m_StepPhysicsWorld.EnqueueCallback(SimulationCallbacks.Phase.PostCreateContacts, callback); return(inputDeps); }
protected override void OnUpdate() { players = GetComponentGroup(typeof(PlayerInput)); new PlayerData() { length = players.CalculateLength(), inputs = players.GetComponentDataArray <PlayerInput>(), }.Execute(); }
protected override void OnUpdate() { var jk_entity = jumpKey.GetEntityArray(); for (var i = 0; i < jumpKey.CalculateLength(); i++) { PostUpdateCommands.RemoveComponent <JumpKeyUp>(jk_entity[i]); } }
protected override void OnUpdate() { var bk_entity = rocketKey.GetEntityArray(); for (var i = 0; i < rocketKey.CalculateLength(); i++) { PostUpdateCommands.RemoveComponent <RocketKeyUp>(bk_entity[i]); } }
protected override void OnUpdate() { var maxCharacterCount = GetSingleton <CharacterCount>().MaxValue; var count = m_Group.CalculateLength(); var entityCount = maxCharacterCount - count; DestroyExceedingCharacters(count, maxCharacterCount, entityCount); InstantiateCharacters(entityCount); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { return(new FlagGoStraightBehaviourJob { Entities = _componentGroup.GetEntityArray(), GoStraightBehaviours = _componentGroup.GetComponentDataArray <GoStraightBehaviour>(), EntityCommandBuffer = _barrier.CreateCommandBuffer().ToConcurrent() }.Schedule(_componentGroup.CalculateLength(), 64, inputDeps)); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { var job = new AddJob() { Adders = _adderGroup.GetComponentDataArray <Adder>() }; return(job.Schedule(_adderGroup.CalculateLength(), 64, inputDeps)); }
private void handlePizzaComplete(int pizzaIndex) { Entity pizzaEntity = pizzaData.Entities[pizzaIndex]; PizzaGroup pizzaGroup = pizzaData.PizzaGroup[pizzaIndex]; Position2D pizzaPosition = pizzaData.Position[pizzaIndex]; PizzaCost pizzaCost = pizzaData.PizzaCost[pizzaIndex]; // Pizza is done. Debug.Log("PIZZA DONE - " + pizzaGroup.PizzaId + ": " + pizzaCost.OrderCost + " | " + pizzaCost.ActualCost); // Update global score. PostUpdateCommands.CreateEntity(); PostUpdateCommands.AddComponent(new DeductScore { Value = pizzaCost.ActualCost }); PostUpdateCommands.AddSharedComponent(new ScoringGroup { GroupId = 0 }); // Delete this Pizza. MoveSpeed toWindow = new MoveSpeed { speed = BootStrap.GameSettings.ArrowSpeed }; TimedLife timedLife = new TimedLife { TimeToLive = 10.0f }; PostUpdateCommands.AddComponent(pizzaEntity, toWindow); PostUpdateCommands.AddComponent(pizzaEntity, timedLife); PostUpdateCommands.RemoveComponent <PizzaGroup>(pizzaEntity); // TODO: While ingredients are flying off with the pizza, arrows could hit them. for (int i = 0; i < IngredientData.CalculateLength(); i++) { Entity ingredientEntity = IngredientData.GetEntityArray()[i]; //PostUpdateCommands.AddComponent(ingredientEntity, toWindow); //PostUpdateCommands.AddComponent(ingredientEntity, timedLife); //PostUpdateCommands.RemoveComponent<PizzaGroup>(ingredientEntity); PostUpdateCommands.DestroyEntity(ingredientEntity); } // Create new Pizza. createNewPizza(pizzaIndex); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { return(new SetWeaponKindJob { Entities = _group.GetEntityArray(), Weapons = _group.GetComponentDataArray <Weapon>(), EntityCommandBuffer = Barrier.CreateCommandBuffer().ToConcurrent(), WeaponKind = WeaponKind }.Schedule(_group.CalculateLength(), 64, inputDeps)); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { return(new FiringJob { EntityCommandBuffer = _barrier.CreateCommandBuffer().ToConcurrent(), Weapons = _componentGroup.GetComponentDataArray <Weapon>(), Positions = _componentGroup.GetComponentDataArray <Position>(), Rotations = _componentGroup.GetComponentDataArray <Rotation>() }.Schedule(_componentGroup.CalculateLength(), 64, inputDeps)); }
protected override void OnUpdate() { playerDatas = GetComponentGroup(typeof(Position), ComponentType.ReadOnly(typeof(PlayerInput))); new Data() { length = playerDatas.CalculateLength(), positions = playerDatas.GetComponentDataArray <Position>(), inputs = playerDatas.GetComponentDataArray <PlayerInput>(), }.Execute(); }
protected override JobHandle OnUpdate(JobHandle inputDeps) { return(new MoveForwardJob { DeltaTime = Time.deltaTime, Positions = _componentGroup.GetComponentDataArray <Position>(), Rotations = _componentGroup.GetComponentDataArray <Rotation>(), MoveSpeeds = _componentGroup.GetComponentDataArray <MoveSpeed>() }.Schedule(_componentGroup.CalculateLength(), 64, inputDeps)); }
protected override void OnUpdate() { var count = (uint)g.CalculateLength(); if (cachedCount == count) { return; } text.text = (cachedCount = count).ToString(); }
protected override void OnUpdate() { if (RequestGroup.CalculateLength() == 0) { return; } // Copy requests as spawning will invalidate Group requestBuffer.Clear(); var requestArray = RequestGroup.GetComponentDataArray <ProjectileRequest>(); var requestEntityArray = RequestGroup.GetEntityArray(); for (var i = 0; i < requestArray.Length; i++) { requestBuffer.Add(requestArray[i]); PostUpdateCommands.DestroyEntity(requestEntityArray[i]); } // Handle requests var projectileRegistry = m_resourceSystem.GetResourceRegistry <ProjectileRegistry>(); foreach (var request in requestBuffer) { var registryIndex = projectileRegistry.FindIndex(request.projectileAssetGuid); if (registryIndex == -1) { GameDebug.LogError("Cant find asset guid in registry"); continue; } // Create projectile and initialize var projectileEntity = m_settings.projectileFactory.Create(EntityManager, m_resourceSystem, m_world); var projectileData = EntityManager.GetComponentData <ProjectileData>(projectileEntity); projectileData.SetupFromRequest(request, registryIndex); projectileData.Initialize(projectileRegistry); EntityManager.SetComponentData(projectileEntity, projectileData); EntityManager.AddComponentData(projectileEntity, new PredictedProjectile(request.startTick)); EntityManager.AddComponentData(projectileEntity, new UpdateProjectileFlag()); if (ProjectileModuleClient.logInfo.IntValue > 0) { GameDebug.Log("New predicted projectile created: " + projectileEntity); } // Create client projectile var clientProjectileEntity = m_clientProjectileFactory.CreateClientProjectile(projectileEntity); EntityManager.AddComponentData(clientProjectileEntity, new UpdateProjectileFlag()); if (ProjectileModuleClient.drawDebug.IntValue == 1) { Debug.DrawLine(projectileData.startPos, projectileData.endPos, Color.cyan, 1.0f); } } }
public void ChunkHeaderMustBeQueriedExplicitly() { var arch0 = m_Manager.CreateArchetype(ComponentType.ChunkComponent <EcsTestData>(), typeof(EcsTestData2)); var entity0 = m_Manager.CreateEntity(arch0); ComponentGroup group0 = m_Manager.CreateComponentGroup(typeof(ChunkHeader), typeof(EcsTestData)); ComponentGroup group1 = m_Manager.CreateComponentGroup(typeof(EcsTestData)); Assert.AreEqual(1, group0.CalculateLength()); Assert.AreEqual(0, group1.CalculateLength()); }