public void build(CustomFurnitureData data, string objectID, Vector2 tile)
        {
            id                = objectID;
            rotatedWidth      = data.rotatedWidth == -1 ? data.height : data.rotatedWidth;
            rotatedWidth     *= 16;
            rotatedHeight     = data.rotatedHeight == -1 ? data.width : data.rotatedHeight;
            rotatedHeight    *= 16;
            rotatedBoxWidth   = data.rotatedBoxWidth == -1 ? data.boxHeight : data.rotatedBoxWidth;
            rotatedBoxWidth  *= Game1.tileSize;
            rotatedBoxHeight  = data.rotatedBoxHeight == -1 ? data.boxWidth : data.rotatedBoxHeight;
            rotatedBoxHeight *= Game1.tileSize;
            string folder = new DirectoryInfo(data.folderName).Name;

            texture         = CustomFurnitureMod.helper.Content.Load <Texture2D>($"Furniture/{folder}/{data.texture}");
            animationFrames = data.animationFrames;
            this.data       = data;
            frameWidth      = data.setWidth;
            frame           = 0;
            skipFrame       = 60 / data.fps;
            counter         = 0;
            tileLocation    = tile;

            CustomFurnitureMod.helper.Reflection.GetPrivateField <string>(this, "_description").SetValue(data.description);

            parentSheetIndex = data.index;

            name = data.name;
            List <string> decorTypes = new List <string>();

            decorTypes.Add("chair");
            decorTypes.Add("bench");
            decorTypes.Add("couch");
            decorTypes.Add("armchair");
            decorTypes.Add("dresser");
            decorTypes.Add("bookcase");
            decorTypes.Add("other");
            string typename = data.type.Contains("table") ? "table" : decorTypes.Contains(data.type) ? "decor" : data.type;

            furniture_type    = data.type.Contains("table") ? 11 : decorTypes.Contains(data.type) ? 8 : CustomFurnitureMod.helper.Reflection.GetPrivateMethod(new Furniture(), "getTypeNumberFromName").Invoke <int>(new[] { data.type });
            furniture_type    = getTypeFromName(typename);
            defaultSourceRect = new Rectangle(data.index * 16 % texture.Width, data.index * 16 / texture.Width * 16, 1, 1);
            drawHeldObjectLow = false;

            defaultSourceRect.Width  = data.width * 16;
            defaultSourceRect.Height = data.height * 16;
            sourceRect         = new Rectangle(defaultSourceRect.X, defaultSourceRect.Y, defaultSourceRect.Width, defaultSourceRect.Height);
            animatedSourceRect = sourceRect;
            defaultSourceRect  = sourceRect;

            defaultBoundingBox = new Rectangle((int)tileLocation.X, (int)tileLocation.Y, data.boxWidth * Game1.tileSize, data.boxHeight * Game1.tileSize);

            boundingBox        = new Rectangle((int)tileLocation.X * Game1.tileSize, (int)tileLocation.Y * Game1.tileSize, defaultBoundingBox.Width, defaultBoundingBox.Height);
            defaultBoundingBox = boundingBox;

            updateDrawPosition();
            rotations = data.rotations;
            price     = data.price;

            fRotation = FurnitureRotation.horizontal;
        }
Ejemplo n.º 2
0
        public void build(CustomFurnitureData data, string objectID, Vector2 tile)
        {
            id              = objectID;
            texture         = CustomFurnitureMod.helper.Content.Load <Texture2D>(Path.Combine("Furniture", data.folderName, data.texture));
            animationFrames = data.animationFrames;
            this.data       = data;
            frameWidth      = data.setWidth;
            frame           = 0;
            skipFrame       = 60 / data.fps;
            counter         = 0;
            tileLocation    = tile;

            CustomFurnitureMod.helper.Reflection.GetPrivateField <string>(this, "_description").SetValue(data.description);

            parentSheetIndex = data.index;

            name              = data.name;
            furniture_type    = getTypeFromName(data.type);
            defaultSourceRect = new Rectangle(data.index * 16 % texture.Width, data.index * 16 / texture.Width * 16, 1, 1);
            drawHeldObjectLow = false;

            defaultSourceRect.Width  = data.width;
            defaultSourceRect.Height = data.height;
            sourceRect         = new Rectangle(data.index * 16 % texture.Width, data.index * 16 / texture.Width * 16, defaultSourceRect.Width * 16, defaultSourceRect.Height * 16);
            animatedSourceRect = sourceRect;
            defaultSourceRect  = sourceRect;

            defaultBoundingBox = new Rectangle((int)tileLocation.X, (int)tileLocation.Y, 1, 1);


            defaultBoundingBox.Width  = data.boxWidth;
            defaultBoundingBox.Height = data.boxHeight;
            boundingBox        = new Rectangle((int)tileLocation.X * Game1.tileSize, (int)tileLocation.Y * Game1.tileSize, defaultBoundingBox.Width * Game1.tileSize, defaultBoundingBox.Height * Game1.tileSize);
            defaultBoundingBox = boundingBox;

            updateDrawPosition();
            rotations = data.rotations;
            price     = data.price;
        }
        public void build(CustomFurnitureData data, string objectID, Vector2 tile)
        {
            id                = objectID;
            rotatedWidth      = data.rotatedWidth == -1 ? data.height : data.rotatedWidth;
            rotatedWidth     *= 16;
            rotatedHeight     = data.rotatedHeight == -1 ? data.width : data.rotatedHeight;
            rotatedHeight    *= 16;
            rotatedBoxWidth   = data.rotatedBoxWidth == -1 ? data.boxHeight : data.rotatedBoxWidth;
            rotatedBoxWidth  *= Game1.tileSize;
            rotatedBoxHeight  = data.rotatedBoxHeight == -1 ? data.boxWidth : data.rotatedBoxHeight;
            rotatedBoxHeight *= Game1.tileSize;
            this.data         = data;

            animationFrames    = data.animationFrames;
            frameWidth         = data.setWidth;
            frame              = 0;
            skipFrame          = 60 / data.fps;
            counter            = 0;
            tileLocation.Value = tile;

            CustomFurnitureMod.helper.Reflection.GetField <string>(this, "_description").SetValue(data.description);
            CustomFurnitureMod.helper.Reflection.GetField <int>(this, "_placementRestriction").SetValue(2);

            parentSheetIndex.Set(data.index);
            setTexture();
            name = data.name;
            List <string> decorTypes = new List <string>();

            /* decorTypes.Add("chair");
             * decorTypes.Add("bench");
             * decorTypes.Add("couch");
             * decorTypes.Add("armchair");*/
            decorTypes.Add("dresser");
            decorTypes.Add("bookcase");
            decorTypes.Add("other");
            string typename = data.type.Contains("table") ? "table" : decorTypes.Contains(data.type) ? "decor" : data.type;

            if (this.Name.Contains("Stool") || data.type == "stool")
            {
                isStool = true;
            }

            //furniture_type.Value = data.type.Contains("table") ? 11 : decorTypes.Contains(data.type) ? 8 : CustomFurnitureMod.helper.Reflection.GetMethod(new Furniture(), "getTypeNumberFromName").Invoke<int>(data.type);
            furniture_type.Value    = getTypeFromName(typename);
            defaultSourceRect.Value = new Rectangle(data.index * 16 % texture.Width, data.index * 16 / texture.Width * 16, 1, 1);
            drawHeldObjectLow.Value = false;

            defaultSourceRect.Width  = data.width * 16;
            defaultSourceRect.Height = data.height * 16;
            sourceRect.Value         = new Rectangle(defaultSourceRect.X, defaultSourceRect.Y, defaultSourceRect.Width, defaultSourceRect.Height);
            animatedSourceRect       = sourceRect;
            defaultSourceRect.Value  = sourceRect;

            defaultBoundingBox.Value = new Rectangle((int)tileLocation.X, (int)tileLocation.Y, data.boxWidth * Game1.tileSize, data.boxHeight * Game1.tileSize);

            boundingBox.Value        = new Rectangle((int)tileLocation.X * Game1.tileSize, (int)tileLocation.Y * Game1.tileSize, defaultBoundingBox.Width, defaultBoundingBox.Height);
            defaultBoundingBox.Value = boundingBox;

            updateDrawPosition();
            rotations.Value = data.rotations;
            price.Value     = data.price;

            fRotation       = FurnitureRotation.horizontal;
            texture         = null;
            textureOverlay  = null;
            textureUnderlay = null;
        }
 public CustomFurniture(CustomFurnitureData data, string objectID, Vector2 tile)
 {
     build(data, objectID, tile);
 }