Exemplo n.º 1
0
        public virtual bool Open(Rectangle dimensions)
        {
            if (isOpened)
            {
                throw new Exception("Cannot open map because it is alread opened.");
            }

            //PoMWorld pomWorld = PathOfModifiers.Instance.GetModWorld<PoMWorld>();
            //int ID = pomWorld.AddOpenMap(this);

            //if (ID < 0)
            //    return false;

            generator.GenerateTerrain(dimensions);
            int npcs = GetNPCFrequency(dimensions);

            generator.SpawnPacks(dimensions, npcs, MakePackArray(npcs));


            openMap = new OpenMap(dimensions);


            //This method should never run on a client, so only case is SP/Server
            if (Main.netMode == NetmodeID.Server)
            {
                MapPacketHandler.SSyncOpenedMap(dimensions);
            }

            return(true);
        }
Exemplo n.º 2
0
        public virtual void Load(TagCompound tag)
        {
            Initialize();
            if (tag.GetBool("isOpened"))
            {
                var openMapTag = tag.GetCompound("openMap");

                //PoMWorld pomWorld = PathOfModifiers.Instance.GetModWorld<PoMWorld>();

                //int ID = openMapTag.GetInt("ID");
                //pomWorld.AddOpenMap(this, ID);

                openMap = new OpenMap(openMapTag.Get <Rectangle>("dimensions"));
            }
        }
Exemplo n.º 3
0
        public virtual void NetReceive(BinaryReader reader)
        {
            if (reader.ReadBoolean())
            {
                //PoMWorld pomWorld = PathOfModifiers.Instance.GetModWorld<PoMWorld>();

                //int ID = reader.ReadInt32();
                //pomWorld.AddOpenMap(this, ID, true);
                openMap = new OpenMap(
                    new Rectangle(
                        reader.ReadInt32(),
                        reader.ReadInt32(),
                        reader.ReadInt32(),
                        reader.ReadInt32()));
            }
        }
Exemplo n.º 4
0
        public virtual void Close()
        {
            if (!isOpened)
            {
                throw new Exception("Cannot close map because it is not opened.");
            }

            generator.ClearMap(openMap.dimensions);


            if (Main.netMode == NetmodeID.Server)
            {
                MapPacketHandler.SSyncOpenedMap(openMap.dimensions, true);
            }


            //PoMWorld pomWorld = PathOfModifiers.Instance.GetModWorld<PoMWorld>();
            //pomWorld.RemoveOpenMap(openMap.ID);

            openMap = null;
        }