Ejemplo n.º 1
0
 public void Execute()
 {
     if (quadrantMultiHashMap.TryGetFirstValue(keys[index], out EntityWithProps inspectedEntityWithProps, out NativeMultiHashMapIterator <int> it))
     {
         do
         {
             for (int i = 0; i < sortedPositionsArray.Length; i++)
             {
                 if (i == 0)
                 {
                     sortedPositionsArray[i] = inspectedEntityWithProps;
                 }
                 else if (inspectedEntityWithProps.vecSqrMag > sortedPositionsArray[i - 1].vecSqrMag)
                 {
                     sortedPositionsArray[i] = inspectedEntityWithProps;
                 }
                 else
                 {
                     int j = i;
                     while (j - 1 >= 0 && inspectedEntityWithProps.vecSqrMag < sortedPositionsArray[j - 1].vecSqrMag)
                     {
                         EntityWithProps tempEntityWithProps = sortedPositionsArray[j - 1];
                         sortedPositionsArray[j - 1] = inspectedEntityWithProps;
                         sortedPositionsArray[j]     = tempEntityWithProps;
                         j--;
                     }
                 }
             }
         }while (quadrantMultiHashMap.TryGetNextValue(out inspectedEntityWithProps, ref it));//TODO can add a boolean if need to stop after first crash
     }
     for (int i = 0; i < sortedPositionsArray.Length - 1; i++)
     {   //adding planetoids with crash distance to queue
         EntityWithProps tempEntityWithProps;
         if (sortedPositionsArray[i + 1].vecSqrMag - sortedPositionsArray[i].vecSqrMag < 0.3f)
         {
             //tempEntityWithProps = sortedPositionsArray[i];
             //tempEntityWithProps.crashTime = realTimeSinceStartUp;
             //sortedPositionsArray[i] = tempEntityWithProps;
             //tempEntityWithProps = sortedPositionsArray[i + 1];
             //tempEntityWithProps.crashTime = realTimeSinceStartUp;
             //sortedPositionsArray[i + 1] = tempEntityWithProps;
         }
     }
     //TODO add everything to cumulative array OR build a static list of crash times and a separate system that would create or revive entities,
 }
Ejemplo n.º 2
0
        public void Execute(Entity entity, int index, ref Translation translation)
        {
            float3 position = translation.Value;

            for (int i = 0; i < entitiesWithProps.Length; i++)
            {
                EntityWithProps entityWithProps = entitiesWithProps[i];
                if (position.x < entityWithProps.position.x)
                {
                    float distance = math.distancesq(position, entityWithProps.position);
                    if (distance < 0.3f)
                    {
                        //Debug.Log("Asteroids destroid, pending to respawn");
                        entityCommandBuffer.DestroyEntity(index, entity);
                        entityCommandBuffer.DestroyEntity(index, entityWithProps.entity);
                        //instead make an array of all destroyed asteroids and deal with them later
                    }
                }
            }
        }