Added in tin ore and made ore be stored in ResourceManager.cs

This commit is contained in:
JoshuaNavarro 2019-08-16 17:19:20 -07:00
parent ff9aa226f7
commit 14fb72fdb9
5 changed files with 277 additions and 13 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

View File

@ -0,0 +1,224 @@
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 PyTK.CustomElementHandler;
using StardewValley;
namespace Revitalize.Framework.Objects.Items.Resources
{
public class Ore:CustomObject,ISaveElement
{
public Ore() { }
public Ore(CustomObjectData PyTKData, BasicItemInformation info,int Stack=1) : base(PyTKData, info) {
this.Stack = Stack;
}
public Ore(CustomObjectData PyTKData, BasicItemInformation info, Vector2 TileLocation,int Stack=1) : base(PyTKData, info, TileLocation)
{
this.Stack = Stack;
}
public override bool checkForAction(Farmer who, bool justCheckingForActivity = false)
{
//ModCore.log("Checking for a clicky click???");
return base.checkForAction(who, justCheckingForActivity);
}
public override bool clicked(Farmer who)
{
//ModCore.log("Clicked a multiTiledComponent!");
return true;
//return base.clicked(who);
}
public override bool rightClicked(Farmer who)
{
if (this.location == null)
this.location = Game1.player.currentLocation;
//ModCore.playerInfo.sittingInfo.sit(this, Vector2.Zero);
return true;
}
public override void performRemoveAction(Vector2 tileLocation, GameLocation environment)
{
this.location = null;
base.performRemoveAction(this.TileLocation, environment);
}
public virtual void removeFromLocation(GameLocation location, Vector2 offset)
{
this.cleanUpLights();
location.removeObject(this.TileLocation, false);
this.location = null;
//this.performRemoveAction(this.TileLocation,location);
}
public virtual void cleanUpLights()
{
if (this.info.lightManager != null) this.info.lightManager.removeForCleanUp(this.location);
}
public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location)
{
//Do nothing because this shouldn't be placeable anywhere.
}
/// <summary>Places an object down.</summary>
public override bool placementAction(GameLocation location, int x, int y, Farmer who = null)
{
/*
this.updateDrawPosition(x, y);
this.location = location;
if (this.location == null) this.location = Game1.player.currentLocation;
this.TileLocation = new Vector2((int)(x / Game1.tileSize), (int)(y / Game1.tileSize));
//ModCore.log("TileLocation: " + this.TileLocation);
/*
return base.placementAction(location, x, y, who);
//this.updateLightManager();
this.performDropDownAction(who);
location.objects.Add(this.TileLocation, this);
*/
//return true;
return false;
}
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadow)
{
if (drawStackNumber && this.maximumStackSize() > 1 && ((double)scaleSize > 0.3 && this.Stack != int.MaxValue) && this.Stack > 1)
Utility.drawTinyDigits(this.Stack, spriteBatch, location + new Vector2((float)(Game1.tileSize - Utility.getWidthOfTinyDigitString(this.Stack, 3f * scaleSize)) + 3f * scaleSize, (float)((double)Game1.tileSize - 18.0 * (double)scaleSize + 2.0)), 3f * scaleSize, 1f, Color.White);
if (drawStackNumber && this.Quality > 0)
{
float num = this.Quality < 4 ? 0.0f : (float)((Math.Cos((double)Game1.currentGameTime.TotalGameTime.Milliseconds * Math.PI / 512.0) + 1.0) * 0.0500000007450581);
spriteBatch.Draw(Game1.mouseCursors, location + new Vector2(12f, (float)(Game1.tileSize - 12) + num), new Microsoft.Xna.Framework.Rectangle?(this.Quality < 4 ? new Microsoft.Xna.Framework.Rectangle(338 + (this.Quality - 1) * 8, 400, 8, 8) : new Microsoft.Xna.Framework.Rectangle(346, 392, 8, 8)), Color.White * transparency, 0.0f, new Vector2(4f, 4f), (float)(3.0 * (double)scaleSize * (1.0 + (double)num)), SpriteEffects.None, layerDepth);
}
spriteBatch.Draw(this.displayTexture, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize)), new Rectangle?(this.animationManager.currentAnimation.sourceRectangle), this.info.drawColor * transparency, 0f, new Vector2((float)(this.animationManager.currentAnimation.sourceRectangle.Width / 2), (float)(this.animationManager.currentAnimation.sourceRectangle.Height)), scaleSize*4f, SpriteEffects.None, layerDepth);
}
public override Item getOne()
{
Ore component = new Ore(this.data, this.info.Copy(), this.TileLocation);
component.Stack = 1;
return component;
}
public override object getReplacement()
{
return base.getReplacement();
}
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
{
//instead of using this.offsetkey.x use get additional save data function and store offset key there
Ore self = Revitalize.ModCore.Serializer.DeserializeGUID<Ore>(additionalSaveData["GUID"]);
if (self == null)
{
return null;
}
/*
if (!Revitalize.ModCore.ObjectGroups.ContainsKey(additionalSaveData["ParentGUID"]))
{
//Get new container
MultiTiledObject obj = (MultiTiledObject)Revitalize.ModCore.Serializer.DeserializeGUID<MultiTiledObject>(additionalSaveData["ParentGUID"]);
self.containerObject = obj;
obj.addComponent(offsetKey, self);
//Revitalize.ModCore.log("ADD IN AN OBJECT!!!!");
Revitalize.ModCore.ObjectGroups.Add(additionalSaveData["ParentGUID"], (MultiTiledObject)obj);
}
else
{
self.containerObject = Revitalize.ModCore.ObjectGroups[additionalSaveData["ParentGUID"]];
Revitalize.ModCore.ObjectGroups[additionalSaveData["GUID"]].addComponent(offsetKey, self);
//Revitalize.ModCore.log("READD AN OBJECT!!!!");
}
*/
return (ICustomObject)self;
}
public override Dictionary<string, string> getAdditionalSaveData()
{
Dictionary<string, string> saveData = base.getAdditionalSaveData();
saveData.Add("GUID", this.guid.ToString());
Revitalize.ModCore.Serializer.SerializeGUID(this.guid.ToString(), this);
return saveData;
}
protected string recreateParentId(string id)
{
StringBuilder b = new StringBuilder();
string[] splits = id.Split('.');
for (int i = 0; i < splits.Length - 1; i++)
{
b.Append(splits[i]);
if (i == splits.Length - 2) continue;
b.Append(".");
}
return b.ToString();
}
/// <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.ignoreBoundingBox == true)
{
x *= -1;
y *= -1;
}
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;
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));
}
}
}

View File

@ -7,6 +7,7 @@ using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Revitalize.Framework.Factories.Objects.Resources;
using Revitalize.Framework.Objects.InformationFiles;
using Revitalize.Framework.Objects.Items.Resources;
using Revitalize.Framework.Objects.Resources.OreVeins;
using Revitalize.Framework.Utilities;
using StardewValley;
@ -28,8 +29,9 @@ namespace Revitalize.Framework.Objects
/// <summary>
/// A list of all of the ores held by the resource manager.
/// </summary>
public Dictionary<string, OreVeinObj> ores;
public Dictionary<string, OreVeinObj> oreVeins;
public Dictionary<string, OreResourceInformation> oreResourceInformationTable;
public Dictionary<string, Ore> ores;
/// <summary>
/// A list of all visited floors on the current visit to the mines.
@ -42,12 +44,14 @@ namespace Revitalize.Framework.Objects
public ResourceManager()
{
self = this;
this.ores = new Dictionary<string, OreVeinObj>();
this.oreVeins = new Dictionary<string, OreVeinObj>();
this.oreResourceInformationTable = new Dictionary<string, OreResourceInformation>();
this.ores = new Dictionary<string, Ore>();
this.visitedFloors = new List<int>();
this.serializeOre();
this.serializeOreVeins();
this.loadOreVeins();
this.loadInOreItems();
}
/// <summary>
@ -111,7 +115,7 @@ namespace Revitalize.Framework.Objects
}
foreach (var v in objs)
{
this.ores.Add(v.Value.info.id, v.Value);
this.oreVeins.Add(v.Value.info.id, v.Value);
//ModCore.ObjectManager.lamps.Add(v.Value.info.id, v.Value);
}
}
@ -121,7 +125,7 @@ namespace Revitalize.Framework.Objects
/// <summary>
/// Serializes an example ore to eb
/// </summary>
private void serializeOre() {
private void serializeOreVeins() {
OreVeinObj testOre = new OreVeinObj(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Test", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Test"), typeof(OreVeinTile), Color.White), new BasicItemInformation("Test Ore Vein", "Omegasis.Revitalize.Resources.Ore.Test", "A ore vein that is used for testing purposes.", "Revitalize.Ore", Color.Black, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Test"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Test"), new Animation(0, 0, 16, 16)), Color.White, false, null, null));
OreVeinTile testOre_0_0= new OreVeinTile(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Resources.Ore.Test", TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Test"), typeof(OreVeinTile), Color.White), new BasicItemInformation("Test Ore Vein", "Omegasis.Revitalize.Resources.Ore.Test", "A ore vein that is used for testing purposes.", "Revitalize.Ore", Color.Black, -300, 0, false, 350, true, true, TextureManager.GetTexture(ModCore.Manifest, "Resources.Ore", "Test"), new AnimationManager(TextureManager.GetExtendedTexture(ModCore.Manifest, "Resources.Ore", "Test"), new Animation(0, 0, 16, 16)), Color.White, false, null, null),
new InformationFiles.OreResourceInformation(new StardewValley.Object(211, 1), true, true, true, false, new List<IntRange>()
@ -138,11 +142,37 @@ namespace Revitalize.Framework.Objects
OreFactoryInfo testOre_0_0_file = new OreFactoryInfo(testOre_0_0);
OreFactoryInfo testOre_file = new OreFactoryInfo(testOre);
ModCore.Serializer.SerializeContentFile("TestOre_0_0", testOre_0_0_file, this.oreResourceDataPath);
ModCore.Serializer.SerializeContentFile("TestOre", testOre_file, this.oreResourceDataPath);
ModCore.Serializer.SerializeContentFile("TestOre_0_0", testOre_0_0_file,Path.Combine(this.oreResourceDataPath,"TestOre"));
ModCore.Serializer.SerializeContentFile("TestOre", testOre_file, Path.Combine(this.oreResourceDataPath, "TestOre"));
}
private void loadInOreItems()
{
Ore tinOre = new Ore(PyTKHelper.CreateOBJData("Omegasis.Revitalize.Items.Resources.Ore.TinOre", TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TinOre"), typeof(Ore), Color.White, true), new BasicItemInformation("Tin Ore", "Omegasis.Revitalize.Items.Resources.Ore.TinOre", "Tin ore that can be smelted into tin ingots for further use.", "Ore", Color.Silver, -300, 0, false, 85, false, false, TextureManager.GetTexture(ModCore.Manifest, "Items.Resources.Ore", "TinOre"), new AnimationManager(), Color.White, true, null, null), 1);
this.ores.Add("Tin", tinOre);
}
/// <summary>
/// Gets an ore from the list of stored ores in this mod.
/// </summary>
/// <param name="name"></param>
/// <param name="Stack"></param>
/// <returns></returns>
public Ore getOre(string name,int Stack=1)
{
if (this.ores.ContainsKey(name))
{
Ore o = (Ore)this.ores[name].getOne();
o.Stack = Stack;
return o;
}
else
{
return null;
}
}
/// <summary>
/// Checks to see if a resource can be spawned here.
/// </summary>
@ -169,10 +199,10 @@ namespace Revitalize.Framework.Objects
/// <param name="name"></param>
public bool spawnOreVein(string name, GameLocation Location, Vector2 TilePosition)
{
if (this.ores.ContainsKey(name))
if (this.oreVeins.ContainsKey(name))
{
OreVeinObj spawn;
this.ores.TryGetValue(name, out spawn);
this.oreVeins.TryGetValue(name, out spawn);
if (spawn != null)
{
spawn = (OreVeinObj)spawn.getOne();
@ -224,7 +254,7 @@ namespace Revitalize.Framework.Objects
}
List<OreVeinObj> spawnableOreVeins = new List<OreVeinObj>();
//Get a list of all of the ores that can spawn on this mine level.
foreach (KeyValuePair<string, OreVeinObj> pair in this.ores)
foreach (KeyValuePair<string, OreVeinObj> pair in this.oreVeins)
{
if (pair.Value.resourceInfo.canSpawnAtLocation() && (pair.Value.resourceInfo as OreResourceInformation).canSpawnOnCurrentMineLevel())
{
@ -294,7 +324,7 @@ namespace Revitalize.Framework.Objects
{
List<OreVeinObj> spawnableOreVeins = new List<OreVeinObj>();
//Get a list of all of the ores that can spawn on this mine level.
foreach (KeyValuePair<string, OreVeinObj> pair in this.ores)
foreach (KeyValuePair<string, OreVeinObj> pair in this.oreVeins)
{
if ((pair.Value.resourceInfo as OreResourceInformation).spawnsInQuarry)
{
@ -348,7 +378,7 @@ namespace Revitalize.Framework.Objects
List<OreVeinObj> spawnableOreVeins = new List<OreVeinObj>();
//Get a list of all of the ores that can spawn on this mine level.
foreach (KeyValuePair<string, OreVeinObj> pair in this.ores)
foreach (KeyValuePair<string, OreVeinObj> pair in this.oreVeins)
{
if ((pair.Value.resourceInfo as OreResourceInformation).spawnsOnFarm)
{

View File

@ -21,6 +21,7 @@ using StardustCore.Animations;
using StardewValley.Menus;
using Revitalize.Framework.Objects.Extras;
using Revitalize.Framework.Minigame.SeasideScrambleMinigame;
using Revitalize.Framework.Objects.Items.Resources;
namespace Revitalize
{
@ -208,6 +209,8 @@ namespace Revitalize
TextureManager.GetTextureManager(Manifest, "InventoryMenu").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Menus", "InventoryMenu"));
TextureManager.AddTextureManager(Manifest, "Resources.Ore");
TextureManager.GetTextureManager(Manifest, "Resources.Ore").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Objects", "Resources", "Ore"));
TextureManager.AddTextureManager(Manifest, "Items.Resources.Ore");
TextureManager.GetTextureManager(Manifest, "Items.Resources.Ore").searchForTextures(ModHelper, this.ModManifest, Path.Combine("Content", "Graphics", "Items", "Resources", "Ore"));
//TextureManager.addTexture("Furniture","Oak Chair", new Texture2DExtended(this.Helper, this.ModManifest, Path.Combine("Content","Graphics","Furniture", "Chairs", "Oak Chair.png")));
//Framework.Graphics.TextureManager.TextureManagers.Add("Furniture", new TextureManager(this.Helper.DirectoryPath, Path.Combine("Content", "Graphics", "Furniture")));
@ -377,7 +380,7 @@ namespace Revitalize
//Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Chairs.OakChair"));
//Game1.player.addItemToInventory(GetObjectFromPool("Omegasis.Revitalize.Furniture.Rugs.RugTest"));
//Game1.player.addItemToInventory(GetObjectFromPool("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"));
//Game1.player.addItemToInventory(ObjectManager.getObject("Omegasis.Revitalize.Furniture.Arcade.SeasideScramble",ObjectManager.miscellaneous));
//Game1.player.addItemToInventory(ObjectManager.getStorageFuriture("Omegasis.Revitalize.Furniture.Storage.OakCabinet"));
@ -389,6 +392,9 @@ namespace Revitalize
*/
//Game1.player.addItemToInventory(ObjectManager.resources.ores["Test"].getOne());
Game1.player.addItemToInventory(ObjectManager.resources.getOre("Tin",19));
ObjectManager.resources.spawnOreVein("Omegasis.Revitalize.Resources.Ore.Test", new Vector2(8, 7));
}

View File

@ -125,6 +125,7 @@
<Compile Include="Framework\Objects\InformationFiles\Furniture\TableInformation.cs" />
<Compile Include="Framework\Objects\InformationFiles\ObjectGUIDInfo.cs" />
<Compile Include="Framework\Objects\InformationFiles\ResourceInformaton.cs" />
<Compile Include="Framework\Objects\Items\Resources\Ore.cs" />
<Compile Include="Framework\Objects\MultiTiledComponent.cs" />
<Compile Include="Framework\Objects\MultiTiledObject.cs" />
<Compile Include="Framework\Objects\ObjectManager.cs" />
@ -167,6 +168,9 @@
<None Include="manifest.json" />
</ItemGroup>
<ItemGroup>
<Content Include="Content\Graphics\Items\Resources\Ore\TinOre.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Graphics\Menus\InventoryMenu\ItemBackground.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>