public static void ConvertMap(MapListEntry map) { var mobiles = new List <SavedGameObject>(); var mapDir = $"maps/{map.name}"; foreach (var mobFile in Tig.FS.Search($"{mapDir}/*.mob")) { using var reader = Tig.FS.OpenBinaryReader(mobFile); mobiles.Add(SavedGameObject.Load(reader)); } mobiles.Sort((a, b) => a.Id.guid.CompareTo(b.Id.guid)); using var stream = new FileStream($"{map.id}_{map.name}_mobiles.json", FileMode.Create); using var writer = new Utf8JsonWriter(stream, new JsonWriterOptions { Indented = true }); writer.WriteStartArray(); foreach (var mobile in mobiles) { WriteMobile(writer, mobile); } writer.WriteEndArray(); }
void HostGame(MapListEntry map) { Network.InitializeServer(32, 25000, false); networkView.RPC("LoadLevel", RPCMode.AllBuffered, map.levelName, lastLevelPrefix + 1); }
public static Dictionary <int, MapListEntry> Parse(IFileSystem fs, bool alwaysFog = false, bool alwaysUnfog = false) { var mapList = fs.ReadMesFile("rules/MapList.mes"); var mapNames = fs.ReadMesFile("mes/map_names.mes"); var mMaps = new Dictionary <int, MapListEntry>(mapList.Count); foreach (var(mapId, line) in mapList) { var entry = new MapListEntry(); var parts = line.Split(','); entry.id = mapId; entry.name = parts[0]; entry.startPosX = int.Parse(parts[1]); entry.startPosY = int.Parse(parts[2]); entry.flags = 0; if (alwaysUnfog) { entry.flags |= 4; } // The rest are key value pairs for (var i = 3; i < parts.Length; ++i) { var subParts = parts[i].Split(':'); var key = subParts[0].Trim(); var value = subParts[1].Trim(); switch (key) { case "Type": switch (value) { case "NONE": entry.type = MapType.None; break; case "START_MAP": entry.type = MapType.StartMap; break; case "SHOPPING_MAP": entry.type = MapType.ShoppingMap; break; case "TUTORIAL_MAP": entry.type = MapType.TutorialMap; break; } break; case "WorldMap": entry.worldmap = int.Parse(value); break; case "Area": entry.area = int.Parse(value); break; case "Movie": entry.movie = int.Parse(value); break; case "Flag": switch (value) { case "DAYNIGHT_XFER": entry.flags |= 1; break; case "OUTDOOR": entry.flags |= 2; break; case "UNFOGGED": { if (!alwaysFog) { entry.flags |= 4; } break; } case "BEDREST": entry.flags |= 8; break; } break; default: Logger.Warn("Unknown map key '{1}' for map {0}", mapId, key); break; } } // Copy the description from map_names.mes if (mapNames.TryGetValue(mapId, out var mapName)) { entry.description = mapName; } else { Logger.Warn("Missing map description for {0}", mapId); entry.description = entry.name; } mMaps[mapId] = entry; } // Get info from hardcoded map areas table (bleh) foreach (var entry in mMaps.Values) { if (entry.area == 0) { entry.area = GetAreaForVanillaMap(entry.id); } } return(mMaps); }