/// <summary>Get a rectangle which roughly bounds the visible sprite relative the viewport.</summary> public override Rectangle GetSpriteArea() { // get object info Object obj = (Object)this.Value; Rectangle boundingBox = obj.getBoundingBox(this.GetTile()); // get sprite area if (this.CustomSprite != null) { Rectangle spriteArea = this.GetSpriteArea(boundingBox, this.CustomSprite.SourceRectangle); return(new Rectangle( x: spriteArea.X, y: spriteArea.Y - (spriteArea.Height / 2), // custom sprite areas are offset from game logic width: spriteArea.Width, height: spriteArea.Height )); } if (obj is Furniture furniture) { return(this.GetSpriteArea(boundingBox, furniture.sourceRect.Value)); } if (obj.bigCraftable.Value) { return(this.GetSpriteArea(boundingBox, Object.getSourceRectForBigCraftable(obj.ParentSheetIndex))); } if (obj is Fence fence) { return(this.GetSpriteArea(boundingBox, this.GetSourceRectangle(fence, Game1.currentLocation))); } else { return(this.GetSpriteArea(boundingBox, Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, obj.ParentSheetIndex, Object.spriteSheetTileSize, Object.spriteSheetTileSize))); } }
/// <summary>Get the area occupied by the target (absolute).</summary> public override Rectangle GetOccupiedArea() { // get object info Object obj = (Object)this.Value; return(obj.getBoundingBox(this.GetTile())); }
private static void ShowObjectParticleEffect(SpriteBatch b, Object instance, int x, int y, string key, ParticleEffectData ped) { var oKey = instance.Name + "|" + x + "," + y; if (!objectEffectDict.TryGetValue(oKey, out EntityParticleData entityParticleData)) { entityParticleData = new EntityParticleData(); objectEffectDict[oKey] = entityParticleData; } if (!entityParticleData.particleDict.TryGetValue(key, out var particleList)) { particleList = new List <ParticleData>(); objectEffectDict[oKey].particleDict[key] = particleList; } ShowParticleEffect(b, particleList, ped, instance.getBoundingBox(new Vector2(x, y)).Center.ToVector2() + new Vector2(ped.fieldOffsetX, ped.fieldOffsetY), Math.Max(0f, ((y + 1) * 64 - 24) / 10000f) + x * 1E-05f); objectEffectDict[oKey] = entityParticleData; }
/// <summary>Get a rectangle which roughly bounds the visible sprite relative the viewport.</summary> public override Rectangle GetSpriteArea() { Object obj = (Object)this.Value; Rectangle boundingBox = obj.getBoundingBox(this.GetTile()); if (obj is Furniture furniture) { return(this.GetSpriteArea(boundingBox, furniture.sourceRect.Value)); } if (obj.bigCraftable.Value) { return(this.GetSpriteArea(boundingBox, Object.getSourceRectForBigCraftable(obj.ParentSheetIndex))); } if (obj is Fence fence) { return(this.GetSpriteArea(boundingBox, this.GetSourceRectangle(fence, Game1.currentLocation))); } else { return(this.GetSpriteArea(boundingBox, Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, obj.ParentSheetIndex, Object.spriteSheetTileSize, Object.spriteSheetTileSize))); } }
public LadderStone(Object obj) : base(obj) { BoundingBox = obj.getBoundingBox(obj.TileLocation); Flipped = obj.Flipped; Tint = GetObjectSpriteAverageColor(SpriteIndex); }
private static void Draw(SObject instance, SpriteBatch spriteBatch, int x, int y, float alpha, Texture2D spriteSheet, Rectangle position) { if (instance.isTemporarilyInvisible) { return; } if ((bool)(instance.bigCraftable)) { Vector2 vector2 = instance.getScale() * 4f; Vector2 local = Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * 64), (float)(y * 64 - 64))); Microsoft.Xna.Framework.Rectangle destinationRectangle = new Microsoft.Xna.Framework.Rectangle((int)((double)local.X - (double)vector2.X / 2.0) + (instance.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0), (int)((double)local.Y - (double)vector2.Y / 2.0) + (instance.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0), (int)(64.0 + (double)vector2.X), (int)(128.0 + (double)vector2.Y / 2.0)); float layerDepth = Math.Max(0.0f, (float)((y + 1) * 64 - 24) / 10000f) + (float)x * 1E-05f; if (instance.ParentSheetIndex == 105) { layerDepth = Math.Max(0.0f, (float)((y + 1) * 64 + 2) / 10000f) + (float)x / 1000000f; } spriteBatch.Draw(Game1.bigCraftableSpriteSheet, destinationRectangle, new Microsoft.Xna.Framework.Rectangle?(SObject.getSourceRectForBigCraftable((bool)(instance.showNextIndex) ? instance.ParentSheetIndex + 1 : instance.ParentSheetIndex)), Color.White * alpha, 0.0f, Vector2.Zero, SpriteEffects.None, layerDepth); if (instance.Name.Equals("Loom") && (int)(instance.minutesUntilReady) > 0) { spriteBatch.Draw(Game1.objectSpriteSheet, instance.getLocalPosition(Game1.viewport) + new Vector2(32f, 0.0f), new Microsoft.Xna.Framework.Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, 435, 16, 16)), Color.White * alpha, instance.scale.X, new Vector2(8f, 8f), 4f, SpriteEffects.None, Math.Max(0.0f, (float)((double)((y + 1) * 64) / 10000.0 + 9.99999974737875E-05 + (double)x * 9.99999974737875E-06))); } if ((bool)(instance.isLamp) && Game1.isDarkOut()) { spriteBatch.Draw(Game1.mouseCursors, local + new Vector2(-32f, -32f), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(88, 1779, 32, 32)), Color.White * 0.75f, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, Math.Max(0.0f, (float)((y + 1) * 64 - 20) / 10000f) + (float)x / 1000000f); } if ((int)(instance.parentSheetIndex) == 126 && (int)(instance.quality) != 0) { spriteBatch.Draw(FarmerRenderer.hatsTexture, local + new Vector2(-3f, -6f) * 4f, new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(((int)(instance.quality) - 1) * 20 % FarmerRenderer.hatsTexture.Width, ((int)(instance.quality) - 1) * 20 / FarmerRenderer.hatsTexture.Width * 20 * 4, 20, 20)), Color.White * alpha, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, Math.Max(0.0f, (float)((y + 1) * 64 - 20) / 10000f) + (float)x * 1E-05f); } } else if (!Game1.eventUp || Game1.CurrentEvent != null && !Game1.CurrentEvent.isTileWalkedOn(x, y)) { if ((int)(instance.parentSheetIndex) == 590) { SpriteBatch spriteBatch1 = spriteBatch; Texture2D mouseCursors = Game1.mouseCursors; Vector2 local = Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * 64 + 32 + (instance.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0)), (float)(y * 64 + 32 + (instance.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0)))); Microsoft.Xna.Framework.Rectangle?sourceRectangle = new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(368 + (Game1.currentGameTime.TotalGameTime.TotalMilliseconds % 1200.0 <= 400.0 ? (int)(Game1.currentGameTime.TotalGameTime.TotalMilliseconds % 400.0 / 100.0) * 16 : 0), 32, 16, 16)); Color color = Color.White * alpha; Vector2 origin = new Vector2(8f, 8f); Vector2 scale = instance.scale; double num1 = (double)instance.scale.Y > 1.0 ? (double)instance.getScale().Y : 4.0; int num2 = (bool)(instance.flipped) ? 1 : 0; double num3 = (instance.isPassable() ? (double)instance.getBoundingBox(new Vector2((float)x, (float)y)).Top : (double)instance.getBoundingBox(new Vector2((float)x, (float)y)).Bottom) / 10000.0; spriteBatch1.Draw(mouseCursors, local, sourceRectangle, color, 0.0f, origin, (float)num1, (SpriteEffects)num2, (float)num3); return; } Microsoft.Xna.Framework.Rectangle rectangle; if ((int)(instance.fragility) != 2) { SpriteBatch spriteBatch1 = spriteBatch; Texture2D shadowTexture = Game1.shadowTexture; Vector2 local = Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * 64 + 32), (float)(y * 64 + 51 + 4))); Microsoft.Xna.Framework.Rectangle?sourceRectangle = new Microsoft.Xna.Framework.Rectangle?(Game1.shadowTexture.Bounds); Color color = Color.White * alpha; rectangle = Game1.shadowTexture.Bounds; double x1 = (double)rectangle.Center.X; rectangle = Game1.shadowTexture.Bounds; double y1 = (double)rectangle.Center.Y; Vector2 origin = new Vector2((float)x1, (float)y1); rectangle = instance.getBoundingBox(new Vector2((float)x, (float)y)); double num = (double)rectangle.Bottom / 15000.0; spriteBatch1.Draw(shadowTexture, local, sourceRectangle, color, 0.0f, origin, 4f, SpriteEffects.None, (float)num); } SpriteBatch spriteBatch2 = spriteBatch; Texture2D objectSpriteSheet = Game1.objectSpriteSheet; Vector2 local1 = Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * 64 + 32 + (instance.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0)), (float)(y * 64 + 32 + (instance.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0)))); Microsoft.Xna.Framework.Rectangle?sourceRectangle1 = new Microsoft.Xna.Framework.Rectangle?(GameLocation.getSourceRectForObject(instance.ParentSheetIndex)); Color color1 = Color.White * alpha; Vector2 origin1 = new Vector2(8f, 8f); Vector2 scale1 = instance.scale; double num4 = (double)instance.scale.Y > 1.0 ? (double)instance.getScale().Y : 4.0; int num5 = (bool)(instance.flipped) ? 1 : 0; int num6; if (!instance.isPassable()) { rectangle = instance.getBoundingBox(new Vector2((float)x, (float)y)); num6 = rectangle.Bottom; } else { rectangle = instance.getBoundingBox(new Vector2((float)x, (float)y)); num6 = rectangle.Top; } double num7 = (double)num6 / 10000.0; spriteBatch2.Draw(spriteSheet, local1, position, color1, 0.0f, origin1, (float)num4, (SpriteEffects)num5, (float)num7); } if (!(bool)(instance.readyForHarvest)) { return; } float num8 = (float)(4.0 * Math.Round(Math.Sin(DateTime.UtcNow.TimeOfDay.TotalMilliseconds / 250.0), 2)); spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * 64 - 8), (float)(y * 64 - 96 - 16) + num8)), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(141, 465, 20, 24)), Color.White * 0.75f, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, (float)((double)((y + 1) * 64) / 10000.0 + 9.99999997475243E-07 + (double)instance.tileLocation.X / 10000.0 + ((int)(instance.parentSheetIndex) == 105 ? 0.00150000001303852 : 0.0))); if (instance.heldObject.Value == null) { return; } spriteBatch.Draw(spriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * 64 + 32), (float)(y * 64 - 64 - 8) + num8)), position, Color.White * 0.75f, 0.0f, new Vector2(8f, 8f), 4f, SpriteEffects.None, (float)((double)((y + 1) * 64) / 10000.0 + 9.99999974737875E-06 + (double)instance.tileLocation.X / 10000.0 + ((int)(instance.parentSheetIndex) == 105 ? 0.00150000001303852 : 0.0))); if (!(instance.heldObject.Value is ColoredObject)) { return; } spriteBatch.Draw(spriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * 64 + 32), (float)(y * 64 - 64 - 8) + num8)), position, (instance.heldObject.Value as ColoredObject).color.Value * 0.75f, 0.0f, new Vector2(8f, 8f), 4f, SpriteEffects.None, (float)((double)((y + 1) * 64) / 10000.0 + 9.99999974737875E-06 + (double)instance.tileLocation.X / 10000.0 + ((int)(instance.parentSheetIndex) == 105 ? 0.00150000001303852 : 9.99999974737875E-06))); }
private static bool Object_draw_Prefix(Object __instance, SpriteBatch spriteBatch, int x, int y, float alpha) { if (!(Game1.currentLocation is MineShaft)) { return(true); } if (rocks.Contains(__instance.parentSheetIndex) || treasures.Contains(__instance.parentSheetIndex)) { if (!flippedObjects.ContainsKey(new Vector2(x, y))) { flippedObjects[new Vector2(x, y)] = Game1.random.NextDouble() < 0.5; } bool flip = flippedObjects[new Vector2(x, y)]; Vector2 origin = new Vector2(8f, 8f); GetTileInfo(Game1.currentLocation.objects, x, y, __instance.parentSheetIndex, flip, out int tileIndex); if (tileIndex == -1) { return(true); } Rectangle sourceRect = new Rectangle(tileIndex * 16 % (sheetWidth * 16), tileIndex * 16 / (sheetWidth * 16) * 16, 16, 16); Vector2 position = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64 + 32 + ((__instance.shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0), y * 64 + 32 + ((__instance.shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0))); spriteBatch.Draw(tilesheet, position, sourceRect, Color.White, 0, origin, (__instance.scale.Y > 1f) ? __instance.getScale().Y : 4f, flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (__instance.isPassable() ? __instance.getBoundingBox(new Vector2(x, y)).Top : __instance.getBoundingBox(new Vector2(x, y)).Bottom) / 10000f); if (treasures.Contains(__instance.parentSheetIndex)) { Rectangle treasureRect = new Rectangle((treasures.IndexOf(__instance.parentSheetIndex) % sheetWidth) * 16, (10 + treasures.IndexOf(__instance.parentSheetIndex) / sheetWidth) * 16, 16, 16); spriteBatch.Draw(tilesheet, position, treasureRect, Color.White, 0, origin, (__instance.scale.Y > 1f) ? __instance.getScale().Y : 4f, flip ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (__instance.isPassable() ? __instance.getBoundingBox(new Vector2(x, y)).Top : __instance.getBoundingBox(new Vector2(x, y)).Bottom) / 10000f + 0.001f); } return(false); } return(true); }
internal static bool DrawPrefix(Object __instance, SpriteBatch spriteBatch, int x, int y, float alpha = 1f) { if (__instance.modData.ContainsKey("AlternativeTextureName")) { var textureModel = AlternativeTextures.textureManager.GetSpecificTextureModel(__instance.modData["AlternativeTextureName"]); if (textureModel is null) { return(true); } var textureVariation = Int32.Parse(__instance.modData["AlternativeTextureVariation"]); if (textureVariation == -1 || AlternativeTextures.modConfig.IsTextureVariationDisabled(textureModel.GetId(), textureVariation)) { return(true); } var textureOffset = textureModel.GetTextureOffset(textureVariation); // Get the current X index for the source tile var xTileOffset = __instance.modData.ContainsKey("AlternativeTextureSheetId") ? __instance.ParentSheetIndex - Int32.Parse(__instance.modData["AlternativeTextureSheetId"]) : 0; if (__instance.showNextIndex) { xTileOffset += 1; } // Override xTileOffset if AlternativeTextureModel has an animation if (textureModel.HasAnimation(textureVariation)) { if (!__instance.modData.ContainsKey("AlternativeTextureCurrentFrame") || !__instance.modData.ContainsKey("AlternativeTextureFrameDuration") || !__instance.modData.ContainsKey("AlternativeTextureElapsedDuration")) { __instance.modData["AlternativeTextureCurrentFrame"] = "0"; __instance.modData["AlternativeTextureFrameDuration"] = textureModel.GetAnimationDataAtIndex(textureVariation, 0).Duration.ToString(); __instance.modData["AlternativeTextureElapsedDuration"] = "0"; } var currentFrame = Int32.Parse(__instance.modData["AlternativeTextureCurrentFrame"]); var frameDuration = Int32.Parse(__instance.modData["AlternativeTextureFrameDuration"]); var elapsedDuration = Int32.Parse(__instance.modData["AlternativeTextureElapsedDuration"]); if (elapsedDuration >= frameDuration) { currentFrame = currentFrame + 1 >= textureModel.GetAnimationData(textureVariation).Count() ? 0 : currentFrame + 1; __instance.modData["AlternativeTextureCurrentFrame"] = currentFrame.ToString(); __instance.modData["AlternativeTextureFrameDuration"] = textureModel.GetAnimationDataAtIndex(textureVariation, currentFrame).Duration.ToString(); __instance.modData["AlternativeTextureElapsedDuration"] = "0"; } else { __instance.modData["AlternativeTextureElapsedDuration"] = (elapsedDuration + Game1.currentGameTime.ElapsedGameTime.Milliseconds).ToString(); } xTileOffset = currentFrame; } xTileOffset *= textureModel.TextureWidth; if (__instance.bigCraftable) { // Get required draw values Vector2 scaleFactor = __instance.getScale() * 4f; Vector2 position = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64, y * 64 - 64)); Rectangle destination = new Rectangle((int)(position.X - scaleFactor.X / 2f) + ((__instance.shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0), (int)(position.Y - scaleFactor.Y / 2f) + ((__instance.shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0), (int)(64f + scaleFactor.X), (int)(128f + scaleFactor.Y / 2f)); float draw_layer = Math.Max(0f, (float)((y + 1) * 64 - 24) / 10000f) + (float)x * 1E-05f; // Handle outliers for draw if (__instance.ParentSheetIndex == 105 || __instance.ParentSheetIndex == 264) { draw_layer = Math.Max(0f, (float)((y + 1) * 64 + 2) / 10000f) + (float)x / 1000000f; } if (__instance.ParentSheetIndex == 272) { spriteBatch.Draw(textureModel.GetTexture(textureVariation), destination, new Rectangle(16, textureOffset, 16, 32), Color.White * alpha, 0f, Vector2.Zero, SpriteEffects.None, draw_layer); spriteBatch.Draw(textureModel.GetTexture(textureVariation), position + new Vector2(8.5f, 12f) * 4f, new Rectangle(32, textureOffset, 16, 32), Color.White * alpha, (float)Game1.currentGameTime.TotalGameTime.TotalSeconds * -1.5f, new Vector2(7.5f, 15.5f), 4f, SpriteEffects.None, draw_layer + 1E-05f); return(false); } // Perform base game draw logic spriteBatch.Draw(textureModel.GetTexture(textureVariation), destination, new Rectangle(xTileOffset, textureOffset, textureModel.TextureWidth, textureModel.TextureHeight), Color.White * alpha, 0f, Vector2.Zero, SpriteEffects.None, draw_layer); // Replicate the extra draw logic from the base game if (__instance.Name.Equals("Loom") && (int)__instance.minutesUntilReady > 0) { spriteBatch.Draw(textureModel.GetTexture(textureVariation), __instance.getLocalPosition(Game1.viewport) + new Vector2(32f, 0f), new Rectangle(32, textureOffset, 16, 16), Color.White * alpha, __instance.scale.X, new Vector2(8f, 8f), 4f, SpriteEffects.None, Math.Max(0f, (float)((y + 1) * 64) / 10000f + 0.0001f + (float)x * 1E-05f)); } if ((bool)__instance.isLamp && Game1.isDarkOut()) { spriteBatch.Draw(Game1.mouseCursors, position + new Vector2(-32f, -32f), new Rectangle(88, 1779, 32, 32), Color.White * 0.75f, 0f, Vector2.Zero, 4f, SpriteEffects.None, Math.Max(0f, (float)((y + 1) * 64 - 20) / 10000f) + (float)x / 1000000f); } if ((int)__instance.parentSheetIndex == 126 && (int)__instance.quality != 0) { spriteBatch.Draw(FarmerRenderer.hatsTexture, position + new Vector2(-3f, -6f) * 4f, new Rectangle(((int)__instance.quality - 1) * 20 % FarmerRenderer.hatsTexture.Width, ((int)__instance.quality - 1) * 20 / FarmerRenderer.hatsTexture.Width * 20 * 4, 20, 20), Color.White * alpha, 0f, Vector2.Zero, 4f, SpriteEffects.None, Math.Max(0f, (float)((y + 1) * 64 - 20) / 10000f) + (float)x * 1E-05f); } } else if (!Game1.eventUp || (Game1.CurrentEvent != null && !Game1.CurrentEvent.isTileWalkedOn(x, y))) { if ((int)__instance.parentSheetIndex == 590) { Vector2 position2 = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64 + 32 + ((__instance.shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0), y * 64 + 32 + ((__instance.shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0))); Color color = Color.White * alpha; Vector2 origin = new Vector2(8f, 8f); int artifactOffset = ((Game1.currentGameTime.TotalGameTime.TotalMilliseconds % 1200.0 <= 400.0) ? ((int)(Game1.currentGameTime.TotalGameTime.TotalMilliseconds % 400.0 / 100.0) * 16) : 0); spriteBatch.Draw(textureModel.GetTexture(textureVariation), position2, new Rectangle(artifactOffset, textureOffset, 16, 16), color, 0f, origin, (__instance.scale.Y > 1f) ? __instance.getScale().Y : 4f, __instance.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (float)(__instance.isPassable() ? __instance.getBoundingBox(new Vector2(x, y)).Top : __instance.getBoundingBox(new Vector2(x, y)).Bottom) / 10000f); return(false); } if ((int)__instance.fragility != 2) { spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64 + 32, y * 64 + 51 + 4)), Game1.shadowTexture.Bounds, Color.White * alpha, 0f, new Vector2(Game1.shadowTexture.Bounds.Center.X, Game1.shadowTexture.Bounds.Center.Y), 4f, SpriteEffects.None, (float)__instance.getBoundingBox(new Vector2(x, y)).Bottom / 15000f); } Color color2 = Color.White * alpha; Vector2 origin2 = new Vector2(8f, 8f); Vector2 position3 = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64 + 32 + ((__instance.shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0), y * 64 + 32 + ((__instance.shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0))); if (__instance.ParentSheetIndex == 746) { origin2 = Vector2.Zero; position3 = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64, y * 64 - 64)); } spriteBatch.Draw(textureModel.GetTexture(textureVariation), position3, new Rectangle(xTileOffset, textureOffset, textureModel.TextureWidth, textureModel.TextureHeight), color2, 0f, origin2, (__instance.scale.Y > 1f) ? __instance.getScale().Y : 4f, __instance.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (float)(__instance.isPassable() ? __instance.getBoundingBox(new Vector2(x, y)).Top : __instance.getBoundingBox(new Vector2(x, y)).Bottom) / 10000f); if (__instance.heldObject.Value != null && __instance.IsSprinkler()) { // Unhandled sprinkler attachments return(false); } } // Check if product is ready to display (if applicable) if (!__instance.readyForHarvest) { return(false); } float base_sort = (float)((y + 1) * 64) / 10000f + __instance.tileLocation.X / 50000f; if ((int)__instance.parentSheetIndex == 105 || (int)__instance.parentSheetIndex == 264) { base_sort += 0.02f; } float yOffset = 4f * (float)Math.Round(Math.Sin(Game1.currentGameTime.TotalGameTime.TotalMilliseconds / 250.0), 2); spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64 - 8, (float)(y * 64 - 96 - 16) + yOffset)), new Microsoft.Xna.Framework.Rectangle(141, 465, 20, 24), Color.White * 0.75f, 0f, Vector2.Zero, 4f, SpriteEffects.None, base_sort + 1E-06f); if (__instance.heldObject.Value != null) { spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64 + 32, (float)(y * 64 - 64 - 8) + yOffset)), Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, __instance.heldObject.Value.parentSheetIndex, 16, 16), Color.White * 0.75f, 0f, new Vector2(8f, 8f), 4f, SpriteEffects.None, base_sort + 1E-05f); if (__instance.heldObject.Value is ColoredObject) { spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64 + 32, (float)(y * 64 - 64 - 8) + yOffset)), Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, (int)__instance.heldObject.Value.parentSheetIndex + 1, 16, 16), (__instance.heldObject.Value as ColoredObject).color.Value * 0.75f, 0f, new Vector2(8f, 8f), 4f, SpriteEffects.None, base_sort + 1.1E-05f); } } return(false); } return(true); }
private static bool Object_draw_Prefix(Object __instance, SpriteBatch spriteBatch, int x, int y, float alpha = 1f) { CustomOreNode node = customOreNodesList.Find(n => n.parentSheetIndex == __instance.ParentSheetIndex); if (node == null) { return(true); } if (__instance.Fragility != 2) { spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64 + 32, y * 64 + 51 + 4)), new Rectangle?(Game1.shadowTexture.Bounds), Color.White * alpha, 0f, new Vector2(Game1.shadowTexture.Bounds.Center.X, Game1.shadowTexture.Bounds.Center.Y), 4f, SpriteEffects.None, __instance.getBoundingBox(new Vector2(x, y)).Bottom / 15000f); } Vector2 position3 = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64 + 32 + ((__instance.shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0), y * 64 + 32 + ((__instance.shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0))); Rectangle?sourceRectangle2 = new Rectangle(node.spriteX, node.spriteY, node.spriteW, node.spriteH); Color color2 = Color.White * alpha; float rotation2 = 0f; Vector2 origin2 = new Vector2(8f, 8f); Vector2 vector2 = __instance.scale; spriteBatch.Draw(node.texture, position3, sourceRectangle2, color2, rotation2, origin2, (__instance.scale.Y > 1f) ? __instance.getScale().Y : 4f, __instance.Flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (__instance.isPassable() ? __instance.getBoundingBox(new Vector2(x, y)).Top : __instance.getBoundingBox(new Vector2(x, y)).Bottom) / 10000f); return(false); }