public void Load(BinaryReader pReader) { Identifier = pReader.ReadInt32(); Flags = (EMapFlags)pReader.ReadUInt16(); ShuffleName = pReader.ReadString(); Music = pReader.ReadString(); MinLevelLimit = pReader.ReadByte(); TimeLimit = pReader.ReadUInt16(); RegenRate = pReader.ReadByte(); Traction = pReader.ReadSingle(); LeftTopX = pReader.ReadInt16(); LeftTopY = pReader.ReadInt16(); RightBottomX = pReader.ReadInt16(); RightBottomY = pReader.ReadInt16(); ReturnMapIdentifier = pReader.ReadInt32(); ForcedReturnMapIdentifier = pReader.ReadInt32(); FieldTypes = (EMapFieldType)pReader.ReadUInt16(); FieldLimits = (EMapFieldLimit)pReader.ReadUInt32(); DecreaseHP = pReader.ReadByte(); DamagePerSecond = pReader.ReadUInt16(); ProtectItemIdentifier = pReader.ReadInt32(); MobRate = pReader.ReadSingle(); LinkIdentifier = pReader.ReadInt32(); int footholdsCount = pReader.ReadInt32(); Footholds = new List<MapFootholdData>(footholdsCount); while (footholdsCount-- > 0) { MapFootholdData foothold = new MapFootholdData(); foothold.Load(pReader); Footholds.Add(foothold); } int npcsCount = pReader.ReadInt32(); NPCs = new List<MapNPCData>(npcsCount); while (npcsCount-- > 0) { MapNPCData npc = new MapNPCData(); npc.Load(pReader); NPCs.Add(npc); } int reactorsCount = pReader.ReadInt32(); Reactors = new List<MapReactorData>(reactorsCount); while (reactorsCount-- > 0) { MapReactorData reactor = new MapReactorData(); reactor.Load(pReader); Reactors.Add(reactor); } int mobsCount = pReader.ReadInt32(); Mobs = new List<MapMobData>(mobsCount); while (mobsCount-- > 0) { MapMobData mob = new MapMobData(); mob.Load(pReader); Mobs.Add(mob); } int portalsCount = pReader.ReadInt32(); Portals = new List<MapPortalData>(portalsCount); while (portalsCount-- > 0) { MapPortalData portal = new MapPortalData(); portal.Load(pReader); Portals.Add(portal); } int seatsCount = pReader.ReadInt32(); Seats = new List<MapSeatData>(seatsCount); while (seatsCount-- > 0) { MapSeatData seat = new MapSeatData(); seat.Load(pReader); Seats.Add(seat); } }
public Portal(MapPortalData data) { this.ID = data.ID; this.Data = data; }
public static void Export(string inputPath, string outputPath) { List <MapData> maps = new List <MapData>(); using (WZFile file = new WZFile(Path.Combine(inputPath, "Map.wz"), WZVariant.GMS, true, WZReadSelection.None)) { foreach (var category in file.MainDirectory["Map"]) { if (category.Name == "AreaCode.img") { continue; } foreach (var node in category) { MapData map = new MapData(); map.MapleID = node.GetID(); map.ReturnMapID = node["info"].GetInt("returnMap"); map.ForcedReturnMapID = node["info"].GetInt("forcedReturn"); map.Footholds = new List <MapFootholdData>(); if (node.HasChild("foothold")) { foreach (var footholdNode in node["foothold"]) { } } map.Mobs = new List <MapMobSpawnData>(); map.Npcs = new List <MapNpcSpawnData>(); if (node.HasChild("life")) { foreach (var lifeNode in node["life"]) { string type = lifeNode.GetString("type"); int mapleID = lifeNode.GetInt("id"); short foothold = (short)lifeNode.GetInt("fh"); Point position = new Point(lifeNode.GetInt("x"), lifeNode.GetInt("y")); bool flip = lifeNode.GetInt("f") == 1; bool hide = lifeNode.GetInt("hide") == 1; if (type == "m") { MapMobSpawnData mob = new MapMobSpawnData(); mob.MapleID = mapleID; mob.Foothold = foothold; mob.Positon = position; mob.Flip = flip; mob.Hide = hide; mob.RespawnTime = lifeNode.GetInt("mobTime"); map.Mobs.Add(mob); } else if (type == "n") { MapNpcSpawnData npc = new MapNpcSpawnData(); npc.MapleID = mapleID; npc.Foothold = foothold; npc.Positon = position; npc.Flip = flip; npc.Hide = hide; npc.MinimumClickX = (short)lifeNode.GetInt("rx0"); npc.MaximumClickX = (short)lifeNode.GetInt("rx1"); map.Npcs.Add(npc); } } } map.Portals = new List <MapPortalData>(); if (node.HasChild("portal")) { foreach (var portalNode in node["portal"]) { MapPortalData portal = new MapPortalData(); portal.ID = byte.Parse(portalNode.Name); portal.Label = portalNode.GetString("pn"); portal.DestinationMap = portalNode.GetInt("tm"); portal.DestinationLabel = portalNode.GetString("tn"); portal.Script = portalNode.GetString("script"); portal.Position = new Point(portalNode.GetInt("x"), portalNode.GetInt("y")); map.Portals.Add(portal); } } map.Reactors = new List <MapReactorData>(); if (node.HasChild("reactor")) { foreach (var reactorNode in node["reactor"]) { } } map.Seats = new List <MapSeatData>(); if (node.HasChild("seat")) { foreach (var seatNode in node["seat"]) { } } maps.Add(map); } } } maps = maps.OrderBy(m => m.MapleID).ToList(); using (FileStream stream = File.Create(Path.Combine(outputPath, "Maps.bin"))) { using (BinaryWriter writer = new BinaryWriter(stream)) { writer.Write(maps.Count); foreach (MapData map in maps) { map.Save(writer); } } } Logger.Write(LogLevel.Info, "Exported {0} maps.", maps.Count); maps.Clear(); }