Esempio n. 1
0
 /// <summary>
 /// Fills the given box with a random distribution of environmental objects.
 /// </summary>
 /// <param name="box">A box in space.</param>
 private void InitialFill(Box3D box)
 {
     foreach (var envObject in v_MSystem.FloatingObjects.Values)
     {
         var amount = box.Volume * envObject.Concentration - Randomizer.Rng.NextDouble();
         for (int i = 0; i < amount; i++)
         {
             Add(new FloatingObjectInWorld(envObject, box.RandomPoint()), false);
         }
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Refills the box (OldSet only!) with floating objects up to their pre-defined concentrations in the environment.
        /// If the concentration of some objects is higher, no objects are removed.
        /// </summary>
        private void RefillBox(Box3D box)
        {
            var population = v_MSystem.FloatingObjects.Values.ToDictionary(obj => obj, obj => 0);

            foreach (var key in KeysInBox(box))
            {
                foreach (var obj in v_Grid[key].OldSet.GetHashSet().Where(fltObject => box.Contains(fltObject.Position)))
                {
                    population[obj.Type]++;
                }
            }

            foreach (var member in population)
            {
                for (int i = 0; i < box.Volume * member.Key.Concentration - member.Value - Randomizer.Rng.NextDouble(); i++)
                {
                    Add(new FloatingObjectInWorld(member.Key, box.RandomPoint()), false);
                }
            }
        }