internal static void LoadData(string name) { MD.Clear(); MBD.Clear(); string data = SaveGameSlots.LoadDataFromSlot(name + "d", SAVE_NAME); if (!string.IsNullOrEmpty(data)) { //MelonLogger.Log("JSON loaded " + data); var foo = JSON.Load(data); foreach (var entry in foo as ProxyObject) { MooseData lMD = new MooseData(); entry.Value.Populate(lMD); MD.Add(entry.Key, lMD); } } data = SaveGameSlots.LoadDataFromSlot(name + "b", SAVE_NAME); if (!string.IsNullOrEmpty(data)) { //MelonLogger.Log("JSON loaded " + data); var foo = JSON.Load(data); foreach (var entry in foo as ProxyObject) { MooseBagData lMBD = new MooseBagData(); entry.Value.Populate(lMBD); MBD.Add(entry.Key, lMBD); } } // look for items in player inverntory and apply stats Inventory inventoryComponent = GameManager.GetInventoryComponent(); foreach (GearItemObject item in inventoryComponent.m_Items) { GearItem gi = item; string guid = Utils.GetGuidFromGameObject(gi.gameObject); if (!string.IsNullOrEmpty(guid) && MD.ContainsKey(guid)) { applyStats(gi, true); } } }
internal static void addToBag(GearItem gi) { float gikg = gi.GetItemWeightKG(); string bgid = findBagSpace(gikg); if (!string.IsNullOrEmpty(bgid)) { string guid = Utils.GetGuidFromGameObject(gi.gameObject); if (string.IsNullOrEmpty(guid)) { Utils.SetGuidForGameObject(gi.gameObject, Guid.NewGuid().ToString()); guid = Utils.GetGuidFromGameObject(gi.gameObject); } //MelonLogger.Log("addtobag: " + gi.name + " " + gikg + " guid: " + guid + " bgid: " + bgid); if (!MD.ContainsKey(guid)) { MooseData lMD = new MooseData(); MD.Add(guid, lMD); } MD[guid].timestamp = GameManager.GetTimeOfDayComponent().GetTODSeconds(GameManager.GetTimeOfDayComponent().GetSecondsPlayedUnscaled()); MD[guid].ver = dataVersion; MD[guid].foodId = guid; MD[guid].bagId = bgid; MD[guid].scentIntensity = gi.m_ScentIntensity; MD[guid].weight = gikg; MBD[bgid].weight += gikg; if (isPerishableFood(gi)) { FoodItem fi = gi.GetComponent <FoodItem>(); MD[guid].foodDecayIndoor = fi.m_DailyHPDecayInside; MD[guid].foodDecayOutdoor = fi.m_DailyHPDecayOutside; } applyStats(gi, true); } }