Exemplo n.º 1
0
        private static bool DrawInMenuPrefix(Flooring __instance, SpriteBatch spriteBatch, Vector2 positionOnScreen, Vector2 tileLocation, float scale, float layerDepth)
        {
            if (__instance.modData.ContainsKey("AlternativeTextureName") && !PatchTemplate.IsDGAObject(__instance))
            {
                var textureModel = AlternativeTextures.textureManager.GetSpecificTextureModel(__instance.modData["AlternativeTextureName"]);
                if (textureModel is null)
                {
                    return(true);
                }

                var textureVariation = Int32.Parse(__instance.modData["AlternativeTextureVariation"]);
                if (textureVariation == -1 || AlternativeTextures.modConfig.IsTextureVariationDisabled(textureModel.GetId(), textureVariation))
                {
                    return(true);
                }
                var textureOffset = textureModel.GetTextureOffset(textureVariation);

                int     sourceRectPosition   = 1;
                byte    drawSum              = 0;
                Vector2 surroundingLocations = tileLocation;
                surroundingLocations.X += 1f;
                GameLocation farm = Game1.getLocationFromName("Farm");
                if (farm.terrainFeatures.ContainsKey(surroundingLocations) && farm.terrainFeatures[surroundingLocations] is Flooring)
                {
                    drawSum = (byte)(drawSum + 2);
                }
                surroundingLocations.X -= 2f;
                if (farm.terrainFeatures.ContainsKey(surroundingLocations) && Game1.currentLocation.terrainFeatures[surroundingLocations] is Flooring)
                {
                    drawSum = (byte)(drawSum + 8);
                }
                surroundingLocations.X += 1f;
                surroundingLocations.Y += 1f;
                if (Game1.currentLocation.terrainFeatures.ContainsKey(surroundingLocations) && farm.terrainFeatures[surroundingLocations] is Flooring)
                {
                    drawSum = (byte)(drawSum + 4);
                }
                surroundingLocations.Y -= 2f;
                if (farm.terrainFeatures.ContainsKey(surroundingLocations) && farm.terrainFeatures[surroundingLocations] is Flooring)
                {
                    drawSum = (byte)(drawSum + 1);
                }
                sourceRectPosition = Flooring.drawGuide[drawSum];
                spriteBatch.Draw(textureModel.GetTexture(textureVariation), positionOnScreen, new Rectangle(sourceRectPosition % 16 * 16, sourceRectPosition / 16 * 16 + textureOffset, 16, 16), Color.White, 0f, Vector2.Zero, scale * 4f, SpriteEffects.None, layerDepth + positionOnScreen.Y / 20000f);

                return(false);
            }
            return(true);
        }
Exemplo n.º 2
0
        private static bool DrawInMenuPrefix(Furniture __instance, NetInt ___sourceIndexOffset, SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, StackDrawType drawStackNumber, Color color, bool drawShadow)
        {
            if (Game1.activeClickableMenu is PaintBucketMenu && !PatchTemplate.IsDGAObject(__instance))
            {
                var texture    = Furniture.furnitureTexture;
                var sourceRect = __instance.rotations > 1 ? __instance.sourceRect.Value : __instance.defaultSourceRect.Value;

                if (__instance.modData.ContainsKey("AlternativeTextureName") && AlternativeTextures.textureManager.GetSpecificTextureModel(__instance.modData["AlternativeTextureName"]) is AlternativeTextureModel textureModel && Int32.TryParse(__instance.modData["AlternativeTextureVariation"], out int textureVariation) && textureVariation != -1)
                {
                    texture      = textureModel.GetTexture(textureVariation);
                    sourceRect.X = Math.Max(0, __instance.sourceRect.X - __instance.defaultSourceRect.X);
                    sourceRect.Y = textureModel.GetTextureOffset(textureVariation);
                }

                sourceRect.X += sourceRect.Width * ___sourceIndexOffset.Value;
                spriteBatch.Draw(texture, location + new Vector2(32f, 32f), sourceRect, color * transparency, 0f, new Vector2(sourceRect.Width / 2, sourceRect.Height / 2), 1f * GetScaleSize(sourceRect) * scaleSize, __instance.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, layerDepth);

                return(false);
            }
            return(true);
        }