Exemplo n.º 1
0
        /*********
        ** Private methods
        *********/
        /// <summary>Get the in-world sprite sheet for a target.</summary>
        /// <param name="target">The target whose texture to get.</param>
        /// <param name="jsonAssets">The Json Assets API.</param>
        /// <param name="texture">The custom sprite texture.</param>
        /// <param name="sourceRect">The custom area within the texture. </param>
        /// <returns>Returns true if the entity has a custom sprite, else false.</returns>
        private void GetSpriteSheet(Crop target, JsonAssetsIntegration jsonAssets, out Texture2D texture, out Rectangle sourceRect)
        {
            // get from Json Assets
            if (jsonAssets.IsLoaded && jsonAssets.TryGetCustomSpriteSheet(target, out texture, out sourceRect, currentSpriteOnly: true))
            {
                return;
            }

            // use vanilla logic
            texture    = Game1.cropSpriteSheet;
            sourceRect = this.Reflection.GetMethod(target, "getSourceRect").Invoke <Rectangle>(target.rowInSpriteSheet.Value);
        }
Exemplo n.º 2
0
        /*********
        ** Private methods
        *********/
        /// <summary>Get the in-world sprite sheet for a target.</summary>
        /// <param name="target">The target whose texture to get.</param>
        /// <param name="jsonAssets">The Json Assets API.</param>
        /// <param name="texture">The custom sprite texture.</param>
        /// <param name="sourceRect">The custom area within the texture. </param>
        /// <returns>Returns true if the entity has a custom sprite, else false.</returns>
        public void GetSpriteSheet(Crop target, JsonAssetsIntegration jsonAssets, out Texture2D texture, out Rectangle sourceRect)
        {
            // get from Json Assets
            if (jsonAssets.IsLoaded && jsonAssets.TryGetCustomSpriteSheet(target, out texture, out sourceRect))
            {
                return;
            }

            // use vanilla logic
            texture    = Game1.cropSpriteSheet;
            sourceRect = new Rectangle(x: target.rowInSpriteSheet.Value % 2 * 128, y: target.rowInSpriteSheet.Value / 2 * 16 * 2, width: 128, height: 32);
        }
Exemplo n.º 3
0
        /*********
        ** Private methods
        *********/
        /// <summary>Get the in-world sprite sheet for a target.</summary>
        /// <param name="target">The target whose texture to get.</param>
        /// <param name="jsonAssets">The Json Assets API.</param>
        /// <param name="texture">The custom sprite texture.</param>
        /// <param name="sourceRect">The custom area within the texture. </param>
        /// <returns>Returns true if the entity has a custom sprite, else false.</returns>
        public void GetSpriteSheet(FruitTree target, JsonAssetsIntegration jsonAssets, out Texture2D texture, out Rectangle sourceRect)
        {
            // get from Json Assets
            if (jsonAssets.IsLoaded && jsonAssets.TryGetCustomSpriteSheet(target, out texture, out sourceRect))
            {
                return;
            }

            // use vanilla logic
            texture    = FruitTree.texture;
            sourceRect = new Rectangle(x: 0, y: target.treeType.Value * 5 * 16, width: 432, height: 80);
        }
Exemplo n.º 4
0
        /*********
        ** Private methods
        *********/
        /// <summary>Get the in-world sprite sheet for a target.</summary>
        /// <param name="target">The target whose texture to get.</param>
        /// <param name="jsonAssets">The Json Assets API.</param>
        /// <param name="texture">The custom sprite texture.</param>
        /// <param name="sourceRect">The custom area within the texture. </param>
        /// <returns>Returns true if the entity has a custom sprite, else false.</returns>
        /// <remarks>Derived from <see cref="Crop.draw"/>.</remarks>
        private void GetSpriteSheet(Crop target, JsonAssetsIntegration jsonAssets, out Texture2D texture, out Rectangle sourceRect)
        {
            // get from Json Assets
            if (jsonAssets.IsLoaded && jsonAssets.TryGetCustomSpriteSheet(target, out texture, out sourceRect, currentSpriteOnly: true))
            {
                return;
            }

            // use vanilla logic
            texture    = Game1.cropSpriteSheet;
            sourceRect = this.Reflection.GetField <Rectangle>(target, "sourceRect").GetValue();
            if (target.forageCrop.Value)
            {
                texture = Game1.mouseCursors;
            }
        }
Exemplo n.º 5
0
        /*********
        ** Private methods
        *********/
        /// <summary>Get the in-world sprite sheet for a target.</summary>
        /// <param name="target">The target whose texture to get.</param>
        /// <param name="jsonAssets">The Json Assets API.</param>
        /// <param name="texture">The custom sprite texture.</param>
        /// <param name="sourceRect">The custom area within the texture. </param>
        /// <returns>Returns true if the entity has a custom sprite, else false.</returns>
        /// <remarks>Derived from <see cref="Crop.draw"/>.</remarks>
        private void GetSpriteSheet(Crop target, JsonAssetsIntegration jsonAssets, out Texture2D texture, out Rectangle sourceRect)
        {
            // get from Json Assets
            if (jsonAssets.IsLoaded && jsonAssets.TryGetCustomSpriteSheet(target, out texture, out sourceRect, currentSpriteOnly: true))
            {
                return;
            }

            // use vanilla logic
            texture    = Game1.cropSpriteSheet;
            sourceRect = this.Reflection.GetField <Rectangle>(target, "sourceRect").GetValue();
            if (target.forageCrop.Value)
            {
                texture = Game1.mouseCursors;
                if (target.whichForageCrop.Value == Crop.forageCrop_ginger)
                {
                    sourceRect = new Rectangle(128 + (int)((Game1.currentGameTime.TotalGameTime.TotalMilliseconds + (this.Tile.X * 111f + this.Tile.Y * 77f)) % 800.0 / 200.0) * 16, 128, 16, 16);
                }
            }
        }