internal static void putBag(GearItem bag) { string guid = Utils.GetGuidFromGameObject(bag.gameObject); if (string.IsNullOrEmpty(guid)) { Utils.SetGuidForGameObject(bag.gameObject, Guid.NewGuid().ToString()); guid = Utils.GetGuidFromGameObject(bag.gameObject); } MooseBagData lMBD = new MooseBagData(); MBD.Add(guid, lMBD); MBD[guid].ver = dataVersion; MBD[guid].timestamp = GameManager.GetTimeOfDayComponent().GetTODSeconds(GameManager.GetTimeOfDayComponent().GetSecondsPlayedUnscaled()); MBD[guid].bagId = guid; MBD[guid].weight = 0; // loop via inventory and add stuff Inventory inventoryComponent = GameManager.GetInventoryComponent(); foreach (GearItemObject item in inventoryComponent.m_Items) { GearItem gi = item; if (gi.name == "GEAR_Gut" || isPerishableFood(gi)) { addToBag(gi); } } }
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); } } }