コード例 #1
0
ファイル: ObjectTarget.cs プロジェクト: mit4web/StardewMods
        /// <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)));
            }
        }
コード例 #2
0
 public static void DrawAnimation(
     SpriteBatch spriteBatch,
     Texture2D texture,
     Rectangle destinationRectangle,
     Rectangle?sourceRectangle,
     Color color,
     float rotation,
     Vector2 origin,
     SpriteEffects effects,
     float layerDepth,
     Object producer)
 {
     if (ProducerController.GetProducerConfig(producer.Name) is ProducerConfig producerConfig)
     {
         if (producerConfig.ProducingAnimation is Animation producingAnimation && producer.minutesUntilReady > 0 && producingAnimation.RelativeFrameIndex.Any())
         {
             int frame = producingAnimation.RelativeFrameIndex[((Game1.ticks + GetLocationSeed(producer.TileLocation)) % (producingAnimation.RelativeFrameIndex.Count * producingAnimation.FrameInterval)) / producingAnimation.FrameInterval];
             spriteBatch.Draw(texture, destinationRectangle, new Rectangle?(Object.getSourceRectForBigCraftable(producer.ParentSheetIndex + frame)), color, rotation, origin, effects, layerDepth);
             return;
         }
         else if (producerConfig.ReadyAnimation is Animation readyAnimation && producer.readyForHarvest.Value && readyAnimation.RelativeFrameIndex.Any())
         {
             int frame = readyAnimation.RelativeFrameIndex[((Game1.ticks + GetLocationSeed(producer.TileLocation)) % (readyAnimation.RelativeFrameIndex.Count * readyAnimation.FrameInterval)) / readyAnimation.FrameInterval];
             spriteBatch.Draw(texture, destinationRectangle, new Rectangle?(Object.getSourceRectForBigCraftable(producer.ParentSheetIndex + frame)), color, rotation, origin, effects, layerDepth);
             return;
         }
     }
コード例 #3
0
ファイル: GameHelper.cs プロジェクト: SlyryD/Stardew
        /// <summary>Get the sprite for an item.</summary>
        /// <param name="item">The item.</param>
        /// <param name="onlyCustom">Only return the sprite info if it's custom.</param>
        /// <returns>Returns a tuple containing the sprite sheet and the sprite's position and dimensions within the sheet.</returns>
        public SpriteInfo GetSprite(Item item, bool onlyCustom = false)
        {
            SObject obj = item as SObject;

            if (onlyCustom)
            {
                return(null);
            }

            // standard object
            if (obj != null)
            {
                return(obj.bigCraftable.Value
                    ? new SpriteInfo(Game1.bigCraftableSpriteSheet, SObject.getSourceRectForBigCraftable(obj.ParentSheetIndex))
                    : new SpriteInfo(Game1.objectSpriteSheet, Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, obj.ParentSheetIndex, SObject.spriteSheetTileSize, SObject.spriteSheetTileSize)));
            }

            // boots or ring
            if (item is Boots || item is Ring)
            {
                int indexInTileSheet = (item as Boots)?.indexInTileSheet ?? ((Ring)item).indexInTileSheet;
                return(new SpriteInfo(Game1.objectSpriteSheet, Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, indexInTileSheet, SObject.spriteSheetTileSize, SObject.spriteSheetTileSize)));
            }

            // unknown item
            return(null);
        }
コード例 #4
0
        /// <summary>Get whether the visible sprite intersects the specified coordinate. This can be an expensive test.</summary>
        /// <param name="tile">The tile to search.</param>
        /// <param name="position">The viewport-relative coordinates to search.</param>
        /// <param name="spriteArea">The approximate sprite area calculated by <see cref="GetSpriteArea"/>.</param>
        public override bool SpriteIntersectsPixel(Vector2 tile, Vector2 position, Rectangle spriteArea)
        {
            Object obj = (Object)this.Value;

            // get sprite data
            Texture2D spriteSheet;
            Rectangle sourceRectangle;

            if (obj is Furniture furniture)
            {
                spriteSheet     = Furniture.furnitureTexture;
                sourceRectangle = furniture.sourceRect.Value;
            }
            else if (obj is Fence fence)
            {
                spriteSheet     = this.Reflection.GetField <Lazy <Texture2D> >(obj, "fenceTexture").GetValue().Value;
                sourceRectangle = this.GetSourceRectangle(fence, Game1.currentLocation);
            }
            else if (obj.bigCraftable.Value)
            {
                spriteSheet     = Game1.bigCraftableSpriteSheet;
                sourceRectangle = Object.getSourceRectForBigCraftable(obj.ParentSheetIndex);
            }
            else
            {
                spriteSheet     = Game1.objectSpriteSheet;
                sourceRectangle = GameLocation.getSourceRectForObject(obj.ParentSheetIndex);
            }

            // check pixel from sprite sheet
            SpriteEffects spriteEffects = obj.Flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None;

            return(this.SpriteIntersectsPixel(tile, position, spriteArea, spriteSheet, sourceRectangle, spriteEffects));
        }
コード例 #5
0
ファイル: Patcher.cs プロジェクト: Pathoschild/smapi-mod-dump
        public static void Draw_Post(Torch __instance, SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
        {
            try
            {
                if (!Game1.eventUp || (Game1.currentLocation != null && Game1.currentLocation.currentEvent != null && Game1.currentLocation.currentEvent.showGroundObjects) || Game1.currentLocation.IsFarm)
                {
                    float draw_layer = Math.Max(0f, (((y + 1) * 64) - 24) / 10000f) + (x * 1E-05f);

                    // draw the upper half of the cookout kit even if isOn == false
                    if (__instance.IsCookoutKit() && !__instance.IsOn)
                    {
                        Rectangle r = StardewObject.getSourceRectForBigCraftable(__instance.ParentSheetIndex + 1);
                        r.Height -= 16;
                        Vector2 scaleFactor = __instance.getScale();
                        scaleFactor *= 4f;
                        Vector2 position    = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64, (y * 64) - 64 + 12));
                        var     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)(64f + (scaleFactor.Y / 2f)));
                        spriteBatch.Draw(Game1.bigCraftableSpriteSheet, destination, new Rectangle?(r), Color.White * alpha, 0f, Vector2.Zero, SpriteEffects.None, draw_layer + 0.0028f);
                    }
                }
            }
            catch (Exception e)
            {
                mod.ErrorLog("There was an exception in a patch", e);
            }
        }
コード例 #6
0
 private void RenderedWorld(object sender, RenderedWorldEventArgs e)
 {
     if (TrackedMachines.ContainsKey(Game1.currentLocation))
     {
         foreach (Vector2 tile in TrackedMachines[Game1.currentLocation])
         {
             Object obj = Game1.currentLocation.getObjectAtTile((int) tile.X, (int) tile.Y);
             Color color = determineColor(obj);
             if (color != Color.White)
             {
                 float alpha = Math.Min(Math.Max(config.AlphaValue, 0), 1);
                 int x = (int) tile.X;
                 int y = (int) tile.Y;
                 Vector2 vector2 = obj.getScale() * 4f;
                 Vector2 local = Game1.GlobalToLocal(Game1.viewport,
                     new Vector2(x * 64, y * 64 - 64));
                 Rectangle destinationRectangle = new Rectangle(
                     (int) (local.X - vector2.X / 2.0) + (obj.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0),
                     (int) (local.Y - vector2.Y / 2.0) + (obj.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0),
                     (int) (64.0 + vector2.X), (int) (128.0 + vector2.Y / 2.0));
                 e.SpriteBatch.Draw(Game1.bigCraftableSpriteSheet, destinationRectangle,
                     new Rectangle?(Object.getSourceRectForBigCraftable(obj.showNextIndex.Value
                         ? obj.ParentSheetIndex + 1
                         : obj.ParentSheetIndex)), color * alpha, 0.0f, Vector2.Zero, SpriteEffects.None,
                     (float) (Math.Max(0.0f, ((y + 1) * 64 - 24) / 10000f) +
                              (obj.ParentSheetIndex == 105 ? 0.00350000010803342 : 0.0) +
                              x * 9.99999974737875E-06));
             }
         }
     }
 }
コード例 #7
0
        public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
        {
            if (Game1.eventUp && (Game1.currentLocation == null || Game1.currentLocation.currentEvent == null || !Game1.currentLocation.currentEvent.showGroundObjects) && !Game1.currentLocation.IsFarm)
            {
                return;
            }
            if (!bigCraftable)
            {
                Rectangle sourceRect = GameLocation.getSourceRectForObject(base.ParentSheetIndex);
                sourceRect.Y      += 8;
                sourceRect.Height /= 2;
                Texture2D objectSpriteSheet = Game1.objectSpriteSheet;
                Vector2   position2         = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64, y * 64 + 32));
                Rectangle?sourceRectangle   = sourceRect;
                Color     white             = Color.White;
                Vector2   zero = Vector2.Zero;
                _ = scale;
                spriteBatch.Draw(objectSpriteSheet, position2, sourceRectangle, white, 0f, zero, (scale.Y > 1f) ? getScale().Y : 4f, SpriteEffects.None, (float)getBoundingBox(new Vector2(x, y)).Bottom / 10000f);
                spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64 + 32 + 2, y * 64 + 16)), new Rectangle(88, 1779, 30, 30), Color.PaleGoldenrod * (Game1.currentLocation.IsOutdoors ? 0.35f : 0.43f), 0f, new Vector2(15f, 15f), 4f + (float)(64.0 * Math.Sin((Game1.currentGameTime.TotalGameTime.TotalMilliseconds + (double)(x * 64 * 777) + (double)(y * 64 * 9746)) % 3140.0 / 1000.0) / 50.0), SpriteEffects.None, 1f);
                sourceRect.X      = 276 + (int)((Game1.currentGameTime.TotalGameTime.TotalMilliseconds + (double)(x * 3204) + (double)(y * 49)) % 700.0 / 100.0) * 8;
                sourceRect.Y      = 1965;
                sourceRect.Width  = 8;
                sourceRect.Height = 8;
                spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64 + 32 + 4, y * 64 + 16 + 4)), sourceRect, Color.White * 0.75f, 0f, new Vector2(4f, 4f), 3f, SpriteEffects.None, (float)(getBoundingBox(new Vector2(x, y)).Bottom + 1) / 10000f);
                for (int i = 0; i < ashes.Length; i++)
                {
                    spriteBatch.Draw(Game1.objectSpriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * 64 + 32) + ashes[i].X, (float)(y * 64 + 32) + ashes[i].Y)), new Rectangle(344 + i % 3, 53, 1, 1), Color.White * 0.5f * ((-100f - ashes[i].Y / 2f) / -100f), 0f, Vector2.Zero, 3f, SpriteEffects.None, (float)getBoundingBox(new Vector2(x, y)).Bottom / 10000f);
                }
                return;
            }
            base.draw(spriteBatch, x, y, alpha);
            float draw_layer = Math.Max(0f, (float)((y + 1) * 64 - 24) / 10000f) + (float)x * 1E-05f;

            if (!isOn)
            {
                return;
            }
            if ((int)parentSheetIndex == 146 || (int)parentSheetIndex == 278)
            {
                spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64 + 16 - 4, y * 64 - 8)), new Rectangle(276 + (int)((Game1.currentGameTime.TotalGameTime.TotalMilliseconds + (double)(x * 3047) + (double)(y * 88)) % 400.0 / 100.0) * 12, 1985, 12, 11), Color.White, 0f, Vector2.Zero, 3f, SpriteEffects.None, draw_layer + 0.0008f);
                spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64 + 32 - 12, y * 64)), new Rectangle(276 + (int)((Game1.currentGameTime.TotalGameTime.TotalMilliseconds + (double)(x * 2047) + (double)(y * 98)) % 400.0 / 100.0) * 12, 1985, 12, 11), Color.White, 0f, Vector2.Zero, 3f, SpriteEffects.None, draw_layer + 0.0009f);
                spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64 + 32 - 20, y * 64 + 12)), new Rectangle(276 + (int)((Game1.currentGameTime.TotalGameTime.TotalMilliseconds + (double)(x * 2077) + (double)(y * 98)) % 400.0 / 100.0) * 12, 1985, 12, 11), Color.White, 0f, Vector2.Zero, 3f, SpriteEffects.None, draw_layer + 0.001f);
                if ((int)parentSheetIndex == 278)
                {
                    Rectangle r = Object.getSourceRectForBigCraftable(base.ParentSheetIndex + 1);
                    r.Height -= 16;
                    Vector2 scaleFactor = getScale();
                    scaleFactor *= 4f;
                    Vector2   position    = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64, y * 64 - 64 + 12));
                    Rectangle destination = new Rectangle((int)(position.X - scaleFactor.X / 2f) + ((shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0), (int)(position.Y - scaleFactor.Y / 2f) + ((shakeTimer > 0) ? Game1.random.Next(-1, 2) : 0), (int)(64f + scaleFactor.X), (int)(64f + scaleFactor.Y / 2f));
                    spriteBatch.Draw(Game1.bigCraftableSpriteSheet, destination, r, Color.White * alpha, 0f, Vector2.Zero, SpriteEffects.None, draw_layer + 0.0028f);
                }
            }
            else
            {
                spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64 + 16 - 8, y * 64 - 64 + 8)), new Rectangle(276 + (int)((Game1.currentGameTime.TotalGameTime.TotalMilliseconds + (double)(x * 3047) + (double)(y * 88)) % 400.0 / 100.0) * 12, 1985, 12, 11), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, draw_layer + 0.0008f);
            }
        }
コード例 #8
0
ファイル: GameHelper.cs プロジェクト: Andrey1225/StardewMods
        /// <summary>Get the sprite for an item.</summary>
        /// <param name="item">The item.</param>
        /// <param name="onlyCustom">Only return the sprite info if it's custom.</param>
        /// <returns>Returns a tuple containing the sprite sheet and the sprite's position and dimensions within the sheet.</returns>
        public SpriteInfo GetSprite(Item item, bool onlyCustom = false)
        {
            SObject obj = item as SObject;

            // Custom Farming Redux
            if (obj != null && this.CustomFarmingRedux.IsLoaded)
            {
                SpriteInfo data = this.CustomFarmingRedux.GetSprite(obj);
                if (data != null)
                {
                    return(data);
                }
            }

            if (onlyCustom)
            {
                return(null);
            }

            // standard object
            if (obj != null)
            {
                return(obj.bigCraftable.Value
                    ? new SpriteInfo(Game1.bigCraftableSpriteSheet, SObject.getSourceRectForBigCraftable(obj.ParentSheetIndex))
                    : new SpriteInfo(Game1.objectSpriteSheet, Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, obj.ParentSheetIndex, SObject.spriteSheetTileSize, SObject.spriteSheetTileSize)));
            }

            // boots or ring
            if (item is Boots || item is Ring)
            {
                int indexInTileSheet = (item as Boots)?.indexInTileSheet ?? ((Ring)item).indexInTileSheet;
                return(new SpriteInfo(Game1.objectSpriteSheet, Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, indexInTileSheet, SObject.spriteSheetTileSize, SObject.spriteSheetTileSize)));
            }

            // clothing
            if (item is Clothing clothing)
            {
                switch (clothing.clothesType.Value)
                {
                case (int)Clothing.ClothesType.SHIRT:
                    return(new ShirtSpriteInfo(clothing));

                case (int)Clothing.ClothesType.PANTS:
                    return(new SpriteInfo(FarmerRenderer.pantsTexture, new Rectangle(192 * (clothing.indexInTileSheetMale.Value % (FarmerRenderer.pantsTexture.Width / 192)), 688 * (clothing.indexInTileSheetMale.Value / (FarmerRenderer.pantsTexture.Width / 192)) + 672, 16, 16)));
                }
            }

            // hat
            if (item is Hat hat)
            {
                return(new SpriteInfo(FarmerRenderer.hatsTexture, new Rectangle(hat.which.Value * 20 % FarmerRenderer.hatsTexture.Width, hat.which.Value * 20 / FarmerRenderer.hatsTexture.Width * 20 * 4, 20, 20)));
            }

            // unknown item
            return(null);
        }
コード例 #9
0
ファイル: GameHelper.cs プロジェクト: amireh/StardewMods
        /// <summary>Get the sprite for an item.</summary>
        /// <param name="item">The item.</param>
        /// <returns>Returns a tuple containing the sprite sheet and the sprite's position and dimensions within the sheet.</returns>
        public static Tuple <Texture2D, Rectangle> GetSprite(Item item)
        {
            // standard object
            if (item is Object obj)
            {
                return(obj.bigCraftable
                    ? Tuple.Create(Game1.bigCraftableSpriteSheet, Object.getSourceRectForBigCraftable(obj.ParentSheetIndex))
                    : Tuple.Create(Game1.objectSpriteSheet, Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, obj.ParentSheetIndex, Object.spriteSheetTileSize, Object.spriteSheetTileSize)));
            }

            // boots or ring
            if (item is Boots || item is Ring)
            {
                int indexInTileSheet = (item as Boots)?.indexInTileSheet ?? ((Ring)item).indexInTileSheet;
                return(Tuple.Create(Game1.objectSpriteSheet, Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, indexInTileSheet, Object.spriteSheetTileSize, Object.spriteSheetTileSize)));
            }

            // unknown item
            return(null);
        }
コード例 #10
0
        /// <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)));
            }
        }
コード例 #11
0
        private Rectangle GetColoredItemSourceRectangle(ColoredObject @object)
        {
            var index = @object.ParentSheetIndex;

            if (index < 0)
            {
                return(new(322, 498, 12, 12));
            }

            if ([email protected])
            {
                index++;
            }
            if (@object.bigCraftable.Value)
            {
                return(SObject.getSourceRectForBigCraftable(index));
            }
            else
            {
                return(Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, index, 16, 16));
            }
        }
コード例 #12
0
        /// <summary>
        /// Patch for drawing a custom sprite (if available) for the object held by the instance.
        /// </summary>
        /// <param name="__instance">Object to be drawn.</param>
        /// <param name="spriteBatch">Sprite batch to draw onto.</param>
        /// <param name="x">The x tile coordinate.</param>
        /// <param name="y">The y tile coordinate.</param>
        /// <param name="alpha">Transparency.</param>
        public static bool Prefix(SObject __instance, SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
        {
            if (
                !(bool)__instance.bigCraftable.Value ||
                !(bool)__instance.readyForHarvest.Value ||
                __instance.heldObject.Value == null ||
                !SpriteLoader.TryLoadSprite(__instance.heldObject.Value, out Texture2D texture, out Rectangle sourceRect)
                )
            {
                return(true);
            }

            Vector2 value = 4 * __instance.getScale();

            Vector2 vector = Game1.GlobalToLocal(
                viewport: Game1.viewport,
                globalPosition: new Vector2(x * 64, y * 64 - 64)
                );

            Rectangle destinationRectangle = new Rectangle(
                (int)(vector.X - value.X / 2f) + ((__instance.shakeTimer > 0)
                    ? Game1.random.Next(-1, 2) : 0),
                (int)(vector.Y - value.Y / 2f) + ((__instance.shakeTimer > 0)
                    ? Game1.random.Next(-1, 2) : 0),
                (int)(64f + value.X),
                (int)(128f + value.Y / 2f)
                );

            spriteBatch.Draw(
                texture: Game1.bigCraftableSpriteSheet,
                destinationRectangle: destinationRectangle,
                sourceRectangle: SObject.getSourceRectForBigCraftable(__instance.showNextIndex.Value
                    ? (__instance.ParentSheetIndex + 1) : __instance.ParentSheetIndex),
                color: Color.White * alpha,
                rotation: 0f,
                origin: Vector2.Zero,
                effects: SpriteEffects.None,
                layerDepth: Math.Max(0f, ((y + 1) * 64 - 24) / 10000f) + (__instance.ParentSheetIndex == 105 ? 0.0035f : 0f) + x * 1E-05f
                );

            if (__instance.Name.Equals("Loom") && __instance.MinutesUntilReady > 0)
            {
                spriteBatch.Draw(
                    texture: Game1.objectSpriteSheet,
                    position: __instance.getLocalPosition(Game1.viewport) + new Vector2(32f, 0f),
                    sourceRectangle: Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, 435, 16, 16),
                    color: Color.White * alpha,
                    rotation: __instance.Scale.X,
                    origin: new Vector2(8f, 8f),
                    scale: 4f,
                    effects: SpriteEffects.None,
                    layerDepth: Math.Max(0f, (y + 1) * 64 / 10000f + 0.0001f + x * 1E-05f)
                    );
            }

            if (__instance.isLamp.Value && Game1.isDarkOut())
            {
                spriteBatch.Draw(
                    texture: Game1.mouseCursors,
                    position: vector + new Vector2(-32f, -32f),
                    sourceRectangle: new Rectangle(88, 1779, 32, 32),
                    color: Color.White * 0.75f,
                    rotation: 0f,
                    origin: Vector2.Zero,
                    scale: 4f,
                    effects: SpriteEffects.None,
                    layerDepth: Math.Max(0f, ((y + 1) * 64 - 20) / 10000f)
                    );
            }

            if (__instance.ParentSheetIndex == 126 && __instance.Quality != 0)
            {
                spriteBatch.Draw(
                    texture: FarmerRenderer.hatsTexture,
                    position: vector + new Vector2(-3f, -6f) * 4f,
                    sourceRectangle: new Rectangle(
                        (__instance.Quality - 1) * 20 % FarmerRenderer.hatsTexture.Width,
                        (__instance.Quality - 1) * 20 / FarmerRenderer.hatsTexture.Width * 20 * 4,
                        20,
                        20
                        ),
                    color: Color.White * alpha,
                    rotation: 0f,
                    origin: Vector2.Zero,
                    scale: 4f,
                    effects: SpriteEffects.None,
                    layerDepth: Math.Max(0f, ((y + 1) * 64 - 20) / 10000f) + x * 1E-05f
                    );
            }

            TimeSpan timeSpan = DateTime.UtcNow.TimeOfDay;
            float    num6     = 4f * (float)Math.Round(Math.Sin(timeSpan.TotalMilliseconds / 250.0), 2);

            spriteBatch.Draw(
                texture: Game1.mouseCursors,
                position: Game1.GlobalToLocal(
                    viewport: Game1.viewport,
                    globalPosition: new Vector2(
                        x * 64 - 8,
                        y * 64 - 96 - 16 + num6
                        )
                    ),
                sourceRectangle: new Rectangle(141, 465, 20, 24),
                color: Color.White * 0.75f,
                rotation: 0f,
                origin: Vector2.Zero,
                scale: 4f,
                effects: SpriteEffects.None,
                layerDepth: (y + 1) * 64 / 10000f + 1E-06f + __instance.TileLocation.X / 10000f
                + ((__instance.ParentSheetIndex == 105) ? 0.0015f : 0f)
                );

            spriteBatch.Draw(
                texture: texture,
                position: Game1.GlobalToLocal(
                    viewport: Game1.viewport,
                    globalPosition: new Vector2(
                        x * 64 + 32,
                        y * 64 - 64 - 8 + num6
                        )
                    ),
                sourceRectangle: sourceRect,
                color: Color.White * 0.75f,
                rotation: 0f,
                origin: new Vector2(8f, 8f),
                scale: 4f,
                effects: SpriteEffects.None,
                layerDepth: (y + 1) * 64 / 10000f + 1E-05f + __instance.TileLocation.X / 10000f
                + ((__instance.ParentSheetIndex == 105) ? 0.0015f : 0f)
                );

            return(false);
        }
コード例 #13
0
        /// <param name="DrawStack">True if <see cref="Item.Stack"/> should be drawn</param>
        /// <param name="DrawQuality">True if <see cref="Object.Quality"/> should be drawn</param>
        /// <param name="IconScale">Does not affect the scaling for the quality, quantity, or other special rendered things like the capacity bar for a watering can</param>
        public static void DrawItem(SpriteBatch b, Rectangle Destination, Item Item, bool DrawStack, bool DrawQuality, float IconScale, float Transparency, Color Overlay, Color StackColor)
        {
            if (Destination.Width != Destination.Height)
            {
                throw new InvalidOperationException("Can only call DrawItem on a perfect square Destination");
            }

            //  Normally I'd just use Item.drawInMenu but that method doesn't scale stack size, qualities, or shadows correctly and thus will only display correctly at the default size of 64x64.
            //  Some items also render several textures to the destination point, and use hardcoded offsets for the sprites that also don't respect desired scaling. (Such as wallpapers or watering cans)
            //  So this method is my attempt at re-creating the Item.drawInMenu implementations in a way that will correctly scale to the desired Destination rectangle.
            //  It doesn't handle all cases correctly, but whatever, it's close enough

            DrawStack   = DrawStack && (Item.maximumStackSize() > 1 || Item.Stack > 1);
            DrawQuality = DrawQuality && Item is Object Obj && Enum.IsDefined(typeof(ObjectQuality), Obj.Quality);

            int       ScaledIconSize        = (int)(Destination.Width * IconScale * 0.8f);
            Rectangle ScaledIconDestination = new Rectangle(Destination.Center.X - ScaledIconSize / 2, Destination.Center.Y - ScaledIconSize / 2, ScaledIconSize, ScaledIconSize);

            Texture2D SourceTexture          = null;
            Rectangle?SourceTextureRectangle = null;

            if (Item is ItemBag Bag)
            {
                float   BaseScale          = Destination.Width / (float)BagInventoryMenu.DefaultInventoryIconSize;
                Vector2 OffsetDueToScaling = new Vector2((BaseScale - 1.0f) * BagInventoryMenu.DefaultInventoryIconSize * 0.5f); // I honestly forget why I needed this lmao. Maybe ItemBag.drawInMenu override was scaling around a different origin or some shit
                Bag.drawInMenu(b, new Vector2(Destination.X, Destination.Y) + OffsetDueToScaling, IconScale * Destination.Width / 64f * 0.8f, Transparency, 1.0f, StackDrawType.Hide, Overlay, false);
            }
            else if (Item is Tool Tool)
            {
                if (Item is MeleeWeapon Weapon)
                {
                    SourceTexture          = MeleeWeapon.weaponsTexture;
                    SourceTextureRectangle = new Rectangle?(Game1.getSquareSourceRectForNonStandardTileSheet(SourceTexture, 16, 16, Tool.IndexOfMenuItemView));
                }
                else
                {
                    SourceTexture          = Game1.toolSpriteSheet;
                    SourceTextureRectangle = new Rectangle?(Game1.getSquareSourceRectForNonStandardTileSheet(SourceTexture, 16, 16, Tool.IndexOfMenuItemView));
                }
            }
            else if (Item is Ring Ring)
            {
                SourceTexture          = Game1.objectSpriteSheet;
                SourceTextureRectangle = new Rectangle?(Game1.getSourceRectForStandardTileSheet(SourceTexture, Ring.indexInTileSheet, 16, 16));
            }
            else if (Item is Hat Hat)
            {
                SourceTexture          = FarmerRenderer.hatsTexture;
                SourceTextureRectangle = new Rectangle?(new Rectangle(Hat.which * 20 % SourceTexture.Width, Hat.which * 20 / SourceTexture.Width * 20 * 4, 20, 20));
            }
            else if (Item is Boots Boots)
            {
                SourceTexture          = Game1.objectSpriteSheet;
                SourceTextureRectangle = new Rectangle?(Game1.getSourceRectForStandardTileSheet(SourceTexture, Boots.indexInTileSheet.Value, 16, 16));
            }
            else if (Item is Clothing Clothing)
            {
                Color clothes_color = Clothing.clothesColor;
                if (Clothing.isPrismatic.Value)
                {
                    clothes_color = Utility.GetPrismaticColor(0);
                }
                if (Clothing.clothesType.Value != 0)
                {
                    if (Clothing.clothesType.Value == 1)
                    {
                        b.Draw(FarmerRenderer.pantsTexture, Destination,
                               new Rectangle?(new Rectangle(192 * (Clothing.indexInTileSheetMale.Value % (FarmerRenderer.pantsTexture.Width / 192)), 688 * (Clothing.indexInTileSheetMale.Value / (FarmerRenderer.pantsTexture.Width / 192)) + 672, 16, 16)),
                               Utility.MultiplyColor(clothes_color, Color.White) * Transparency, 0f, Vector2.Zero, SpriteEffects.None, 1f);
                        //b.Draw(FarmerRenderer.pantsTexture, location + new Vector2(32f, 32f),
                        //new Rectangle?(new Rectangle(192 * (this.indexInTileSheetMale.Value % (FarmerRenderer.pantsTexture.Width / 192)), 688 * (this.indexInTileSheetMale.Value / (FarmerRenderer.pantsTexture.Width / 192)) + 672, 16, 16)),
                        //Utility.MultiplyColor(clothes_color, color) * transparency, 0f, new Vector2(8f, 8f), scaleSize * 4f, SpriteEffects.None, layerDepth);
                    }
                }
                else
                {
                    b.Draw(FarmerRenderer.shirtsTexture, Destination,
                           new Rectangle?(new Rectangle(Clothing.indexInTileSheetMale.Value * 8 % 128, Clothing.indexInTileSheetMale.Value * 8 / 128 * 32, 8, 8)),
                           Color.White * Transparency, 0f, Vector2.Zero, SpriteEffects.None, 1f);
                    b.Draw(FarmerRenderer.shirtsTexture, Destination,
                           new Rectangle?(new Rectangle(Clothing.indexInTileSheetMale.Value * 8 % 128 + 128, Clothing.indexInTileSheetMale.Value * 8 / 128 * 32, 8, 8)),
                           Utility.MultiplyColor(clothes_color, Color.White) * Transparency, 0f, Vector2.Zero, SpriteEffects.None, 1f);
                    //b.Draw(FarmerRenderer.shirtsTexture, location + new Vector2(32f, 32f), new Rectangle?(new Rectangle(this.indexInTileSheetMale.Value * 8 % 128, this.indexInTileSheetMale.Value * 8 / 128 * 32, 8, 8)), color * transparency, 0f, new Vector2(4f, 4f), scaleSize * 4f, SpriteEffects.None, layerDepth);
                    //b.Draw(FarmerRenderer.shirtsTexture, location + new Vector2(32f, 32f), new Rectangle?(new Rectangle(this.indexInTileSheetMale.Value * 8 % 128 + 128, this.indexInTileSheetMale.Value * 8 / 128 * 32, 8, 8)), Utility.MultiplyColor(clothes_color, color) * transparency, 0f, new Vector2(4f, 4f), scaleSize * 4f, SpriteEffects.None, layerDepth + dye_portion_layer_offset);
                }
            }
            else if (Item is Fence Fence)
            {
                int DrawSum            = Fence.getDrawSum(Game1.currentLocation);
                int SourceRectPosition = Fence.fenceDrawGuide[DrawSum];
                SourceTexture = Fence.fenceTexture.Value;
                if (Fence.isGate)
                {
                    if (DrawSum == 110)
                    {
                        SourceTextureRectangle = new Rectangle?(new Rectangle(0, 512, 88, 24));
                    }
                    else if (DrawSum == 1500)
                    {
                        SourceTextureRectangle = new Rectangle?(new Rectangle(112, 512, 16, 64));
                    }
                }
                SourceTextureRectangle = new Rectangle?(Game1.getArbitrarySourceRect(SourceTexture, 64, 128, SourceRectPosition));
            }
            else if (Item is Furniture Furniture)
            {
                SourceTexture          = Furniture.furnitureTexture;
                SourceTextureRectangle = Furniture.defaultSourceRect;
            }
            else if (Item is Wallpaper WP)
            {
                SourceTexture          = null; // Wallpaper.wallpaperTexture; //Stardew Valley beta 1.5.5 no longer has a Wallpaper.wallpaperTexture field. No idea where it is now
                SourceTextureRectangle = WP.sourceRect;
            }
            else
            {
                if (Item is Object BigCraftable && BigCraftable.bigCraftable.Value)
                {
                    SourceTexture          = Game1.bigCraftableSpriteSheet;
                    SourceTextureRectangle = Object.getSourceRectForBigCraftable(Item.ParentSheetIndex);
                    //ScaledIconDestination = new Rectangle(ScaledIconDestination.X + ScaledIconDestination.Width / 8, ScaledIconDestination.Y - ScaledIconDestination.Height / 8,
                    //    ScaledIconDestination.Width - ScaledIconDestination.Width / 4, ScaledIconDestination.Height + ScaledIconDestination.Height / 4);
                    ScaledIconDestination = new Rectangle(ScaledIconDestination.X + ScaledIconDestination.Width / 4, ScaledIconDestination.Y,
                                                          ScaledIconDestination.Width - ScaledIconDestination.Width / 2, ScaledIconDestination.Height);
                    //From decompiled .exe code:
                    //spriteBatch.Draw(Game1.bigCraftableSpriteSheet, location + new Vector2(32f, 32f), new Rectangle?(sourceRect), color * transparency,
                    //    0f, new Vector2(8f, 16f), 4f * ((double)scaleSize < 0.2 ? scaleSize : scaleSize / 2f), SpriteEffects.None, layerDepth);
                }
コード例 #14
0
 public virtual void draw(SpriteBatch spriteBatch, bool localPosition = false, int xOffset = 0, int yOffset = 0)
 {
     if (this.local)
     {
         localPosition = true;
     }
     if (this.currentParentTileIndex < 0 || this.delayBeforeAnimationStart > 0)
     {
         return;
     }
     if (this.text != null)
     {
         spriteBatch.DrawString(Game1.dialogueFont, this.text, localPosition ? this.Position : Game1.GlobalToLocal(Game1.viewport, this.Position), this.color * this.alpha, this.rotation, Vector2.Zero, this.scale, SpriteEffects.None, this.layerDepth);
     }
     else if (this.Texture != null)
     {
         spriteBatch.Draw(this.Texture, (localPosition ? this.Position : Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((int)this.Position.X + xOffset), (float)((int)this.Position.Y + yOffset)))) + new Vector2((float)(this.sourceRect.Width / 2), (float)(this.sourceRect.Height / 2)) * this.scale + new Vector2((double)this.shakeIntensity > 0.0 ? (float)Game1.random.Next(-(int)this.shakeIntensity, (int)this.shakeIntensity + 1) : 0.0f, (double)this.shakeIntensity > 0.0 ? (float)Game1.random.Next(-(int)this.shakeIntensity, (int)this.shakeIntensity + 1) : 0.0f), new Rectangle?(this.sourceRect), this.color * this.alpha, this.rotation, new Vector2((float)(this.sourceRect.Width / 2), (float)(this.sourceRect.Height / 2)), this.scale, this.flipped ? SpriteEffects.FlipHorizontally : (this.verticalFlipped ? SpriteEffects.FlipVertically : SpriteEffects.None), (double)this.layerDepth >= 0.0 ? this.layerDepth : (float)(((double)this.Position.Y + (double)this.sourceRect.Height) / 10000.0));
     }
     else if (this.bigCraftable)
     {
         spriteBatch.Draw(Game1.bigCraftableSpriteSheet, localPosition ? this.Position : Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((int)this.Position.X + xOffset), (float)((int)this.Position.Y + yOffset))) + new Vector2((float)(this.sourceRect.Width / 2), (float)(this.sourceRect.Height / 2)), new Rectangle?(Object.getSourceRectForBigCraftable(this.currentParentTileIndex)), Color.White, 0.0f, new Vector2((float)(this.sourceRect.Width / 2), (float)(this.sourceRect.Height / 2)), this.scale, SpriteEffects.None, (float)(((double)this.Position.Y + (double)(Game1.tileSize / 2)) / 10000.0));
     }
     else
     {
         if (this.swordswipe)
         {
             return;
         }
         spriteBatch.Draw(Game1.objectSpriteSheet, localPosition ? this.Position : Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((int)this.Position.X + xOffset), (float)((int)this.Position.Y + yOffset))) + new Vector2(8f, 8f) * (float)Game1.pixelZoom + new Vector2((double)this.shakeIntensity > 0.0 ? (float)Game1.random.Next(-(int)this.shakeIntensity, (int)this.shakeIntensity + 1) : 0.0f, (double)this.shakeIntensity > 0.0 ? (float)Game1.random.Next(-(int)this.shakeIntensity, (int)this.shakeIntensity + 1) : 0.0f), new Rectangle?(Game1.currentLocation.getSourceRectForObject(this.currentParentTileIndex)), (this.flash ? Color.LightBlue * 0.85f : Color.White) * this.alpha, this.rotation, new Vector2(8f, 8f), (float)Game1.pixelZoom * this.scale, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (double)this.layerDepth >= 0.0 ? this.layerDepth : (float)(((double)this.Position.Y + (double)(Game1.tileSize / 2)) / 10000.0));
     }
 }
コード例 #15
0
        /// <summary>Draw the correct texture based on <see cref="SObject.preservedParentSheetIndex"/> or <see cref="SObject.Name"/>.</summary>
        private static bool Prefix(SObject __instance, SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, Color color, StackDrawType drawStackNumber, bool drawShadow, int stackNumber)
        {
            if (!ModEntry.Instance.GetDrawInfo(__instance, out Texture2D spriteSheet, out Rectangle position, out Rectangle iconPosition))
            {
                return(true);
            }
            bool flag;

            if (Constants.TargetPlatform == GamePlatform.Android)
            {
                if (__instance.IsRecipe)
                {
                    transparency = 0.5f;
                }
                flag = (((drawStackNumber == StackDrawType.Draw) && (__instance.maximumStackSize() > 1) && (__instance.Stack > 1)) || (drawStackNumber == StackDrawType.Draw_OneInclusive)) && (scaleSize > 0.3) && (__instance.Stack != int.MaxValue) && (__instance.maximumStackSize() > 1) && (scaleSize > 0.3) && (__instance.Stack != int.MaxValue) && (__instance.Stack > 1);
                if (__instance.IsRecipe)
                {
                    flag = false;
                }
                int itemSlotSize = (int)typeof(StardewValley.Item).GetProperty("itemSlotSize", BindingFlags.Instance | BindingFlags.Public).GetValue(__instance);
                if (__instance.bigCraftable.Value)
                {
                    Microsoft.Xna.Framework.Rectangle rectForBigCraftable = SObject.getSourceRectForBigCraftable(__instance.ParentSheetIndex);
                    spriteBatch.Draw(Game1.bigCraftableSpriteSheet, location + new Vector2((float)(itemSlotSize / 2), (float)(itemSlotSize / 2)), new Rectangle?(rectForBigCraftable), Color.White * transparency, 0f, new Vector2(8f, 16f), (float)(4f * ((scaleSize < 0.2) ? scaleSize : (scaleSize / 2f))), SpriteEffects.None, layerDepth);
                    if (flag)
                    {
                        Utility.drawTinyDigits((stackNumber == -1) ? (__instance.Stack) : stackNumber, spriteBatch, location + new Vector2(itemSlotSize - Utility.getWidthOfTinyDigitString((stackNumber == -1) ? (__instance.Stack) : stackNumber, 3f * scaleSize) - (3f * scaleSize), itemSlotSize - (24f * scaleSize)), 3f * scaleSize, layerDepth, Color.White);
                    }
                    if (color != Color.White)
                    {
                        spriteBatch.Draw(Game1.bigCraftableSpriteSheet, location + new Vector2((float)(itemSlotSize / 2), (float)(itemSlotSize / 2)), new Rectangle?(rectForBigCraftable), color * transparency, 0f, new Vector2(8f, 16f), (float)(4f * ((scaleSize < 0.2) ? scaleSize : (scaleSize / 2f))), SpriteEffects.None, layerDepth);
                    }
                }
                else
                {
                    if ((scaleSize == 1f) && __instance.ParentSheetIndex != 590)
                    {
                        spriteBatch.Draw(Game1.shadowTexture, location + new Vector2(Game1.tileSize / 2, Game1.tileSize * 3 / 4), new Microsoft.Xna.Framework.Rectangle?(Game1.shadowTexture.Bounds), Color.White * 0.5f, 0.0f, new Vector2(Game1.shadowTexture.Bounds.Center.X, Game1.shadowTexture.Bounds.Center.Y), 3f, SpriteEffects.None, layerDepth - 0.0001f);
                    }
                    spriteBatch.Draw(spriteSheet, location + new Vector2((int)(itemSlotSize / 2 * (double)scaleSize), (int)(itemSlotSize / 2 * (double)scaleSize)), new Microsoft.Xna.Framework.Rectangle?(position), Color.White * transparency, 0.0f, new Vector2(8f, 8f) * scaleSize, Game1.pixelZoom * scaleSize, SpriteEffects.None, layerDepth);
                    if (flag)
                    {
                        Utility.drawTinyDigits((stackNumber == -1) ? (__instance.Stack) : stackNumber, spriteBatch, location + new Vector2(itemSlotSize - Utility.getWidthOfTinyDigitString((stackNumber == -1) ? (__instance.Stack) : stackNumber, 3f * scaleSize) - (3f * scaleSize), itemSlotSize - (24f * scaleSize)), 3f * scaleSize, layerDepth, Color.White);
                    }
                    if (color != Color.White)
                    {
                        spriteBatch.Draw(spriteSheet, location + new Vector2((int)(itemSlotSize / 2 * (double)scaleSize), (int)(itemSlotSize / 2 * (double)scaleSize)), new Microsoft.Xna.Framework.Rectangle?(position), color * transparency, 0.0f, new Vector2(8f, 8f) * scaleSize, Game1.pixelZoom * scaleSize, SpriteEffects.None, layerDepth);
                    }
                    //By popular demand, don't show icons near the mouse cursor, which are drawn with lowered transparency.
                    if (transparency >= 1 && iconPosition != Rectangle.Empty)
                    {
                        spriteBatch.Draw(Game1.objectSpriteSheet, location + new Vector2(itemSlotSize / 6 * scaleSize, itemSlotSize / 6 * scaleSize), new Microsoft.Xna.Framework.Rectangle?(iconPosition), Color.White * transparency, 0.0f, new Vector2(4f, 4f), (3f / 2f) * scaleSize, SpriteEffects.None, layerDepth);
                    }
                    if (drawStackNumber != StackDrawType.Hide && (__instance.Quality > 0))
                    {
                        if (__instance.Quality >= 4)
                        {
                            Math.Cos((Game1.currentGameTime.TotalGameTime.Milliseconds * 3.1415926535897931) / 512.0);
                        }
                        spriteBatch.Draw(Game1.mouseCursors, location + new Vector2((itemSlotSize / 2) - (30f * scaleSize), itemSlotSize - (24f * scaleSize)), new Rectangle?((__instance.quality < 4) ? new Rectangle(0x152 + ((__instance.Quality - 1) * 8), 400, 8, 8) : new Rectangle(0x15a, 0x187, 8, 8)), Color.White * transparency, 0f, new Vector2(4f, 4f), (float)(3f * scaleSize), SpriteEffects.None, layerDepth);
                    }
                    if (__instance.Category == -22 && __instance.uses.Value > 0)
                    {
                        float power = ((float)(FishingRod.maxTackleUses - __instance.uses.Value) + 0.0f) / (float)FishingRod.maxTackleUses;
                        spriteBatch.Draw(Game1.staminaRect, new Rectangle((int)(location.X + 8f), (int)((location.Y + itemSlotSize) - 16f), (int)((itemSlotSize - 0x10) * power), 8), Utility.getRedToGreenLerpColor(power));
                    }
                }
                if (__instance.IsRecipe)
                {
                    scaleSize *= 0.5f;
                    spriteBatch.Draw(Game1.objectSpriteSheet, location + new Vector2(-12f * scaleSize, -20f * scaleSize), new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, 0x1c3, 0x10, 0x10)), Color.White, 0f, Vector2.Zero, (float)(4f * scaleSize), SpriteEffects.None, layerDepth + 0.0001f);
                }
                return(false);
            }
            if (__instance.IsRecipe)
            {
                transparency = 0.5f;
                scaleSize   *= 0.75f;
            }
            flag = (drawStackNumber == StackDrawType.Draw && __instance.maximumStackSize() > 1 && __instance.Stack > 1 || drawStackNumber == StackDrawType.Draw_OneInclusive) && (double)scaleSize > 0.3 && __instance.Stack != int.MaxValue;
            if (__instance.IsRecipe)
            {
                flag = false;
            }
            if (__instance.bigCraftable.Value)
            {
                Microsoft.Xna.Framework.Rectangle rectForBigCraftable = SObject.getSourceRectForBigCraftable(__instance.ParentSheetIndex);
                spriteBatch.Draw(Game1.bigCraftableSpriteSheet, location + new Vector2(32f, 32f), new Microsoft.Xna.Framework.Rectangle?(rectForBigCraftable), color * transparency, 0.0f, new Vector2(8f, 16f), (float)(4.0 * ((double)scaleSize < 0.2 ? (double)scaleSize : (double)scaleSize / 2.0)), SpriteEffects.None, layerDepth);
                if (flag)
                {
                    Utility.drawTinyDigits(__instance.Stack, spriteBatch, location + new Vector2((float)(64 - Utility.getWidthOfTinyDigitString(__instance.Stack, 3f * scaleSize)) + 3f * scaleSize, (float)(64.0 - 18.0 * (double)scaleSize + 2.0)), 3f * scaleSize, 1f, color);
                }
            }
            else
            {
                if (__instance.ParentSheetIndex != 590 & drawShadow)
                {
                    spriteBatch.Draw(Game1.shadowTexture, location + new Vector2(32f, 48f), new Microsoft.Xna.Framework.Rectangle?(Game1.shadowTexture.Bounds), color * 0.5f, 0.0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), 3f, SpriteEffects.None, layerDepth - 0.0001f);
                }
                // modified
                spriteBatch.Draw(spriteSheet, location + new Vector2((float)(int)(32.0 * (double)scaleSize), (float)(int)(32.0 * (double)scaleSize)), new Microsoft.Xna.Framework.Rectangle?(position), color * transparency, 0.0f, new Vector2(8f, 8f) * scaleSize, 4f * scaleSize, SpriteEffects.None, layerDepth);
                if (flag)
                {
                    Utility.drawTinyDigits(__instance.Stack, spriteBatch, location + new Vector2((float)(64 - Utility.getWidthOfTinyDigitString(__instance.Stack, 3f * scaleSize)) + 3f * scaleSize, (float)(64.0 - 18.0 * (double)scaleSize + 1.0)), 3f * scaleSize, 1f, color);
                }

                // New
                if (transparency >= 1 && iconPosition != Rectangle.Empty)
                {
                    spriteBatch.Draw(Game1.objectSpriteSheet, location + new Vector2(Game1.tileSize / 6 * scaleSize, Game1.tileSize / 6 * scaleSize), new Microsoft.Xna.Framework.Rectangle?(iconPosition), Color.White * transparency, 0.0f, new Vector2(4f, 4f), (3f / 2f) * scaleSize, SpriteEffects.None, layerDepth);
                }

                if (drawStackNumber != StackDrawType.Hide && __instance.Quality > 0)
                {
                    float num = __instance.Quality < 4 ? 0.0f : (float)((Math.Cos((double)Game1.currentGameTime.TotalGameTime.Milliseconds * Math.PI / 512.0) + 1.0) * 0.0500000007450581);
                    spriteBatch.Draw(Game1.mouseCursors, location + new Vector2(12f, 52f + num), new Microsoft.Xna.Framework.Rectangle?(__instance.Quality < 4 ? new Microsoft.Xna.Framework.Rectangle(338 + (__instance.Quality - 1) * 8, 400, 8, 8) : new Microsoft.Xna.Framework.Rectangle(346, 392, 8, 8)), color * transparency, 0.0f, new Vector2(4f, 4f), (float)(3.0 * (double)scaleSize * (1.0 + (double)num)), SpriteEffects.None, layerDepth);
                }
                if (__instance.Category == -22 && __instance.uses.Value > 0)
                {
                    float power = ((float)(FishingRod.maxTackleUses - __instance.uses.Value) + 0.0f) / (float)FishingRod.maxTackleUses;
                    spriteBatch.Draw(Game1.staminaRect, new Microsoft.Xna.Framework.Rectangle((int)location.X, (int)((double)location.Y + 56.0 * (double)scaleSize), (int)(64.0 * (double)scaleSize * (double)power), (int)(8.0 * (double)scaleSize)), Utility.getRedToGreenLerpColor(power));
                }
            }
            if (__instance.IsRecipe)
            {
                spriteBatch.Draw(Game1.objectSpriteSheet, location + new Vector2(16f, 16f), new Microsoft.Xna.Framework.Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, 451, 16, 16)), color, 0.0f, Vector2.Zero, 3f, SpriteEffects.None, layerDepth + 0.0001f);
            }

            return(false);
        }
コード例 #16
0
        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)));
        }
コード例 #17
0
        /// <summary>Draw the correct texture based on <see cref="SObject.preservedParentSheetIndex"/> or <see cref="SObject.Name"/>.</summary>
        private static bool Prefix(SObject __instance, SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, Color color, StackDrawType drawStackNumber, bool drawShadow)
        {
            if (!ModEntry.Instance.GetDrawInfo(__instance, out Texture2D spriteSheet, out Rectangle position, out Rectangle iconPosition))
            {
                return(true);
            }

            if (__instance.IsRecipe)
            {
                transparency = 0.5f;
                scaleSize   *= 0.75f;
            }
            bool flag = (drawStackNumber == StackDrawType.Draw && __instance.maximumStackSize() > 1 && __instance.Stack > 1 || drawStackNumber == StackDrawType.Draw_OneInclusive) && (double)scaleSize > 0.3 && __instance.Stack != int.MaxValue;

            if (__instance.IsRecipe)
            {
                flag = false;
            }
            if (__instance.bigCraftable.Value)
            {
                Microsoft.Xna.Framework.Rectangle rectForBigCraftable = SObject.getSourceRectForBigCraftable(__instance.ParentSheetIndex);
                spriteBatch.Draw(Game1.bigCraftableSpriteSheet, location + new Vector2(32f, 32f), new Microsoft.Xna.Framework.Rectangle?(rectForBigCraftable), color * transparency, 0.0f, new Vector2(8f, 16f), (float)(4.0 * ((double)scaleSize < 0.2 ? (double)scaleSize : (double)scaleSize / 2.0)), SpriteEffects.None, layerDepth);
                if (flag)
                {
                    Utility.drawTinyDigits(__instance.Stack, spriteBatch, location + new Vector2((float)(64 - Utility.getWidthOfTinyDigitString(__instance.Stack, 3f * scaleSize)) + 3f * scaleSize, (float)(64.0 - 18.0 * (double)scaleSize + 2.0)), 3f * scaleSize, 1f, color);
                }
            }
            else
            {
                if (__instance.ParentSheetIndex != 590 & drawShadow)
                {
                    spriteBatch.Draw(Game1.shadowTexture, location + new Vector2(32f, 48f), new Microsoft.Xna.Framework.Rectangle?(Game1.shadowTexture.Bounds), color * 0.5f, 0.0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), 3f, SpriteEffects.None, layerDepth - 0.0001f);
                }
                // modified
                spriteBatch.Draw(spriteSheet, location + new Vector2((float)(int)(32.0 * (double)scaleSize), (float)(int)(32.0 * (double)scaleSize)), new Microsoft.Xna.Framework.Rectangle?(position), color * transparency, 0.0f, new Vector2(8f, 8f) * scaleSize, 4f * scaleSize, SpriteEffects.None, layerDepth);
                if (flag)
                {
                    Utility.drawTinyDigits(__instance.Stack, spriteBatch, location + new Vector2((float)(64 - Utility.getWidthOfTinyDigitString(__instance.Stack, 3f * scaleSize)) + 3f * scaleSize, (float)(64.0 - 18.0 * (double)scaleSize + 1.0)), 3f * scaleSize, 1f, color);
                }

                // New
                if (transparency >= 1 && iconPosition != Rectangle.Empty)
                {
                    spriteBatch.Draw(Game1.objectSpriteSheet, location + new Vector2(Game1.tileSize / 6 * scaleSize, Game1.tileSize / 6 * scaleSize), new Microsoft.Xna.Framework.Rectangle?(iconPosition), Color.White * transparency, 0.0f, new Vector2(4f, 4f), (3f / 2f) * scaleSize, SpriteEffects.None, layerDepth);
                }

                if (drawStackNumber != StackDrawType.Hide && __instance.Quality > 0)
                {
                    float num = __instance.Quality < 4 ? 0.0f : (float)((Math.Cos((double)Game1.currentGameTime.TotalGameTime.Milliseconds * Math.PI / 512.0) + 1.0) * 0.0500000007450581);
                    spriteBatch.Draw(Game1.mouseCursors, location + new Vector2(12f, 52f + num), new Microsoft.Xna.Framework.Rectangle?(__instance.Quality < 4 ? new Microsoft.Xna.Framework.Rectangle(338 + (__instance.Quality - 1) * 8, 400, 8, 8) : new Microsoft.Xna.Framework.Rectangle(346, 392, 8, 8)), color * transparency, 0.0f, new Vector2(4f, 4f), (float)(3.0 * (double)scaleSize * (1.0 + (double)num)), SpriteEffects.None, layerDepth);
                }
                if (__instance.Category == -22 && __instance.uses.Value > 0)
                {
                    float power = ((float)(FishingRod.maxTackleUses - __instance.uses.Value) + 0.0f) / (float)FishingRod.maxTackleUses;
                    spriteBatch.Draw(Game1.staminaRect, new Microsoft.Xna.Framework.Rectangle((int)location.X, (int)((double)location.Y + 56.0 * (double)scaleSize), (int)(64.0 * (double)scaleSize * (double)power), (int)(8.0 * (double)scaleSize)), Utility.getRedToGreenLerpColor(power));
                }
            }
            if (__instance.IsRecipe)
            {
                spriteBatch.Draw(Game1.objectSpriteSheet, location + new Vector2(16f, 16f), new Microsoft.Xna.Framework.Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, 451, 16, 16)), color, 0.0f, Vector2.Zero, 3f, SpriteEffects.None, layerDepth + 0.0001f);
            }

            return(false);
        }
コード例 #18
0
        public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f)
        {
            Vector2 vector2 = this.getScale() * 4f;
            Vector2 local   = objectPosition;
            var     x       = local.X / 64;
            var     y       = (local.Y + 64) / 64;

            spriteBatch.Draw(Game1.bigCraftableSpriteSheet, objectPosition, new Rectangle?(Object.getSourceRectForBigCraftable(f.ActiveObject.ParentSheetIndex)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, Math.Max(0.0f, (float)(f.getStandingY() + 2) / 10000f));
            if (this.hoeDirt.Value.fertilizer.Value != 0)
            {
                int num = 0;
                switch (this.hoeDirt.Value.fertilizer.Value)
                {
                case 369:
                    num = 1;
                    break;

                case 370:
                    num = 2;
                    break;

                case 371:
                    num = 3;
                    break;

                case 465:
                    num = 4;
                    break;

                case 466:
                    num = 5;
                    break;
                }
                spriteBatch.Draw(Game1.mouseCursors, new Vector2((float)((double)objectPosition.X + 4.0), (float)(objectPosition.Y + 52)), new Rectangle?(new Rectangle(173 + num / 2 * 16, 466 + num % 2 * 16, 13, 13)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, Math.Max(0.0f, (float)(f.getStandingY() + 2) / 10000f) + 0.0001f);
            }

            if (this.tree is Tree tree)
            {
                drawTree(tree, spriteBatch, objectPosition);
            }
            else if (this.tree is FruitTree fruitTreetree)
            {
                drawFruitTree(fruitTreetree, spriteBatch, objectPosition);
            }

            if (this.hoeDirt.Value.crop != null)
            {
                DrawWithOffset(this.hoeDirt.Value.crop, spriteBatch, objectPosition, this.hoeDirt.Value.state.Value != 1 || this.hoeDirt.Value.crop.currentPhase.Value != 0 || this.hoeDirt.Value.crop.raisedSeeds.Value ? Color.White : new Color(180, 100, 200) * 1f, this.hoeDirt.Value.getShakeRotation(), new Vector2(32f, 72), f);
            }
            if (this.heldObject.Value == null)
            {
                return;
            }
            this.heldObject.Value.draw(spriteBatch, (int)x * 64, (int)(y * 64 - 48), (float)((objectPosition.Y + 0.660000026226044) * 64.0 / 10000.0 + (double)x * 9.99999974737875E-06), 1f);
        }
コード例 #19
0
        public void drawItem(PipeNode pipe, SpriteBatch spriteBatch, int x, int y)
        {
            Item      item = pipe.StoredItem;
            Texture2D SpriteSheet;
            Rectangle srcRect;
            Vector2   originalPosition;
            Vector2   position;

            //How to handle drawing custom mod items
            //Igual hacer como coger la sprite y redimensionarla
            //relativamente a su size original y listo
            //try catch para loadear la sprite
            if (item is PipeItem)
            {
                PipeItem pipeItem = (PipeItem)item;
                SpriteSheet      = pipeItem.ItemTexture;
                srcRect          = new Rectangle(0, 0, 16, 16);
                originalPosition = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64, y * 64 - 64));
                position         = new Vector2(originalPosition.X + 16, originalPosition.Y + 64 + 16);
                spriteBatch.Draw(SpriteSheet, position, srcRect, Color.White, 0f, Vector2.Zero, 2f, SpriteEffects.None,
                                 ((float)(y * 64 + 32) / 10000f) + 0.002f);
            }
            else if (item is PPMItem)
            {
                PPMItem PPM = (PPMItem)item;
                SpriteSheet      = PPM.ItemTexture;
                srcRect          = new Rectangle(0, 0, 16, 32);
                originalPosition = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64, y * 64 - 64));
                position         = new Vector2(originalPosition.X + 23, originalPosition.Y + 64 + 10);
                spriteBatch.Draw(SpriteSheet, position, srcRect, Color.White, 0f, Vector2.Zero, 1.2f, SpriteEffects.None,
                                 ((float)(y * 64 + 32) / 10000f) + 0.002f);
            }
            else if (item is SObject && (item as SObject).bigCraftable.Value)
            {
                SpriteSheet      = Game1.bigCraftableSpriteSheet;
                srcRect          = SObject.getSourceRectForBigCraftable(item.ParentSheetIndex);
                originalPosition = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64, y * 64 - 64));
                position         = new Vector2(originalPosition.X + 23, originalPosition.Y + 64 + 10);
                spriteBatch.Draw(SpriteSheet, position, srcRect, Color.White, 0f, Vector2.Zero, 1.2f, SpriteEffects.None,
                                 ((float)(y * 64 + 32) / 10000f) + 0.002f);
            }
            else if (item is Tool)
            {
                Tool tool = (Tool)item;
                if (item is MeleeWeapon || item is Slingshot || item is Sword)
                {
                    SpriteSheet      = Tool.weaponsTexture;
                    srcRect          = Game1.getSquareSourceRectForNonStandardTileSheet(SpriteSheet, 16, 16, tool.IndexOfMenuItemView);
                    originalPosition = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64, y * 64 - 64));
                    position         = new Vector2(originalPosition.X + 19, originalPosition.Y + 64 + 19);
                    spriteBatch.Draw(SpriteSheet, position, srcRect, Color.White, 0f, Vector2.Zero, 1.7f, SpriteEffects.None,
                                     ((float)(y * 64 + 32) / 10000f) + 0.002f);
                }
                else
                {
                    SpriteSheet      = Game1.toolSpriteSheet;
                    srcRect          = Game1.getSquareSourceRectForNonStandardTileSheet(SpriteSheet, 16, 16, tool.IndexOfMenuItemView);
                    originalPosition = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64, y * 64 - 64));
                    position         = new Vector2(originalPosition.X + 19, originalPosition.Y + 64 + 18);
                    spriteBatch.Draw(SpriteSheet, position, srcRect, Color.White, 0f, Vector2.Zero, 1.7f, SpriteEffects.None,
                                     ((float)(y * 64 + 32) / 10000f) + 0.002f);
                }
            }
            //Boots = standard
            else if (item is Boots)
            {
                Boots boot = (Boots)item;
                SpriteSheet      = Game1.objectSpriteSheet;
                srcRect          = Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, boot.indexInTileSheet.Value, 16, 16);
                originalPosition = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64, y * 64 - 64));
                position         = new Vector2(originalPosition.X + 18, originalPosition.Y + 64 + 16);
                spriteBatch.Draw(SpriteSheet, position, srcRect, Color.White, 0f, Vector2.Zero, 2f, SpriteEffects.None,
                                 ((float)(y * 64 + 32) / 10000f) + 0.002f);
            }
            //rings = standard
            else if (item is Ring)
            {
                SpriteSheet      = Game1.objectSpriteSheet;
                srcRect          = Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, item.ParentSheetIndex, 16, 16);
                originalPosition = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64, y * 64 - 64));
                position         = new Vector2(originalPosition.X + 10, originalPosition.Y + 64 + 14);
                spriteBatch.Draw(SpriteSheet, position, srcRect, Color.White, 0f, Vector2.Zero, 2.5f, SpriteEffects.None,
                                 ((float)(y * 64 + 32) / 10000f) + 0.002f);
            }
            else if (item is Hat)
            {
                Hat hat = (Hat)item;
                SpriteSheet      = FarmerRenderer.hatsTexture;
                srcRect          = new Rectangle((int)hat.which * 20 % FarmerRenderer.hatsTexture.Width, (int)hat.which * 20 / FarmerRenderer.hatsTexture.Width * 20 * 4, 20, 20);
                originalPosition = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64, y * 64 - 64));
                position         = new Vector2(originalPosition.X + 12, originalPosition.Y + 64 + 18);
                spriteBatch.Draw(SpriteSheet, position, srcRect, Color.White, 0f, Vector2.Zero, 2f, SpriteEffects.None,
                                 ((float)(y * 64 + 32) / 10000f) + 0.002f);
            }
            else if (item is Clothing)
            {
                Clothing cloth         = (Clothing)item;
                Color    clothes_color = cloth.clothesColor;
                if (cloth.isPrismatic.Value)
                {
                    clothes_color = Utility.GetPrismaticColor();
                }
                if (cloth.clothesType.Value == 0)
                {
                    SpriteSheet      = FarmerRenderer.shirtsTexture;
                    srcRect          = new Rectangle(cloth.indexInTileSheetMale.Value * 8 % 128, cloth.indexInTileSheetMale.Value * 8 / 128 * 32, 8, 8);
                    originalPosition = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64, y * 64 - 64));
                    position         = new Vector2(originalPosition.X + 20, originalPosition.Y + 64 + 20);
                    spriteBatch.Draw(SpriteSheet, position, srcRect, clothes_color, 0f, Vector2.Zero, 3f, SpriteEffects.None,
                                     ((float)(y * 64 + 32) / 10000f) + 0.002f);
                }
                else if (cloth.clothesType.Value == 1)
                {
                    SpriteSheet      = FarmerRenderer.pantsTexture;
                    srcRect          = new Rectangle(192 * (cloth.indexInTileSheetMale.Value % (FarmerRenderer.pantsTexture.Width / 192)), 688 * (cloth.indexInTileSheetMale.Value / (FarmerRenderer.pantsTexture.Width / 192)) + 672, 16, 16);
                    originalPosition = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64, y * 64 - 64));
                    position         = new Vector2(originalPosition.X + 8, originalPosition.Y + 64 + 10);
                    spriteBatch.Draw(SpriteSheet, position, srcRect, clothes_color, 0f, Vector2.Zero, 3f, SpriteEffects.None,
                                     ((float)(y * 64 + 32) / 10000f) + 0.002f);
                }
            }
            else
            {
                SpriteSheet      = Game1.objectSpriteSheet;
                srcRect          = Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, item.ParentSheetIndex, 16, 16);
                originalPosition = Game1.GlobalToLocal(Game1.viewport, new Vector2(x * 64, y * 64 - 64));
                position         = new Vector2(originalPosition.X + 17, originalPosition.Y + 64 + 17);
                spriteBatch.Draw(SpriteSheet, position, srcRect, Color.White, 0f, Vector2.Zero, 1.9f, SpriteEffects.None,
                                 ((float)(y * 64 + 32) / 10000f) + 0.002f);
            }
        }
コード例 #20
0
        private static Rectangle GetSourceRect(int index, IndoorPot __instance)
        {
            if (!Config.EnableMod || __instance.modData.ContainsKey("aedenthorn.WallPlanter/offset") || !IsConnectedPot(__instance))
            {
                return(Object.getSourceRectForBigCraftable(index));
            }

            drawingConnectedPot = false;

            bool[]  potTiles = new bool[9];
            Vector2 tile     = __instance.TileLocation;

            for (int x = 0; x < 3; x++)
            {
                for (int y = 0; y < 3; y++)
                {
                    int i = 3 * y + x;
                    potTiles[i] = Game1.currentLocation.objects.TryGetValue(tile + new Vector2(x - 1, y - 1), out Object obj) && obj is IndoorPot && !obj.modData.ContainsKey("aedenthorn.WallPlanter/offset");
                }
            }
            topIndex            = -2;
            leftIndex           = -2;
            rightIndex          = -2;
            drawingConnectedPot = true;

            if (!potTiles[1])         // none top
            {
                if (!potTiles[3])     // none left
                {
                    if (!potTiles[5]) // pot below
                    {
                        topIndex = 6;
                        potIndex = 0;
                    }
                    else if (!potTiles[7]) // pot right
                    {
                        topIndex = 0;
                        potIndex = 2;
                    }
                    else // pot right pot below
                    {
                        topIndex = 0;
                        potIndex = 0;
                    }
                }
                else if (!potTiles[5]) // pot left none right
                {
                    if (!potTiles[7])  // pot left
                    {
                        topIndex = 4;
                        potIndex = 6;
                    }
                    else // pot left pot below
                    {
                        topIndex = 4;
                        potIndex = 0;
                    }
                }
                else if (!potTiles[7]) // pot left pot right
                {
                    topIndex = 2;
                    potIndex = 4;
                }
                else // pot left pot right pot below
                {
                    topIndex = 2;
                    potIndex = 0;
                }
            }
            else // pot top
            {
                if (!potTiles[3]) // none left
                {
                    if (!potTiles[5])     // none right
                    {
                        if (!potTiles[7]) // pot top
                        {
                            potIndex = 8;
                        }
                        else // pot top pot bottom
                        {
                            potIndex = 0;
                        }
                    }
                    else // pot right
                    {
                        if (!potTiles[7]) // pot top pot right
                        {
                            potIndex = 2;
                        }
                        else // pot top pot right pot bottom
                        {
                            potIndex = 0;
                        }
                    }
                }
                else if (!potTiles[5]) // pot left none right
                {
                    if (!potTiles[7])  // pot top pot left
                    {
                        potIndex = 6;
                    }
                    else // pot top pot left pot below
                    {
                        potIndex = 0;
                    }
                }
                else if (!potTiles[7]) // pot top pot left pot right
                {
                    potIndex = 4;
                }
                else // pot top pot left pot right pot below
                {
                    potIndex = 0;
                }
            }
            if (potIndex == 0)
            {
                if (!potTiles[3])
                {
                    leftIndex = potTiles[6] ? 2 : 0;
                }
                else if (!potTiles[6])
                {
                    leftIndex = 4;
                }
                if (!potTiles[5])
                {
                    rightIndex = potTiles[8] ? 2 : 0;
                }
                else if (!potTiles[8])
                {
                    rightIndex = 4;
                }
            }
            if (__instance.showNextIndex.Value)
            {
                potIndex++;
                topIndex++;
                leftIndex++;
                rightIndex++;
            }

            return(new Rectangle(potIndex * 16, 0, 16, 32));
        }
コード例 #21
0
 public static void DrawAnimation(
     SpriteBatch spriteBatch,
     Texture2D texture,
     Rectangle destinationRectangle,
     Rectangle?sourceRectangle,
     Color color,
     float rotation,
     Vector2 origin,
     SpriteEffects effects,
     float layerDepth,
     Object producer)
 {
     if (producer.heldObject.Value != null && ProducerController.GetProducerConfig(producer.Name) is ProducerConfig producerConfig)
     {
         if (producerConfig.ProducingAnimation is Animation producingAnimation && producer.minutesUntilReady > 0 && producerConfig.CheckSeasonCondition(Game1.currentLocation) && producerConfig.CheckWeatherCondition() && producerConfig.CheckCurrentTimeCondition())
         {
             List <int> animationList;
             if (producingAnimation.AdditionalAnimationsId.ContainsKey(producer.heldObject.Value.ParentSheetIndex))
             {
                 animationList = producingAnimation.AdditionalAnimationsId[producer.heldObject.Value.ParentSheetIndex];
             }
             else if (producingAnimation.AdditionalAnimationsId.ContainsKey(producer.heldObject.Value.Category))
             {
                 animationList = producingAnimation.AdditionalAnimationsId[producer.heldObject.Value.Category];
             }
             else
             {
                 animationList = producingAnimation.RelativeFrameIndex;
             }
             if (animationList.Any())
             {
                 int frame = animationList[((Game1.ticks + GetLocationSeed(producer.TileLocation)) % (animationList.Count * producingAnimation.FrameInterval)) / producingAnimation.FrameInterval];
                 spriteBatch.Draw(texture, destinationRectangle, new Rectangle?(Object.getSourceRectForBigCraftable(producer.ParentSheetIndex + frame)), color, rotation, origin, effects, layerDepth);
                 return;
             }
         }
         else if (producerConfig.ReadyAnimation is Animation readyAnimation && producer.readyForHarvest.Value)
         {
             List <int> animationList;
             if (readyAnimation.AdditionalAnimationsId.ContainsKey(producer.heldObject.Value.ParentSheetIndex))
             {
                 animationList = readyAnimation.AdditionalAnimationsId[producer.heldObject.Value.ParentSheetIndex];
             }
             else if (readyAnimation.AdditionalAnimationsId.ContainsKey(producer.heldObject.Value.Category))
             {
                 animationList = readyAnimation.AdditionalAnimationsId[producer.heldObject.Value.Category];
             }
             else
             {
                 animationList = readyAnimation.RelativeFrameIndex;
             }
             if (animationList.Any())
             {
                 int frame = animationList[((Game1.ticks + GetLocationSeed(producer.TileLocation)) % (animationList.Count * readyAnimation.FrameInterval)) / readyAnimation.FrameInterval];
                 spriteBatch.Draw(texture, destinationRectangle, new Rectangle?(Object.getSourceRectForBigCraftable(producer.ParentSheetIndex + frame)), color, rotation, origin, effects, layerDepth);
                 return;
             }
         }
     }
コード例 #22
0
        /// <summary>Draw the correct texture for machines that are ready for harvest and displaying their results.</summary>
        /// <remarks>We can't just set <see cref="SObject.readyForHarvest"/> to be false during the draw call and draw the
        /// tool tip ourselves because draw calls getScale, which actually modifies the object scale based upon <see cref="SObject.readyForHarvest"/>.</remarks>
        public static bool Prefix(SObject __instance, SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
        {
            if (!__instance.readyForHarvest.Value || !__instance.bigCraftable.Value || __instance.heldObject.Value == null ||
                !ArtisanGoodsManager.GetDrawInfo(__instance.heldObject.Value, out Texture2D spriteSheet, out Rectangle position, out Rectangle iconPosition))
            {
                return(true);
            }
            Vector2 vector2 = __instance.getScale() * (float)Game1.pixelZoom;
            Vector2 local   = Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), (float)(y * Game1.tileSize - Game1.tileSize)));

            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)((double)Game1.tileSize + (double)vector2.X), (int)((double)(Game1.tileSize * 2) + (double)vector2.Y / 2.0));
            spriteBatch.Draw(Game1.bigCraftableSpriteSheet, destinationRectangle, new Microsoft.Xna.Framework.Rectangle?(SObject.getSourceRectForBigCraftable(__instance.showNextIndex.Value ? __instance.ParentSheetIndex + 1 : __instance.ParentSheetIndex)), Color.White * alpha, 0.0f, Vector2.Zero, SpriteEffects.None, (float)((double)Math.Max(0.0f, (float)((y + 1) * Game1.tileSize - Game1.pixelZoom * 6) / 10000f) + (__instance.ParentSheetIndex == 105 ? 0.00350000010803342 : 0.0) + (double)x * 9.99999974737875E-06));
            if (__instance.Name.Equals("Loom") && __instance.MinutesUntilReady > 0)
            {
                spriteBatch.Draw(Game1.objectSpriteSheet, __instance.getLocalPosition(Game1.viewport) + new Vector2((float)(Game1.tileSize / 2f), 0.0f), new Microsoft.Xna.Framework.Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, 435, 16, 16)), Color.White * alpha, __instance.scale.X, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0.0f, (float)((double)((y + 1) * Game1.tileSize) / 10000.0 + 9.99999974737875E-05 + (double)x * 9.99999974737875E-06)));
            }
            if (__instance.isLamp.Value && Game1.isDarkOut())
            {
                spriteBatch.Draw(Game1.mouseCursors, local + new Vector2((float)(-Game1.tileSize / 2f), (float)(-Game1.tileSize / 2f)), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(88, 1779, 32, 32)), Color.White * 0.75f, 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0.0f, (float)((y + 1) * Game1.tileSize - Game1.pixelZoom * 5) / 10000f));
            }
            if (__instance.ParentSheetIndex == 126 && __instance.Quality != 0)
            {
                spriteBatch.Draw(FarmerRenderer.hatsTexture, local + new Vector2(-3f, -6f) * (float)Game1.pixelZoom, new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle((__instance.Quality - 1) * 20 % FarmerRenderer.hatsTexture.Width, (__instance.Quality - 1) * 20 / FarmerRenderer.hatsTexture.Width * 20 * 4, 20, 20)), Color.White * alpha, 0.0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0.0f, (float)((y + 1) * Game1.tileSize - Game1.pixelZoom * 5) / 10000f) + (float)x * 1E-05f);
            }

            float num = (float)(4.0 * Math.Round(Math.Sin(DateTime.Now.TimeOfDay.TotalMilliseconds / 250.0), 2));

            spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize - 8), (float)(y * Game1.tileSize - Game1.tileSize * 3 / 2 - 16) + num)), 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) * Game1.tileSize) / 10000.0 + 9.99999997475243E-07 + (double)__instance.TileLocation.X / 10000.0 + (__instance.ParentSheetIndex == 105 ? 0.00150000001303852 : 0.0)));
            spriteBatch.Draw(spriteSheet, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize + Game1.tileSize / 2), (float)(y * Game1.tileSize - Game1.tileSize - Game1.tileSize / 8) + num)), new Microsoft.Xna.Framework.Rectangle?(position), Color.White * 0.75f, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)((double)((y + 1) * Game1.tileSize) / 10000.0 + 9.99999974737875E-06 + (double)__instance.TileLocation.X / 10000.0 + (__instance.ParentSheetIndex == 105 ? 0.00150000001303852 : 0.0)));
            return(false);
        }
コード例 #23
0
    private static bool ObjectDrawPrefix(SObject __instance, SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
    {
        if (__instance.isTemporarilyInvisible)
        {
            return(false);                                   // don't run original logic
        }
        if (!__instance.bigCraftable.Value || !__instance.readyForHarvest.Value || __instance.heldObject.Value is not
        {
            ParentSheetIndex : Globals.MEAD_INDEX_I, preservedParentSheetIndex.Value : > 0
        } mead)
        {
            return(true);                                                                                       // run original logic
        }
        var parameters = new object?[] { __instance, null, null, null };
        var got        = (bool)_GetDrawInfo.Invoke(null, parameters) !;

        if (!got)
        {
            return(true);      // run original logic
        }
        var spritesheet = (Texture2D)parameters[1] !;
        var position    = (Rectangle)parameters[2] !;

        var(sx, sy) = __instance.getScale() * Game1.pixelZoom;

        var(px, py) = Game1.GlobalToLocal(
            viewport: Game1.viewport,
            globalPosition: new Vector2(x * Game1.tileSize, y * Game1.tileSize - Game1.tileSize)
            );

        var destinationRect = new Rectangle(
            (int)(px - sx / 2f) + (__instance.shakeTimer > 0
                ? Game1.random.Next(-1, 2) : 0),
            (int)(py - sy / 2f) + (__instance.shakeTimer > 0
                ? Game1.random.Next(-1, 2) : 0),
            (int)(64f + sx),
            (int)(128f + sy / 2f)
            );

        spriteBatch.Draw(
            texture: Game1.bigCraftableSpriteSheet,
            destinationRectangle: destinationRect,
            sourceRectangle: SObject.getSourceRectForBigCraftable(__instance.showNextIndex.Value
                ? __instance.ParentSheetIndex + 1
                : __instance.ParentSheetIndex),
            color: Color.White * alpha,
            rotation: 0f,
            origin: Vector2.Zero,
            effects: SpriteEffects.None,
            layerDepth: Math.Max(0f, ((y + 1) * 64 - 24) / 10000f) + x * 1E-05f
            );

        var num = 4f * (float)Math.Round(Math.Sin(Game1.currentGameTime.TotalGameTime.TotalMilliseconds / 250.0), 2);

        spriteBatch.Draw(
            texture: Game1.mouseCursors,
            position: Game1.GlobalToLocal(
                viewport: Game1.viewport,
                globalPosition: new Vector2(
                    x * 64 - 8,
                    y * 64 - 96 - 16 + num
                    )
                ),
            sourceRectangle: new Rectangle(141, 465, 20, 24),
            color: Color.White * 0.75f,
            rotation: 0f,
            origin: Vector2.Zero,
            scale: 4f,
            effects: SpriteEffects.None,
            layerDepth: (float)((y + 1) * 64 / 10000f + 1E-06f + __instance.TileLocation.X / 10000f + 9.99999997475243E-07 + __instance.TileLocation.X / 10000.0)
            );

        spriteBatch.Draw(
            texture: spritesheet,
            position: Game1.GlobalToLocal(
                viewport: Game1.viewport,
                globalPosition: new Vector2(
                    x * 64 + 32,
                    y * 64 - 64 - 8 + num
                    )
                ),
            sourceRectangle: position,
            color: Color.White * 0.75f,
            rotation: 0f,
            origin: new Vector2(8f, 8f),
            scale: 4f,
            effects: SpriteEffects.None,
            layerDepth: (float)((y + 1) * 64 / 10000f + __instance.TileLocation.X / 10000f + 9.99999974737875E-06 + __instance.TileLocation.X / 10000.0)
            );

        return(false); // don't run original logic
    }
コード例 #24
0
        private static bool Prefix(SObject __instance, SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f)
        {
            if (!ModEntry.Instance.GetDrawInfo(__instance, out Texture2D spriteSheet, out Rectangle position, out Rectangle iconPosition))
            {
                return(true);
            }

            //By popular demand, don't show icons when held.

            if (f.ActiveObject.bigCraftable.Value)
            {
                spriteBatch.Draw(Game1.bigCraftableSpriteSheet, objectPosition, new Microsoft.Xna.Framework.Rectangle?(SObject.getSourceRectForBigCraftable(f.ActiveObject.ParentSheetIndex)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, Math.Max(0.0f, (float)(f.getStandingY() + 3) / 10000f));
            }
            else
            {
                spriteBatch.Draw(spriteSheet, objectPosition, position, Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, Math.Max(0.0f, (float)(f.getStandingY() + 3) / 10000f));
                if (!(f.ActiveObject == null || !f.ActiveObject.Name.Contains("=")))
                {
                    spriteBatch.Draw(spriteSheet, objectPosition + new Vector2(32f, 32f), position, Color.White, 0.0f, new Vector2(32f, 32f), (float)(4.0 + (double)Math.Abs(Game1.starCropShimmerPause) / 8.0), SpriteEffects.None, Math.Max(0.0f, (float)(f.getStandingY() + 3) / 10000f));
                    if (!((double)Math.Abs(Game1.starCropShimmerPause) <= 0.0500000007450581 && Game1.random.NextDouble() < 0.97))
                    {
                        Game1.starCropShimmerPause += 0.04f;
                        if (!(Game1.starCropShimmerPause < 0.800000011920929))
                        {
                            Game1.starCropShimmerPause = -0.8f;
                        }
                    }
                }
            }

            return(false);
        }
コード例 #25
0
        private static void GameLocation_draw_Postfix(GameLocation __instance, SpriteBatch b)
        {
            if (!Config.EnableMod)
            {
                return;
            }

            foreach (Furniture f in __instance.furniture)
            {
                var name = f.rotations.Value > 1 ? f.Name + ":" + f.currentRotation.Value : f.Name;

                if (!furnitureDisplayDict.ContainsKey(name))
                {
                    continue;
                }

                for (int i = 0; i < furnitureDisplayDict[name].slots.Length; i++)
                {
                    if (!f.modData.ContainsKey("aedenthorn.FurnitureDisplayFramework/" + i) || f.modData["aedenthorn.FurnitureDisplayFramework/" + i].Length == 0)
                    {
                        continue;
                    }
                    var currentItem = f.modData["aedenthorn.FurnitureDisplayFramework/" + i].Split(',');
                    var obj         = GetObjectFromID(currentItem[0], int.Parse(currentItem[1]), int.Parse(currentItem[2]));
                    if (obj == null)
                    {
                        continue;
                    }
                    float scale      = 4;
                    var   itemRect   = new Rectangle(Utility.Vector2ToPoint(f.getLocalPosition(Game1.viewport) + new Vector2(furnitureDisplayDict[name].slots[i].itemRect.X, furnitureDisplayDict[name].slots[i].itemRect.Y) * scale), Utility.Vector2ToPoint(new Vector2(furnitureDisplayDict[name].slots[i].itemRect.Width, furnitureDisplayDict[name].slots[i].itemRect.Height) * scale));
                    var   layerDepth = ((f.furniture_type.Value == 12) ? (2E-09f + f.TileLocation.Y / 100000f) : ((f.boundingBox.Value.Bottom - ((f.furniture_type.Value == 6 || f.furniture_type.Value == 17 || f.furniture_type.Value == 13) ? 48 : 8)) + 1) / 10000f);
                    if (obj.bigCraftable.Value)
                    {
                        b.Draw(Game1.bigCraftableSpriteSheet, itemRect, new Rectangle?(Object.getSourceRectForBigCraftable(obj.ParentSheetIndex)), Color.White, 0f, Vector2.Zero, SpriteEffects.None, layerDepth);
                    }
                    else
                    {
                        b.Draw(Game1.objectSpriteSheet, itemRect, new Rectangle?(GameLocation.getSourceRectForObject(obj.ParentSheetIndex)), Color.White, 0f, Vector2.Zero, SpriteEffects.None, layerDepth);
                    }
                }
            }
        }