コード例 #1
0
 public static bool SetRandomPositionInHome(SDV.FarmAnimal animal)
 {
     if (!HasHome(animal))
     {
         return(false);
     }
     animal.setRandomPosition(animal.home.indoors.Value);
     return(true);
 }
コード例 #2
0
        public StardewValley.FarmAnimal ToFarmAnimal()
        {
            // Create a new resource
            StardewValley.FarmAnimal BaseFarmAnimal = new StardewValley.FarmAnimal(this.type, this.myID, this.ownerID);

            // Copy the identification
            ((NetFieldBase <string, NetString>)BaseFarmAnimal.type).Set(this.type);
            ((NetFieldBase <long, NetLong>)BaseFarmAnimal.myID).Set(this.myID);
            ((NetFieldBase <long, NetLong>)BaseFarmAnimal.ownerID).Set(this.ownerID);

            // Copy the name
            BaseFarmAnimal.Name        = this.Name;
            BaseFarmAnimal.displayName = this.displayName;

            // Copy the biology
            ((NetFieldBase <int, NetInt>)BaseFarmAnimal.health).Set(this.health);
            ((NetFieldBase <long, NetLong>)BaseFarmAnimal.parentId).Set(this.parentId);

            // Copy the data
            ((NetFieldBase <byte, NetByte>)BaseFarmAnimal.daysToLay).Set(this.daysToLay);
            ((NetFieldBase <byte, NetByte>)BaseFarmAnimal.ageWhenMature).Set(this.ageWhenMature);
            ((NetFieldBase <int, NetInt>)BaseFarmAnimal.defaultProduceIndex).Set(this.defaultProduceIndex);
            ((NetFieldBase <int, NetInt>)BaseFarmAnimal.deluxeProduceIndex).Set(this.deluxeProduceIndex);
            ((NetFieldBase <string, NetString>)BaseFarmAnimal.sound).Set(this.sound);
            ((NetFieldBase <Rectangle, NetRectangle>)BaseFarmAnimal.frontBackBoundingBox).Set(this.frontBackBoundingBox);
            ((NetFieldBase <Rectangle, NetRectangle>)BaseFarmAnimal.sidewaysBoundingBox).Set(this.sidewaysBoundingBox);
            ((NetFieldBase <byte, NetByte>)BaseFarmAnimal.harvestType).Set(this.harvestType);
            ((NetFieldBase <bool, NetBool>)BaseFarmAnimal.showDifferentTextureWhenReadyForHarvest).Set(this.showDifferentTextureWhenReadyForHarvest);
            ((NetFieldBase <string, NetString>)BaseFarmAnimal.buildingTypeILiveIn).Set(this.buildingTypeILiveIn);
            BaseFarmAnimal.Sprite = this.Sprite;
            ((NetFieldBase <Rectangle, NetRectangle>)BaseFarmAnimal.frontBackSourceRect).Set(this.frontBackSourceRect);
            ((NetFieldBase <Rectangle, NetRectangle>)BaseFarmAnimal.sidewaysSourceRect).Set(this.sidewaysSourceRect);
            ((NetFieldBase <byte, NetByte>)BaseFarmAnimal.fullnessDrain).Set(this.fullnessDrain);
            ((NetFieldBase <byte, NetByte>)BaseFarmAnimal.happinessDrain).Set(this.happinessDrain);
            ((NetFieldBase <byte, NetByte>)BaseFarmAnimal.happiness).Set(this.happiness);
            ((NetFieldBase <byte, NetByte>)BaseFarmAnimal.fullness).Set(this.fullness);
            ((NetFieldBase <string, NetString>)BaseFarmAnimal.toolUsedForHarvest).Set(this.toolUsedForHarvest);
            ((NetFieldBase <int, NetInt>)BaseFarmAnimal.meatIndex).Set(this.meatIndex);
            ((NetFieldBase <int, NetInt>)BaseFarmAnimal.price).Set(this.price);

            // Copy the location information
            BaseFarmAnimal.home = this.home;
            BaseFarmAnimal.homeLocation.Set(this.homeLocation);

            if (this.home != null)
            {
                // Reset their position
                // !!! They will get stuck not moving if this is just copied over
                BaseFarmAnimal.setRandomPosition(this.home.indoors);
            }

            // Copy the misc information
            ((NetFieldBase <int, NetInt>)BaseFarmAnimal.friendshipTowardFarmer).Set(this.friendshipTowardFarmer);
            ((NetFieldBase <int, NetInt>)BaseFarmAnimal.daysSinceLastFed).Set(this.daysSinceLastFed);
            BaseFarmAnimal.uniqueFrameAccumulator = this.uniqueFrameAccumulator;
            ((NetFieldBase <int, NetInt>)BaseFarmAnimal.age).Set(this.age);
            ((NetFieldBase <int, NetInt>)BaseFarmAnimal.produceQuality).Set(this.produceQuality);
            ((NetFieldBase <byte, NetByte>)BaseFarmAnimal.daysSinceLastLay).Set(this.daysSinceLastLay);
            ((NetFieldBase <bool, NetBool>)BaseFarmAnimal.wasPet).Set(this.wasPet);
            ((NetFieldBase <bool, NetBool>)BaseFarmAnimal.allowReproduction).Set(this.allowReproduction);
            ((NetFieldBase <int, NetInt>)BaseFarmAnimal.moodMessage).Set(this.moodMessage);

            return(BaseFarmAnimal);
        }