public static void setMissingFloorsToDefault(StardewValley.Locations.FarmHouse house) { List <Rectangle> floors = house.getFloors(); while (house.floor.Count < floors.Count) { house.floor[house.floor.Count] = getFloorIndex(house.map, floors[house.floor.Count].X, floors[house.floor.Count].Y); } }
public static void setMissingWallpaperToDefault(StardewValley.Locations.FarmHouse house) { List <Rectangle> walls = house.getWalls(); while (house.wallPaper.Count < walls.Count) { house.wallPaper[house.wallPaper.Count] = getWallpaperIndex(house.map, walls[house.wallPaper.Count].X, walls[house.wallPaper.Count].Y); } }
//organize items behaviour public void OrganizeItems() { items.Sort(); items.Reverse(); StardewValley.Locations.FarmHouse h = (StardewValley.Locations.FarmHouse)Game1.currentLocation; h.fridge.items = items; currentpage = 0; ShowCurrentPage(); }
public static void setWallpaperDefaults(StardewValley.Locations.FarmHouse house) { List <Rectangle> walls = house.getWalls(); List <Rectangle> floors = house.getFloors(); for (int wallIndex = 0; wallIndex < walls.Count; wallIndex++) { Logger.Log("Setting default wall for the wall " + walls[wallIndex].ToString() + "..."); int wallPaperIndex = getWallpaperIndex(house.map, walls[wallIndex].X, walls[wallIndex].Y); house.setWallpaper(wallPaperIndex, wallIndex, true); } }
public void clearNulls() { for (int index = this.items.Count <Item>() - 1; index >= 0; --index) { if (this.items[index] == null) { this.items.RemoveAt(index); //if (_autoSwitchPageOnGrab) { currentpage = GetPageForIndex(index); } } } StardewValley.Locations.FarmHouse h = (StardewValley.Locations.FarmHouse)Game1.currentLocation; h.fridge.items = items; }
public static Point getKitchenSpot(StardewValley.Locations.FarmHouse house) { if (kitchenData == null) { updateFromMapPath(house.mapPath); } if (kitchenData != "") { Logger.Log("Map defined kitchen location..."); string[] kitchenPoint = kitchenData.Split(' '); return(new Point(Convert.ToInt32(kitchenPoint[0]), Convert.ToInt32(kitchenPoint[1]))); } else { Logger.Log("Map did not define kitchen location."); return(house.getKitchenStandingSpot()); } }
public static Point getCellarLocation(StardewValley.Locations.FarmHouse house) { if (cellarData == null) { updateFromMapPath(house.mapPath); } if (cellarData != "") { Logger.Log("Map defined entry location..."); string[] cellarPoint = cellarData.Split(' '); return(new Point(Convert.ToInt32(cellarPoint[0]), Convert.ToInt32(cellarPoint[1]))); } else { Logger.Log("Map did not define cellar return location."); return(new Point(-1, -1)); } }
public static Point getEntryLocation(StardewValley.Locations.FarmHouse house) { if (entryData == null) { updateFromMapPath(house.mapPath); } if (entryData != "") { Logger.Log("Map defined entry location..."); string[] entryPoint = entryData.Split(' '); return(new Point(Convert.ToInt32(entryPoint[0]), Convert.ToInt32(entryPoint[1]))); } else { Logger.Log("Map did not define entry location."); return(house.getEntryLocation()); } }
//behaviorOnItemGrab public void grabItemFromChest(Item item, StardewValley.Farmer who) { if (!who.couldInventoryAcceptThisItem(item)) { return; } this.items.Remove(item); this.clearNulls(); StardewValley.Locations.FarmHouse h = (StardewValley.Locations.FarmHouse)Game1.currentLocation; h.fridge.items = items; //TODO: implement page change //List<Item> newItems = GetCurrentPageItems(); this.ShowCurrentPage(); }
public Item addItem(Item item) { lastAddedItem = null; for (int index = 0; index < this.items.Count <Item>(); ++index) { if (this.items[index] != null && this.items[index].canStackWith(item)) { item.Stack = this.items[index].addToStack(item.Stack); if (item.Stack <= 0) { return((Item)null); } if (_autoSwitchPageOnGrab) { currentpage = GetPageForIndex(index); } } } if (this.items.Count <Item>() >= MAX_CAPACITY) { return(item); } this.items.Add(item); if (_autoSwitchPageOnGrab) { currentpage = GetPageForIndex(this.items.Count); } lastAddedItem = item; StardewValley.Locations.FarmHouse h = (StardewValley.Locations.FarmHouse)Game1.currentLocation; h.fridge.items = items; return((Item)null); }
public static Point getBedSpot(StardewValley.Locations.FarmHouse house, bool spouse = false) { Logger.Log("Getting bed location..."); if (bedData == null) { FarmHouseStates.updateFromMapPath(house.mapPath); } if (FarmHouseStates.bedData != "") { Logger.Log("Map defined bed location..."); string[] bedPoint = FarmHouseStates.bedData.Split(' '); return(new Point(Convert.ToInt32(bedPoint[0]) + (spouse ? 2 : 0), Convert.ToInt32(bedPoint[1]))); } else { Logger.Log("Map did not define a bed location, using vanilla."); if (spouse) { return(house.getSpouseBedSpot()); } return(house.getBedSpot()); } }
public static void myConsumeIngredients(CraftingRecipe recipe, bool actuallyConsume = true, List <ConsumedItem> used = null) { ///// (removed this) Dictionary <int, int> recipeList = (Dictionary <int, int>)Util.GetInstanceField(typeof(CraftingRecipe), recipe, "recipeList"); ///// for (int index1 = recipeList.Count - 1; index1 >= 0; --index1) { int recipe1 = recipeList[recipeList.Keys.ElementAt <int>(index1)]; bool flag = false; for (int index2 = Game1.player.items.Count - 1; index2 >= 0; --index2) { if (Game1.player.items[index2] != null && Game1.player.items[index2] is SObject && !(bool)((NetFieldBase <bool, NetBool>)(Game1.player.items[index2] as SObject).bigCraftable) && ((int)((NetFieldBase <int, NetInt>)Game1.player.items[index2].parentSheetIndex) == recipeList.Keys.ElementAt <int>(index1) || Game1.player.items[index2].Category == recipeList.Keys.ElementAt <int>(index1))) { int recipe2 = recipeList[recipeList.Keys.ElementAt <int>(index1)]; recipeList[recipeList.Keys.ElementAt <int>(index1)] -= Game1.player.items[index2].Stack; ///// if (used != null) { used.Add(new ConsumedItem(Game1.player.items[index1] as SObject)); } if (actuallyConsume) { ///// Game1.player.items[index2].Stack -= recipe2; } if (Game1.player.items[index2].Stack <= 0) { Game1.player.items[index2] = (Item)null; } if (recipeList[recipeList.Keys.ElementAt <int>(index1)] <= 0) { recipeList[recipeList.Keys.ElementAt <int>(index1)] = recipe1; flag = true; break; } } } ///// Use of recipe, StardewValley.Locations if (recipe.isCookingRecipe && !flag) { StardewValley.Locations.FarmHouse homeOfFarmer = Utility.getHomeOfFarmer(Game1.player); if (homeOfFarmer != null) { for (int index2 = homeOfFarmer.fridge.Value.items.Count - 1; index2 >= 0; --index2) { if (homeOfFarmer.fridge.Value.items[index2] != null && homeOfFarmer.fridge.Value.items[index2] is SObject && ((int)((NetFieldBase <int, NetInt>)homeOfFarmer.fridge.Value.items[index2].parentSheetIndex) == recipeList.Keys.ElementAt <int>(index1) || homeOfFarmer.fridge.Value.items[index2].Category == recipeList.Keys.ElementAt <int>(index1))) { int recipe2 = recipeList[recipeList.Keys.ElementAt <int>(index1)]; recipeList[recipeList.Keys.ElementAt <int>(index1)] -= homeOfFarmer.fridge.Value.items[index2].Stack; ///// if (used != null) { used.Add(new ConsumedItem(homeOfFarmer.fridge.Value.items[index2] as SObject)); } if (actuallyConsume) { ///// homeOfFarmer.fridge.Value.items[index2].Stack -= recipe2; } if (homeOfFarmer.fridge.Value.items[index2].Stack <= 0) { homeOfFarmer.fridge.Value.items[index2] = (Item)null; } if (recipeList[recipeList.Keys.ElementAt <int>(index1)] <= 0) { recipeList[recipeList.Keys.ElementAt <int>(index1)] = recipe1; break; } } } } } } }
public static void myConsumeIngredients(CraftingRecipe recipe, bool actuallyConsume = true, List <ConsumedItem> used = null) { Dictionary <int, int> recipeList = (Dictionary <int, int>)Util.GetInstanceField(typeof(CraftingRecipe), recipe, "recipeList"); for (int i = recipeList.Count - 1; i >= 0; i--) { int value = recipeList[recipeList.Keys.ElementAt(i)]; bool flag = false; for (int j = Game1.player.items.Count - 1; j >= 0; j--) { if (Game1.player.items[j] != null && Game1.player.items[j] is StardewValley.Object && !(Game1.player.items[j] as Object).bigCraftable && (((Object)Game1.player.items[j]).parentSheetIndex == recipeList.Keys.ElementAt(i) || ((StardewValley.Object)Game1.player.items[j]).category == recipeList.Keys.ElementAt(i))) { int num = recipeList[recipeList.Keys.ElementAt(i)]; Dictionary <int, int> dictionary = recipeList; int key = recipeList.Keys.ElementAt(i); dictionary[key] -= Game1.player.items[j].Stack; /////////////////////////////////////////////////////// if (used != null) { used.Add(new ConsumedItem(Game1.player.items[j] as StardewValley.Object)); } if (actuallyConsume) { /////////////////////////////////////////////////////// Game1.player.items[j].Stack -= num; } if (Game1.player.items[j].Stack <= 0) { Game1.player.items[j] = null; } if (recipeList[recipeList.Keys.ElementAt(i)] <= 0) { recipeList[recipeList.Keys.ElementAt(i)] = value; flag = true; break; } } } if (recipe.isCookingRecipe && !flag) { StardewValley.Locations.FarmHouse homeOfFarmer = Utility.getHomeOfFarmer(Game1.player); if (homeOfFarmer != null) { for (int k = homeOfFarmer.fridge.Value.items.Count - 1; k >= 0; k--) { if (homeOfFarmer.fridge.Value.items[k] != null && homeOfFarmer.fridge.Value.items[k] is StardewValley.Object && (((StardewValley.Object)homeOfFarmer.fridge.Value.items[k]).parentSheetIndex == recipeList.Keys.ElementAt(i) || ((Object)homeOfFarmer.fridge.Value.items[k]).category == recipeList.Keys.ElementAt(i))) { int num2 = recipeList[recipeList.Keys.ElementAt(i)]; Dictionary <int, int> dictionary = recipeList; int key = recipeList.Keys.ElementAt(i); dictionary[key] -= homeOfFarmer.fridge.Value.items[k].Stack; /////////////////////////////////////////////////////// if (used != null) { used.Add(new ConsumedItem(homeOfFarmer.fridge.Value.items[k] as StardewValley.Object)); } if (actuallyConsume) { /////////////////////////////////////////////////////// homeOfFarmer.fridge.Value.items[k].Stack -= num2; } if (homeOfFarmer.fridge.Value.items[k].Stack <= 0) { homeOfFarmer.fridge.Value.items[k] = null; } if (recipeList[recipeList.Keys.ElementAt(i)] <= 0) { recipeList[recipeList.Keys.ElementAt(i)] = value; break; } } } } } } }