Example #1
0
 public AI(Entity e)
 {
     entity = e;
     entity.ai = this;
     entity.Component<AIController>(true).ai = this;
 }
 public List<Fish> SpawnFish(Entity fluid)
 {
     List<Fish> fishes = new List<Fish>();
     Vector3 scale = fluid.Scale();
     float volume = scale.x * scale.y * scale.z;
     float density = 1.5f / 125000f;
     float max = 100;
     float num = Mathf.Min(volume * density, max) * Random.value;
     for (int i = 1; i <= num; i++)
     {
         Vector3 offset = Vector3.Scale(Util.RandomVector(), scale/2);
         Vector3 pos = fluid.Position() + offset;
         float sizeMin = 0.5f;
         float sizeMax = Mathf.Pow(volume, 0.25f);
         float x = Random.value;
         float y = Random.value;
         Vector3 size = (sizeMin + 1f / (1f/sizeMax + x*y)) * Util.RandomVector(1f, 1.5f);
         Fish fish = new Fish(pos, size);
         fish.currentFluid = fluid.Component<Fluid>();
         fishes.Add(fish);
     }
     return fishes;
 }