public virtual void recreateComponents() { if (ModCore.CustomObjects.ContainsKey(this.guid)) { if ((ModCore.CustomObjects[this.guid] as MultiTiledObject).objects.Count > 0) { this.objects = (ModCore.CustomObjects[this.guid] as MultiTiledObject).objects; } else { } if ((ModCore.CustomObjects[this.guid] as MultiTiledObject).childrenGuids.Count > 0) { this.childrenGuids = (ModCore.CustomObjects[this.guid] as MultiTiledObject).childrenGuids; } } else { MultiplayerUtilities.RequestGuidObject(this.guid); MultiplayerUtilities.RequestGuidObject_Tile(this.guid); } if (this.objects == null || this.childrenGuids == null) { //ModCore.log("Either objects or children guids are null"); return; } //ModCore.log("Recreate children components"); if (this.objects.Count < this.childrenGuids.Count) { foreach (KeyValuePair <Vector2, Guid> pair in this.childrenGuids) { if (ModCore.CustomObjects.ContainsKey(pair.Value)) { this.removeComponent(pair.Key); this.addComponent(pair.Key, (MultiTiledComponent)ModCore.CustomObjects[pair.Value]); } else { MultiplayerUtilities.RequestGuidObject(pair.Value); MultiplayerUtilities.RequestGuidObject_Tile(pair.Value); } } } else { //ModCore.log("Count is exactly the same!"); //ModCore.log("Count is: " + this.objects.Count+" : and " + this.childrenGuids.Count); } }
public override void updateInfo() { if (this.info == null || this.containerObject == null) { this.ItemInfo = this.text; //ModCore.log("Updated item info!"); return; } if (this.requiresUpdate()) { //this.ItemInfo = this.text; this.text = this.ItemInfo; this.info.cleanAfterUpdate(); MultiplayerUtilities.RequestUpdateSync(this.guid); } }
public override void updateInfo() { //this.recreateComponents(); if (this.info == null) { this.ItemInfo = this.text; //ModCore.log("Updated item info for container!"); return; } if (this.objects != null) { if (this.childrenGuids != null) { if (this.objects.Count == 0 || this.objects.Count != this.childrenGuids.Count) { this.ItemInfo = this.text; //ModCore.log("Updated item info for container!"); return; } } else { if (this.objects.Count == 0) { this.ItemInfo = this.text; //ModCore.log("Updated item info for container!"); return; } } } if (this.requiresUpdate()) { //this.ItemInfo = this.text; this.text = this.ItemInfo; this.info.cleanAfterUpdate(); MultiplayerUtilities.RequestUpdateSync(this.guid); } }
public override void DoFunction(GameLocation location, int x, int y, int power, Farmer who) { //base.DoFunction(location, x, y, power, who); if (this.GetEnergyManager().hasEnoughEnergy(this.getEnergyConsumptionRate()) == true) { } else { Game1.showRedMessage("Out of energy!"); return; } this.baseDoFunction(location, x, y, power, who); power = who.toolPower; //who.Stamina -= (float)(2 * (power + 1)) - (float)who.MiningLevel * 0.1f; //Drain energy here; this.GetEnergyManager().consumeEnergy(this.getEnergyConsumptionRate()); //Double check to prevent animation from happening with even no power Utility.clampToTile(new Vector2((float)x, (float)y)); int num1 = x / 64; int num2 = y / 64; Vector2 index = new Vector2((float)num1, (float)num2); if (location.performToolAction((Tool)this, num1, num2)) { return; } StardewValley.Object @object = (StardewValley.Object)null; location.Objects.TryGetValue(index, out @object); if (@object == null) { if (who.FacingDirection == 0 || who.FacingDirection == 2) { num1 = (x - 8) / 64; location.Objects.TryGetValue(new Vector2((float)num1, (float)num2), out @object); if (@object == null) { num1 = (x + 8) / 64; location.Objects.TryGetValue(new Vector2((float)num1, (float)num2), out @object); } } else { num2 = (y + 8) / 64; location.Objects.TryGetValue(new Vector2((float)num1, (float)num2), out @object); if (@object == null) { num2 = (y - 8) / 64; location.Objects.TryGetValue(new Vector2((float)num1, (float)num2), out @object); } } x = num1 * 64; y = num2 * 64; if (location.terrainFeatures.ContainsKey(index) && location.terrainFeatures[index].performToolAction((Tool)this, 0, index, location)) { location.terrainFeatures.Remove(index); } } index = new Vector2((float)num1, (float)num2); if (@object != null) { if (@object.Name.Equals("Stone")) { location.playSound("hammer"); if (@object.MinutesUntilReady > 0) { int num3 = Math.Max(1, this.UpgradeLevel + 1); @object.MinutesUntilReady -= num3; @object.shakeTimer = 200; if (@object.MinutesUntilReady > 0) { Game1.createRadialDebris(Game1.currentLocation, 14, num1, num2, Game1.random.Next(2, 5), false, -1, false, -1); return; } } if (@object.ParentSheetIndex < 200 && !Game1.objectInformation.ContainsKey(@object.ParentSheetIndex + 1)) { MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(@object.ParentSheetIndex + 1, 300f, 1, 2, new Vector2((float)(x - x % 64), (float)(y - y % 64)), true, @object.Flipped) { alphaFade = 0.01f }); } else { MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(47, new Vector2((float)(num1 * 64), (float)(num2 * 64)), Color.Gray, 10, false, 80f, 0, -1, -1f, -1, 0)); } Game1.createRadialDebris(location, 14, num1, num2, Game1.random.Next(2, 5), false, -1, false, -1); MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(46, new Vector2((float)(num1 * 64), (float)(num2 * 64)), Color.White, 10, false, 80f, 0, -1, -1f, -1, 0) { motion = new Vector2(0.0f, -0.6f), acceleration = new Vector2(0.0f, 1f / 500f), alphaFade = 0.015f }); if (!location.Name.StartsWith("UndergroundMine")) { if (@object.ParentSheetIndex == 343 || @object.ParentSheetIndex == 450) { Random random = new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame / 2 + num1 * 2000 + num2); if (random.NextDouble() < 0.035 && Game1.stats.DaysPlayed > 1U) { Game1.createObjectDebris(535 + (Game1.stats.DaysPlayed <= 60U || random.NextDouble() >= 0.2 ? (Game1.stats.DaysPlayed <= 120U || random.NextDouble() >= 0.2 ? 0 : 2) : 1), num1, num2, this.getLastFarmerToUse().UniqueMultiplayerID); } if (random.NextDouble() < 0.035 * (who.professions.Contains(21) ? 2.0 : 1.0) && Game1.stats.DaysPlayed > 1U) { Game1.createObjectDebris(382, num1, num2, this.getLastFarmerToUse().UniqueMultiplayerID); } if (random.NextDouble() < 0.01 && Game1.stats.DaysPlayed > 1U) { Game1.createObjectDebris(390, num1, num2, this.getLastFarmerToUse().UniqueMultiplayerID); } } Revitalize.ModCore.ModHelper.Reflection.GetMethod(location, "breakStone").Invoke(@object.ParentSheetIndex, num1, num2, who, new Random((int)Game1.stats.DaysPlayed + (int)Game1.uniqueIDForThisGame / 2 + num1 * 4000 + num2)); } else { Game1.mine.checkStoneForItems(@object.ParentSheetIndex, num1, num2, who); } if (@object.MinutesUntilReady > 0) { return; } location.Objects.Remove(new Vector2((float)num1, (float)num2)); location.playSound("stoneCrack"); ++Game1.stats.RocksCrushed; } else if (@object.Name.Contains("Boulder")) { location.playSound("hammer"); if (this.UpgradeLevel < 2) { Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\StringsFromCSFiles:Pickaxe.cs.14194"))); } else { if (num1 == this.boulderTileX && num2 == this.boulderTileY) { this.hitsToBoulder += power + 1; @object.shakeTimer = 190; } else { this.hitsToBoulder = 0; this.boulderTileX = num1; this.boulderTileY = num2; } if (this.hitsToBoulder < 4) { return; } location.removeObject(index, false); MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(5, new Vector2((float)(64.0 * (double)index.X - 32.0), (float)(64.0 * ((double)index.Y - 1.0))), Color.Gray, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0) { delayBeforeAnimationStart = 0 }); MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(5, new Vector2((float)(64.0 * (double)index.X + 32.0), (float)(64.0 * ((double)index.Y - 1.0))), Color.Gray, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0) { delayBeforeAnimationStart = 200 }); MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(5, new Vector2(64f * index.X, (float)(64.0 * ((double)index.Y - 1.0) - 32.0)), Color.Gray, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0) { delayBeforeAnimationStart = 400 }); MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(5, new Vector2(64f * index.X, (float)(64.0 * (double)index.Y - 32.0)), Color.Gray, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, -1, 0) { delayBeforeAnimationStart = 600 }); MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(25, new Vector2(64f * index.X, 64f * index.Y), Color.White, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, 128, 0)); MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(25, new Vector2((float)(64.0 * (double)index.X + 32.0), 64f * index.Y), Color.White, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, 128, 0) { delayBeforeAnimationStart = 250 }); MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(25, new Vector2((float)(64.0 * (double)index.X - 32.0), 64f * index.Y), Color.White, 8, Game1.random.NextDouble() < 0.5, 50f, 0, -1, -1f, 128, 0) { delayBeforeAnimationStart = 500 }); location.playSound("boulderBreak"); ++Game1.stats.BouldersCracked; } } else { if ([email protected]((Tool)this, location)) { return; } @object.performRemoveAction(index, location); if (@object.Type.Equals((object)"Crafting") && @object.Fragility != 2) { NetCollection <Debris> debris1 = Game1.currentLocation.debris; int objectIndex = @object.bigCraftable.Value ? [email protected] : @object.ParentSheetIndex; Vector2 toolLocation = who.GetToolLocation(false); Rectangle boundingBox = who.GetBoundingBox(); double x1 = (double)boundingBox.Center.X; boundingBox = who.GetBoundingBox(); double y1 = (double)boundingBox.Center.Y; Vector2 playerPosition = new Vector2((float)x1, (float)y1); Debris debris2 = new Debris(objectIndex, toolLocation, playerPosition); debris1.Add(debris2); } Game1.currentLocation.Objects.Remove(index); } } else { location.playSound("woodyHit"); if (location.doesTileHaveProperty(num1, num2, "Diggable", "Back") == null) { return; } MultiplayerUtilities.GetMultiplayer().broadcastSprites(location, new TemporaryAnimatedSprite(12, new Vector2((float)(num1 * 64), (float)(num2 * 64)), Color.White, 8, false, 80f, 0, -1, -1f, -1, 0) { alphaFade = 0.015f }); } }