Beispiel #1
0
        public override bool Drop(int i, int j)
        {
            Tile tile = Main.tile[i, j];                                                                                // a variable to make our code look cleaner

            TileObjectData data           = TileObjectData.GetTileData(tile);                                           //grabs the TileObjectData associated with our tile. So we dont have to use as many magic numbers
            int            fullFrameWidth = data.Width * (data.CoordinateWidth + data.CoordinatePadding);               //the width of a full frame of our multitile in pixels. We get this by multiplying the size of 1 full frame with padding by the width of our tile in tiles.

            if (PlantHelper.CurrentStage(i, j) == Stage.Grown && tile.frameY == 0 && tile.frameX % fullFrameWidth == 0) //Check if the current stage is fully grown and if this is the top left tile
            {
                Item.NewItem(i * 16, j * 16, 16, 16, ModContent.ItemType <Strawberry>(), Main.rand.Next(2, 5));         //spawn item in stacks of 2-4
            }
            return(false);
        }
Beispiel #2
0
        public virtual void OnDayBeginning()
        {
            if (!hasBeenWatered)
            {
                PlantHelper.Kill(Position.X, Position.Y, ObjectData);
            }
            else
            {
                Tile tile           = Framing.GetTileSafely(Position);                                                //you could probably add more safety checks if you want to be extra giga secure, but we assume RandomUpdate only calls valid tiles here
                int  fullFrameWidth = ObjectData.Width * (ObjectData.CoordinateWidth + ObjectData.CoordinatePadding); //the width of a full frame of our multitile in pixels. We get this by multiplying the size of 1 full frame with padding by the width of our tile in tiles.

                if (tile.frameY == 0 && tile.frameX % fullFrameWidth == 0 && PlantHelper.CurrentStage(Position.X, Position.Y) != Stage.Grown)
                {
                    PlantHelper.ProgressWithEffects(Position, ObjectData);
                }
            }

            hasBeenWatered = false;
        }