示例#1
0
        public static void ShiftPositionForBed(Farmer who)
        {
            BedFurniture bed = GetBedAtTile(who.currentLocation, (int)(who.position.X / 64f), (int)(who.position.Y / 64f));

            if (bed != null)
            {
                who.Position = Utility.PointToVector2(bed.GetBedSpot()) * 64f;
                if (bed.bedType != BedType.Double)
                {
                    if (who.currentLocation.map == null)
                    {
                        who.currentLocation.reloadMap();
                    }
                    if (!who.currentLocation.isTileLocationTotallyClearAndPlaceable(new Vector2(bed.TileLocation.X - 1f, bed.TileLocation.Y + 1f)))
                    {
                        who.faceDirection(3);
                    }
                    else
                    {
                        who.position.X -= 64f;
                        who.faceDirection(1);
                    }
                }
                else
                {
                    bool should_wake_up_in_spouse_spot = false;
                    if (who.currentLocation is FarmHouse)
                    {
                        FarmHouse farmhouse = who.currentLocation as FarmHouse;
                        if (farmhouse.owner != null)
                        {
                            if (farmhouse.owner.team.GetSpouse(farmhouse.owner.UniqueMultiplayerID) == who.UniqueMultiplayerID)
                            {
                                should_wake_up_in_spouse_spot = true;
                            }
                            else if (farmhouse.owner != who && !farmhouse.owner.isMarried())
                            {
                                should_wake_up_in_spouse_spot = true;
                            }
                        }
                    }
                    if (should_wake_up_in_spouse_spot)
                    {
                        who.position.X += 64f;
                        who.faceDirection(3);
                    }
                    else
                    {
                        who.position.X -= 64f;
                        who.faceDirection(1);
                    }
                }
            }
            who.position.Y += 32f;
            if (who.NetFields.Root != null)
            {
                (who.NetFields.Root as NetRoot <Farmer>).CancelInterpolation();
            }
        }
示例#2
0
        public override Item getOne()
        {
            BedFurniture bedFurniture = new BedFurniture(parentSheetIndex, tileLocation);

            bedFurniture.drawPosition.Value       = drawPosition;
            bedFurniture.defaultBoundingBox.Value = defaultBoundingBox;
            bedFurniture.boundingBox.Value        = boundingBox;
            bedFurniture.currentRotation.Value    = (int)currentRotation - 1;
            bedFurniture.isOn.Value      = false;
            bedFurniture.rotations.Value = rotations;
            bedFurniture.bedType         = bedType;
            bedFurniture.rotate();
            bedFurniture._GetOneFrom(this);
            return(bedFurniture);
        }