Added in ores to be bought from Clints shop. Added in the rest of the vanilla furnace ingot smelting recipes.

This commit is contained in:
JoshuaNavarro 2019-08-22 20:04:49 -07:00
parent a558c15f26
commit f194b5eb4f
7 changed files with 145 additions and 25 deletions

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Revitalize.Framework.Utilities;
using StardewValley; using StardewValley;
namespace Revitalize.Framework.Crafting namespace Revitalize.Framework.Crafting
@ -35,9 +36,41 @@ namespace Revitalize.Framework.Crafting
{ {
{ModCore.ObjectManager.resources.getOre("Tin"),5 }, {ModCore.ObjectManager.resources.getOre("Tin"),5 },
{new StardewValley.Object(382,1),1} {new StardewValley.Object(382,1),1}
}, new KeyValuePair<Item, int>(ModCore.ObjectManager.GetItem("TinIngot"), 1), 50, new StatCost(), false); }, new KeyValuePair<Item, int>(ModCore.ObjectManager.GetItem("TinIngot"), 1), TimeUtilities.GetMinutesFromTime(0,0,50), new StatCost(), false);
this.recipesByObjectName["Furnace"].Add("Tin Ore", furnace_tinOre); this.recipesByObjectName["Furnace"].Add("Tin Ore", furnace_tinOre);
VanillaRecipe furnace_bauxiteOre = new VanillaRecipe(new Dictionary<Item, int>()
{
{ModCore.ObjectManager.resources.getOre("Bauxite"),5 },
{new StardewValley.Object(382,1),1}
}, new KeyValuePair<Item, int>(ModCore.ObjectManager.GetItem("AluminumIngot"), 1), TimeUtilities.GetMinutesFromTime(0,1,30), new StatCost(), false);
this.recipesByObjectName["Furnace"].Add("Bauxite Ore", furnace_bauxiteOre);
VanillaRecipe furnace_leadOre = new VanillaRecipe(new Dictionary<Item, int>()
{
{ModCore.ObjectManager.resources.getOre("Lead"),5 },
{new StardewValley.Object(382,1),1}
}, new KeyValuePair<Item, int>(ModCore.ObjectManager.GetItem("LeadIngot"), 1), TimeUtilities.GetMinutesFromTime(0,2,0), new StatCost(), false);
this.recipesByObjectName["Furnace"].Add("Lead Ore", furnace_leadOre);
VanillaRecipe furnace_silverOre = new VanillaRecipe(new Dictionary<Item, int>()
{
{ModCore.ObjectManager.resources.getOre("Silver"),5 },
{new StardewValley.Object(382,1),1}
}, new KeyValuePair<Item, int>(ModCore.ObjectManager.GetItem("SilverIngot"), 1), TimeUtilities.GetMinutesFromTime(0,3,0), new StatCost(), false);
this.recipesByObjectName["Furnace"].Add("Silver Ore", furnace_silverOre);
VanillaRecipe furnace_titaniumOre = new VanillaRecipe(new Dictionary<Item, int>()
{
{ModCore.ObjectManager.resources.getOre("Titanium"),5 },
{new StardewValley.Object(382,1),1}
}, new KeyValuePair<Item, int>(ModCore.ObjectManager.GetItem("TitaniumIngot"), 1), TimeUtilities.GetMinutesFromTime(0,4,0), new StatCost(), false);
this.recipesByObjectName["Furnace"].Add("Titanium Ore", furnace_titaniumOre);
} }
/// <summary> /// <summary>
@ -100,7 +133,6 @@ namespace Revitalize.Framework.Crafting
{ {
if (this.DoesARecipeExistForHeldObjectName(Machine)) if (this.DoesARecipeExistForHeldObjectName(Machine))
{ {
ModCore.log("Recipe exists!");
VanillaRecipe rec = this.GetVanillaRecipeFromHeldObjectName(Machine); VanillaRecipe rec = this.GetVanillaRecipeFromHeldObjectName(Machine);
bool crafted=rec.craft(Machine); bool crafted=rec.craft(Machine);
if(crafted)this.playCraftingSound(Machine); if(crafted)this.playCraftingSound(Machine);
@ -108,7 +140,7 @@ namespace Revitalize.Framework.Crafting
} }
else else
{ {
ModCore.log("No recipe!"); //ModCore.log("No recipe!");
return false; return false;
} }
} }

View File

@ -46,7 +46,6 @@ namespace Revitalize.Framework.Hacks
if (obj == null) return; if (obj == null) return;
if (ObjectUtilities.IsObjectFurnace(obj) && ObjectUtilities.IsObjectHoldingItem(obj)==false) if (ObjectUtilities.IsObjectFurnace(obj) && ObjectUtilities.IsObjectHoldingItem(obj)==false)
{ {
ModCore.log("Found a furnace!");
bool crafted=VanillaRecipeBook.VanillaRecipes.TryToCraftRecipe(obj); bool crafted=VanillaRecipeBook.VanillaRecipes.TryToCraftRecipe(obj);
if (crafted == false) return; if (crafted == false) return;
obj.initializeLightSource((Vector2)(obj.TileLocation), false); obj.initializeLightSource((Vector2)(obj.TileLocation), false);

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PyTK.Types;
namespace Revitalize.Framework.Hacks
{
/// <summary>
/// Deals with modifications for SDV shops.
/// </summary>
public class ShopHacks
{
/// <summary>
/// Adds in ore to clint's shop.
/// </summary>
public static void AddOreToClintsShop()
{
PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Tin",1),100), "Clint");
PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Bauxite", 1), 150), "Clint");
PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Lead", 1), 200), "Clint");
PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Silver", 1), 250), "Clint");
PyTK.Extensions.PyEvents.addToNPCShop(new InventoryItem(ModCore.ObjectManager.resources.getOre("Titanium", 1), 300), "Clint");
}
}
}

View File

@ -55,7 +55,7 @@ namespace Revitalize.Framework.Objects
public Guid guid; public Guid guid;
/// <summary>The animation manager.</summary> /// <summary>The animation manager.</summary>
public AnimationManager animationManager => this.info.animationManager; public AnimationManager animationManager => this.info.animationManager;
@ -71,22 +71,23 @@ namespace Revitalize.Framework.Objects
} }
set set
{ {
this.info =(BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(value, typeof(BasicItemInformation)); this.info = (BasicItemInformation)Revitalize.ModCore.Serializer.DeserializeFromJSONString(value, typeof(BasicItemInformation));
} }
} }
protected Netcode.NetString netItemInfo;
protected Netcode.NetString netItemInfo;
/// <summary>Empty constructor.</summary> /// <summary>Empty constructor.</summary>
public CustomObject() { public CustomObject()
{
this.guid = Guid.NewGuid(); this.guid = Guid.NewGuid();
this.InitNetFields(); this.InitNetFields();
} }
/// <summary>Construct an instance.</summary> /// <summary>Construct an instance.</summary>
public CustomObject(CustomObjectData PyTKData, BasicItemInformation info,int Stack=1) public CustomObject(CustomObjectData PyTKData, BasicItemInformation info, int Stack = 1)
: base(PyTKData, Vector2.Zero) : base(PyTKData, Vector2.Zero)
{ {
this.info = info; this.info = info;
@ -97,7 +98,7 @@ namespace Revitalize.Framework.Objects
} }
/// <summary>Construct an instance.</summary> /// <summary>Construct an instance.</summary>
public CustomObject(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation,int Stack=1) public CustomObject(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation, int Stack = 1)
: base(PyTKData, TileLocation) : base(PyTKData, TileLocation)
{ {
this.info = info; this.info = info;
@ -133,7 +134,7 @@ namespace Revitalize.Framework.Objects
public override bool isPassable() public override bool isPassable()
{ {
return this.info.ignoreBoundingBox || Revitalize.ModCore.playerInfo.sittingInfo.SittingObject==this; return this.info.ignoreBoundingBox || Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this;
} }
public override Rectangle getBoundingBox(Vector2 tileLocation) public override Rectangle getBoundingBox(Vector2 tileLocation)
@ -147,7 +148,7 @@ namespace Revitalize.Framework.Objects
/// <summary>Checks for interaction with the object.</summary> /// <summary>Checks for interaction with the object.</summary>
public override bool checkForAction(Farmer who, bool justCheckingForActivity = false) public override bool checkForAction(Farmer who, bool justCheckingForActivity = false)
{ {
MouseState mState = Mouse.GetState(); MouseState mState = Mouse.GetState();
KeyboardState keyboardState = Game1.GetKeyboardState(); KeyboardState keyboardState = Game1.GetKeyboardState();
@ -173,7 +174,7 @@ namespace Revitalize.Framework.Objects
{ {
CustomObjectData data = CustomObjectData.collection[additionalSaveData["id"]]; CustomObjectData data = CustomObjectData.collection[additionalSaveData["id"]];
BasicItemInformation info = Revitalize.ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(additionalSaveData["ItemInfo"]); BasicItemInformation info = Revitalize.ModCore.Serializer.DeserializeFromJSONString<BasicItemInformation>(additionalSaveData["ItemInfo"]);
return new CustomObject(data,info,(replacement as Chest).TileLocation); return new CustomObject(data, info, (replacement as Chest).TileLocation);
} }
public override Dictionary<string, string> getAdditionalSaveData() public override Dictionary<string, string> getAdditionalSaveData()
{ {
@ -213,8 +214,6 @@ namespace Revitalize.Framework.Objects
{ {
//ModCore.log("Clicky click!"); //ModCore.log("Clicky click!");
ModCore.log(System.Environment.StackTrace);
return this.removeAndAddToPlayersInventory(); return this.removeAndAddToPlayersInventory();
//return base.clicked(who); //return base.clicked(who);
} }
@ -276,6 +275,8 @@ namespace Revitalize.Framework.Objects
/// <summary>Places an object down.</summary> /// <summary>Places an object down.</summary>
public override bool placementAction(GameLocation location, int x, int y, Farmer who = null) public override bool placementAction(GameLocation location, int x, int y, Farmer who = null)
{ {
if (this.info.canBeSetIndoors == false && location.IsOutdoors == false) return false;
if (this.info.canBeSetOutdoors == false && location.IsOutdoors) return false;
this.updateDrawPosition(x, y); this.updateDrawPosition(x, y);
this.location = location; this.location = location;
return base.placementAction(location, x, y, who); return base.placementAction(location, x, y, who);
@ -283,7 +284,7 @@ namespace Revitalize.Framework.Objects
public override bool canBePlacedHere(GameLocation l, Vector2 tile) public override bool canBePlacedHere(GameLocation l, Vector2 tile)
{ {
if (this.info.ignoreBoundingBox && l.isObjectAtTile((int)tile.X,(int)tile.Y)==false) return true; if (this.info.ignoreBoundingBox && l.isObjectAtTile((int)tile.X, (int)tile.Y) == false) return true;
return base.canBePlacedHere(l, tile); return base.canBePlacedHere(l, tile);
} }
@ -306,8 +307,8 @@ namespace Revitalize.Framework.Objects
public string generateRotationalAnimationKey() public string generateRotationalAnimationKey()
{ {
return (this.info.animationManager.currentAnimationName.Split('_')[0]) +"_"+ (int)this.info.facingDirection; return (this.info.animationManager.currentAnimationName.Split('_')[0]) + "_" + (int)this.info.facingDirection;
} }
public string generateDefaultRotationalAnimationKey() public string generateDefaultRotationalAnimationKey()
@ -325,7 +326,7 @@ namespace Revitalize.Framework.Objects
/// <summary>Gets a clone of the game object.</summary> /// <summary>Gets a clone of the game object.</summary>
public override Item getOne() public override Item getOne()
{ {
return new CustomObject(this.data,this.info); return new CustomObject(this.data, this.info);
} }
/// <summary>What happens when the object is drawn at a tile location.</summary> /// <summary>What happens when the object is drawn at a tile location.</summary>
@ -353,7 +354,7 @@ namespace Revitalize.Framework.Objects
int addedDepth = 0; int addedDepth = 0;
if (this.info.ignoreBoundingBox) addedDepth++; if (this.info.ignoreBoundingBox) addedDepth++;
if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this) addedDepth++; if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this) addedDepth++;
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)( (this.TileLocation.Y+addedDepth) * Game1.tileSize) / 10000f)); 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)((this.TileLocation.Y + addedDepth) * Game1.tileSize) / 10000f));
try try
{ {
this.animationManager.tickAnimation(); this.animationManager.tickAnimation();
@ -372,6 +373,7 @@ namespace Revitalize.Framework.Objects
/// <summary>Draw the game object at a non-tile spot. Aka like debris.</summary> /// <summary>Draw the game object at a non-tile spot. Aka like debris.</summary>
public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1f) public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1f)
{ {
/*
if (Game1.eventUp && Game1.CurrentEvent.isTileWalkedOn(xNonTile / 64, yNonTile / 64)) if (Game1.eventUp && Game1.CurrentEvent.isTileWalkedOn(xNonTile / 64, yNonTile / 64))
return; return;
if ((int)(this.ParentSheetIndex) != 590 && (int)(this.Fragility) != 2) if ((int)(this.ParentSheetIndex) != 590 && (int)(this.Fragility) != 2)
@ -389,6 +391,37 @@ namespace Revitalize.Framework.Objects
double num4 = (double)layerDepth; double num4 = (double)layerDepth;
spriteBatch1.Draw(this.displayTexture, local, this.animationManager.defaultDrawFrame.sourceRectangle, this.info.drawColor * alpha, (float)num1, origin, (float)4f, (SpriteEffects)num3, (float)num4); spriteBatch1.Draw(this.displayTexture, local, this.animationManager.defaultDrawFrame.sourceRectangle, this.info.drawColor * alpha, (float)num1, origin, (float)4f, (SpriteEffects)num3, (float)num4);
*/
//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)(xNonTile), yNonTile)), 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, layerDepth));
// Log.AsyncG("ANIMATION IS NULL?!?!?!?!");
}
else
{
//Log.AsyncC("Animation Manager is working!");
int addedDepth = 0;
if (this.info.ignoreBoundingBox) addedDepth++;
if (Revitalize.ModCore.playerInfo.sittingInfo.SittingObject == this) addedDepth++;
this.animationManager.draw(spriteBatch, this.displayTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(xNonTile), yNonTile)), 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, layerDepth));
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));
} }
/// <summary>What happens when the object is drawn in a menu.</summary> /// <summary>What happens when the object is drawn in a menu.</summary>
@ -407,7 +440,7 @@ namespace Revitalize.Framework.Objects
/// <summary>What happens when the object is drawn when held by a player.</summary> /// <summary>What happens when the object is drawn when held by a player.</summary>
public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f) public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f)
{ {
if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null"); if (this.animationManager == null) Revitalize.ModCore.log("Animation Manager Null");
if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null"); if (this.displayTexture == null) Revitalize.ModCore.log("Display texture is null");
if (f.ActiveObject.bigCraftable.Value) if (f.ActiveObject.bigCraftable.Value)
@ -433,9 +466,14 @@ namespace Revitalize.Framework.Objects
//base.drawWhenHeld(spriteBatch, objectPosition, f); //base.drawWhenHeld(spriteBatch, objectPosition, f);
} }
public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location)
{
//Do nothing because this shouldn't be placeable anywhere.
}
public void InitNetFields() public void InitNetFields()
{ {
if (Game1.IsMultiplayer == false &&(Game1.IsClient==false || Game1.IsClient==false)) return; if (Game1.IsMultiplayer == false && (Game1.IsClient == false || Game1.IsClient == false)) return;
this.initNetFields(); this.initNetFields();
this.syncObject = new PySync(this); this.syncObject = new PySync(this);
this.NetFields.AddField(this.syncObject); this.NetFields.AddField(this.syncObject);
@ -449,7 +487,7 @@ namespace Revitalize.Framework.Objects
/// <returns></returns> /// <returns></returns>
public override Dictionary<string, string> getSyncData() public override Dictionary<string, string> getSyncData()
{ {
Dictionary<string,string> syncData= base.getSyncData(); Dictionary<string, string> syncData = base.getSyncData();
syncData.Add("BasicItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info)); syncData.Add("BasicItemInfo", Revitalize.ModCore.Serializer.ToJSONString(this.info));
return syncData; return syncData;
} }
@ -478,7 +516,7 @@ namespace Revitalize.Framework.Objects
//ModCore.log("This is my BB: " + this.boundingBox.Value); //ModCore.log("This is my BB: " + this.boundingBox.Value);
} }
} }
public string getDisplayNameFromStringsFile(string objectID) public string getDisplayNameFromStringsFile(string objectID)
{ {

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Revitalize.Framework.Utilities
{
public class TimeUtilities
{
public static int GetMinutesFromTime(int Days, int Hours, int Minutes)
{
int amount=0;
amount += Days * 24 * 60;
amount += Hours * 60;
amount += Minutes;
return amount;
}
}
}

View File

@ -384,6 +384,7 @@ namespace Revitalize
throw new Exception("Can't run Revitalize in multiplayer due to lack of current support!"); throw new Exception("Can't run Revitalize in multiplayer due to lack of current support!");
} }
Serializer.afterLoad(); Serializer.afterLoad();
ShopHacks.AddOreToClintsShop();
// Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.BigTiledTest")); // Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.BigTiledTest"));

View File

@ -68,6 +68,7 @@
<Compile Include="Framework\Factories\Objects\Resources\OreFactoryInfo.cs" /> <Compile Include="Framework\Factories\Objects\Resources\OreFactoryInfo.cs" />
<Compile Include="Framework\Hacks\MenuHacks.cs" /> <Compile Include="Framework\Hacks\MenuHacks.cs" />
<Compile Include="Framework\Hacks\ObjectInteractionHacks.cs" /> <Compile Include="Framework\Hacks\ObjectInteractionHacks.cs" />
<Compile Include="Framework\Hacks\ShopHacks.cs" />
<Compile Include="Framework\Illuminate\ColorExtensions.cs" /> <Compile Include="Framework\Illuminate\ColorExtensions.cs" />
<Compile Include="Framework\Illuminate\FakeLightSource.cs" /> <Compile Include="Framework\Illuminate\FakeLightSource.cs" />
<Compile Include="Framework\Illuminate\LightManager.cs" /> <Compile Include="Framework\Illuminate\LightManager.cs" />
@ -157,6 +158,7 @@
<Compile Include="Framework\Utilities\Serialization\Converters\Vector2Converter.cs" /> <Compile Include="Framework\Utilities\Serialization\Converters\Vector2Converter.cs" />
<Compile Include="Framework\Utilities\Serialization\Serialization.cs" /> <Compile Include="Framework\Utilities\Serialization\Serialization.cs" />
<Compile Include="Framework\Utilities\Serialization\SpriteBatchUtilities.cs" /> <Compile Include="Framework\Utilities\Serialization\SpriteBatchUtilities.cs" />
<Compile Include="Framework\Utilities\TimeUtilities.cs" />
<Compile Include="Framework\Utilities\Vector2Utilities.cs" /> <Compile Include="Framework\Utilities\Vector2Utilities.cs" />
<Compile Include="ModCore.cs" /> <Compile Include="ModCore.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />