Ejemplo n.º 1
0
        public override Item getOne()
        {
            ModularDecoration ModularDecoration = new ModularDecoration(this.parentSheetIndex, this.tileLocation, this.SourceFilePathAndName);

            /*
             * drawPosition = this.drawPosition;
             * defaultBoundingBox = this.defaultBoundingBox;
             * boundingBox = this.boundingBox;
             * currentRotation = this.currentRotation - 1;
             * rotations = this.rotations;
             * rotate();
             */
            return(ModularDecoration);
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
0
        public override bool canBePlacedHere(GameLocation l, Vector2 tile)
        {
            if ((l is FarmHouse))
            {
                for (int i = 0; i < this.boundingBox.Width / Game1.tileSize; i++)
                {
                    for (int j = 0; j < this.boundingBox.Height / Game1.tileSize; j++)
                    {
                        Vector2 vector = tile * (float)Game1.tileSize + new Vector2((float)i, (float)j) * (float)Game1.tileSize;
                        vector.X += (float)(Game1.tileSize / 2);
                        vector.Y += (float)(Game1.tileSize / 2);
                        foreach (KeyValuePair <Vector2, StardewValley.Object> something in l.objects)
                        {
                            StardewValley.Object obj = something.Value;
                            if ((obj.GetType()).ToString().Contains("ModularDecoration"))
                            {
                                ModularDecoration current = (ModularDecoration)obj;
                                if (current.Decoration_type == 11 && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y) && current.heldObject == null && this.getTilesWide() == 1)
                                {
                                    bool result = true;
                                    return(result);
                                }
                                if ((current.Decoration_type != 12 || this.Decoration_type == 12) && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y))
                                {
                                    bool result = false;
                                    return(result);
                                }
                            }
                        }
                    }
                }
                return(base.canBePlacedHere(l, tile));
            }
            else
            {
                // Game1.showRedMessage("NOT FARMHOUSE");
                for (int i = 0; i < this.boundingBox.Width / Game1.tileSize; i++)
                {
                    for (int j = 0; j < this.boundingBox.Height / Game1.tileSize; j++)
                    {
                        Vector2 vector = tile * (float)Game1.tileSize + new Vector2((float)i, (float)j) * (float)Game1.tileSize;
                        vector.X += (float)(Game1.tileSize / 2);
                        vector.Y += (float)(Game1.tileSize / 2);

                        /*
                         * foreach (Decoration current in (l as FarmHouse).Decoration)
                         * {
                         *  if (current.Decoration_type == 11 && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y) && current.heldObject == null && this.getTilesWide() == 1)
                         *  {
                         *      bool result = true;
                         *      return result;
                         *  }
                         *  if ((current.Decoration_type != 12 || this.Decoration_type == 12) && current.getBoundingBox(current.tileLocation).Contains((int)vector.X, (int)vector.Y))
                         *  {
                         *      bool result = false;
                         *      return result;
                         *  }
                         * }
                         */
                    }
                }
                return(base.canBePlacedHere(l, tile));
            }
        }