Added in crafting books for workbenches and other crafting tables, added in unlockable crafting recipes, and made the menu show up when innteracting with new crafting tables.
This commit is contained in:
parent
733461ecde
commit
cf3029306b
Binary file not shown.
After Width: | Height: | Size: 917 B |
Binary file not shown.
After Width: | Height: | Size: 558 B |
|
@ -0,0 +1,240 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Revitalize.Framework.Menus;
|
||||||
|
using Revitalize.Framework.Utilities;
|
||||||
|
using StardewValley;
|
||||||
|
using StardustCore.Animations;
|
||||||
|
using StardustCore.UIUtilities;
|
||||||
|
using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons;
|
||||||
|
|
||||||
|
namespace Revitalize.Framework.Crafting
|
||||||
|
{
|
||||||
|
public class CraftingRecipeBook
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Organizes crafting recipes by group. So a workbench would have a workbench crafting book, and anvil has different recipes, etc.
|
||||||
|
/// </summary>
|
||||||
|
public static Dictionary<string, CraftingRecipeBook> CraftingRecipesByGroup;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// All of the crafting recipes contained by this crafting list.
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, UnlockableCraftingRecipe> craftingRecipes;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// All of the crafting tabs to be used for the menu.
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<string, AnimatedButton> craftingMenuTabs;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Which group of crafting recipes this book belongs to.
|
||||||
|
/// </summary>
|
||||||
|
public string craftingGroup;
|
||||||
|
|
||||||
|
public string defaultTab;
|
||||||
|
|
||||||
|
public CraftingRecipeBook()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public CraftingRecipeBook(string CraftingGroup)
|
||||||
|
{
|
||||||
|
this.craftingGroup = CraftingGroup;
|
||||||
|
this.craftingRecipes = new Dictionary<string, UnlockableCraftingRecipe>();
|
||||||
|
this.craftingMenuTabs = new Dictionary<string, AnimatedButton>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds in a new crafting recipe.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Name"></param>
|
||||||
|
/// <param name="Recipe"></param>
|
||||||
|
public void addCraftingRecipe(string Name, UnlockableCraftingRecipe Recipe)
|
||||||
|
{
|
||||||
|
if (this.craftingRecipes.ContainsKey(Name) == false)
|
||||||
|
{
|
||||||
|
this.craftingRecipes.Add(Name, Recipe);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("This crafting book already contains a recipe with the same id!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds in a crafting recipe.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Name"></param>
|
||||||
|
/// <param name="Recipe"></param>
|
||||||
|
/// <param name="Unlocked">Is this recipe already unlocked?</param>
|
||||||
|
public void addCraftingRecipe(string Name, Recipe Recipe, bool Unlocked)
|
||||||
|
{
|
||||||
|
UnlockableCraftingRecipe recipe = new UnlockableCraftingRecipe(this.craftingGroup, Recipe, Unlocked);
|
||||||
|
this.addCraftingRecipe(Name, recipe);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addInCraftingTab(string TabName, AnimatedButton TabSprite, bool IsDefaultTab)
|
||||||
|
{
|
||||||
|
if (this.craftingMenuTabs.ContainsKey(TabName))
|
||||||
|
{
|
||||||
|
throw new Exception("A tab with the same name already exists!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.craftingMenuTabs.Add(TabName, TabSprite);
|
||||||
|
}
|
||||||
|
if (IsDefaultTab)
|
||||||
|
{
|
||||||
|
this.defaultTab = TabName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the crafting recipe by it's name.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Name"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public UnlockableCraftingRecipe getCraftingRecipe(string Name)
|
||||||
|
{
|
||||||
|
if (this.craftingRecipes.ContainsKey(Name))
|
||||||
|
{
|
||||||
|
return this.craftingRecipes[Name];
|
||||||
|
}
|
||||||
|
else return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks to see if a crafting recipe has been unlocked.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Name"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool hasUnlockedCraftingRecipe(string Name)
|
||||||
|
{
|
||||||
|
UnlockableCraftingRecipe recipe = this.getCraftingRecipe(Name);
|
||||||
|
if (recipe == null) return false;
|
||||||
|
else return recipe.hasUnlocked;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unlocks the crating recipe so that it can be shown in the menu.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Name"></param>
|
||||||
|
public void unlockRecipe(string Name)
|
||||||
|
{
|
||||||
|
UnlockableCraftingRecipe recipe = this.getCraftingRecipe(Name);
|
||||||
|
if (recipe == null) return;
|
||||||
|
else recipe.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Opens up a crafting menu from this crafting book.
|
||||||
|
/// </summary>
|
||||||
|
public void openCraftingMenu()
|
||||||
|
{
|
||||||
|
CraftingMenuV1 menu = new Framework.Menus.CraftingMenuV1(100, 100, 400, 700, Color.White, Game1.player.Items);
|
||||||
|
//menu.addInCraftingPageTab("Default", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f));
|
||||||
|
|
||||||
|
foreach (KeyValuePair<string, AnimatedButton> pair in this.craftingMenuTabs)
|
||||||
|
{
|
||||||
|
menu.addInCraftingPageTab(pair.Key, pair.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (KeyValuePair<string, UnlockableCraftingRecipe> pair in this.craftingRecipes)
|
||||||
|
{
|
||||||
|
if (pair.Value.hasUnlocked)
|
||||||
|
{
|
||||||
|
menu.addInCraftingRecipe(new Framework.Menus.MenuComponents.CraftingRecipeButton(pair.Value.recipe, null, new Vector2(), new Rectangle(0, 0, 16, 16), 4f, true, Color.White), pair.Value.whichTab);
|
||||||
|
ModCore.log("Add in a crafting recipe to the menu!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ModCore.log("Recipe is locked!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
menu.currentTab = this.defaultTab;
|
||||||
|
menu.sortRecipes();
|
||||||
|
if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = menu;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region
|
||||||
|
//~~~~~~~~~~~~~~~~~~~~//
|
||||||
|
// Static Functions //
|
||||||
|
//~~~~~~~~~~~~~~~~~~~~//
|
||||||
|
|
||||||
|
|
||||||
|
public static void BeforeSave_SaveRecipeBooks(object o, StardewModdingAPI.Events.SavingEventArgs e)
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData"))) Directory.CreateDirectory(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData"));
|
||||||
|
string[] directories = Directory.GetDirectories(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData"));
|
||||||
|
string playerData = Path.Combine(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData"), PlayerUtilities.GetUniqueCharacterString());
|
||||||
|
string objectPath = Path.Combine(playerData, "RecipeInformation");
|
||||||
|
Directory.CreateDirectory(objectPath);
|
||||||
|
string[] objectFiles = Directory.GetFiles(objectPath);
|
||||||
|
|
||||||
|
foreach (KeyValuePair<string, CraftingRecipeBook> book in CraftingRecipeBook.CraftingRecipesByGroup)
|
||||||
|
{
|
||||||
|
string recipePath = Path.Combine(objectPath, book.Key + ".json");
|
||||||
|
ModCore.Serializer.Serialize(recipePath, book.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AfterLoad_LoadRecipeBooks(object o, StardewModdingAPI.Events.SaveLoadedEventArgs e)
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData"))) Directory.CreateDirectory(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData"));
|
||||||
|
string[] directories = Directory.GetDirectories(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData"));
|
||||||
|
string playerData = Path.Combine(Path.Combine(Revitalize.ModCore.ModHelper.DirectoryPath, "SaveData"), PlayerUtilities.GetUniqueCharacterString());
|
||||||
|
string objectPath = Path.Combine(playerData, "RecipeInformation");
|
||||||
|
Directory.CreateDirectory(objectPath);
|
||||||
|
string[] objectFiles = Directory.GetFiles(objectPath);
|
||||||
|
foreach (string file in objectFiles)
|
||||||
|
{
|
||||||
|
CraftingRecipeBook book = ModCore.Serializer.Deserialize<CraftingRecipeBook>(file);
|
||||||
|
string fileName = Path.GetFileNameWithoutExtension(file);
|
||||||
|
CraftingRecipeBook.CraftingRecipesByGroup.Add(fileName, book);
|
||||||
|
}
|
||||||
|
|
||||||
|
InitializeRecipeBooks();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void InitializeRecipeBooks()
|
||||||
|
{
|
||||||
|
|
||||||
|
CraftingRecipeBook WorkbenchRecipes = new CraftingRecipeBook("Workbench");
|
||||||
|
WorkbenchRecipes.addInCraftingTab("Default", new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f),true);
|
||||||
|
WorkbenchRecipes.addCraftingRecipe("Nothing", new UnlockableCraftingRecipe("Default", new Recipe(new List<CraftingRecipeComponent>()
|
||||||
|
{
|
||||||
|
//Inputs here
|
||||||
|
new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.Coal,1),1),
|
||||||
|
}, new CraftingRecipeComponent(new StardewValley.Object((int)Enums.SDVObject.FairyRose, 1), 1)), true));
|
||||||
|
|
||||||
|
if (CraftingRecipesByGroup.ContainsKey(WorkbenchRecipes.craftingGroup))
|
||||||
|
{
|
||||||
|
foreach(KeyValuePair<string, UnlockableCraftingRecipe> recipe in WorkbenchRecipes.craftingRecipes)
|
||||||
|
{
|
||||||
|
if (CraftingRecipesByGroup[WorkbenchRecipes.craftingGroup].craftingRecipes.ContainsKey(recipe.Key))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CraftingRecipesByGroup[WorkbenchRecipes.craftingGroup].craftingRecipes.Add(recipe.Key, recipe.Value); //Add in new recipes automatically without having to delete the old crafting recipe book.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CraftingRecipesByGroup.Add("Workbench", WorkbenchRecipes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using StardewValley;
|
||||||
|
|
||||||
|
namespace Revitalize.Framework.Crafting
|
||||||
|
{
|
||||||
|
public class CraftingRecipeComponent
|
||||||
|
{
|
||||||
|
public Item item;
|
||||||
|
public int requiredAmount;
|
||||||
|
|
||||||
|
public CraftingRecipeComponent()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public CraftingRecipeComponent(Item I, int RequiredAmount)
|
||||||
|
{
|
||||||
|
this.item = I;
|
||||||
|
this.requiredAmount = RequiredAmount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,11 +13,11 @@ namespace Revitalize.Framework.Crafting
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The ingredients necessary to craft this recipe.
|
/// The ingredients necessary to craft this recipe.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<Item, int> ingredients;
|
public List<CraftingRecipeComponent> ingredients;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The items produced by this recipe.
|
/// The items produced by this recipe.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<Item, int> outputs;
|
public List<CraftingRecipeComponent> outputs;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The item that is displayed for the crafting recipe.
|
/// The item that is displayed for the crafting recipe.
|
||||||
|
@ -26,7 +26,7 @@ namespace Revitalize.Framework.Crafting
|
||||||
|
|
||||||
public Item DisplayItem
|
public Item DisplayItem
|
||||||
{
|
{
|
||||||
get => this.displayItem ?? this.outputs.ElementAt(0).Key;
|
get => this.displayItem ?? this.outputs.ElementAt(0).item;
|
||||||
set => this.displayItem = value;
|
set => this.displayItem = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,20 +49,20 @@ namespace Revitalize.Framework.Crafting
|
||||||
/// <summary>Constructor for single item output.</summary>
|
/// <summary>Constructor for single item output.</summary>
|
||||||
/// <param name="inputs">All the ingredients required to make the output.</param>
|
/// <param name="inputs">All the ingredients required to make the output.</param>
|
||||||
/// <param name="output">The item given as output with how many</param>
|
/// <param name="output">The item given as output with how many</param>
|
||||||
public Recipe(Dictionary<Item, int> inputs, KeyValuePair<Item, int> output, StatCost StatCost = null)
|
public Recipe(List<CraftingRecipeComponent> inputs, CraftingRecipeComponent output, StatCost StatCost = null)
|
||||||
{
|
{
|
||||||
this.ingredients = inputs;
|
this.ingredients = inputs;
|
||||||
this.DisplayItem = output.Key;
|
this.DisplayItem = output.item;
|
||||||
this.outputDescription = output.Key.getDescription();
|
this.outputDescription = output.item.getDescription();
|
||||||
this.outputName = output.Key.DisplayName;
|
this.outputName = output.item.DisplayName;
|
||||||
this.outputs = new Dictionary<Item, int>
|
this.outputs = new List<CraftingRecipeComponent>()
|
||||||
{
|
{
|
||||||
[output.Key] = output.Value
|
output
|
||||||
};
|
};
|
||||||
this.statCost = StatCost ?? new StatCost();
|
this.statCost = StatCost ?? new StatCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Recipe(Dictionary<Item, int> inputs, Dictionary<Item, int> outputs, string OutputName, string OutputDescription, Item DisplayItem = null, StatCost StatCost = null)
|
public Recipe(List<CraftingRecipeComponent> inputs, List<CraftingRecipeComponent> outputs, string OutputName, string OutputDescription, Item DisplayItem = null, StatCost StatCost = null)
|
||||||
{
|
{
|
||||||
this.ingredients = inputs;
|
this.ingredients = inputs;
|
||||||
this.outputs = outputs;
|
this.outputs = outputs;
|
||||||
|
@ -79,7 +79,7 @@ namespace Revitalize.Framework.Crafting
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Checks if a player contains a recipe ingredient.</summary>
|
/// <summary>Checks if a player contains a recipe ingredient.</summary>
|
||||||
public bool PlayerContainsIngredient(KeyValuePair<Item, int> pair)
|
public bool PlayerContainsIngredient(CraftingRecipeComponent pair)
|
||||||
{
|
{
|
||||||
return this.InventoryContainsIngredient(Game1.player.Items.ToList(), pair);
|
return this.InventoryContainsIngredient(Game1.player.Items.ToList(), pair);
|
||||||
}
|
}
|
||||||
|
@ -87,17 +87,17 @@ namespace Revitalize.Framework.Crafting
|
||||||
/// <summary>Checks if an inventory contains all items.</summary>
|
/// <summary>Checks if an inventory contains all items.</summary>
|
||||||
public bool InventoryContainsAllIngredient(IList<Item> items)
|
public bool InventoryContainsAllIngredient(IList<Item> items)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<Item, int> pair in this.ingredients)
|
foreach (CraftingRecipeComponent pair in this.ingredients)
|
||||||
if (!this.InventoryContainsIngredient(items, pair)) return false;
|
if (!this.InventoryContainsIngredient(items, pair)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>Checks if an inventory contains an ingredient.</summary>
|
/// <summary>Checks if an inventory contains an ingredient.</summary>
|
||||||
public bool InventoryContainsIngredient(IList<Item> items, KeyValuePair<Item, int> pair)
|
public bool InventoryContainsIngredient(IList<Item> items, CraftingRecipeComponent pair)
|
||||||
{
|
{
|
||||||
foreach (Item i in items)
|
foreach (Item i in items)
|
||||||
{
|
{
|
||||||
if (i != null && this.ItemEqualsOther(i, pair.Key) && pair.Value <= i.Stack)
|
if (i != null && this.ItemEqualsOther(i, pair.item) && pair.requiredAmount <= i.Stack)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -123,17 +123,17 @@ namespace Revitalize.Framework.Crafting
|
||||||
|
|
||||||
InventoryManager manager = new InventoryManager(from);
|
InventoryManager manager = new InventoryManager(from);
|
||||||
List<Item> removalList = new List<Item>();
|
List<Item> removalList = new List<Item>();
|
||||||
foreach (KeyValuePair<Item, int> pair in this.ingredients)
|
foreach (CraftingRecipeComponent pair in this.ingredients)
|
||||||
{
|
{
|
||||||
foreach (Item item in manager.items)
|
foreach (Item item in manager.items)
|
||||||
{
|
{
|
||||||
if (item == null) continue;
|
if (item == null) continue;
|
||||||
if (this.ItemEqualsOther(item, pair.Key))
|
if (this.ItemEqualsOther(item, pair.item))
|
||||||
{
|
{
|
||||||
if (item.Stack == pair.Value)
|
if (item.Stack == pair.requiredAmount)
|
||||||
removalList.Add(item); //remove the item
|
removalList.Add(item); //remove the item
|
||||||
else
|
else
|
||||||
item.Stack -= pair.Value; //or reduce the stack size.
|
item.Stack -= pair.requiredAmount; //or reduce the stack size.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -155,10 +155,10 @@ namespace Revitalize.Framework.Crafting
|
||||||
var manager = isPlayerInventory
|
var manager = isPlayerInventory
|
||||||
? new InventoryManager(new List<Item>())
|
? new InventoryManager(new List<Item>())
|
||||||
: new InventoryManager(to);
|
: new InventoryManager(to);
|
||||||
foreach (KeyValuePair<Item, int> pair in this.outputs)
|
foreach (CraftingRecipeComponent pair in this.outputs)
|
||||||
{
|
{
|
||||||
Item item = pair.Key.getOne();
|
Item item = pair.item.getOne();
|
||||||
item.addToStack(pair.Value - 1);
|
item.addToStack(pair.requiredAmount - 1);
|
||||||
bool added = manager.addItem(item);
|
bool added = manager.addItem(item);
|
||||||
if (!added && dropToGround)
|
if (!added && dropToGround)
|
||||||
Game1.createItemDebris(item, Game1.player.getStandingPosition(), Game1.player.getDirection());
|
Game1.createItemDebris(item, Game1.player.getStandingPosition(), Game1.player.getDirection());
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Revitalize.Framework.Crafting
|
||||||
|
{
|
||||||
|
public class UnlockableCraftingRecipe
|
||||||
|
{
|
||||||
|
public Recipe recipe;
|
||||||
|
public bool hasUnlocked;
|
||||||
|
public string whichTab;
|
||||||
|
|
||||||
|
public UnlockableCraftingRecipe()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnlockableCraftingRecipe(string WhichTab, Recipe recipe, bool HasUnlocked=false)
|
||||||
|
{
|
||||||
|
this.recipe = recipe;
|
||||||
|
this.hasUnlocked = HasUnlocked;
|
||||||
|
this.whichTab = WhichTab;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unlock()
|
||||||
|
{
|
||||||
|
this.hasUnlocked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using Revitalize.Framework.Crafting;
|
||||||
using Revitalize.Framework.Menus.MenuComponents;
|
using Revitalize.Framework.Menus.MenuComponents;
|
||||||
using Revitalize.Framework.Objects;
|
using Revitalize.Framework.Objects;
|
||||||
using Revitalize.Framework.Utilities;
|
using Revitalize.Framework.Utilities;
|
||||||
|
@ -58,8 +59,8 @@ namespace Revitalize.Framework.Menus
|
||||||
this.requiredItems = new Dictionary<ItemDisplayButton, int>();
|
this.requiredItems = new Dictionary<ItemDisplayButton, int>();
|
||||||
for (int i = 0; i < this.infoButton.recipe.ingredients.Count; i++)
|
for (int i = 0; i < this.infoButton.recipe.ingredients.Count; i++)
|
||||||
{
|
{
|
||||||
ItemDisplayButton b = new ItemDisplayButton(this.infoButton.recipe.ingredients.ElementAt(i).Key, null, new Vector2(this.xPositionOnScreen + 64, this.getIngredientHeightOffset().Y), new Rectangle(0, 0, 64, 64), 2f, true, Color.White);
|
ItemDisplayButton b = new ItemDisplayButton(this.infoButton.recipe.ingredients.ElementAt(i).item, null, new Vector2(this.xPositionOnScreen + 64, this.getIngredientHeightOffset().Y), new Rectangle(0, 0, 64, 64), 2f, true, Color.White);
|
||||||
this.requiredItems.Add(b, this.infoButton.recipe.ingredients.ElementAt(i).Value);
|
this.requiredItems.Add(b, this.infoButton.recipe.ingredients.ElementAt(i).requiredAmount);
|
||||||
}
|
}
|
||||||
this.craftingButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("CraftingButton", new Vector2(this.xPositionOnScreen + this.width / 2-96, this.getCraftingButtonHeight()),new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "CraftingMenu", "CraftButton"),new StardustCore.Animations.Animation(0,0,48,16)), Color.White),new Rectangle(0,0,48,16),4f);
|
this.craftingButton = new AnimatedButton(new StardustCore.Animations.AnimatedSprite("CraftingButton", new Vector2(this.xPositionOnScreen + this.width / 2-96, this.getCraftingButtonHeight()),new StardustCore.Animations.AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "CraftingMenu", "CraftButton"),new StardustCore.Animations.Animation(0,0,48,16)), Color.White),new Rectangle(0,0,48,16),4f);
|
||||||
}
|
}
|
||||||
|
@ -130,7 +131,8 @@ namespace Revitalize.Framework.Menus
|
||||||
|
|
||||||
public Color getNameColor(Item I, int amount)
|
public Color getNameColor(Item I, int amount)
|
||||||
{
|
{
|
||||||
KeyValuePair<Item, int> Pair = new KeyValuePair<Item, int>(I, amount);
|
CraftingRecipeComponent Pair = new CraftingRecipeComponent(I, amount);
|
||||||
|
|
||||||
if (this.infoButton.recipe.InventoryContainsIngredient(this.inventory, Pair))
|
if (this.infoButton.recipe.InventoryContainsIngredient(this.inventory, Pair))
|
||||||
{
|
{
|
||||||
return Color.Black;
|
return Color.Black;
|
||||||
|
|
|
@ -0,0 +1,266 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using PyTK.CustomElementHandler;
|
||||||
|
using Revitalize.Framework.Utilities;
|
||||||
|
using StardewValley;
|
||||||
|
|
||||||
|
namespace Revitalize.Framework.Objects.CraftingTables
|
||||||
|
{
|
||||||
|
public class CraftingTableTile: MultiTiledComponent
|
||||||
|
{
|
||||||
|
|
||||||
|
public string craftingBookName;
|
||||||
|
|
||||||
|
[JsonIgnore]
|
||||||
|
public override string ItemInfo
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
string info = Revitalize.ModCore.Serializer.ToJSONString(this.info);
|
||||||
|
string guidStr = this.guid.ToString();
|
||||||
|
string pyTkData = ModCore.Serializer.ToJSONString(this.data);
|
||||||
|
string offsetKey = this.offsetKey != null ? ModCore.Serializer.ToJSONString(this.offsetKey) : "";
|
||||||
|
string container = this.containerObject != null ? this.containerObject.guid.ToString() : "";
|
||||||
|
string furnitureInfo = this.craftingBookName;
|
||||||
|
return info + "<" + guidStr + "<" + pyTkData + "<" + offsetKey + "<" + container + "<" + furnitureInfo;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(value)) return;
|
||||||
|
string[] data = value.Split('<');
|
||||||
|
string infoString = data[0];
|
||||||
|
string guidString = data[1];
|
||||||
|
string pyTKData = data[2];
|
||||||
|
string offsetVec = data[3];
|
||||||
|
string containerObject = data[4];
|
||||||
|
string craftingBookName = data[5];
|
||||||
|
this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(infoString, typeof(BasicItemInformation));
|
||||||
|
this.data = Revitalize.ModCore.Serializer.DeserializeFromJSONString<CustomObjectData>(pyTKData);
|
||||||
|
if (string.IsNullOrEmpty(offsetVec)) return;
|
||||||
|
if (string.IsNullOrEmpty(containerObject)) return;
|
||||||
|
this.offsetKey = ModCore.Serializer.DeserializeFromJSONString<Vector2>(offsetVec);
|
||||||
|
Guid oldGuid = this.guid;
|
||||||
|
this.guid = Guid.Parse(guidString);
|
||||||
|
if (ModCore.CustomObjects.ContainsKey(this.guid))
|
||||||
|
{
|
||||||
|
//ModCore.log("Update item with guid: " + this.guid);
|
||||||
|
ModCore.CustomObjects[this.guid] = this;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//ModCore.log("Add in new guid: " + this.guid);
|
||||||
|
ModCore.CustomObjects.Add(this.guid, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.containerObject == null)
|
||||||
|
{
|
||||||
|
//ModCore.log(containerObject);
|
||||||
|
Guid containerGuid = Guid.Parse(containerObject);
|
||||||
|
if (ModCore.CustomObjects.ContainsKey(containerGuid))
|
||||||
|
{
|
||||||
|
this.containerObject = (MultiTiledObject)ModCore.CustomObjects[containerGuid];
|
||||||
|
this.containerObject.removeComponent(this.offsetKey);
|
||||||
|
this.containerObject.addComponent(this.offsetKey, this);
|
||||||
|
//ModCore.log("Set container object from existing object!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//ModCore.log("Container hasn't been synced???");
|
||||||
|
MultiplayerUtilities.RequestGuidObject(containerGuid);
|
||||||
|
MultiplayerUtilities.RequestGuidObject_Tile(this.guid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.containerObject.updateInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ModCore.CustomObjects.ContainsKey(oldGuid) && ModCore.CustomObjects.ContainsKey(this.guid))
|
||||||
|
{
|
||||||
|
if (ModCore.CustomObjects[oldGuid] == ModCore.CustomObjects[this.guid] && oldGuid != this.guid)
|
||||||
|
{
|
||||||
|
//ModCore.CustomObjects.Remove(oldGuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(craftingBookName) == false)
|
||||||
|
{
|
||||||
|
this.craftingBookName = craftingBookName;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public CraftingTableTile() : base()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public CraftingTableTile(CustomObjectData PyTKData, BasicItemInformation Info, string CraftingTableRecipeBookName) : base(PyTKData, Info)
|
||||||
|
{
|
||||||
|
this.craftingBookName = CraftingTableRecipeBookName;
|
||||||
|
this.Price = Info.price;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CraftingTableTile(CustomObjectData PyTKData, BasicItemInformation Info, Vector2 TileLocation, string CraftingTableRecipeBookName) : base(PyTKData, Info, TileLocation)
|
||||||
|
{
|
||||||
|
this.craftingBookName = CraftingTableRecipeBookName;
|
||||||
|
this.Price = Info.price;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When the chair is right clicked ensure that all pieces associated with it are also rotated.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="who"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public override bool rightClicked(Farmer who)
|
||||||
|
{
|
||||||
|
if (Framework.Crafting.CraftingRecipeBook.CraftingRecipesByGroup.ContainsKey(this.craftingBookName))
|
||||||
|
{
|
||||||
|
Framework.Crafting.CraftingRecipeBook.CraftingRecipesByGroup[this.craftingBookName].openCraftingMenu();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override Item getOne()
|
||||||
|
{
|
||||||
|
CraftingTableTile component = new CraftingTableTile(this.data, this.info.Copy(),this.craftingBookName);
|
||||||
|
component.containerObject = this.containerObject;
|
||||||
|
component.offsetKey = this.offsetKey;
|
||||||
|
return component;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
||||||
|
{
|
||||||
|
Vector2 offsetKey = new Vector2(Convert.ToInt32(additionalSaveData["offsetKeyX"]), Convert.ToInt32(additionalSaveData["offsetKeyY"]));
|
||||||
|
string GUID = additionalSaveData["GUID"];
|
||||||
|
CraftingTableTile self = Revitalize.ModCore.Serializer.DeserializeGUID<CraftingTableTile>(additionalSaveData["GUID"]);
|
||||||
|
if (ModCore.IsNullOrDefault<CraftingTableTile>(self)) return null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
|
||||||
|
{
|
||||||
|
MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID<MultiTiledObject>(additionalSaveData["ParentGUID"]);
|
||||||
|
self.containerObject = obj;
|
||||||
|
self.containerObject.removeComponent(offsetKey);
|
||||||
|
self.containerObject.addComponent(offsetKey, self);
|
||||||
|
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], obj);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
|
||||||
|
self.containerObject.removeComponent(offsetKey);
|
||||||
|
self.containerObject.addComponent(offsetKey, self);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception err)
|
||||||
|
{
|
||||||
|
ModCore.log(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Dictionary<string, string> getAdditionalSaveData()
|
||||||
|
{
|
||||||
|
Dictionary<string, string> saveData = base.getAdditionalSaveData();
|
||||||
|
Revitalize.ModCore.Serializer.SerializeGUID(this.containerObject.childrenGuids[this.offsetKey].ToString(), this);
|
||||||
|
this.containerObject.getAdditionalSaveData();
|
||||||
|
return saveData;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///Used to manage graphics for chairs that need to deal with special "layering" for transparent chair backs. Otherwise the player would be hidden.
|
||||||
|
/// </summary>
|
||||||
|
public void checkForSpecialUpSittingAnimation()
|
||||||
|
{
|
||||||
|
if (this.info.facingDirection == Enums.Direction.Up && Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject)
|
||||||
|
{
|
||||||
|
string animationKey = "Sitting_" + (int)Enums.Direction.Up;
|
||||||
|
if (this.animationManager.animations.ContainsKey(animationKey))
|
||||||
|
{
|
||||||
|
this.animationManager.setAnimation(animationKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>What happens when the object is drawn at a tile location.</summary>
|
||||||
|
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (this.info == null)
|
||||||
|
{
|
||||||
|
Revitalize.ModCore.log("info is null");
|
||||||
|
if (this.syncObject == null) Revitalize.ModCore.log("DEAD SYNC");
|
||||||
|
}
|
||||||
|
if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null");
|
||||||
|
if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null");
|
||||||
|
|
||||||
|
//The actual planter box being drawn.
|
||||||
|
if (this.animationManager == null)
|
||||||
|
{
|
||||||
|
if (this.animationManager.getExtendedTexture() == null)
|
||||||
|
ModCore.ModMonitor.Log("Tex Extended is null???");
|
||||||
|
|
||||||
|
spriteBatch.Draw(this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)(y * Game1.tileSize) / 10000f));
|
||||||
|
// Log.AsyncG("ANIMATION IS NULL?!?!?!?!");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Log.AsyncC("Animation Manager is working!");
|
||||||
|
float addedDepth = 0;
|
||||||
|
|
||||||
|
|
||||||
|
if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this.containerObject && this.info.facingDirection == Enums.Direction.Up)
|
||||||
|
{
|
||||||
|
addedDepth += (this.containerObject.Height - 1) - ((int)(this.offsetKey.Y));
|
||||||
|
if (this.info.ignoreBoundingBox) addedDepth += 1.5f;
|
||||||
|
}
|
||||||
|
else if (this.info.ignoreBoundingBox)
|
||||||
|
{
|
||||||
|
addedDepth += 1.0f;
|
||||||
|
}
|
||||||
|
this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.Flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, Math.Max(0f, (float)((y + addedDepth) * Game1.tileSize) / 10000f) + .00001f);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.animationManager.tickAnimation();
|
||||||
|
// Log.AsyncC("Tick animation");
|
||||||
|
}
|
||||||
|
catch (Exception err)
|
||||||
|
{
|
||||||
|
ModCore.ModMonitor.Log(err.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f)
|
||||||
|
{
|
||||||
|
if (objectPosition.X < 0) objectPosition.X *= -1;
|
||||||
|
if (objectPosition.Y < 0) objectPosition.Y *= -1;
|
||||||
|
base.drawWhenHeld(spriteBatch, objectPosition, f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -471,7 +471,7 @@ namespace Revitalize.Framework.Objects
|
||||||
if (this.info == null)
|
if (this.info == null)
|
||||||
{
|
{
|
||||||
this.ItemInfo = this.text;
|
this.ItemInfo = this.text;
|
||||||
ModCore.log("Updated item info for container!");
|
//ModCore.log("Updated item info for container!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.objects != null)
|
if (this.objects != null)
|
||||||
|
@ -531,12 +531,12 @@ namespace Revitalize.Framework.Objects
|
||||||
}
|
}
|
||||||
if (this.objects == null || this.childrenGuids == null)
|
if (this.objects == null || this.childrenGuids == null)
|
||||||
{
|
{
|
||||||
ModCore.log("Either objects or children guids are null");
|
//ModCore.log("Either objects or children guids are null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ModCore.log("Recreate children components");
|
//ModCore.log("Recreate children components");
|
||||||
if (this.objects.Count < this.childrenGuids.Count)
|
if (this.objects.Count < this.childrenGuids.Count)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<Vector2, Guid> pair in this.childrenGuids)
|
foreach (KeyValuePair<Vector2, Guid> pair in this.childrenGuids)
|
||||||
|
@ -555,8 +555,8 @@ namespace Revitalize.Framework.Objects
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ModCore.log("Count is exactly the same!");
|
//ModCore.log("Count is exactly the same!");
|
||||||
ModCore.log("Count is: " + this.objects.Count+" : and " + this.childrenGuids.Count);
|
//ModCore.log("Count is: " + this.objects.Count+" : and " + this.childrenGuids.Count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using StardewValley;
|
||||||
|
|
||||||
|
namespace Revitalize.Framework.Utilities
|
||||||
|
{
|
||||||
|
public class PlayerUtilities
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the unique id for the character.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetUniqueCharacterString()
|
||||||
|
{
|
||||||
|
return Game1.player.Name + "_" + Game1.player.UniqueMultiplayerID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,6 +28,7 @@ using StardewValley.Locations;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons;
|
using StardustCore.UIUtilities.MenuComponents.ComponentsV2.Buttons;
|
||||||
using Revitalize.Framework.Menus;
|
using Revitalize.Framework.Menus;
|
||||||
|
using Revitalize.Framework.Objects.CraftingTables;
|
||||||
|
|
||||||
namespace Revitalize
|
namespace Revitalize
|
||||||
{
|
{
|
||||||
|
@ -253,38 +254,32 @@ namespace Revitalize
|
||||||
|
|
||||||
//Adds in event handling for the mod.
|
//Adds in event handling for the mod.
|
||||||
ModHelper.Events.GameLoop.SaveLoaded += this.GameLoop_SaveLoaded;
|
ModHelper.Events.GameLoop.SaveLoaded += this.GameLoop_SaveLoaded;
|
||||||
|
ModHelper.Events.GameLoop.SaveLoaded += CraftingRecipeBook.AfterLoad_LoadRecipeBooks;
|
||||||
|
ModHelper.Events.GameLoop.Saving += CraftingRecipeBook.BeforeSave_SaveRecipeBooks;
|
||||||
|
|
||||||
ModHelper.Events.GameLoop.TimeChanged += this.GameLoop_TimeChanged;
|
ModHelper.Events.GameLoop.TimeChanged += this.GameLoop_TimeChanged;
|
||||||
ModHelper.Events.GameLoop.UpdateTicked += this.GameLoop_UpdateTicked;
|
ModHelper.Events.GameLoop.UpdateTicked += this.GameLoop_UpdateTicked;
|
||||||
ModHelper.Events.GameLoop.ReturnedToTitle += this.GameLoop_ReturnedToTitle;
|
ModHelper.Events.GameLoop.ReturnedToTitle += this.GameLoop_ReturnedToTitle;
|
||||||
ModHelper.Events.Input.ButtonPressed += this.Input_ButtonPressed;
|
|
||||||
ModHelper.Events.Player.Warped += ObjectManager.resources.OnPlayerLocationChanged;
|
ModHelper.Events.Player.Warped += ObjectManager.resources.OnPlayerLocationChanged;
|
||||||
ModHelper.Events.GameLoop.DayStarted += ObjectManager.resources.DailyResourceSpawn;
|
ModHelper.Events.GameLoop.DayStarted += ObjectManager.resources.DailyResourceSpawn;
|
||||||
|
ModHelper.Events.Input.ButtonPressed += this.Input_ButtonPressed;
|
||||||
ModHelper.Events.Input.ButtonPressed += ObjectInteractionHacks.Input_CheckForObjectInteraction;
|
ModHelper.Events.Input.ButtonPressed += ObjectInteractionHacks.Input_CheckForObjectInteraction;
|
||||||
|
|
||||||
ModHelper.Events.GameLoop.DayEnding += Serializer.DayEnding_CleanUpFilesForDeletion;
|
ModHelper.Events.GameLoop.DayEnding += Serializer.DayEnding_CleanUpFilesForDeletion;
|
||||||
ModHelper.Events.Display.RenderedWorld += ObjectInteractionHacks.Render_RenderCustomObjectsHeldInMachines;
|
ModHelper.Events.Display.RenderedWorld += ObjectInteractionHacks.Render_RenderCustomObjectsHeldInMachines;
|
||||||
//ModHelper.Events.Display.Rendered += MenuHacks.EndOfDay_OnMenuChanged;
|
//ModHelper.Events.Display.Rendered += MenuHacks.EndOfDay_OnMenuChanged;
|
||||||
//ModHelper.Events.GameLoop.Saved += MenuHacks.EndOfDay_CleanupForNewDay;
|
//ModHelper.Events.GameLoop.Saved += MenuHacks.EndOfDay_CleanupForNewDay;
|
||||||
ModHelper.Events.Multiplayer.ModMessageReceived += MultiplayerUtilities.GetModMessage;
|
ModHelper.Events.Multiplayer.ModMessageReceived += MultiplayerUtilities.GetModMessage;
|
||||||
ModHelper.Events.GameLoop.DayEnding += this.GameLoop_DayEnding;
|
|
||||||
ModHelper.Events.GameLoop.Saving += this.GameLoop_Saving;
|
|
||||||
|
|
||||||
//Adds in recipes to the mod.
|
//Adds in recipes to the mod.
|
||||||
VanillaRecipeBook = new VanillaRecipeBook();
|
VanillaRecipeBook = new VanillaRecipeBook();
|
||||||
|
CraftingRecipeBook.CraftingRecipesByGroup = new Dictionary<string, CraftingRecipeBook>();
|
||||||
|
|
||||||
ModHelper.Events.Display.MenuChanged += MenuHacks.RecreateFarmhandInventory;
|
ModHelper.Events.Display.MenuChanged += MenuHacks.RecreateFarmhandInventory;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GameLoop_Saving(object sender, StardewModdingAPI.Events.SavingEventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void GameLoop_DayEnding(object sender, StardewModdingAPI.Events.DayEndingEventArgs e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Loads in textures to be used by the mod.
|
/// Loads in textures to be used by the mod.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -302,6 +297,9 @@ namespace Revitalize
|
||||||
TextureManager.GetTextureManager(Manifest, "Menus").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Menus", "Misc"));
|
TextureManager.GetTextureManager(Manifest, "Menus").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Menus", "Misc"));
|
||||||
TextureManager.AddTextureManager(Manifest, "CraftingMenu");
|
TextureManager.AddTextureManager(Manifest, "CraftingMenu");
|
||||||
TextureManager.GetTextureManager(Manifest, "CraftingMenu").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Menus", "CraftingMenu"));
|
TextureManager.GetTextureManager(Manifest, "CraftingMenu").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Menus", "CraftingMenu"));
|
||||||
|
|
||||||
|
TextureManager.AddTextureManager(Manifest, "Objects.Crafting");
|
||||||
|
TextureManager.GetTextureManager(Manifest, "Objects.Crafting").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Objects", "Crafting"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e)
|
private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e)
|
||||||
|
@ -327,7 +325,7 @@ namespace Revitalize
|
||||||
|
|
||||||
if (e.Button == SButton.U)
|
if (e.Button == SButton.U)
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
CraftingMenuV1 menu= new Framework.Menus.CraftingMenuV1(100, 100, 400, 700, Color.White, Game1.player.Items);
|
CraftingMenuV1 menu= new Framework.Menus.CraftingMenuV1(100, 100, 400, 700, Color.White, Game1.player.Items);
|
||||||
menu.addInCraftingPageTab("Default",new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f));
|
menu.addInCraftingPageTab("Default",new AnimatedButton(new StardustCore.Animations.AnimatedSprite("Default Tab", new Vector2(100 + 48, 100 + (24 * 4)), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Menus", "MenuTabHorizontal"), new Animation(0, 0, 24, 24)), Color.White), new Rectangle(0, 0, 24, 24), 2f));
|
||||||
|
|
||||||
|
@ -387,6 +385,7 @@ namespace Revitalize
|
||||||
menu.sortRecipes();
|
menu.sortRecipes();
|
||||||
|
|
||||||
if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = menu;
|
if (Game1.activeClickableMenu == null) Game1.activeClickableMenu = menu;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,10 +413,12 @@ namespace Revitalize
|
||||||
bigObject.addComponent(new Vector2(1, 0), obj2);
|
bigObject.addComponent(new Vector2(1, 0), obj2);
|
||||||
bigObject.addComponent(new Vector2(2, 0), obj3);
|
bigObject.addComponent(new Vector2(2, 0), obj3);
|
||||||
|
|
||||||
|
/*
|
||||||
Recipe pie = new Recipe(new Dictionary<Item, int>()
|
Recipe pie = new Recipe(new Dictionary<Item, int>()
|
||||||
{
|
{
|
||||||
[bigObject] = 1
|
[bigObject] = 1
|
||||||
}, new KeyValuePair<Item, int>(new Furniture(3, Vector2.Zero), 1), new StatCost(100, 50, 0, 0));
|
}, new KeyValuePair<Item, int>(new Furniture(3, Vector2.Zero), 1), new StatCost(100, 50, 0, 0));
|
||||||
|
*/
|
||||||
|
|
||||||
ObjectManager.miscellaneous.Add("Omegasis.BigTiledTest", bigObject);
|
ObjectManager.miscellaneous.Add("Omegasis.BigTiledTest", bigObject);
|
||||||
|
|
||||||
|
@ -464,6 +465,19 @@ namespace Revitalize
|
||||||
ObjectManager.miscellaneous.Add("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", sscCabinet);
|
ObjectManager.miscellaneous.Add("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble", sscCabinet);
|
||||||
|
|
||||||
//ModCore.log("Added in SSC!");
|
//ModCore.log("Added in SSC!");
|
||||||
|
|
||||||
|
|
||||||
|
MultiTiledObject WorkbenchObj = new MultiTiledObject(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(), Color.White, false, null, null));
|
||||||
|
CraftingTableTile workbenchTile_0_0 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Workbench"), new Animation(0, 0, 16, 16)), Color.White, false, null, null), "Workbench");
|
||||||
|
CraftingTableTile workbenchTile_1_0 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Workbench"), new Animation(16, 0, 16, 16)), Color.White, false, null, null), "Workbench");
|
||||||
|
CraftingTableTile workbenchTile_0_1 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Workbench"), new Animation(0, 16, 16, 16)), Color.White, false, null, null), "Workbench");
|
||||||
|
CraftingTableTile workbenchTile_1_1 = new CraftingTableTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Objects.Crafting.Workbench", TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), typeof(MultiTiledObject), Color.White, true), new BasicItemInformation("Workbench", "Omegasis.Revitalize.Objects.Crafting.Workbench", "A workbench that can be used for crafting different objects.", "Crafting", Color.Brown, -300, 0, false, 500, true, true, TextureManager.GetTexture(Manifest, "Objects.Crafting", "Workbench"), new AnimationManager(TextureManager.GetExtendedTexture(Manifest, "Objects.Crafting", "Workbench"), new Animation(16, 16, 16, 16)), Color.White, false, null, null), "Workbench");
|
||||||
|
WorkbenchObj.addComponent(new Vector2(0,0),workbenchTile_0_0);
|
||||||
|
WorkbenchObj.addComponent(new Vector2(1, 0), workbenchTile_1_0);
|
||||||
|
WorkbenchObj.addComponent(new Vector2(0, 1), workbenchTile_0_1);
|
||||||
|
WorkbenchObj.addComponent(new Vector2(1, 1), workbenchTile_1_1);
|
||||||
|
|
||||||
|
ObjectManager.AddItem("Workbench", WorkbenchObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createDirectories()
|
private void createDirectories()
|
||||||
|
@ -506,7 +520,9 @@ namespace Revitalize
|
||||||
|
|
||||||
|
|
||||||
// Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.BigTiledTest"));
|
// Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.BigTiledTest"));
|
||||||
Game1.player.addItemToInventory(ObjectManager.getChair("Omegasis.Revitalize.Furniture.Chairs.OakChair"));
|
//Game1.player.addItemToInventory(ObjectManager.getChair("Omegasis.Revitalize.Furniture.Chairs.OakChair"));
|
||||||
|
|
||||||
|
Game1.player.addItemToInventoryBool(ObjectManager.GetItem("Workbench"));
|
||||||
//Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Rugs.RugTest"));
|
//Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Rugs.RugTest"));
|
||||||
//Game1.player.addItemToInventory(ObjectManager.getTable("Omegasis.Revitalize.Furniture.Tables.OakTable"));
|
//Game1.player.addItemToInventory(ObjectManager.getTable("Omegasis.Revitalize.Furniture.Tables.OakTable"));
|
||||||
//Game1.player.addItemToInventory(ObjectManager.getLamp("Omegasis.Revitalize.Furniture.Lamps.OakLamp"));
|
//Game1.player.addItemToInventory(ObjectManager.getLamp("Omegasis.Revitalize.Furniture.Lamps.OakLamp"));
|
||||||
|
|
|
@ -56,10 +56,13 @@
|
||||||
<Compile Include="Framework\Configs\FurnitureConfig.cs" />
|
<Compile Include="Framework\Configs\FurnitureConfig.cs" />
|
||||||
<Compile Include="Framework\Configs\Shops_BlacksmithConfig.cs" />
|
<Compile Include="Framework\Configs\Shops_BlacksmithConfig.cs" />
|
||||||
<Compile Include="Framework\Configs\VanillaMachineRecipeConfig.cs" />
|
<Compile Include="Framework\Configs\VanillaMachineRecipeConfig.cs" />
|
||||||
|
<Compile Include="Framework\Crafting\CraftingRecipeBook.cs" />
|
||||||
|
<Compile Include="Framework\Crafting\CraftingRecipeComponent.cs" />
|
||||||
<Compile Include="Framework\Crafting\MachineCraftingRecipe.cs" />
|
<Compile Include="Framework\Crafting\MachineCraftingRecipe.cs" />
|
||||||
<Compile Include="Framework\Crafting\Recipe.cs" />
|
<Compile Include="Framework\Crafting\Recipe.cs" />
|
||||||
<Compile Include="Framework\Crafting\RecipeBook.cs" />
|
<Compile Include="Framework\Crafting\RecipeBook.cs" />
|
||||||
<Compile Include="Framework\Crafting\StatCost.cs" />
|
<Compile Include="Framework\Crafting\StatCost.cs" />
|
||||||
|
<Compile Include="Framework\Crafting\UnlockableCraftingRecipe.cs" />
|
||||||
<Compile Include="Framework\Crafting\VanillaRecipeBook.cs" />
|
<Compile Include="Framework\Crafting\VanillaRecipeBook.cs" />
|
||||||
<Compile Include="Framework\Crafting\VanillaRecipe.cs" />
|
<Compile Include="Framework\Crafting\VanillaRecipe.cs" />
|
||||||
<Compile Include="Framework\Enums\Enums.cs" />
|
<Compile Include="Framework\Enums\Enums.cs" />
|
||||||
|
@ -117,6 +120,7 @@
|
||||||
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCStatusEffects\StatusEffect.cs" />
|
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCStatusEffects\StatusEffect.cs" />
|
||||||
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCStatusEffects\StatusEffectManager.cs" />
|
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCStatusEffects\StatusEffectManager.cs" />
|
||||||
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCTextureUtilities.cs" />
|
<Compile Include="Framework\Minigame\SeasideScrambleMinigame\SSCTextureUtilities.cs" />
|
||||||
|
<Compile Include="Framework\Objects\CraftingTables\CraftingTableTile.cs" />
|
||||||
<Compile Include="Framework\Objects\Extras\ArcadeCabinetOBJ.cs" />
|
<Compile Include="Framework\Objects\Extras\ArcadeCabinetOBJ.cs" />
|
||||||
<Compile Include="Framework\Objects\Extras\ArcadeCabinetTile.cs" />
|
<Compile Include="Framework\Objects\Extras\ArcadeCabinetTile.cs" />
|
||||||
<Compile Include="Framework\Objects\BasicItemInformation.cs" />
|
<Compile Include="Framework\Objects\BasicItemInformation.cs" />
|
||||||
|
@ -155,6 +159,7 @@
|
||||||
<Compile Include="Framework\Utilities\LocationUtilities.cs" />
|
<Compile Include="Framework\Utilities\LocationUtilities.cs" />
|
||||||
<Compile Include="Framework\Utilities\MultiplayerUtilities.cs" />
|
<Compile Include="Framework\Utilities\MultiplayerUtilities.cs" />
|
||||||
<Compile Include="Framework\Utilities\ObjectUtilities.cs" />
|
<Compile Include="Framework\Utilities\ObjectUtilities.cs" />
|
||||||
|
<Compile Include="Framework\Utilities\PlayerUtilities.cs" />
|
||||||
<Compile Include="Framework\Utilities\PyTKHelper.cs" />
|
<Compile Include="Framework\Utilities\PyTKHelper.cs" />
|
||||||
<Compile Include="Framework\Utilities\RotationUtilities.cs" />
|
<Compile Include="Framework\Utilities\RotationUtilities.cs" />
|
||||||
<Compile Include="Framework\Utilities\Serialization\ContractResolvers\NetFieldContract.cs" />
|
<Compile Include="Framework\Utilities\Serialization\ContractResolvers\NetFieldContract.cs" />
|
||||||
|
@ -257,6 +262,12 @@
|
||||||
<Content Include="Content\Graphics\Menus\Misc\MenuTabHorizontal.png">
|
<Content Include="Content\Graphics\Menus\Misc\MenuTabHorizontal.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="Content\Graphics\Objects\Crafting\Anvil.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="Content\Graphics\Objects\Crafting\Workbench.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="Content\Graphics\Objects\Furniture\Arcade\SeasideScrambleArcade.png">
|
<Content Include="Content\Graphics\Objects\Furniture\Arcade\SeasideScrambleArcade.png">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
Loading…
Reference in New Issue