示例#1
0
 public StardewValley.FarmAnimal CreateFarmAnimal(
     string type,
     string name = null,
     StardewValley.Buildings.Building building = null)
 {
     return(Paritee.StardewValley.Core.Characters.FarmAnimal.CreateFarmAnimal(type, GetUniqueId(), name, building));
 }
        //public static IEnumerable<CodeInstruction> Buildings_Building_doAction_transp(IEnumerable<CodeInstruction> oldInstructions) {
        //    var walker = new InstructionsWalker(oldInstructions);

        //    /* Looking for CIL:
        //        // [280 13 - 280 200]
        //        IL_02f1: ldsfld       class StardewValley.LocalizedContentManager StardewValley.Game1::content
        //        IL_02f6: ldstr        "Strings\\Buildings:PiecesOfHay"
        //        IL_02fb: ldstr        "Farm"
        //        IL_0300: call         class StardewValley.GameLocation StardewValley.Game1::getLocationFromName(string)
        //        IL_0305: isinst       StardewValley.Farm
        //        IL_030a: ldfld        class [Netcode]Netcode.NetInt StardewValley.Farm::piecesOfHay
        //        IL_030f: call         int32 StardewValley.Utility::numSilos()
        //        IL_0314: ldc.i4       240 // 0x000000f0
        //        IL_0319: mul
        //        IL_031a: box          [mscorlib]System.Int32
        //        IL_031f: callvirt     instance string StardewValley.LocalizedContentManager::LoadString(string, object, object)
        //        IL_0324: call         void StardewValley.Game1::drawObjectDialogue(string)
        //    */
        //    var to_replace = new WantOp(OpCodes.Ldc_I4, 240);
        //    var target = new WantOp[] {
        //        new WantOp(OpCodes.Ldsfld, "content"),
        //        new WantOp(OpCodes.Ldstr, "Strings\\Buildings:PiecesOfHay"),
        //        new WantOp(OpCodes.Ldstr, "Farm"),
        //        new WantOp(OpCodes.Call, "getLocationFromName"),
        //        new WantOp(OpCodes.Isinst),
        //        wopc.fld_piecesofhay,
        //        wopc.call_numsilos,
        //        wopc.int_240,
        //        wopc.mul,
        //        wopc.box,
        //        new WantOp(OpCodes.Callvirt, "LoadString"),
        //        new WantOp(OpCodes.Call, "drawObjectDialogue")
        //        };
        //    walker
        //        .GoFind(target)
        //        .GoForward(7)
        //        .ReplaceAt(with: new CodeInstruction(OpCodes.Ldc_I4, SiloCapacity), assert_previous: to_replace)
        //        ;

        //    return walker.Instructions;
        //    }

        public static bool Buildings_Building_doAction_prefix(StardewValley.Buildings.Building __instance, ref bool __result, Vector2 tileLocation, Farmer who)
        {
            try {
                if (who.isRidingHorse())
                {
                    // Hand over to original
                    return(true);
                }
                float tileLocX = tileLocation.X;
                float tileLocY = tileLocation.Y;
                int   tileX    = __instance.tileX.Value;
                int   tileY    = __instance.tileY.Value;
                if (
                    who.IsLocalPlayer &&
                    tileLocX >= tileX &&
                    tileLocX < (tileX + __instance.tilesWide.Value) &&
                    tileLocY >= tileY &&
                    tileLocY < (tileY + __instance.tilesHigh.Value) &&
                    __instance.daysOfConstructionLeft.Value > 0
                    )
                {
                    // Hand over to original
                    return(true);
                }
                Point humanDoor = __instance.humanDoor.Value;
                if (!(
                        who.IsLocalPlayer &&
                        tileLocX == (humanDoor.X + tileX) &&
                        tileLocY == (humanDoor.Y + tileY) &&
                        __instance.indoors.Value != null
                        ))
                {
                    if (who.IsLocalPlayer && __instance.buildingType.Equals("Silo") && !__instance.isTilePassable(tileLocation))
                    {
                        if (who.ActiveObject is null || who.ActiveObject.parentSheetIndex.Value != 178)
                        {
                            Game1.drawObjectDialogue(
                                Game1.content.LoadString(
                                    "Strings\\Buildings:PiecesOfHay",
                                    Game1.getFarm().piecesOfHay,
                                    Utility.numSilos() * SiloCapacity
                                    )
                                );
                            __result = false;
                            return(false);  // We've taken over, do not execute original function
                        }
                    }
                }
                // Everything else, execute original function
                return(true);
            }
            catch (Exception ex) {
                Monitor.Log($"Buildings_Building_doAction_prefix technical issue:\n{ex}", LogLevel.Error);
                Monitor.Log("Reverting to unpatched Buildings.Building.doAction behavior!", LogLevel.Warn);
                return(true);
            }
        }
 public AnimalBuilding(StardewValley.Buildings.Building building, Farm farm) :
     base(building)
 {
     this.Farm = farm;
 }
示例#4
0
 public Building(StardewValley.Buildings.Building building)
 {
     this.building = building;
 }
示例#5
0
 public AnimalBuilding(StardewValley.Buildings.Building building) :
     base(building)
 {
 }
示例#6
0
 public void AddToBuilding(StardewValley.Buildings.Building building)
 {
     Paritee.StardewValley.Core.Characters.FarmAnimal.AddToBuilding(GetOriginal(), building);
 }
示例#7
0
 public void Reload(StardewValley.Buildings.Building building)
 {
     Paritee.StardewValley.Core.Characters.FarmAnimal.Reload(GetOriginal(), building);
 }
示例#8
0
 public bool CanLiveIn(StardewValley.Buildings.Building building)
 {
     return(Paritee.StardewValley.Core.Characters.FarmAnimal.CanLiveIn(GetOriginal(), building));
 }
示例#9
0
 public void SetHome(StardewValley.Buildings.Building building)
 {
     Paritee.StardewValley.Core.Characters.FarmAnimal.SetHome(GetOriginal(), building);
 }
示例#10
0
 public Building(StardewValley.Buildings.Building original)
     : base(original)
 {
 }
示例#11
0
 public void SetNewAnimalHome(StardewValley.Buildings.Building building)
 {
     PurchaseAnimals.SetNewAnimalHome(GetOriginal(), building);
 }