public override bool clicked(StardewValley.Farmer who) { Console.Write("Clicked"); Game1.haltAfterCheck = false; if (furniture_type.Value == 11 && who.ActiveObject != null && (who.ActiveObject != null && this.heldObject.Value == null)) { return(false); } if (this.heldObject.Value == null && (who.ActiveObject == null || !(who.ActiveObject is Furniture))) { if (who.addItemToInventoryBool((Item)this.Revert(), false)) { Game1.playSound("coin"); return(true); } return(true); } if (this.heldObject.Value != null) { StardewValley.Object @object = this.heldObject.Value; this.heldObject.Value = (StardewValley.Object)null; if (who.addItemToInventoryBool((Item)this.Revert(), false)) { @object.performRemoveAction(TileLocation, who.currentLocation); Game1.playSound("coin"); return(true); } this.heldObject.Value = @object; } return(false); }
public virtual bool collect(Farmer farmer, Chunk chunk = null) { if (chunk == null) { if (chunks.Count <= 0) { return(false); } chunk = chunks[0]; } int switcher = ((DebrisType)debrisType == DebrisType.ARCHAEOLOGY || (DebrisType)debrisType == DebrisType.OBJECT) ? chunk.debrisType : (chunk.debrisType - chunk.debrisType % 2); if ((DebrisType)debrisType == DebrisType.ARCHAEOLOGY) { Game1.farmerFindsArtifact(chunk.debrisType); } else if (item != null) { Item tmpItem = item; item = null; if (!farmer.addItemToInventoryBool(tmpItem)) { item = tmpItem; return(false); } } else if ((DebrisType)debrisType != 0 || switcher != 8) { if (switcher <= -10000) { if (!farmer.addItemToInventoryBool(new MeleeWeapon(switcher))) { return(false); } } else if (switcher <= 0) { if (!farmer.addItemToInventoryBool(new Object(Vector2.Zero, -switcher))) { return(false); } } else if (!farmer.addItemToInventoryBool((switcher == 93 || switcher == 94) ? new Torch(Vector2.Zero, 1, switcher) : new Object(Vector2.Zero, switcher, 1) { Quality = itemQuality })) { return(false); } } return(true); }
public bool deliverProduce(StardewValley.Farmer who) { if (lastDropIn != null) { (this.heldObject as StardewValley.Object).price += (lastDropIn.price * requiredStack) / (this.heldObject as StardewValley.Object).Stack; } if (who.IsMainPlayer && !who.addItemToInventoryBool((Item)this.heldObject, false)) { Game1.showRedMessage("Inventory Full"); return(false); } this.readyForHarvest = false; this.lastDropIn = null; this.heldObject = null; this.isSpecial = false; if (this.materials.Count == 0) { this.startWorking(); } Game1.playSound("coin"); return(true); }
public override bool clicked(StardewValley.Farmer who) { if (removable == false) { return(false); } // Game1.showRedMessage("THIS IS CLICKED!!!"); Game1.haltAfterCheck = false; if (this.Decoration_type == 11 && who.ActiveObject != null && who.ActiveObject != null && this.heldObject == null) { // Game1.showRedMessage("Why1?"); return(false); } if (this.heldObject == null && (who.ActiveObject == null || !(who.ActiveObject is ModularDecoration))) { if (Game1.player.currentLocation is FarmHouse) { // Game1.showRedMessage("Why2?"); // this.heldObject = new Decoration(parentSheetIndex, Vector2.Zero); Util.addItemToInventoryAndCleanTrackedList(this); this.flaggedForPickUp = true; this.thisLocation = null; return(true); } else { // return true; this.flaggedForPickUp = true; if (this is TV) { this.heldObject = new TV(parentSheetIndex, Vector2.Zero); } else { // this.heldObject = new Decoration(parentSheetIndex, Vector2.Zero); Util.addItemToInventoryAndCleanTrackedList(this); // this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); // this.heldObject = null; Game1.playSound("coin"); this.thisLocation = null; return(true); } } } if (this.heldObject != null && who.addItemToInventoryBool(this.heldObject, false)) { // Game1.showRedMessage("Why3?"); this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); this.heldObject = null; Util.addItemToInventoryAndCleanTrackedList(this); Game1.playSound("coin"); this.thisLocation = null; return(true); } return(false); }
public override bool checkForAction(StardewValley.Farmer who, bool justCheckingForActivity = false) { if (!justCheckingForActivity && who != null && who.currentLocation.isObjectAt(who.getTileX(), who.getTileY() - 1) && who.currentLocation.isObjectAt(who.getTileX(), who.getTileY() + 1) && who.currentLocation.isObjectAt(who.getTileX() + 1, who.getTileY()) && who.currentLocation.isObjectAt(who.getTileX() - 1, who.getTileY())) { this.performToolAction(null); } if (justCheckingForActivity) { return(true); } else { //perform a basic pickup if (who.IsMainPlayer && who.addItemToInventoryBool(this, true)) { who.currentLocation.objects.Remove(this.tileLocation); Game1.playSound("coin"); tileLocation = Vector2.Zero; return(true); } else { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588", new object[0])); return(false); } } }
//DONT USE THIS BASE IT IS TERRIBLE public override bool clicked(StardewValley.Farmer who) { // Game1.showRedMessage("THIS IS CLICKED!!!"); //var mState = Microsoft.Xna.Framework.Input.Mouse.GetState(); if (removable == false) { return(false); } Game1.haltAfterCheck = false; if (this.Decoration_type == 11 && who.ActiveObject != null && who.ActiveObject != null && this.heldObject == null) { // Game1.showRedMessage("Why1?"); return(false); } if (this.heldObject == null && (who.ActiveObject == null || !(who.ActiveObject is Light))) { if (Game1.player.currentLocation is FarmHouse) { // Util.addItemToInventoryAndCleanTrackedList(this); removeLights(this.thisLocation); this.lightsOn = false; Game1.playSound("coin"); // this.flaggedForPickUp = true; thisLocation = null; return(true); } else { // return true; // this.heldObject = new Light(parentSheetIndex, Vector2.Zero, this.lightColor, this.inventoryMaxSize); Util.addItemToInventoryAndCleanTrackedList(this); removeLights(this.thisLocation); this.lightsOn = false; Game1.playSound("coin"); thisLocation = null; return(true); } } if (this.heldObject != null && who.addItemToInventoryBool(this.heldObject, false)) { // Game1.showRedMessage("Why3?"); // if(this.heldObject!=null) Game1.player.addItemByMenuIfNecessary((Item)this.heldObject); Util.addItemToInventoryAndCleanTrackedList(this); this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); this.heldObject = null; Game1.playSound("coin"); removeLights(this.thisLocation); this.lightsOn = false; thisLocation = null; return(true); } return(false); }
public override bool clicked(StardewValley.Farmer who) { Game1.haltAfterCheck = false; if (this.furniture_type == 11 && who.ActiveObject != null && (who.ActiveObject != null && this.heldObject == null)) { return(false); } if (this.heldObject == null && (who.ActiveObject == null || !(who.ActiveObject is Furniture))) { return(who.addItemToInventoryBool(this.Revert())); } if (this.heldObject == null || !who.addItemToInventoryBool(this.heldObject)) { return(false); } this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); this.heldObject = null; Game1.playSound("coin"); return(true); }
/// <summary>Add an item to the player inventory from the container.</summary> /// <param name="item">The item taken.</param> /// <param name="player">The player taking the item.</param> private void GrabItemFromContainerImpl(Item item, SFarmer player) { if (!player.addItemToInventoryBool(item)) { return; } this.ShippingBin.Remove(item); if (item == this.Farm.lastItemShipped) { this.Farm.lastItemShipped = this.Farm.shippingBin.LastOrDefault(); } }
//DONT USE THIS BASE IT IS TERRIBLE public override bool clicked(StardewValley.Farmer who) { if (removable == false) { return(false); } Game1.haltAfterCheck = false; if (this.Decoration_type == 11 && who.ActiveObject != null && who.ActiveObject != null && this.heldObject == null) { return(false); } if (this.heldObject == null && (who.ActiveObject == null || !(who.ActiveObject is Spell))) { if (Game1.player.currentLocation is FarmHouse) { Util.addItemToInventoryAndCleanTrackedList(this); removeLights(this.thisLocation); this.lightsOn = false; Game1.playSound("coin"); // this.flaggedForPickUp = true; thisLocation = null; return(true); } else { Util.addItemToInventoryAndCleanTrackedList(this); removeLights(this.thisLocation); this.lightsOn = false; Game1.playSound("coin"); thisLocation = null; return(true); } } if (this.heldObject != null && who.addItemToInventoryBool(this.heldObject, false)) { Util.addItemToInventoryAndCleanTrackedList(this); this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); this.heldObject = null; Game1.playSound("coin"); removeLights(this.thisLocation); this.lightsOn = false; thisLocation = null; return(true); } return(false); }
public override bool clicked(StardewValley.Farmer who) { int range = 2; if (StardustCore.Utilities.isWithinRange(range, this.tileLocation) == false) { return(false); } if (StardustCore.Utilities.isWithinDirectionRange(Game1.player.FacingDirection, range, this.tileLocation)) { if (Game1.player.CurrentItem != null) { if (Game1.player.getToolFromName(Game1.player.CurrentItem.Name) is StardewValley.Tools.WateringCan) { //this.animationManager.setAnimation("Watered", 0); //TileExceptionMetaData t = new TileExceptionMetaData(this, "Water"); bool foundRemoval = false; foreach (var exc in Utilities.tileExceptionList) { if (exc.tile == this && exc.actionType == "Water") { this.thisLocation.objects.Remove(this.tileLocation); foundRemoval = true; StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(this); } } if (foundRemoval == true) { PathFindingCore.Utilities.cleanExceptionList(this); } return(false); } } if (Game1.player.CurrentItem != null) { if (Game1.player.CurrentItem is StardewValley.Tools.MeleeWeapon || Game1.player.CurrentItem is StardewValley.Tools.Sword) { } } } if (removable == false) { return(false); } // Game1.showRedMessage("THIS IS CLICKED!!!"); Game1.haltAfterCheck = false; if (this.Decoration_type == 11 && who.ActiveObject != null && who.ActiveObject != null && this.heldObject == null) { // Game1.showRedMessage("Why1?"); return(false); } if (this.heldObject == null && (who.ActiveObject == null || !(who.ActiveObject is TileNode))) { if (Game1.player.currentLocation is FarmHouse) { // Game1.showRedMessage("Why2?"); // this.heldObject = new TileNode(parentSheetIndex, Vector2.Zero); StardustCore.Utilities.addItemToInventoryAndCleanTrackedList(this, StardustCore.ModCore.SerializationManager); this.flaggedForPickUp = true; this.thisLocation = null; this.locationsName = ""; return(true); } else { // return true; this.flaggedForPickUp = true; if (this is TV) { this.heldObject = new TV(parentSheetIndex, Vector2.Zero); } else { // this.heldObject = new TileNode(parentSheetIndex, Vector2.Zero); StardustCore.Utilities.addItemToInventoryAndCleanTrackedList(this, StardustCore.ModCore.SerializationManager); // this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); // this.heldObject = null; Game1.playSound("coin"); this.thisLocation = null; this.locationsName = ""; return(true); } } } if (this.heldObject != null && who.addItemToInventoryBool(this.heldObject, false)) { // Game1.showRedMessage("Why3?"); this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); this.heldObject = null; StardustCore.Utilities.addItemToInventoryAndCleanTrackedList(this, StardustCore.ModCore.SerializationManager); Game1.playSound("coin"); this.thisLocation = null; this.locationsName = ""; return(true); } return(false); }
public bool harvest(int xTile, int yTile, HoeDirt soil, JunimoHarvester junimoHarvester = null) { if (this.dead) { return(junimoHarvester != null); } if (this.forageCrop) { Object @object = null; int howMuch = 3; int fertilizer = this.whichForageCrop; if (fertilizer == 1) { @object = new Object(399, 1, false, -1, 0); } if (Game1.player.professions.Contains(16)) { @object.quality = 4; } else if (Game1.random.NextDouble() < (double)((float)Game1.player.ForagingLevel / 30f)) { @object.quality = 2; } else if (Game1.random.NextDouble() < (double)((float)Game1.player.ForagingLevel / 15f)) { @object.quality = 1; } Game1.stats.ItemsForaged += (uint)@object.Stack; if (junimoHarvester != null) { junimoHarvester.tryToAddItemToHut(@object); return(true); } if (Game1.player.addItemToInventoryBool(@object, false)) { Vector2 vector = 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 (this.regrowAfterHarvest == -1) { Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(17, new Vector2(vector.X * (float)Game1.tileSize, vector.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(vector.X * (float)Game1.tileSize, vector.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); } Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588", new object[0])); } else if (this.currentPhase >= this.phaseDays.Count - 1 && (!this.fullyGrown || this.dayOfCurrentPhase <= 0)) { int num = 1; int num2 = 0; int num3 = 0; if (this.indexOfHarvest == 0) { return(true); } Random random = new Random(xTile * 7 + yTile * 11 + (int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame); int fertilizer = soil.fertilizer; if (fertilizer != 368) { if (fertilizer == 369) { num3 = 2; } } else { num3 = 1; } double num4 = 0.2 * ((double)Game1.player.FarmingLevel / 10.0) + 0.2 * (double)num3 * (((double)Game1.player.FarmingLevel + 2.0) / 12.0) + 0.01; double num5 = Math.Min(0.75, num4 * 2.0); if (random.NextDouble() < num4) { num2 = 2; } else if (random.NextDouble() < num5) { num2 = 1; } if (this.minHarvest > 1 || this.maxHarvest > 1) { num = random.Next(this.minHarvest, Math.Min(this.minHarvest + 1, this.maxHarvest + 1 + Game1.player.FarmingLevel / this.maxHarvestIncreasePerFarmingLevel)); } if (this.chanceForExtraCrops > 0.0) { while (random.NextDouble() < Math.Min(0.9, this.chanceForExtraCrops)) { num++; } } if (this.harvestMethod == 1) { if (junimoHarvester == null) { DelayedAction.playSoundAfterDelay("daggerswipe", 150); } if (junimoHarvester != null && Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { Game1.playSound("harvest"); } if (junimoHarvester != null && Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { DelayedAction.playSoundAfterDelay("coin", 260); } for (int i = 0; i < num; i++) { if (junimoHarvester != null) { junimoHarvester.tryToAddItemToHut(new Object(this.indexOfHarvest, 1, false, -1, num2)); } else { Game1.createObjectDebris(this.indexOfHarvest, xTile, yTile, -1, num2, 1f, null); } } if (this.regrowAfterHarvest == -1) { return(true); } this.dayOfCurrentPhase = this.regrowAfterHarvest; this.fullyGrown = true; } else { if (junimoHarvester == null) { Farmer arg_4C0_0 = Game1.player; Object arg_4C0_1; if (!this.programColored) { arg_4C0_1 = new Object(this.indexOfHarvest, 1, false, -1, num2); } else { (arg_4C0_1 = new ColoredObject(this.indexOfHarvest, 1, this.tintColor)).quality = num2; } if (!arg_4C0_0.addItemToInventoryBool(arg_4C0_1, false)) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588", new object[0])); return(false); } } Vector2 vector2 = new Vector2((float)xTile, (float)yTile); if (junimoHarvester == null) { Game1.player.animateOnce(279 + Game1.player.facingDirection); Game1.player.canMove = false; } else { Object arg_536_1; if (!this.programColored) { arg_536_1 = new Object(this.indexOfHarvest, 1, false, -1, num2); } else { (arg_536_1 = new ColoredObject(this.indexOfHarvest, 1, this.tintColor)).quality = num2; } junimoHarvester.tryToAddItemToHut(arg_536_1); } if (random.NextDouble() < (double)((float)Game1.player.LuckLevel / 1500f) + Game1.dailyLuck / 1200.0 + 9.9999997473787516E-05) { num *= 2; if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { Game1.playSound("dwoop"); } } else if (this.harvestMethod == 0) { if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { Game1.playSound("harvest"); } if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { DelayedAction.playSoundAfterDelay("coin", 260); } if (this.regrowAfterHarvest == -1 && (junimoHarvester == null || junimoHarvester.currentLocation.Equals(Game1.currentLocation))) { 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)); } } if (this.indexOfHarvest == 421) { this.indexOfHarvest = 431; num = random.Next(1, 4); } for (int j = 0; j < num - 1; j++) { if (junimoHarvester == null) { Game1.createObjectDebris(this.indexOfHarvest, xTile, yTile, -1, 0, 1f, null); } else { junimoHarvester.tryToAddItemToHut(new Object(this.indexOfHarvest, 1, false, -1, 0)); } } int num6 = Convert.ToInt32(Game1.objectInformation[this.indexOfHarvest].Split(new char[] { '/' })[1]); float num7 = (float)(16.0 * Math.Log(0.018 * (double)num6 + 1.0, 2.7182818284590451)); if (junimoHarvester == null) { Game1.player.gainExperience(0, (int)Math.Round((double)num7)); } if (this.regrowAfterHarvest == -1) { return(true); } this.dayOfCurrentPhase = this.regrowAfterHarvest; this.fullyGrown = true; } } return(false); }
public bool updateChunks(GameTime time) { this.timeSinceDoneBouncing = this.timeSinceDoneBouncing + (float)time.ElapsedGameTime.Milliseconds; if ((double)this.timeSinceDoneBouncing >= (this.floppingFish ? 2500.0 : (this.debrisType == Debris.DebrisType.SPRITECHUNKS || this.debrisType == Debris.DebrisType.NUMBERS ? 1800.0 : 600.0))) { if (this.debrisType == Debris.DebrisType.LETTERS || this.debrisType == Debris.DebrisType.NUMBERS || (this.debrisType == Debris.DebrisType.SQUARES || this.debrisType == Debris.DebrisType.SPRITECHUNKS) || this.debrisType == Debris.DebrisType.CHUNKS && this.chunks[0].debrisType - this.chunks[0].debrisType % 2 != 8) { return(true); } if (this.debrisType == Debris.DebrisType.ARCHAEOLOGY || this.debrisType == Debris.DebrisType.OBJECT || (this.debrisType == Debris.DebrisType.RESOURCE || this.debrisType == Debris.DebrisType.CHUNKS)) { this.chunksMoveTowardPlayer = true; } this.timeSinceDoneBouncing = 0.0f; } for (int index = this.chunks.Count - 1; index >= 0; --index) { if ((double)this.chunks[index].alpha > 0.100000001490116 && (this.debrisType == Debris.DebrisType.SPRITECHUNKS || this.debrisType == Debris.DebrisType.NUMBERS) && (double)this.timeSinceDoneBouncing > 600.0) { this.chunks[index].alpha = (float)((1800.0 - (double)this.timeSinceDoneBouncing) / 1000.0); } if ((double)this.chunks[index].position.X < (double)(-Game1.tileSize * 2) || (double)this.chunks[index].position.Y < (double)-Game1.tileSize || ((double)this.chunks[index].position.X >= (double)(Game1.currentLocation.map.DisplayWidth + Game1.tileSize) || (double)this.chunks[index].position.Y >= (double)(Game1.currentLocation.map.DisplayHeight + Game1.tileSize))) { this.chunks.RemoveAt(index); } else { bool flag1 = (double)Math.Abs(this.chunks[index].position.X + (float)(Game1.tileSize / 2) - (float)Game1.player.getStandingX()) <= (double)Game1.player.MagneticRadius && (double)Math.Abs(this.chunks[index].position.Y + (float)(Game1.tileSize / 2) - (float)Game1.player.getStandingY()) <= (double)Game1.player.MagneticRadius; if (flag1) { switch (this.debrisType) { case Debris.DebrisType.ARCHAEOLOGY: case Debris.DebrisType.OBJECT: if (this.item != null) { flag1 = Game1.player.couldInventoryAcceptThisItem(this.item); break; } flag1 = Game1.player.couldInventoryAcceptThisObject(this.chunks[index].debrisType, 1, this.itemQuality); if (this.chunks[index].debrisType == 102 && Game1.activeClickableMenu != null) { flag1 = false; break; } break; case Debris.DebrisType.RESOURCE: flag1 = Game1.player.couldInventoryAcceptThisObject(this.chunks[index].debrisType - this.chunks[index].debrisType % 2, 1, 0); break; default: flag1 = true; break; } } if (((this.chunksMoveTowardPlayer ? 1 : (this.isFishable ? 1 : 0)) & (flag1 ? 1 : 0)) != 0) { if ((double)this.chunks[index].position.X < (double)Game1.player.position.X - 12.0) { this.chunks[index].xVelocity = Math.Min(this.chunks[index].xVelocity + 0.8f, 8f); } else if ((double)this.chunks[index].position.X > (double)Game1.player.position.X + 12.0) { this.chunks[index].xVelocity = Math.Max(this.chunks[index].xVelocity - 0.8f, -8f); } if ((double)this.chunks[index].position.Y + (double)(Game1.tileSize / 2) < (double)(Game1.player.getStandingY() - 12)) { this.chunks[index].yVelocity = Math.Max(this.chunks[index].yVelocity - 0.8f, -8f); } else if ((double)this.chunks[index].position.Y + (double)(Game1.tileSize / 2) > (double)(Game1.player.getStandingY() + 12)) { this.chunks[index].yVelocity = Math.Min(this.chunks[index].yVelocity + 0.8f, 8f); } this.chunks[index].position.X += this.chunks[index].xVelocity; this.chunks[index].position.Y -= this.chunks[index].yVelocity; if ((double)Math.Abs(this.chunks[index].position.X + (float)(Game1.tileSize / 2) - (float)Game1.player.getStandingX()) <= 64.0 && (double)Math.Abs(this.chunks[index].position.Y + (float)(Game1.tileSize / 2) - (float)Game1.player.getStandingY()) <= 64.0) { int num1 = this.debrisType == Debris.DebrisType.ARCHAEOLOGY || this.debrisType == Debris.DebrisType.OBJECT ? this.chunks[index].debrisType : this.chunks[index].debrisType - this.chunks[index].debrisType % 2; if (this.debrisType == Debris.DebrisType.ARCHAEOLOGY) { Game1.farmerFindsArtifact(this.chunks[index].debrisType); } else if (this.item != null) { if (!Game1.player.addItemToInventoryBool(this.item, false)) { continue; } } else if (this.debrisType != Debris.DebrisType.CHUNKS || num1 != 8) { if (num1 <= -10000) { if (!Game1.player.addItemToInventoryBool((Item) new MeleeWeapon(num1), false)) { continue; } } else if (num1 <= 0) { if (!Game1.player.addItemToInventoryBool((Item) new Object(Vector2.Zero, -num1, false), false)) { continue; } } else { Farmer player = Game1.player; Object @object; if (num1 != 93 && num1 != 94) { @object = new Object(Vector2.Zero, num1, 1) { quality = this.itemQuality } } ; else { @object = (Object) new Torch(Vector2.Zero, 1, num1); } int num2 = 0; if (!player.addItemToInventoryBool((Item)@object, num2 != 0)) { continue; } } } if ((double)Game1.debrisSoundInterval <= 0.0) { Game1.debrisSoundInterval = 10f; Game1.playSound("coin"); } if (Game1.IsMultiplayer) { MultiplayerUtility.broadcastDebrisPickup(this.uniqueID, Game1.currentLocation.name, Game1.player.uniqueMultiplayerID); } this.chunks.RemoveAt(index); } } else { if (this.debrisType == Debris.DebrisType.NUMBERS && this.toHover != null) { this.relativeXPosition = this.relativeXPosition + this.chunks[index].xVelocity; this.chunks[index].position.X = this.toHover.position.X + (float)(Game1.tileSize / 2) + this.relativeXPosition; this.chunks[index].scale = Math.Min(2f, Math.Max(1f, (float)(0.899999976158142 + (double)Math.Abs(this.chunks[index].position.Y - (float)this.chunkFinalYLevel) / ((double)Game1.tileSize * 2.0)))); this.chunkFinalYLevel = this.toHover.getStandingY() + 8; if ((double)this.timeSinceDoneBouncing > 250.0) { this.chunks[index].alpha = Math.Max(0.0f, this.chunks[index].alpha - 0.033f); } if (!this.toHover.Equals((object)Game1.player) && !this.nonSpriteChunkColor.Equals(Color.Yellow) && !this.nonSpriteChunkColor.Equals(Color.Green)) { this.nonSpriteChunkColor.R = (byte)Math.Max((double)Math.Min((int)byte.MaxValue, 200 + this.chunkType), Math.Min((double)Math.Min((int)byte.MaxValue, 220 + this.chunkType), 400.0 * Math.Sin((double)this.timeSinceDoneBouncing / (256.0 * Math.PI) + Math.PI / 12.0))); this.nonSpriteChunkColor.G = (byte)Math.Max((double)(150 - this.chunkType), Math.Min((double)((int)byte.MaxValue - this.chunkType), (int)this.nonSpriteChunkColor.R > 220 ? 300.0 * Math.Sin((double)this.timeSinceDoneBouncing / (256.0 * Math.PI) + Math.PI / 12.0) : 0.0)); this.nonSpriteChunkColor.B = (byte)Math.Max(0, Math.Min((int)byte.MaxValue, (int)this.nonSpriteChunkColor.G > 200 ? (int)this.nonSpriteChunkColor.G - 20 : 0)); } } this.chunks[index].position.X += this.chunks[index].xVelocity; this.chunks[index].position.Y -= this.chunks[index].yVelocity; if (this.movingFinalYLevel) { this.chunkFinalYLevel = this.chunkFinalYLevel - (int)Math.Ceiling((double)this.chunks[index].yVelocity / 2.0); if (this.chunkFinalYLevel <= this.chunkFinalYTarget) { this.chunkFinalYLevel = this.chunkFinalYTarget; this.movingFinalYLevel = false; } } if (this.debrisType == Debris.DebrisType.SQUARES && (double)this.chunks[index].position.Y < (double)(this.chunkFinalYLevel - Game1.tileSize * 3 / 2) && Game1.random.NextDouble() < 0.1) { this.chunks[index].position.Y = (float)(this.chunkFinalYLevel - Game1.random.Next(1, Game1.tileSize / 3)); this.chunks[index].yVelocity = (float)Game1.random.Next(30, 80) / 40f; this.chunks[index].position.X = (float)Game1.random.Next((int)((double)this.chunks[index].position.X - (double)this.chunks[index].position.X % (double)Game1.tileSize + 1.0), (int)((double)this.chunks[index].position.X - (double)this.chunks[index].position.X % (double)Game1.tileSize + 64.0)); } if (this.debrisType != Debris.DebrisType.SQUARES) { this.chunks[index].yVelocity -= 0.4f; } bool flag2 = false; if ((double)this.chunks[index].position.Y >= (double)this.chunkFinalYLevel && this.chunks[index].hasPassedRestingLineOnce && this.chunks[index].bounces <= (this.floppingFish ? 65 : 2)) { if (this.debrisType != Debris.DebrisType.LETTERS && this.debrisType != Debris.DebrisType.NUMBERS && this.debrisType != Debris.DebrisType.SPRITECHUNKS && (this.debrisType != Debris.DebrisType.CHUNKS || this.chunks[index].debrisType - this.chunks[index].debrisType % 2 == 8)) { Game1.playSound("shiny4"); } ++this.chunks[index].bounces; if (this.floppingFish) { this.chunks[index].yVelocity = Math.Abs(this.chunks[index].yVelocity) * (!this.movingUp || this.chunks[index].bounces >= 2 ? 0.9f : 0.6f); this.chunks[index].xVelocity = (float)Game1.random.Next(-250, 250) / 100f; } else { this.chunks[index].yVelocity = Math.Abs((float)((double)this.chunks[index].yVelocity * 2.0 / 3.0)); this.chunks[index].rotationVelocity = Game1.random.NextDouble() < 0.5 ? this.chunks[index].rotationVelocity / 2f : (float)(-(double)this.chunks[index].rotationVelocity * 2.0 / 3.0); this.chunks[index].xVelocity -= this.chunks[index].xVelocity / 2f; } if (this.debrisType != Debris.DebrisType.LETTERS && this.debrisType != Debris.DebrisType.SPRITECHUNKS && (this.debrisType != Debris.DebrisType.NUMBERS && Game1.currentLocation.doesTileHaveProperty((int)(((double)this.chunks[index].position.X + (double)(Game1.tileSize / 2)) / (double)Game1.tileSize), (int)(((double)this.chunks[index].position.Y + (double)(Game1.tileSize / 2)) / (double)Game1.tileSize), "Water", "Back") != null)) { Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(28, 300f, 2, 1, this.chunks[index].position, false, false)); Game1.playSound("dropItemInWater"); flag2 = true; } } if (!this.chunks[index].hitWall && Game1.currentLocation.Map.GetLayer("Buildings").Tiles[(int)(((double)this.chunks[index].position.X + (double)(Game1.tileSize / 2)) / (double)Game1.tileSize), (int)(((double)this.chunks[index].position.Y + (double)(Game1.tileSize / 2)) / (double)Game1.tileSize)] != null || Game1.currentLocation.Map.GetLayer("Back").Tiles[(int)(((double)this.chunks[index].position.X + (double)(Game1.tileSize / 2)) / (double)Game1.tileSize), (int)(((double)this.chunks[index].position.Y + (double)(Game1.tileSize / 2)) / (double)Game1.tileSize)] == null) { this.chunks[index].xVelocity = -this.chunks[index].xVelocity; this.chunks[index].hitWall = true; } if ((double)this.chunks[index].position.Y < (double)this.chunkFinalYLevel) { this.chunks[index].hasPassedRestingLineOnce = true; } if (this.chunks[index].bounces > (this.floppingFish ? 65 : 2)) { this.chunks[index].yVelocity = 0.0f; this.chunks[index].xVelocity = 0.0f; this.chunks[index].rotationVelocity = 0.0f; } this.chunks[index].rotation += this.chunks[index].rotationVelocity; if (flag2) { this.chunks.RemoveAt(index); } } } } return(this.chunks.Count == 0); }
public override bool checkForAction(StardewValley.Farmer who, bool justCheckingForActivity = false) { if (justCheckingForActivity || who == null) { return(true); } if ((who.currentLocation.isObjectAt(who.getTileX(), who.getTileY() - 1) && who.currentLocation.isObjectAt(who.getTileX(), who.getTileY() + 1)) && (who.currentLocation.isObjectAt(who.getTileX() + 1, who.getTileY()) && who.currentLocation.isObjectAt(who.getTileX() - 1, who.getTileY()))) { this.performToolAction((Tool)null, who.currentLocation); } if (this.name.Contains("Hopper") && who.ActiveObject == null) { if (who.freeSpotsInInventory() > 0) { int piecesOfHay = Game1.getFarm().piecesOfHay.Value; if (piecesOfHay > 0) { if (Game1.currentLocation is AnimalHouse animalHouse) { int val1 = Math.Max(1, Math.Min(animalHouse.animalsThatLiveHere.Count, piecesOfHay)); int num1 = animalHouse.numberOfObjectsWithName("Hay"); int num2 = Math.Min(val1, animalHouse.animalLimit.Value - num1); //##CHANGES if (num2 == 0) { num2 = 1; } if (Game1.player.couldInventoryAcceptThisObject(178, num2, 0)) { Game1.getFarm().piecesOfHay.Value -= Math.Max(1, num2); who.addItemToInventoryBool((Item) new SObject(178, num2, false, -1, 0), false); Game1.playSound("shwip"); if (Game1.getFarm().piecesOfHay.Value <= 0) { this.showNextIndex.Value = false; } return(true); } } else if (Game1.player.couldInventoryAcceptThisObject(178, 1, 0)) { --Game1.getFarm().piecesOfHay.Value; who.addItemToInventoryBool((Item) new SObject(178, 1, false, -1, 0), false); Game1.playSound("shwip"); } if (Game1.getFarm().piecesOfHay.Value <= 0) { this.showNextIndex.Value = false; } } else { Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:Object.cs.12942")); } } else { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588")); } } return(false); }
public override bool checkAction(Location tileLocation, xTile.Dimensions.Rectangle viewport, StardewValley.Farmer who) { Vector2 vector = new Vector2((float)tileLocation.X, (float)tileLocation.Y); if (this.objects.ContainsKey(vector) && this.objects[vector].Type != null) { if ((this.objects[vector].Type.Equals("Crafting") || this.objects[vector].Type.Equals("interactive")) && this.objects[vector].name.Equals("Bee House")) { Object beeHive = this.objects[vector]; if (!beeHive.readyForHarvest.Value) { return(false); } beeHive.honeyType.Value = new Object.HoneyType?(Object.HoneyType.Wild); string str = "Wild"; int num6 = 0; Crop crop = this.findCloseFlower(beeHive.TileLocation); if (crop != null) { str = Game1.objectInformation[crop.indexOfHarvest.Value].Split(new char[] { '/' })[0]; int indexOfHarvest = crop.indexOfHarvest.Value; if (indexOfHarvest != 376) { switch (indexOfHarvest) { case 591: beeHive.honeyType.Value = new Object.HoneyType?(Object.HoneyType.Tulip); break; case 593: beeHive.honeyType.Value = new Object.HoneyType?(Object.HoneyType.SummerSpangle); break; case 595: beeHive.honeyType.Value = new Object.HoneyType?(Object.HoneyType.FairyRose); break; case 597: beeHive.honeyType.Value = new Object.HoneyType?(Object.HoneyType.BlueJazz); break; } } else { beeHive.honeyType.Value = new Object.HoneyType?(Object.HoneyType.Poppy); } num6 = Convert.ToInt32(Game1.objectInformation[crop.indexOfHarvest.Value].Split(new char[] { '/' })[1]) * 2; } if (beeHive.heldObject.Value != null) { beeHive.heldObject.Value.name = str + " Honey"; string displayName = framework.helper.Reflection.GetMethod(beeHive, "loadDisplayName").Invoke <string>(); beeHive.heldObject.Value.displayName = displayName; beeHive.heldObject.Value.Price += num6; if (Game1.currentSeason.Equals("winter")) { beeHive.heldObject.Value = null; beeHive.readyForHarvest.Value = false; beeHive.showNextIndex.Value = false; return(false); } if (who.IsMainPlayer && !who.addItemToInventoryBool(beeHive.heldObject.Value, false)) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588", new object[0])); return(false); } Game1.playSound("coin"); } beeHive.readyForHarvest.Value = false; beeHive.showNextIndex.Value = false; if (!Game1.currentSeason.Equals("winter")) { beeHive.heldObject.Value = new Object(Vector2.Zero, 340, null, false, true, false, false); beeHive.MinutesUntilReady = 2400 - Game1.timeOfDay + 4320; } return(true); } } return(base.checkAction(tileLocation, viewport, who)); }
//DONT USE THIS BASE IT IS TERRIBLE public override bool clicked(StardewValley.Farmer who) { // Game1.showRedMessage("THIS IS CLICKED!!!"); Game1.haltAfterCheck = false; if (this.heldObject != null) { this.spillInventoryEverywhere(); return(false); } if (this.heldObject == null && (who.ActiveObject == null || !(who.ActiveObject is Machine))) { if (Game1.player.currentLocation is FarmHouse) { // Game1.showRedMessage("Why2?"); // this.spillInventoryEverywhere(); if (this.heldObject != null) { Util.addItemToInventoryElseDrop(this.heldObject.getOne()); } this.heldObject = new Machine(parentSheetIndex, Vector2.Zero, this.inventoryMaxSize); Util.addItemToInventoryAndCleanTrackedList(this); this.heldObject = null; this.flaggedForPickUp = true; this.thisLocation = null; return(true); } else { // return true; this.flaggedForPickUp = true; if (this is TV) { // this.heldObject = new TV(parentSheetIndex, Vector2.Zero); } else { // Util.addItemToInventoryElseDrop(this.heldObject); var obj = new Machine(parentSheetIndex, Vector2.Zero, this.inventoryMaxSize); Util.addItemToInventoryAndCleanTrackedList(this); // this.spillInventoryEverywhere(); if (this.heldObject != null) { this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); } this.heldObject = null; Game1.playSound("coin"); this.thisLocation = null; return(true); } } } if (this.heldObject != null && who.addItemToInventoryBool(this.heldObject, false)) { // Game1.showRedMessage("Why3?"); // if(this.heldObject!=null) Game1.player.addItemByMenuIfNecessary((Item)this.heldObject); // this.spillInventoryEverywhere(); var obj = new Machine(parentSheetIndex, Vector2.Zero, this.inventoryMaxSize); Util.addItemToInventoryAndCleanTrackedList(this); if (this.heldObject != null) { this.heldObject.performRemoveAction(this.tileLocation, who.currentLocation); } this.heldObject = null; Game1.playSound("coin"); this.thisLocation = null; return(true); } return(false); }
// Token: 0x0600018E RID: 398 RVA: 0x00011DF8 File Offset: 0x0000FFF8 public bool updateChunks(GameTime time) { this.timeSinceDoneBouncing += (float)time.ElapsedGameTime.Milliseconds; if (this.timeSinceDoneBouncing >= (this.floppingFish ? 2500f : ((this.debrisType == Debris.DebrisType.SPRITECHUNKS || this.debrisType == Debris.DebrisType.NUMBERS) ? 1800f : 600f))) { if (this.debrisType == Debris.DebrisType.LETTERS || this.debrisType == Debris.DebrisType.NUMBERS || this.debrisType == Debris.DebrisType.SQUARES || this.debrisType == Debris.DebrisType.SPRITECHUNKS || (this.debrisType == Debris.DebrisType.CHUNKS && this.chunks[0].debrisType - this.chunks[0].debrisType % 2 != 8)) { return(true); } if (this.debrisType == Debris.DebrisType.ARCHAEOLOGY || this.debrisType == Debris.DebrisType.OBJECT || this.debrisType == Debris.DebrisType.RESOURCE || this.debrisType == Debris.DebrisType.CHUNKS) { this.chunksMoveTowardPlayer = true; } this.timeSinceDoneBouncing = 0f; } for (int i = this.chunks.Count - 1; i >= 0; i--) { if (this.chunks[i].alpha > 0.1f && (this.debrisType == Debris.DebrisType.SPRITECHUNKS || this.debrisType == Debris.DebrisType.NUMBERS) && this.timeSinceDoneBouncing > 600f) { this.chunks[i].alpha = (1800f - this.timeSinceDoneBouncing) / 1000f; } if (this.chunks[i].position.X < (float)(-(float)Game1.tileSize * 2) || this.chunks[i].position.Y < (float)(-(float)Game1.tileSize) || this.chunks[i].position.X >= (float)(Game1.currentLocation.map.DisplayWidth + Game1.tileSize) || this.chunks[i].position.Y >= (float)(Game1.currentLocation.map.DisplayHeight + Game1.tileSize)) { this.chunks.RemoveAt(i); } else { bool canMoveTowardPlayer = Math.Abs(this.chunks[i].position.X + (float)(Game1.tileSize / 2) - (float)Game1.player.getStandingX()) <= (float)Game1.player.MagneticRadius && Math.Abs(this.chunks[i].position.Y + (float)(Game1.tileSize / 2) - (float)Game1.player.getStandingY()) <= (float)Game1.player.MagneticRadius; if (canMoveTowardPlayer) { switch (this.debrisType) { case Debris.DebrisType.ARCHAEOLOGY: case Debris.DebrisType.OBJECT: if (this.item != null) { canMoveTowardPlayer = Game1.player.couldInventoryAcceptThisItem(this.item); goto IL_338; } canMoveTowardPlayer = Game1.player.couldInventoryAcceptThisObject(this.chunks[i].debrisType, 1, this.itemQuality); if (this.chunks[i].debrisType == 102 && Game1.activeClickableMenu != null) { canMoveTowardPlayer = false; goto IL_338; } goto IL_338; case Debris.DebrisType.RESOURCE: canMoveTowardPlayer = Game1.player.couldInventoryAcceptThisObject(this.chunks[i].debrisType - this.chunks[i].debrisType % 2, 1, 0); goto IL_338; } canMoveTowardPlayer = true; } IL_338: if ((this.chunksMoveTowardPlayer || this.isFishable) & canMoveTowardPlayer) { if (this.chunks[i].position.X < Game1.player.position.X - 12f) { this.chunks[i].xVelocity = Math.Min(this.chunks[i].xVelocity + 0.8f, 8f); } else if (this.chunks[i].position.X > Game1.player.position.X + 12f) { this.chunks[i].xVelocity = Math.Max(this.chunks[i].xVelocity - 0.8f, -8f); } if (this.chunks[i].position.Y + (float)(Game1.tileSize / 2) < (float)(Game1.player.getStandingY() - 12)) { this.chunks[i].yVelocity = Math.Max(this.chunks[i].yVelocity - 0.8f, -8f); } else if (this.chunks[i].position.Y + (float)(Game1.tileSize / 2) > (float)(Game1.player.getStandingY() + 12)) { this.chunks[i].yVelocity = Math.Min(this.chunks[i].yVelocity + 0.8f, 8f); } Chunk expr_4EA_cp_0_cp_0 = this.chunks[i]; expr_4EA_cp_0_cp_0.position.X = expr_4EA_cp_0_cp_0.position.X + this.chunks[i].xVelocity; Chunk expr_515_cp_0_cp_0 = this.chunks[i]; expr_515_cp_0_cp_0.position.Y = expr_515_cp_0_cp_0.position.Y - this.chunks[i].yVelocity; if (Math.Abs(this.chunks[i].position.X + (float)(Game1.tileSize / 2) - (float)Game1.player.getStandingX()) <= 64f && Math.Abs(this.chunks[i].position.Y + (float)(Game1.tileSize / 2) - (float)Game1.player.getStandingY()) <= 64f) { int switcher = (this.debrisType == Debris.DebrisType.ARCHAEOLOGY || this.debrisType == Debris.DebrisType.OBJECT) ? this.chunks[i].debrisType : (this.chunks[i].debrisType - this.chunks[i].debrisType % 2); if (this.debrisType == Debris.DebrisType.ARCHAEOLOGY) { Game1.farmerFindsArtifact(this.chunks[i].debrisType); } else if (this.item != null) { if (!Game1.player.addItemToInventoryBool(this.item, false)) { goto IL_1077; } } else if (this.debrisType != Debris.DebrisType.CHUNKS || switcher != 8) { if (switcher <= -10000) { if (!Game1.player.addItemToInventoryBool(new MeleeWeapon(switcher), false)) { goto IL_1077; } } else if (switcher <= 0) { if (!Game1.player.addItemToInventoryBool(new Object(Vector2.Zero, -switcher, false), false)) { goto IL_1077; } } else { Farmer arg_6C2_0 = Game1.player; Object arg_6C2_1; if (switcher != 93 && switcher != 94) { (arg_6C2_1 = new Object(Vector2.Zero, switcher, 1)).quality = this.itemQuality; } else { arg_6C2_1 = new Torch(Vector2.Zero, 1, switcher); } if (!arg_6C2_0.addItemToInventoryBool(arg_6C2_1, false)) { goto IL_1077; } } } if (Game1.debrisSoundInterval <= 0f) { Game1.debrisSoundInterval = 10f; Game1.playSound("coin"); } if (Game1.IsMultiplayer) { MultiplayerUtility.broadcastDebrisPickup(this.uniqueID, Game1.currentLocation.name, Game1.player.uniqueMultiplayerID); } this.chunks.RemoveAt(i); } } else { if (this.debrisType == Debris.DebrisType.NUMBERS && this.toHover != null) { this.relativeXPosition += this.chunks[i].xVelocity; this.chunks[i].position.X = this.toHover.position.X + (float)(Game1.tileSize / 2) + this.relativeXPosition; this.chunks[i].scale = Math.Min(2f, Math.Max(1f, 0.9f + Math.Abs(this.chunks[i].position.Y - (float)this.chunkFinalYLevel) / ((float)Game1.tileSize * 2f))); this.chunkFinalYLevel = this.toHover.getStandingY() + 8; if (this.timeSinceDoneBouncing > 250f) { this.chunks[i].alpha = Math.Max(0f, this.chunks[i].alpha - 0.033f); } if (!this.toHover.Equals(Game1.player) && !this.nonSpriteChunkColor.Equals(Color.Yellow) && !this.nonSpriteChunkColor.Equals(Color.Green)) { this.nonSpriteChunkColor.R = (byte)Math.Max((double)Math.Min(255, 200 + this.chunkType), Math.Min((double)Math.Min(255, 220 + this.chunkType), 400.0 * Math.Sin((double)this.timeSinceDoneBouncing / 804.247719318987 + 0.26179938779914941))); this.nonSpriteChunkColor.G = (byte)Math.Max((double)(150 - this.chunkType), Math.Min((double)(255 - this.chunkType), (this.nonSpriteChunkColor.R > 220) ? (300.0 * Math.Sin((double)this.timeSinceDoneBouncing / 804.247719318987 + 0.26179938779914941)) : 0.0)); this.nonSpriteChunkColor.B = (byte)Math.Max(0, Math.Min(255, (int)((this.nonSpriteChunkColor.G > 200) ? (this.nonSpriteChunkColor.G - 20) : 0))); } } Chunk expr_9B4_cp_0_cp_0 = this.chunks[i]; expr_9B4_cp_0_cp_0.position.X = expr_9B4_cp_0_cp_0.position.X + this.chunks[i].xVelocity; Chunk expr_9DF_cp_0_cp_0 = this.chunks[i]; expr_9DF_cp_0_cp_0.position.Y = expr_9DF_cp_0_cp_0.position.Y - this.chunks[i].yVelocity; if (this.movingFinalYLevel) { this.chunkFinalYLevel -= (int)Math.Ceiling((double)(this.chunks[i].yVelocity / 2f)); if (this.chunkFinalYLevel <= this.chunkFinalYTarget) { this.chunkFinalYLevel = this.chunkFinalYTarget; this.movingFinalYLevel = false; } } if (this.debrisType == Debris.DebrisType.SQUARES && this.chunks[i].position.Y < (float)(this.chunkFinalYLevel - Game1.tileSize * 3 / 2) && Game1.random.NextDouble() < 0.1) { this.chunks[i].position.Y = (float)(this.chunkFinalYLevel - Game1.random.Next(1, Game1.tileSize / 3)); this.chunks[i].yVelocity = (float)Game1.random.Next(30, 80) / 40f; this.chunks[i].position.X = (float)Game1.random.Next((int)(this.chunks[i].position.X - this.chunks[i].position.X % (float)Game1.tileSize + 1f), (int)(this.chunks[i].position.X - this.chunks[i].position.X % (float)Game1.tileSize + 64f)); } if (this.debrisType != Debris.DebrisType.SQUARES) { this.chunks[i].yVelocity -= 0.4f; } bool destroyThisChunk = false; if (this.chunks[i].position.Y >= (float)this.chunkFinalYLevel && this.chunks[i].hasPassedRestingLineOnce && this.chunks[i].bounces <= (this.floppingFish ? 65 : 2)) { if (this.debrisType != Debris.DebrisType.LETTERS && this.debrisType != Debris.DebrisType.NUMBERS && this.debrisType != Debris.DebrisType.SPRITECHUNKS && (this.debrisType != Debris.DebrisType.CHUNKS || this.chunks[i].debrisType - this.chunks[i].debrisType % 2 == 8)) { Game1.playSound("shiny4"); } this.chunks[i].bounces++; if (this.floppingFish) { this.chunks[i].yVelocity = Math.Abs(this.chunks[i].yVelocity) * ((this.movingUp && this.chunks[i].bounces < 2) ? 0.6f : 0.9f); this.chunks[i].xVelocity = (float)Game1.random.Next(-250, 250) / 100f; } else { this.chunks[i].yVelocity = Math.Abs(this.chunks[i].yVelocity * 2f / 3f); this.chunks[i].rotationVelocity = ((Game1.random.NextDouble() < 0.5) ? (this.chunks[i].rotationVelocity / 2f) : (-this.chunks[i].rotationVelocity * 2f / 3f)); this.chunks[i].xVelocity -= this.chunks[i].xVelocity / 2f; } if (this.debrisType != Debris.DebrisType.LETTERS && this.debrisType != Debris.DebrisType.SPRITECHUNKS && this.debrisType != Debris.DebrisType.NUMBERS && Game1.currentLocation.doesTileHaveProperty((int)((this.chunks[i].position.X + (float)(Game1.tileSize / 2)) / (float)Game1.tileSize), (int)((this.chunks[i].position.Y + (float)(Game1.tileSize / 2)) / (float)Game1.tileSize), "Water", "Back") != null) { Game1.currentLocation.TemporarySprites.Add(new TemporaryAnimatedSprite(28, 300f, 2, 1, this.chunks[i].position, false, false)); Game1.playSound("dropItemInWater"); destroyThisChunk = true; } } if ((!this.chunks[i].hitWall && Game1.currentLocation.Map.GetLayer("Buildings").Tiles[(int)((this.chunks[i].position.X + (float)(Game1.tileSize / 2)) / (float)Game1.tileSize), (int)((this.chunks[i].position.Y + (float)(Game1.tileSize / 2)) / (float)Game1.tileSize)] != null) || Game1.currentLocation.Map.GetLayer("Back").Tiles[(int)((this.chunks[i].position.X + (float)(Game1.tileSize / 2)) / (float)Game1.tileSize), (int)((this.chunks[i].position.Y + (float)(Game1.tileSize / 2)) / (float)Game1.tileSize)] == null) { this.chunks[i].xVelocity = -this.chunks[i].xVelocity; this.chunks[i].hitWall = true; } if (this.chunks[i].position.Y < (float)this.chunkFinalYLevel) { this.chunks[i].hasPassedRestingLineOnce = true; } if (this.chunks[i].bounces > (this.floppingFish ? 65 : 2)) { this.chunks[i].yVelocity = 0f; this.chunks[i].xVelocity = 0f; this.chunks[i].rotationVelocity = 0f; } this.chunks[i].rotation += this.chunks[i].rotationVelocity; if (destroyThisChunk) { this.chunks.RemoveAt(i); } } } IL_1077 :; } return(this.chunks.Count == 0); }
public bool harvest(int xTile, int yTile, HoeDirt soil, JunimoHarvester junimoHarvester = null) { if (this.dead) { return(junimoHarvester != null); } if (this.forageCrop) { ModularCropObject @object = (ModularCropObject)null; int howMuch = 3; if (this.whichForageCrop == 1) { //@object = new ModularCropObject(399, 1, false, -1, 0); if (Game1.player.professions.Contains(16)) { @object.Quality = 4; } else if (Game1.random.NextDouble() < (double)Game1.player.ForagingLevel / 30.0) { @object.Quality = 2; } else if (Game1.random.NextDouble() < (double)Game1.player.ForagingLevel / 15.0) { @object.Quality = 1; } } Game1.stats.ItemsForaged += (uint)@object.Stack; if (junimoHarvester != null) { junimoHarvester.tryToAddItemToHut((Item)@object); return(true); } if (Game1.player.addItemToInventoryBool((Item)@object, 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 (this.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); } Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588")); } else if (this.currentPhase >= this.phaseDays.Count - 1 && (!this.fullyGrown || this.dayOfCurrentPhase <= 0)) { int num1 = 1; int num2 = 0; int num3 = 0; if (this.indexOfHarvest == 0) { return(true); } Random random = new Random(xTile * 7 + yTile * 11 + (int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame); switch (soil.fertilizer.Value) { case 368: num3 = 1; break; case 369: num3 = 2; break; } double num4 = 0.2 * ((double)Game1.player.FarmingLevel / 10.0) + 0.2 * (double)num3 * (((double)Game1.player.FarmingLevel + 2.0) / 12.0) + 0.01; double num5 = Math.Min(0.75, num4 * 2.0); if (random.NextDouble() < num4) { num2 = 2; } else if (random.NextDouble() < num5) { num2 = 1; } if (this.minHarvest > 1 || this.maxHarvest > 1) { num1 = random.Next(this.minHarvest, Math.Min(this.minHarvest + 1, this.maxHarvest + 1 + Game1.player.FarmingLevel / this.maxHarvestIncreasePerFarmingLevel)); } if (this.chanceForExtraCrops > 0.0) { while (random.NextDouble() < Math.Min(0.9, this.chanceForExtraCrops)) { ++num1; } } if (this.harvestMethod == 1) { if (junimoHarvester == null) { DelayedAction.playSoundAfterDelay("daggerswipe", 150); } if (junimoHarvester != null && Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { Game1.playSound("harvest"); } if (junimoHarvester != null && Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { DelayedAction.playSoundAfterDelay("coin", 260); } for (int index = 0; index < num1; ++index) { if (junimoHarvester != null) { junimoHarvester.tryToAddItemToHut((Item) new ModularCropObject(this.spriteSheet.getHelper(), this.indexOfHarvest, 1, this.cropObjectTexture, this.cropObjectData)); } else { AdditionalCropsFramework.Utilities.createObjectDebris((Item) new ModularCropObject(this.spriteSheet.getHelper(), this.indexOfHarvest, this.getAmountForHarvest(), this.cropObjectTexture, this.cropObjectData), xTile, yTile, xTile, yTile, -1, this.getQualityOfCrop(), 1); } //Game1.createObjectDebris(this.indexOfHarvest, xTile, yTile, -1, num2, 1f, (GameLocation)null); } if (this.regrowAfterHarvest == -1) { return(true); } this.dayOfCurrentPhase = this.regrowAfterHarvest; this.fullyGrown = true; } else { if (junimoHarvester == null) { Farmer player = Game1.player; ModularCropObject @object = new ModularCropObject(this.spriteSheet.getHelper(), this.indexOfHarvest, 1, this.cropObjectTexture, this.cropObjectData); int num7 = 0; if (!player.addItemToInventoryBool((Item)@object, num7 != 0)) { Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:Crop.cs.588")); goto label_86; } } Vector2 vector2 = new Vector2((float)xTile, (float)yTile); if (junimoHarvester == null) { // Game1.player.animateOnce(279 + Game1.player.facingDirection); Game1.player.canMove = false; } else { JunimoHarvester junimoHarvester1 = junimoHarvester; ModularCropObject @object = new ModularCropObject(this.spriteSheet.getHelper(), this.indexOfHarvest, 1, this.cropObjectTexture, this.cropObjectData); junimoHarvester1.tryToAddItemToHut((Item)@object); } if (random.NextDouble() < (double)Game1.player.LuckLevel / 1500.0 + Game1.dailyLuck / 1200.0 + 9.99999974737875E-05) { num1 *= 2; if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { Game1.playSound("dwoop"); } } else if (this.harvestMethod == 0) { if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { Game1.playSound("harvest"); } if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { DelayedAction.playSoundAfterDelay("coin", 260); } if (this.regrowAfterHarvest == -1 && (junimoHarvester == null || junimoHarvester.currentLocation.Equals((object)Game1.currentLocation))) { 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)); } } if (this.indexOfHarvest == 421) { this.indexOfHarvest = 431; num1 = random.Next(1, 4); } for (int index = 0; index < num1 - 1; ++index) { if (junimoHarvester == null) { AdditionalCropsFramework.Utilities.createObjectDebris((Item) new ModularCropObject(this.spriteSheet.getHelper(), this.indexOfHarvest, this.getAmountForHarvest(), this.cropObjectTexture, this.cropObjectData), xTile, yTile, xTile, yTile, -1, this.getQualityOfCrop(), 1); } else { junimoHarvester.tryToAddItemToHut((Item) new ModularCropObject(this.spriteSheet.getHelper(), this.indexOfHarvest, this.getAmountForHarvest(), this.cropObjectTexture, this.cropObjectData)); } } float num8 = (float)(16.0 * Math.Log(0.018 * (double)Convert.ToInt32(this.experienceGainWhenHarvesting + 1.0), Math.E)); if (junimoHarvester == null) { Game1.player.gainExperience(0, (int)Math.Round((double)num8)); } if (this.regrowAfterHarvest == -1) { return(true); } this.dayOfCurrentPhase = this.regrowAfterHarvest; this.fullyGrown = true; } } label_86: return(false); }
public override bool clicked(StardewValley.Farmer who) { int range = 2; if (StardustCore.Utilities.isWithinRange(range, this.TileLocation) == false) { return(false); } if (StardustCore.Utilities.isWithinDirectionRange(Game1.player.FacingDirection, range, this.TileLocation)) { if (Game1.player.CurrentItem != null) { if (Game1.player.getToolFromName(Game1.player.CurrentItem.Name) is StardewValley.Tools.WateringCan) { this.isWatered = true; this.animationManager.setAnimation("Watered", 0); return(false); } } if (Game1.player.CurrentItem != null) { if (Game1.player.CurrentItem is StardewValley.Tools.MeleeWeapon || Game1.player.CurrentItem is StardewValley.Tools.Sword) { if (this.modularCrop != null) { if (this.modularCrop.dead == true) { this.modularCrop = null; return(false); } } if (this.crop != null) { if (this.crop.dead.Value == true) { this.crop = null; return(false); } } } } } if (removable == false) { return(false); } // Game1.showRedMessage("THIS IS CLICKED!!!"); Game1.haltAfterCheck = false; if (this.Decoration_type == 11 && who.ActiveObject != null && who.ActiveObject != null && this.heldObject.Value == null) { // Game1.showRedMessage("Why1?"); return(false); } if (this.heldObject.Value == null && (who.ActiveObject == null || !(who.ActiveObject is PlanterBox))) { if (Game1.player.currentLocation is FarmHouse) { // Game1.showRedMessage("Why2?"); // this.heldObject = new PlanterBox(parentSheetIndex, Vector2.Zero); Utilities.addItemToInventoryAndCleanTrackedList(this); this.flaggedForPickUp = true; this.thisLocation = null; this.locationsName = ""; return(true); } else { // return true; this.flaggedForPickUp = true; // this.heldObject = new PlanterBox(parentSheetIndex, Vector2.Zero); Utilities.addItemToInventoryAndCleanTrackedList(this); // this.heldObject.performRemoveAction(this.TileLocation, who.currentLocation); // this.heldObject = null; Game1.playSound("coin"); this.thisLocation = null; this.locationsName = ""; return(true); } } if (this.heldObject.Value != null && who.addItemToInventoryBool(this.heldObject.Value, false)) { // Game1.showRedMessage("Why3?"); this.heldObject.Value.performRemoveAction(this.TileLocation, who.currentLocation); this.heldObject.Value = null; Utilities.addItemToInventoryAndCleanTrackedList(this); Game1.playSound("coin"); this.thisLocation = null; this.locationsName = ""; return(true); } return(false); }
// Token: 0x06000308 RID: 776 RVA: 0x0003CDAC File Offset: 0x0003AFAC public bool harvest(int xTile, int yTile, HoeDirt soil, JunimoHarvester junimoHarvester = null) { if (this.dead) { return(junimoHarvester != null); } if (this.forageCrop) { Object o = null; int experience = 3; int fertilizer = this.whichForageCrop; if (fertilizer == 1) { o = new Object(399, 1, false, -1, 0); } if (Game1.player.professions.Contains(16)) { o.quality = 4; } else if (Game1.random.NextDouble() < (double)((float)Game1.player.ForagingLevel / 30f)) { o.quality = 2; } else if (Game1.random.NextDouble() < (double)((float)Game1.player.ForagingLevel / 15f)) { o.quality = 1; } if (junimoHarvester != null) { junimoHarvester.tryToAddItemToHut(o); return(true); } if (Game1.player.addItemToInventoryBool(o, false)) { Vector2 initialTile = 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 (this.regrowAfterHarvest == -1) { Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(17, new Vector2(initialTile.X * (float)Game1.tileSize, initialTile.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(initialTile.X * (float)Game1.tileSize, initialTile.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0)); } Game1.player.gainExperience(2, experience); return(true); } Game1.showRedMessage("Inventory Full"); } else if (this.currentPhase >= this.phaseDays.Count - 1 && (!this.fullyGrown || this.dayOfCurrentPhase <= 0)) { int numToHarvest = 1; int cropQuality = 0; int fertilizerQualityLevel = 0; if (this.indexOfHarvest == 0) { return(true); } Random r = new Random(xTile * 7 + yTile * 11 + (int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame); int fertilizer = soil.fertilizer; if (fertilizer != 368) { if (fertilizer == 369) { fertilizerQualityLevel = 2; } } else { fertilizerQualityLevel = 1; } double chanceForGoldQuality = 0.2 * (double)(Game1.player.FarmingLevel / 10) + 0.2 * (double)fertilizerQualityLevel * (double)((float)(Game1.player.FarmingLevel + 2) / 12f) + 0.01; double chanceForSilverQuality = Math.Min(0.75, chanceForGoldQuality * 2.0); if (r.NextDouble() < chanceForGoldQuality) { cropQuality = 2; } else if (r.NextDouble() < chanceForSilverQuality) { cropQuality = 1; } if (this.minHarvest > 1 || this.maxHarvest > 1) { numToHarvest = r.Next(this.minHarvest, Math.Min(this.minHarvest + 1, this.maxHarvest + 1 + Game1.player.FarmingLevel / this.maxHarvestIncreasePerFarmingLevel)); } if (this.chanceForExtraCrops > 0.0) { while (r.NextDouble() < Math.Min(0.9, this.chanceForExtraCrops)) { numToHarvest++; } } if (this.harvestMethod == 1) { if (junimoHarvester == null) { DelayedAction.playSoundAfterDelay("daggerswipe", 150); } if (junimoHarvester != null && Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { Game1.playSound("harvest"); } if (junimoHarvester != null && Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { DelayedAction.playSoundAfterDelay("coin", 260); } for (int i = 0; i < numToHarvest; i++) { if (junimoHarvester != null) { junimoHarvester.tryToAddItemToHut(new Object(this.indexOfHarvest, 1, false, -1, cropQuality)); } else { Game1.createObjectDebris(this.indexOfHarvest, xTile, yTile, -1, cropQuality, 1f, null); } } if (this.regrowAfterHarvest == -1) { return(true); } this.dayOfCurrentPhase = this.regrowAfterHarvest; this.fullyGrown = true; } else { if (junimoHarvester == null) { Farmer arg_487_0 = Game1.player; Object arg_487_1; if (!this.programColored) { arg_487_1 = new Object(this.indexOfHarvest, 1, false, -1, cropQuality); } else { (arg_487_1 = new ColoredObject(this.indexOfHarvest, 1, this.tintColor)).quality = cropQuality; } if (!arg_487_0.addItemToInventoryBool(arg_487_1, false)) { Game1.showRedMessage("Inventory Full"); return(false); } } Vector2 initialTile2 = new Vector2((float)xTile, (float)yTile); if (junimoHarvester == null) { Game1.player.animateOnce(279 + Game1.player.facingDirection); Game1.player.canMove = false; } else { Object arg_4FD_1; if (!this.programColored) { arg_4FD_1 = new Object(this.indexOfHarvest, 1, false, -1, cropQuality); } else { (arg_4FD_1 = new ColoredObject(this.indexOfHarvest, 1, this.tintColor)).quality = cropQuality; } junimoHarvester.tryToAddItemToHut(arg_4FD_1); } if (r.NextDouble() < (double)((float)Game1.player.LuckLevel / 1500f) + Game1.dailyLuck / 1200.0 + 9.9999997473787516E-05) { numToHarvest *= 2; if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { Game1.playSound("dwoop"); } } else if (this.harvestMethod == 0) { if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { Game1.playSound("harvest"); } if (junimoHarvester == null || Utility.isOnScreen(junimoHarvester.getTileLocationPoint(), Game1.tileSize, junimoHarvester.currentLocation)) { DelayedAction.playSoundAfterDelay("coin", 260); } if (this.regrowAfterHarvest == -1 && (junimoHarvester == null || junimoHarvester.currentLocation.Equals(Game1.currentLocation))) { Game1.currentLocation.temporarySprites.Add(new TemporaryAnimatedSprite(17, new Vector2(initialTile2.X * (float)Game1.tileSize, initialTile2.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(initialTile2.X * (float)Game1.tileSize, initialTile2.Y * (float)Game1.tileSize), Color.White, 7, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0)); } } if (this.indexOfHarvest == 421) { this.indexOfHarvest = 431; numToHarvest = r.Next(1, 4); } for (int j = 0; j < numToHarvest - 1; j++) { if (junimoHarvester == null) { Game1.createObjectDebris(this.indexOfHarvest, xTile, yTile, -1, 0, 1f, null); } else { junimoHarvester.tryToAddItemToHut(new Object(this.indexOfHarvest, 1, false, -1, 0)); } } int price = Convert.ToInt32(Game1.objectInformation[this.indexOfHarvest].Split(new char[] { '/' })[1]); float experience2 = (float)(16.0 * Math.Log(0.018 * (double)price + 1.0, 2.7182818284590451)); if (junimoHarvester == null) { Game1.player.gainExperience(0, (int)Math.Round((double)experience2)); } if (this.regrowAfterHarvest == -1) { return(true); } this.dayOfCurrentPhase = this.regrowAfterHarvest; this.fullyGrown = true; } } return(false); }