2017-08-23 08:45:30 +08:00
|
|
|
|
|
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
2017-09-14 04:53:12 +08:00
|
|
|
|
using Newtonsoft.Json.Linq;
|
2017-08-23 08:45:30 +08:00
|
|
|
|
using StardewModdingAPI;
|
|
|
|
|
using StardewValley;
|
|
|
|
|
using StardewValley.Locations;
|
|
|
|
|
using StardewValley.Menus;
|
|
|
|
|
using StardewValley.Objects;
|
2017-09-05 19:13:42 +08:00
|
|
|
|
using StardustCore;
|
2017-09-14 04:53:12 +08:00
|
|
|
|
using StardustCore.Animations;
|
2018-05-01 09:21:31 +08:00
|
|
|
|
using StardustCore.UIUtilities;
|
2017-08-23 08:45:30 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2017-09-13 07:30:30 +08:00
|
|
|
|
using System.IO;
|
2017-08-23 08:45:30 +08:00
|
|
|
|
using System.Xml.Serialization;
|
|
|
|
|
|
|
|
|
|
namespace AdditionalCropsFramework
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Revitalize ModularCropObject Class. This is a core class and should only be extended upon.
|
|
|
|
|
/// </summary>
|
|
|
|
|
///
|
2017-09-05 19:13:42 +08:00
|
|
|
|
public class ModularCropObject : CoreObject
|
2017-08-23 08:45:30 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public new bool flipped;
|
|
|
|
|
|
|
|
|
|
public string cropType;
|
|
|
|
|
|
2017-09-14 04:53:12 +08:00
|
|
|
|
public string dataFileName;
|
|
|
|
|
|
2017-08-23 08:45:30 +08:00
|
|
|
|
public override string Name
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return this.name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ModularCropObject()
|
|
|
|
|
{
|
|
|
|
|
this.updateDrawPosition();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ModularCropObject(bool f)
|
|
|
|
|
{
|
|
|
|
|
//does nothng
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-01 09:21:31 +08:00
|
|
|
|
public ModularCropObject(IModHelper helper,int which, int initalStack, string ObjectTextureSheetName, string DataFileName)
|
2017-09-13 17:39:50 +08:00
|
|
|
|
{
|
2017-09-14 04:53:12 +08:00
|
|
|
|
this.serializationName = this.GetType().ToString();
|
|
|
|
|
// if (File.Exists(ObjectTextureSheetName)) Log.AsyncC("YAY");
|
2018-05-01 09:21:31 +08:00
|
|
|
|
this.TileLocation = Vector2.Zero;
|
2017-09-13 17:39:50 +08:00
|
|
|
|
|
2018-05-01 09:21:31 +08:00
|
|
|
|
this.Stack = initalStack;
|
2017-09-13 17:39:50 +08:00
|
|
|
|
try
|
|
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
|
this.TextureSheet = new Texture2DExtended(helper, ObjectTextureSheetName);
|
|
|
|
|
//TextureSheet = ModCore.ModHelper.Content.Load<Texture2D>(Path.Combine(Utilities.EntensionsFolderName, ObjectTextureSheetName)); //Game1.content.Load<Texture2D>("TileSheets\\furniture");
|
2017-09-13 17:39:50 +08:00
|
|
|
|
}
|
|
|
|
|
catch(Exception err)
|
|
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
|
err.ToString();
|
2017-09-14 04:53:12 +08:00
|
|
|
|
// Log.AsyncM(err);
|
2017-09-13 17:39:50 +08:00
|
|
|
|
}
|
|
|
|
|
texturePath = ObjectTextureSheetName;
|
2017-08-23 08:45:30 +08:00
|
|
|
|
this.dataFileName = DataFileName;
|
2018-05-01 09:21:31 +08:00
|
|
|
|
this.CanBeSetDown = false;
|
2017-09-14 04:53:12 +08:00
|
|
|
|
// Log.AsyncG(Path.Combine(Utilities.EntensionsFolderName,DataFileName));
|
|
|
|
|
// Log.AsyncC(which);
|
|
|
|
|
Dictionary<int, string> dictionary = new Dictionary<int, string>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
dictionary = ModCore.ModHelper.Content.Load<Dictionary<int, string>>(Path.Combine(Utilities.EntensionsFolderName, DataFileName));
|
|
|
|
|
}
|
|
|
|
|
catch(Exception err)
|
|
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
|
err.ToString();
|
2017-09-14 04:53:12 +08:00
|
|
|
|
// Log.AsyncC(err);
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-23 08:45:30 +08:00
|
|
|
|
|
|
|
|
|
string[] array = dictionary[which].Split(new char[]
|
|
|
|
|
{
|
|
|
|
|
'/'
|
|
|
|
|
});
|
|
|
|
|
this.name = array[0];
|
2018-05-01 09:21:31 +08:00
|
|
|
|
this.Price = Convert.ToInt32(array[1]);
|
|
|
|
|
this.Edibility =Convert.ToInt32(array[2]);
|
2017-09-13 17:39:50 +08:00
|
|
|
|
string[] array2 = array[3].Split(' ');
|
|
|
|
|
this.cropType = array2[0];
|
2018-05-01 09:21:31 +08:00
|
|
|
|
this.Category =Convert.ToInt32(array2[1]);
|
|
|
|
|
this.Type = this.cropType;
|
2017-09-13 17:39:50 +08:00
|
|
|
|
this.displayName = this.name;
|
|
|
|
|
|
|
|
|
|
this.description = array[5];
|
2017-09-14 01:52:27 +08:00
|
|
|
|
|
|
|
|
|
string[] dArray = this.description.Split(' ');
|
|
|
|
|
string newDes = "";
|
|
|
|
|
int MaxWords = 7;
|
|
|
|
|
int currentCount = 0;
|
|
|
|
|
foreach (var v in dArray)
|
|
|
|
|
{
|
|
|
|
|
if (currentCount == MaxWords)
|
|
|
|
|
{
|
|
|
|
|
currentCount = 0;
|
|
|
|
|
newDes += "\n";
|
|
|
|
|
}
|
|
|
|
|
newDes += v+" ";
|
|
|
|
|
currentCount++;
|
|
|
|
|
}
|
|
|
|
|
this.description = newDes;
|
|
|
|
|
|
2018-05-01 09:21:31 +08:00
|
|
|
|
this.defaultSourceRect = new Rectangle(which * 16 % TextureSheet.texture.Width, which * 16 / TextureSheet.texture.Width * 16, 16, 16);
|
2017-09-13 17:39:50 +08:00
|
|
|
|
this.sourceRect = this.defaultSourceRect;
|
|
|
|
|
|
2017-09-14 04:53:12 +08:00
|
|
|
|
|
|
|
|
|
|
2017-09-13 17:39:50 +08:00
|
|
|
|
this.defaultBoundingBox = new Rectangle(0, 0, 16, 16);
|
2018-05-01 09:21:31 +08:00
|
|
|
|
this.boundingBox.Value = this.defaultBoundingBox;
|
2017-08-23 08:45:30 +08:00
|
|
|
|
|
|
|
|
|
this.updateDrawPosition();
|
2018-05-01 09:21:31 +08:00
|
|
|
|
this.ParentSheetIndex = which;
|
2017-09-14 04:53:12 +08:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2017-11-17 18:50:22 +08:00
|
|
|
|
this.animationManager = new StardustCore.Animations.AnimationManager(this.TextureSheet, new StardustCore.Animations.Animation(this.defaultSourceRect, -1), AnimationManager.parseAnimationsFromXNB(array[3]), "Default");
|
2017-09-14 04:53:12 +08:00
|
|
|
|
this.animationManager.setAnimation("Default", 0);
|
|
|
|
|
//Log.AsyncC("Using animation manager");
|
|
|
|
|
}
|
|
|
|
|
catch (Exception errr)
|
|
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
|
errr.ToString();
|
2017-09-14 04:53:12 +08:00
|
|
|
|
this.animationManager = new StardustCore.Animations.AnimationManager(this.TextureSheet, new StardustCore.Animations.Animation(this.defaultSourceRect, -1));
|
|
|
|
|
}
|
2017-08-23 08:45:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string getDescription()
|
|
|
|
|
{
|
|
|
|
|
return this.description;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
public override bool performDropDownAction(StardewValley.Farmer who)
|
|
|
|
|
{
|
|
|
|
|
this.resetOnPlayerEntry((who == null) ? Game1.currentLocation : who.currentLocation);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
public override void hoverAction()
|
|
|
|
|
{
|
|
|
|
|
base.hoverAction();
|
|
|
|
|
if (!Game1.player.isInventoryFull())
|
|
|
|
|
{
|
|
|
|
|
Game1.mouseCursor = 2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool canBeGivenAsGift()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool canBePlacedHere(GameLocation l, Vector2 tile)
|
|
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
|
return false;
|
2017-08-23 08:45:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-01 09:21:31 +08:00
|
|
|
|
public override void updateDrawPosition()
|
2017-08-23 08:45:30 +08:00
|
|
|
|
{
|
|
|
|
|
this.drawPosition = new Vector2((float)this.boundingBox.X, (float)(this.boundingBox.Y - (this.sourceRect.Height * Game1.pixelZoom - this.boundingBox.Height)));
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-01 09:21:31 +08:00
|
|
|
|
public override int getTilesWide()
|
2017-08-23 08:45:30 +08:00
|
|
|
|
{
|
|
|
|
|
return this.boundingBox.Width / Game1.tileSize;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-01 09:21:31 +08:00
|
|
|
|
public override int getTilesHigh()
|
2017-08-23 08:45:30 +08:00
|
|
|
|
{
|
|
|
|
|
return this.boundingBox.Height / Game1.tileSize;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-01 09:21:31 +08:00
|
|
|
|
|
2017-08-23 08:45:30 +08:00
|
|
|
|
public override bool placementAction(GameLocation location, int x, int y, StardewValley.Farmer who = null)
|
|
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
|
return false;
|
2017-08-23 08:45:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool isPlaceable()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Rectangle getBoundingBox(Vector2 tileLocation)
|
|
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
|
return this.boundingBox.Value;
|
2017-08-23 08:45:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int salePrice()
|
|
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
|
return this.Price;
|
2017-08-23 08:45:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int maximumStackSize()
|
|
|
|
|
{
|
2017-09-13 17:39:50 +08:00
|
|
|
|
return 999;
|
2017-08-23 08:45:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int getStack()
|
|
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
|
return this.Stack;
|
2017-08-23 08:45:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private float getScaleSize()
|
|
|
|
|
{
|
|
|
|
|
int num = this.sourceRect.Width / 16;
|
|
|
|
|
int num2 = this.sourceRect.Height / 16;
|
|
|
|
|
if (num >= 5)
|
|
|
|
|
{
|
|
|
|
|
return 0.75f;
|
|
|
|
|
}
|
|
|
|
|
if (num2 >= 3)
|
|
|
|
|
{
|
|
|
|
|
return 1f;
|
|
|
|
|
}
|
|
|
|
|
if (num <= 2)
|
|
|
|
|
{
|
|
|
|
|
return 2f;
|
|
|
|
|
}
|
|
|
|
|
if (num <= 4)
|
|
|
|
|
{
|
|
|
|
|
return 1f;
|
|
|
|
|
}
|
|
|
|
|
return 0.1f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f)
|
|
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
|
if (f.ActiveObject.bigCraftable.Value)
|
2017-08-23 08:45:30 +08:00
|
|
|
|
{
|
|
|
|
|
spriteBatch.Draw(Game1.bigCraftableSpriteSheet, objectPosition, new Microsoft.Xna.Framework.Rectangle?(StardewValley.Object.getSourceRectForBigCraftable(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-05-01 09:21:31 +08:00
|
|
|
|
spriteBatch.Draw(Game1.objectSpriteSheet, objectPosition, new Microsoft.Xna.Framework.Rectangle?(GameLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
|
2017-08-23 08:45:30 +08:00
|
|
|
|
if (f.ActiveObject != null && f.ActiveObject.Name.Contains("="))
|
|
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
|
spriteBatch.Draw(Game1.objectSpriteSheet, objectPosition + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Microsoft.Xna.Framework.Rectangle?(GameLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), (float)Game1.pixelZoom + Math.Abs(Game1.starCropShimmerPause) / 8f, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
|
2017-08-23 08:45:30 +08:00
|
|
|
|
if (Math.Abs(Game1.starCropShimmerPause) <= 0.05f && Game1.random.NextDouble() < 0.97)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Game1.starCropShimmerPause += 0.04f;
|
|
|
|
|
if (Game1.starCropShimmerPause >= 0.8f)
|
|
|
|
|
{
|
|
|
|
|
Game1.starCropShimmerPause = -0.8f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//base.drawWhenHeld(spriteBatch, objectPosition, f);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-01 09:21:31 +08:00
|
|
|
|
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawWithShadows)
|
2017-08-23 08:45:30 +08:00
|
|
|
|
{
|
2017-09-14 01:52:27 +08:00
|
|
|
|
|
|
|
|
|
//spriteBatch.Draw(TextureSheet, location + new Vector2((float)(Game1.tileSize), (float)(Game1.tileSize)), new Rectangle?(this.sourceRect), Color.White * transparency, 0f, new Vector2((float)(this.sourceRect.Width / 2), (float)(this.sourceRect.Height)), 1f * 3, SpriteEffects.None, layerDepth);
|
2018-05-01 09:21:31 +08:00
|
|
|
|
spriteBatch.Draw(TextureSheet.texture, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), new Rectangle?(this.defaultSourceRect), Color.White * transparency, 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height / 2)), 1f * this.getScaleSize() * scaleSize * 1.5f, SpriteEffects.None, layerDepth);
|
2017-09-14 01:52:27 +08:00
|
|
|
|
|
|
|
|
|
if (drawStackNumber && this.maximumStackSize() > 1 && ((double)scaleSize > 0.3 && this.Stack != int.MaxValue) && this.Stack > 1)
|
2018-05-01 09:21:31 +08:00
|
|
|
|
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)
|
2017-09-14 01:52:27 +08:00
|
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
|
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);
|
2017-09-13 17:39:50 +08:00
|
|
|
|
}
|
2017-09-14 01:52:27 +08:00
|
|
|
|
}
|
2017-08-23 08:45:30 +08:00
|
|
|
|
|
|
|
|
|
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
|
|
|
|
|
{
|
|
|
|
|
if (x == -1)
|
|
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
|
spriteBatch.Draw(TextureSheet.texture, Game1.GlobalToLocal(Game1.viewport, this.drawPosition), new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.Decoration_type == 12) ? 0f : ((float)(this.boundingBox.Bottom - 8) / 10000f));
|
2017-08-23 08:45:30 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
|
spriteBatch.Draw(TextureSheet.texture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), (float)(y * Game1.tileSize - (this.sourceRect.Height * Game1.pixelZoom - this.boundingBox.Height)))), new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.Decoration_type == 12) ? 0f : ((float)(this.boundingBox.Bottom - 8) / 10000f));
|
2017-08-23 08:45:30 +08:00
|
|
|
|
}
|
2018-05-01 09:21:31 +08:00
|
|
|
|
if (this.heldObject.Value != null)
|
2017-08-23 08:45:30 +08:00
|
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
|
if (this.heldObject.Value is ModularCropObject)
|
2017-08-23 08:45:30 +08:00
|
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
|
(this.heldObject.Value as ModularCropObject).drawAtNonTileSpot(spriteBatch, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - (this.heldObject.Value as ModularCropObject).sourceRect.Height * Game1.pixelZoom - Game1.tileSize / 4))), (float)(this.boundingBox.Bottom - 7) / 10000f, alpha);
|
2017-08-23 08:45:30 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))) + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize * 5 / 6)), new Rectangle?(Game1.shadowTexture.Bounds), Color.White * alpha, 0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), 4f, SpriteEffects.None, (float)this.boundingBox.Bottom / 10000f);
|
2018-05-01 09:21:31 +08:00
|
|
|
|
spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(this.boundingBox.Center.X - Game1.tileSize / 2), (float)(this.boundingBox.Center.Y - Game1.tileSize * 4 / 3))), new Rectangle?(GameLocation.getSourceRectForObject(this.heldObject.Value.ParentSheetIndex)), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, (float)(this.boundingBox.Bottom + 1) / 10000f);
|
2017-08-23 08:45:30 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-01 09:21:31 +08:00
|
|
|
|
public override void drawAtNonTileSpot(SpriteBatch spriteBatch, Vector2 location, float layerDepth, float alpha = 1f)
|
2017-08-23 08:45:30 +08:00
|
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
|
spriteBatch.Draw(TextureSheet.texture, location, new Rectangle?(this.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth);
|
2017-08-23 08:45:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-01 09:21:31 +08:00
|
|
|
|
public override Item getOne(IModHelper helper)
|
2017-08-23 08:45:30 +08:00
|
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
|
ModularCropObject ModularCropObject = new ModularCropObject(helper,this.ParentSheetIndex,this.Stack,this.texturePath,this.dataFileName);
|
2017-08-23 08:45:30 +08:00
|
|
|
|
|
|
|
|
|
ModularCropObject.drawPosition = this.drawPosition;
|
|
|
|
|
ModularCropObject.defaultBoundingBox = this.defaultBoundingBox;
|
2018-05-01 09:21:31 +08:00
|
|
|
|
ModularCropObject.boundingBox.Value = this.boundingBox.Value;
|
2017-08-23 08:45:30 +08:00
|
|
|
|
ModularCropObject.currentRotation = this.currentRotation - 1;
|
|
|
|
|
ModularCropObject.rotations = this.rotations;
|
|
|
|
|
//rotate();
|
|
|
|
|
|
|
|
|
|
return ModularCropObject;
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-01 09:21:31 +08:00
|
|
|
|
public virtual void resetTexture(IModHelper helper)
|
2017-08-23 08:45:30 +08:00
|
|
|
|
{
|
2018-05-01 09:21:31 +08:00
|
|
|
|
TextureSheet = new Texture2DExtended(helper, TextureSheet.path);
|
2017-08-23 08:45:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string getCategoryName()
|
|
|
|
|
{
|
2017-09-13 17:39:50 +08:00
|
|
|
|
if (this.cropType != "") return ("Modded Crop:"+this.cropType);
|
|
|
|
|
return "Modded Crop";
|
|
|
|
|
//return "Modded Crop";
|
2017-08-23 08:45:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Color getCategoryColor()
|
|
|
|
|
{
|
|
|
|
|
return Color.DarkBlue;
|
2017-09-05 19:13:42 +08:00
|
|
|
|
|
2017-08-23 08:45:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-13 17:39:50 +08:00
|
|
|
|
|
2017-09-14 04:53:12 +08:00
|
|
|
|
public static new void Serialize(Item I)
|
|
|
|
|
{
|
2017-09-05 19:13:42 +08:00
|
|
|
|
|
2017-09-14 04:53:12 +08:00
|
|
|
|
StardustCore.ModCore.SerializationManager.WriteToJsonFile(Path.Combine(StardustCore.ModCore.SerializationManager.playerInventoryPath, I.Name + ".json"), (ModularCropObject)I);
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-14 08:11:05 +08:00
|
|
|
|
public static void Serialize(Item I,string s)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
StardustCore.ModCore.SerializationManager.WriteToJsonFile(Path.Combine(s, I.Name + ".json"), (ModularCropObject)I);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-01 09:21:31 +08:00
|
|
|
|
public static ModularCropObject ParseIntoInventory(string s)
|
2017-09-14 04:53:12 +08:00
|
|
|
|
{
|
|
|
|
|
// PlanterBox p = new PlanterBox();
|
|
|
|
|
// return p;
|
|
|
|
|
|
2018-05-01 09:21:31 +08:00
|
|
|
|
var crop = StardustCore.ModCore.ModHelper.ReadJsonFile<ModularCropObject>(s);
|
|
|
|
|
return crop;
|
2017-09-14 04:53:12 +08:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SerializeFromWorld(Item I)
|
|
|
|
|
{
|
|
|
|
|
// ModCore.serilaizationManager.WriteToJsonFile(Path.Combine(ModCore.serilaizationManager.objectsInWorldPath, (c as CoreObject).thisLocation.name, c.Name + ".json"), (PlanterBox)c);
|
|
|
|
|
StardustCore.ModCore.SerializationManager.WriteToJsonFile(Path.Combine(StardustCore.ModCore.SerializationManager.objectsInWorldPath, I.Name + ".json"), (ModularCropObject)I);
|
|
|
|
|
}
|
2017-08-23 08:45:30 +08:00
|
|
|
|
}
|
|
|
|
|
}
|