Ejemplo n.º 1
0
        public World(JSMap map, WorldDesc desc)
        {
            Map    = map;
            Width  = map.Width;
            Height = map.Height;

            Background    = desc.Background;
            ShowDisplays  = desc.ShowDisplays;
            AllowTeleport = desc.AllowTeleport;
            BlockSight    = desc.BlockSight;

            Name        = desc.Id;
            DisplayName = desc.DisplayName;

            Entities  = new Dictionary <int, Entity>();
            Quests    = new Dictionary <int, Entity>();
            Constants = new Dictionary <int, Entity>();
            Players   = new Dictionary <int, Player>();
            Statics   = new Dictionary <int, StaticObject>();

            EntityChunks = new ChunkController(Width, Height);
            PlayerChunks = new ChunkController(Width, Height);

            ChatMessages = new List <string>();

            Tiles = new Tile[Width, Height];

            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    JSTile js   = map.Tiles[x, y];
                    Tile   tile = Tiles[x, y] = new Tile()
                    {
                        Type        = js.GroundType,
                        Region      = js.Region,
                        UpdateCount = int.MaxValue / 2
                    };

                    if (js.ObjectType != 0xff)
                    {
                        Entity entity = Entity.Resolve(js.ObjectType);
                        if (entity.Desc.Static)
                        {
                            if (entity.Desc.BlocksSight)
                            {
                                tile.BlocksSight = true;
                            }
                            tile.StaticObject = (StaticObject)entity;
                        }

                        AddEntity(entity, new Position(x + 0.5f, y + 0.5f));
                    }
                }
            }
            UpdateCount = int.MaxValue / 2;
        }
Ejemplo n.º 2
0
        public static World AddWorld(WorldDesc desc, int id)
        {
            World world = new World(desc.Maps[MathUtils.Next(desc.Maps.Length)], desc);

            world.Id         = id;
            Worlds[world.Id] = world;
#if DEBUG
            Program.Print(PrintType.Debug, $"Added World ID <{world.Id}> <{desc.Id}:{desc.DisplayName}>");
#endif
            return(world);
        }
Ejemplo n.º 3
0
 public static void AddWorld(WorldDesc desc)
 {
     AddWorld(desc, ++NextWorldId);
 }