Example #1
0
        public override bool placementAction(GameLocation location, int x, int y, StardewValley.Farmer who = null)
        {
            Point point = new Point(x / Game1.tileSize, y / Game1.tileSize);


            this.tileLocation = new Vector2((float)point.X, (float)point.Y);
            bool flag = false;

            if (this.Decoration_type == 6 || this.Decoration_type == 13 || this.parentSheetIndex == 1293)
            {
                int  num   = (this.parentSheetIndex == 1293) ? 3 : 0;
                bool flag2 = false;

                if (!flag2)
                {
                    Game1.showRedMessage("Must be placed on wall");
                    return(false);
                }
                flag = true;
            }
            for (int i = point.X; i < point.X + this.getTilesWide(); i++)
            {
                for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++)
                {
                    if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null)
                    {
                        Game1.showRedMessage("Furniture can't be placed here");
                        return(false);
                    }

                    if (location.getTileIndexAt(i, j, "Buildings") != -1)
                    {
                        return(false);
                    }
                }
            }
            if (this.boundingBox.Width == 0 && this.boundingBox.Height == 0)
            {
                this.boundingBox = new Rectangle(Int32.MinValue, y / Game1.tileSize * Game1.tileSize, 0, 0);
            }

            else
            {
                this.boundingBox = new Rectangle(x / Game1.tileSize * Game1.tileSize, y / Game1.tileSize * Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height);
            }

            /*
             * foreach (Furniture current2 in (location as DecoratableLocation).furniture)
             *  {
             *      if (current2.furniture_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox))
             *      {
             *          current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who);
             *          bool result = true;
             *          return result;
             *      }
             *  }
             */
            using (List <StardewValley.Farmer> .Enumerator enumerator3 = location.getFarmers().GetEnumerator())
            {
                while (enumerator3.MoveNext())
                {
                    if (enumerator3.Current.GetBoundingBox().Intersects(this.boundingBox))
                    {
                        Game1.showRedMessage("Can't place on top of a person.");
                        bool result = false;
                        return(result);
                    }
                }
            }
            this.updateDrawPosition();
            bool f = Util.placementAction(this, location, x, y, who);

            Log.AsyncM(this.sourceRect);
            int fff = 1;

            for (int X = 0; X < (this.sourceRect.Width / 16) * Game1.tileSize; X += Game1.tileSize)
            {
                for (int Y = 0; Y < (this.sourceRect.Height / 16) * Game1.tileSize; Y += Game1.tileSize)
                {
                    if (X == 0 && Y == 0)
                    {
                        continue;
                    }

                    ModularDecoration newThing = new ModularDecoration(this.parentSheetIndex, Vector2.Zero, this.SourceFilePathAndName, false, (X / Game1.tileSize), Y / Game1.tileSize);
                    newThing.placementActionNonRecursive(location, x + X, y + Y, who);
                    fff++;
                    Log.AsyncO("Placed an object: " + fff + " times.");
                    // f = Util.placementAction(newThing, location, x+X, y+Y, who);
                    //Log.AsyncG("X: "+X+" Y: "+Y);
                }
            }

            /*
             * if (f == true)
             * {
             *   foreach(var v in blankSpace)
             *   {
             *       v.placementAction(Game1.player.currentLocation, x+(v.xTileOffset), y+(v.yTileOffset), who);
             *   }
             * }
             */
            return(f);
            //  Game1.showRedMessage("Can only be placed in House");
            //  return false;
        }