public static void ReloadBlueprints(bool ingame) { BlueprintsState.LoadedBlueprints.Clear(); string[] blueprintFiles = Directory.GetFiles(GetBlueprintDirectory()); foreach (string blueprintFile in blueprintFiles) { if (blueprintFile.EndsWith(".blueprint") || blueprintFile.EndsWith(".json")) { Blueprint blueprint = new Blueprint(blueprintFile); if (blueprint.ReadBinary() && !blueprint.IsEmpty()) { BlueprintsState.LoadedBlueprints.Add(blueprint); } else if (blueprint.ReadJSON() && !blueprint.IsEmpty()) { BlueprintsState.LoadedBlueprints.Add(blueprint); } } } if (ingame && BlueprintsState.LoadedBlueprints.Count > 0) { BlueprintsState.SelectedBlueprintIndex = 0; BlueprintsState.ClearVisuals(); BlueprintsState.VisualizeBlueprint(Grid.PosToXY(PlayerController.GetCursorPos(KInputManager.GetMousePos())), BlueprintsState.SelectedBlueprint); } }
public static bool LoadBlueprint(string blueprintLocation, out Blueprint blueprint) { blueprint = new Blueprint(blueprintLocation); if (!blueprint.ReadBinary()) { blueprint.ReadJson(); } return(!blueprint.IsEmpty()); }
public static void LoadFolder(string folder) { string[] files = Directory.GetFiles(folder); string[] subfolders = Directory.GetDirectories(folder); foreach (string file in files) { if (file.EndsWith(".blueprint") || file.EndsWith(".json")) { Blueprint blueprint = new Blueprint(file); bool valid = false; if (blueprint.ReadBinary() && !blueprint.IsEmpty()) { valid = true; } else { blueprint.ReadJSON(); if (!blueprint.IsEmpty()) { valid = true; } } if (valid) { PlaceIntoFolder(blueprint); } } } foreach (string subfolder in subfolders) { LoadFolder(subfolder); } }