Ejemplo n.º 1
0
 /// <summary>
 /// Processes the block queue
 /// </summary>
 public void ProcessQueue()
 {
     //I am not sure why the function never exits, however, this is the intended behaviour.
     while (WorldRef.Terrain.Queue.Count > 0)
     {
         Vector2 b  = WorldRef.Terrain.Queue.Dequeue();
         int     rd = WorldRef.Terrain.RenderDistance == 0 ? 8 : WorldRef.Terrain.RenderDistance;
         // Unit blk = WorldLoader.Load((int)b.X, (int)b.Y);
         // blk = WorldGenerator.GenerateBlock((int)b.X, (int)b.Y, 64);
         //Math.Abs(blk.Value.X - X) > rd || Math.Abs(blk.Value.Y - Y) > rd
         Unit         blk    = null;
         WinRNG       rng    = new WinRNG(this.Seed);
         NPCGenerator npcgen = new NPCGenerator(rng);
         if (Map == null)
         {
             continue;
         }
         Location l = Map.Locations[Map.LocationData[(int)b.X, (int)b.Y]];
         if (blk == null)
         {
             if (Math.Abs(b.X - LastX) > rd || Math.Abs(b.Y - LastY) > rd)
             {
                 continue;
             }
             if (b.X < 0 || b.Y < 0)
             {
                 continue;
             }
             //create terrain block
             blk = GenerateBlock((int)b.X, (int)b.Y);
             Terrain.Console.Write("^00FF00 Generated " + ((int)b.X).ToString() + "." + ((int)b.Y).ToString());
             //code to place NPCs and other crap goes here!!
             if (l.Type == Location.LocationType.Town)
             {
                 int amount = rng.NextInt(5, 20);
                 for (int i = 0; i < amount; i++)
                 {
                     GameObject.MapEntities.Actors.NPC npc = npcgen.GenerateOneNPC();
                     npc.Position.BX = (int)b.X;
                     npc.Position.BY = (int)b.Y;
                     npc.Position   += new Vector3(rng.NextInt(1, BlockSize - 1), -1, rng.NextInt(1, BlockSize - 1));
                     npc.WorldSpawn  = WorldRef;
                     npc.Greeting    = "Hello, I live in " + l.Name;
                     WorldRef.Entities.Add(npc);
                 }
             }
         }
         else
         {
             //  Volatile.Console.Write("^00FF00 Loaded " + ((int)b.X).ToString() + "." + ((int)b.Y).ToString());
         }
         lock (blk)
         {
             WorldRef.Terrain.Blocks.GetOrAdd(blk.X + blk.Y * BlockSize, blk);
         }
     }
 }
Ejemplo n.º 2
0
        public List <MapEntity> GenerateObjectsTest(int count)
        {
            List <MapEntity> results = new List <MapEntity>();
            MonsterGenerator mg      = new MonsterGenerator(this.RNG);
            NPCGenerator     ng      = new NPCGenerator(this.RNG);

            results.AddRange(mg.GenerateTestMonsters((int)count / 3));
            results.AddRange(ng.GenerateTestNPCs((int)count));
            return(results);
        }