Fixed regular crops to grow now, and now can propperly harvest crops that don't regrow.

This commit is contained in:
2017-09-13 10:52:27 -07:00
parent dcafabcaa0
commit b3193b52fc
5 changed files with 202 additions and 78 deletions

View File

@ -83,19 +83,9 @@ namespace AdditionalCropsFramework
Log.AsyncG("BUBBLES");
}
}
*/
public static void plantRegularCropHere()
{
/*
Log.AsyncY(Game1.player.ActiveObject.name);
if (Lists.saplingNames.Contains(Game1.player.ActiveObject.name))
{
Log.AsyncY("PLANT THE SAPLING");
bool f = plantSappling();
if (f == true) return;
}
*/
HoeDirt t;
TerrainFeature r;
bool plant = Game1.player.currentLocation.terrainFeatures.TryGetValue(Game1.currentCursorTile, out r);
@ -111,7 +101,7 @@ namespace AdditionalCropsFramework
}
}
}
*/
public static bool placementAction(CoreObject cObj, GameLocation location, int x, int y, StardewValley.Farmer who = null, bool playSound = true)
@ -734,6 +724,18 @@ namespace AdditionalCropsFramework
return new Microsoft.Xna.Framework.Rectangle(Convert.ToInt32(parsed[2]), Convert.ToInt32(parsed[4]), Convert.ToInt32(parsed[6]), Convert.ToInt32(parsed[8]));
}
public static bool isCropFullGrown(Crop c)
{
if (c.currentPhase >= c.phaseDays.Count - 1)
{
c.currentPhase = c.phaseDays.Count - 1;
c.dayOfCurrentPhase = 0;
return true;
}
return false;
}
public static void cropNewDay(Crop c,int state, int fertilizer, int xTile, int yTile, GameLocation environment)
{
/*
@ -751,7 +753,15 @@ namespace AdditionalCropsFramework
if (state == 1)
{
c.dayOfCurrentPhase++;
Log.AsyncG(c.dayOfCurrentPhase);
Log.AsyncG("DaY OF CURRRENT PHASE BISCUITS!"+c.dayOfCurrentPhase);
Log.AsyncC(c.currentPhase);
if (c.dayOfCurrentPhase >= c.phaseDays[c.currentPhase])
{
c.currentPhase++;
c.dayOfCurrentPhase = 0;
}
//c.dayOfCurrentPhase = c.fullyGrown ? c.dayOfCurrentPhase - 1 : Math.Min(c.dayOfCurrentPhase + 1, c.phaseDays.Count > 0 ? c.phaseDays[Math.Min(c.phaseDays.Count - 1, c.currentPhase)] : 0);
if (c.dayOfCurrentPhase >= (c.phaseDays.Count > 0 ? c.phaseDays[Math.Min(c.phaseDays.Count - 1, c.currentPhase)] : 0) && c.currentPhase < c.phaseDays.Count - 1)
{
@ -761,7 +771,7 @@ namespace AdditionalCropsFramework
foreach(var v in c.phaseDays)
{
Log.AsyncR(v);
Log.AsyncR("PHASE DAY"+v);
}
while (c.currentPhase < c.phaseDays.Count - 1 && c.phaseDays.Count > 0 && c.phaseDays[c.currentPhase] <= 0)
c.currentPhase = c.currentPhase + 1;
@ -913,12 +923,34 @@ namespace AdditionalCropsFramework
public static bool harvestCrop(Crop c,int xTile, int yTile, int fertilizer, JunimoHarvester junimoHarvester = null)
{
Item I = (Item)new StardewValley.Object(c.indexOfHarvest, 1);
int howMuch = 3;
if (Game1.player.addItemToInventoryBool(I, false))
{
Vector2 vector2 = new Vector2((float)xTile, (float)yTile);
Game1.player.animateOnce(279 + Game1.player.facingDirection);
Game1.player.canMove = false;
Game1.playSound("harvest");
DelayedAction.playSoundAfterDelay("coin", 260);
if (c.regrowAfterHarvest == -1)
{
Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(17, new Vector2(vector2.X * (float)Game1.tileSize, vector2.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 125f, 0, -1, -1f, -1, 0));
Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(14, new Vector2(vector2.X * (float)Game1.tileSize, vector2.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0));
}
Game1.player.gainExperience(2, howMuch);
return true;
}
return false;
if (c.dead)
return junimoHarvester != null;
if (c.forageCrop)
{
StardewValley.Object @object = (StardewValley.Object)null;
int howMuch = 3;
// int howMuch = 3;
if (c.whichForageCrop == 1)
@object = new StardewValley.Object(399, 1, false, -1, 0);
if (Game1.player.professions.Contains(16))
@ -1091,11 +1123,26 @@ namespace AdditionalCropsFramework
public static bool harvestModularCrop(ModularCrop c, int xTile, int yTile, int fertilizer, JunimoHarvester junimoHarvester = null)
{
Item I = (Item)new ModularCropObject(c.indexOfHarvest, 1, c.cropObjectTexture, c.cropObjectData);
if (I == null)
int howMuch = 3;
if (Game1.player.addItemToInventoryBool(I, false))
{
Log.AsyncC("BAD JUJU");
return false;
Vector2 vector2 = new Vector2((float)xTile, (float)yTile);
Game1.player.animateOnce(279 + Game1.player.facingDirection);
Game1.player.canMove = false;
Game1.playSound("harvest");
DelayedAction.playSoundAfterDelay("coin", 260);
if (c.regrowAfterHarvest == -1)
{
Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(17, new Vector2(vector2.X * (float)Game1.tileSize, vector2.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 125f, 0, -1, -1f, -1, 0));
Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(14, new Vector2(vector2.X * (float)Game1.tileSize, vector2.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0));
}
Game1.player.gainExperience(2, howMuch);
return true;
}
return false;
Game1.player.addItemToInventoryBool(I);
return true;
@ -1105,7 +1152,7 @@ namespace AdditionalCropsFramework
if (c.forageCrop)
{
ModularCropObject @object = (ModularCropObject)null;
int howMuch = 3;
//int howMuch = 3;
if (c.whichForageCrop == 1)
// @object = new StardewValley.Object(399, 1, false, -1, 0);
if (Game1.player.professions.Contains(16))

View File

@ -56,10 +56,11 @@ namespace AdditionalCropsFramework
{
Directory.CreateDirectory(Path.Combine(ModCore.ModHelper.DirectoryPath, Utilities.EntensionsFolderName));
}
StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick;
// StardewModdingAPI.Events.GameEvents.UpdateTick += GameEvents_UpdateTick;
this.shippingList = new List<Item>();
}
//Unused
private void GameEvents_UpdateTick(object sender, EventArgs e)
{

View File

@ -119,6 +119,23 @@ namespace AdditionalCropsFramework
this.displayName = this.name;
this.description = array[5];
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;
this.defaultSourceRect = new Rectangle(which * 16 % TextureSheet.Width, which * 16 / TextureSheet.Width * 16, 16, 16);
this.sourceRect = this.defaultSourceRect;
@ -128,7 +145,6 @@ namespace AdditionalCropsFramework
this.updateDrawPosition();
this.parentSheetIndex = which;
this.quality = 1;
}
@ -1115,10 +1131,6 @@ namespace AdditionalCropsFramework
return this.stack;
}
public override int addToStack(int amount)
{
return 1;
}
private float getScaleSize()
{
@ -1169,8 +1181,17 @@ namespace AdditionalCropsFramework
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber)
{
//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);
spriteBatch.Draw(TextureSheet, 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);
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);
}
}
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)

View File

@ -290,7 +290,8 @@ namespace AdditionalCropsFramework
// Game1.showRedMessage("YOOO");
//do some stuff when the right button is down
// rotate();
if (Game1.player.ActiveObject == null) return false;
if (Game1.player.ActiveObject != null)
{
if (Game1.player.ActiveObject is ModularSeeds || Game1.player.ActiveObject.getCategoryName() == "Modular Seeds")
{
this.plantModdedCrop((Game1.player.ActiveObject as ModularSeeds));
@ -302,6 +303,36 @@ namespace AdditionalCropsFramework
this.plantRegularCrop();
// Log.AsyncY("regular seeds");
}
}
if (this.crop != null)
{
if (Utilities.isCropFullGrown(this.crop) == true)
{
//this.crop.harvest();
bool f= Utilities.harvestCrop(this.crop, (int)this.tileLocation.X, (int)this.tileLocation.Y, 0);
if (f == true && this.crop.regrowAfterHarvest == -1) this.crop = null;
}
}
if (this.modularCrop != null)
{
Log.AsyncM("HELLO MOD CROP");
if (this.modularCrop.isFullyGrown() == true)
{
Log.AsyncM("FULL BLOW");
bool f = Utilities.harvestModularCrop(this.modularCrop, (int)this.tileLocation.X, (int)this.tileLocation.Y, 0);
if (f == true)
{
//this.modularCrop = null;
if (f == true && this.modularCrop.regrowAfterHarvest == -1) this.modularCrop = null;
Log.AsyncO("HARVEST");
return false;
}
else
{
Log.AsyncC("failed to harvest crop. =/");
}
}
}
@ -335,9 +366,22 @@ namespace AdditionalCropsFramework
public void plantRegularCrop()
{
if (this.crop != null) return;
this.normalCropSeedName = Game1.player.ActiveObject.name;
this.normalCropSeedIndex = Game1.player.ActiveObject.parentSheetIndex;
this.crop = new Crop(Game1.player.ActiveObject.parentSheetIndex, (int)Game1.currentCursorTile.X, (int)Game1.currentCursorTile.Y);
this.normalCropSeedName = Game1.player.CurrentItem.Name;
this.normalCropSeedIndex = Game1.player.CurrentItem.parentSheetIndex;
try
{
this.crop = new Crop(Game1.player.CurrentItem.parentSheetIndex, (int)Game1.currentCursorTile.X, (int)Game1.currentCursorTile.Y);
}
catch(Exception e)
{
Log.AsyncM(e);
}
foreach (var v in this.crop.phaseDays)
{
Log.AsyncC("I grow! " + v);
}
Game1.player.reduceActiveItemByOne();
Game1.playSound("dirtyHit");
}
@ -355,36 +399,7 @@ namespace AdditionalCropsFramework
return false;
}
}
if (this.crop != null)
{
if (this.crop.fullyGrown == true)
{
//this.crop.harvest();
}
}
if (this.modularCrop != null)
{
Log.AsyncM("HELLO MOD CROP");
if (this.modularCrop.isFullyGrown() == true)
{
Log.AsyncM("FULL BLOW");
bool f = Utilities.harvestModularCrop(this.modularCrop, (int)this.tileLocation.X, (int)this.tileLocation.Y, 0);
if (f == true)
{
//this.modularCrop = null;
Log.AsyncO("HARVEST");
return false;
}
else
{
Log.AsyncC("failed to harvest crop. =/");
}
}
}
else
{
Log.AsyncR("WTF???");
}
@ -964,7 +979,7 @@ namespace AdditionalCropsFramework
d.locationsName = obj.locationsName;
d.drawColor = obj.drawColor;
d.normalCropSeedIndex = obj.normalCropSeedIndex;
d.cropInformationString = obj.cropInformationString;
d.IsSolid = obj.IsSolid;
@ -1019,11 +1034,50 @@ namespace AdditionalCropsFramework
}
if (cropInfo[0] == "false") //non-modular crop
{
Crop c = new Crop(Convert.ToInt32(cropInfo[1]), Convert.ToInt32(cropInfo[2]), Convert.ToInt32(cropInfo[3]));
Crop c = new Crop(Convert.ToInt32(d.normalCropSeedIndex), Convert.ToInt32(cropInfo[2]), Convert.ToInt32(cropInfo[3]));
Dictionary<int, string> dictionary = Game1.content.Load<Dictionary<int, string>>("Data\\Crops");
if (dictionary.ContainsKey(Convert.ToInt32(cropInfo[1])))
{
string[] strArray1 = dictionary[Convert.ToInt32(cropInfo[1])].Split('/');
string str1 = strArray1[0];
char[] chArray1 = new char[1] { ' ' };
c.phaseDays = new List<int>();
foreach (string str2 in str1.Split(chArray1))
{
c.phaseDays.Add(Convert.ToInt32(str2));
}
c.phaseDays.Add(99999);
}
else
{
Log.AsyncR("AOSIDHA(IUDGUDIUBGDLIUGDOIHDO:IHDOIHDIOHDIOP");
}
c.currentPhase = Convert.ToInt32(cropInfo[4]);
c.dayOfCurrentPhase = Convert.ToInt32(cropInfo[5]);
try
{
c.fullyGrown = Convert.ToBoolean(cropInfo[10]);
}
catch (Exception e)
{
}
Log.AsyncM("PARSED Regular CROP!");
Log.AsyncG(cropInfo[1]);
Log.AsyncG(cropInfo[2]);
Log.AsyncG(cropInfo[3]);
Log.AsyncR(c.phaseDays.Count);
Log.AsyncM("PARSED REGULAR CROP! FINISH");
foreach(var v in c.phaseDays)
{
Log.AsyncG("THIS IS THE FINAL COUNT DOWN " + v);
}
d.crop = c;
// Log.AsyncM("PARSED REGULAR CROP!");
}
}
catch (Exception err)

View File

@ -20,8 +20,6 @@ namespace StardustCore
public class CoreObject : StardewValley.Object
{
public new int price;
public int Decoration_type;
public int rotations;
@ -1293,7 +1291,7 @@ namespace StardustCore
public override int maximumStackSize()
{
return 1;
return 999;
}
public override int getStack()
@ -1301,10 +1299,6 @@ namespace StardustCore
return this.stack;
}
public override int addToStack(int amount)
{
return 1;
}
private float getScaleSize()
{
@ -1355,6 +1349,13 @@ namespace StardustCore
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber)
{
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(TextureSheet, location + new Vector2((float)(Game1.tileSize), (float)(Game1.tileSize)), new Rectangle?(this.defaultSourceRect), Color.White * transparency, 0f, new Vector2((float)(this.defaultSourceRect.Width / 2), (float)(this.defaultSourceRect.Height)), 1f * this.getScaleSize() * scaleSize * .5f, SpriteEffects.None, layerDepth);
}