public Inventory(dynamic json, string groupName, InventoryItemTypes invItemTypes, IEnumerable <InventoryItemCategory> allowedCategories, int maxWidth, int maxHeight) { _json = json; _groupName = groupName; _invItemTypes = invItemTypes; _maxWidth = maxWidth; _maxHeight = maxHeight; _allowedCategories = new HashSet <InventoryItemCategory>(allowedCategories); _maxProductAmount = allowedCategories.Contains(InventoryItemCategory.Product) ? 1 * (int)_json.ProductMaxStorageMultiplier : 0; _maxSubstanceAmount = allowedCategories.Contains(InventoryItemCategory.Substance) ? 250 * (int)_json.SubstanceMaxStorageMultiplier : 0; LoadSlots(); }
public GameSave(string jsonStr, InventoryItemTypes invItemTypes) { _json = JObject.Parse(jsonStr); _invItemTypes = invItemTypes; }
/// <summary> /// Creates a GameSaveManager attached to the specified NMS game save directory. /// </summary> public GameSaveManager(string saveDir, TextWriter log, TextWriter logVerbose) { _log = log; _logVerbose = logVerbose; if (saveDir != null) { if (Directory.EnumerateFiles(saveDir, "save*.hg").Count() > 0) { _savePath = saveDir; } else { throw new FileNotFoundException(string.Format("Specified save game directory does not contain any save game files: {0}", saveDir)); } } else { var nmsPath = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "HelloGames"), "NMS"); if (!Directory.Exists(nmsPath)) { throw new FileNotFoundException(string.Format("No Man's Sky save game folder not found at expected location: {0}", nmsPath)); } LogVerbose("Using NMS AppData folder: {0}", nmsPath); // Check for GoG version of the game (hat tip to Reddit user, Yarmoshuk) var gogDir = Path.Combine(nmsPath, "DefaultUser"); if (Directory.Exists(gogDir) && Directory.EnumerateFiles(gogDir, "save*.hg").Count() > 0) { _savePath = gogDir; } if (null == _savePath) { foreach (var dir in Directory.EnumerateDirectories(nmsPath)) { _profileKey = GetProfileKeyFromPath(dir); if (null != _profileKey) { _savePath = dir; break; } } } if (null == _savePath) { foreach (var dir in Directory.EnumerateDirectories(nmsPath)) { if (Directory.EnumerateFiles(dir, "save*.hg").Count() > 0) { _savePath = dir; } } } if (null == _savePath) { throw new FileNotFoundException(string.Format("No save game profile folder found in NMS save game folder: {0}", nmsPath)); } } LogVerbose("Using save path: {0}", _savePath); // Attempt to load list of valid item types _inventoryItemTypes = new InventoryItemTypes(LoadInventoryItemTypesFromDefaultCsvFile()); }