Exemplo n.º 1
0
        public static bool Prefix(Fence __instance, Item dropIn, bool probe, Farmer who, ref bool __result)
        {
            if (__instance.health.Value > 1 || !__instance.CanRepairWithThisItem(dropIn))
            {
                return(true);
            }

            foreach (var fence in Mod.instance.fences)
            {
                if (__instance.whichType.Value == fence.correspondingObject.GetObjectId())
                {
                    if (probe)
                    {
                        __result = true;
                        return(false);
                    }

                    if (dropIn.ParentSheetIndex == fence.correspondingObject.GetObjectId())
                    {
                        __instance.health.Value = fence.MaxHealth + Game1.random.Next(-1000, 1000) / 100f;   // Technically I should add a field to the json to make this changeable, but meh.
                        who.currentLocation.playSound(fence.RepairSound, NetAudio.SoundContext.Default);
                        __result = true;
                        return(false);
                    }
                }
            }

            return(true);
        }