Ejemplo n.º 1
0
    private static void UpdateNeighbors(HoeDirt dirt, int tileX, int tileY, GameLocation location)
    {
        Vector2 v = new(tileX, tileY);

        dirt.nearWaterForPaddy.Value = -1;
        if (dirt.hasPaddyCrop() && dirt.paddyWaterCheck(location, v))
        {
            dirt.state.Value = -1;
            dirt.updateNeighbors(location, v);
        }
    }
 public static void DayUpdatePostfix(HoeDirt __instance, ref GameLocation environment, ref Vector2 tileLocation, ref int __state)
 {
     if (environment is Farm || environment.isGreenhouse.Value)
     {
         if ((!__instance.hasPaddyCrop() || !__instance.paddyWaterCheck(environment, tileLocation)) && __state == 1 && (__instance.fertilizer.Value == 370 || __instance.fertilizer.Value == 371))
         {
             if (TileLocationState.ContainsKey(tileLocation))
             {
                 __instance.state.Value = TileLocationState[tileLocation];
                 return;
             }
             else
             {
                 TileLocationState[tileLocation] = __instance.state.Value;
                 AddStateAdjacentFertilizedTiles(environment, tileLocation, __instance.state.Value, __instance.fertilizer.Value);
             }
         }
     }
 }
Ejemplo n.º 3
0
        public static void dayUpdate(HoeDirt hoeDirt, GameLocation environment, Vector2 tileLocation)
        {
            if (hoeDirt.crop != null)
            {
                hoeDirt.crop.newDay((int)((NetFieldBase <int, NetInt>)hoeDirt.state), (int)((NetFieldBase <int, NetInt>)hoeDirt.fertilizer), (int)tileLocation.X, (int)tileLocation.Y, environment);

                /*if ((bool)((NetFieldBase<bool, NetBool>)environment.isOutdoors) && Game1.currentSeason.Equals("winter") && (this.crop != null && !this.crop.isWildSeedCrop()) && !environment.IsGreenhouse)
                 *  this.destroyCrop(tileLocation, false, environment);
                 */
            }
            if ((!hoeDirt.hasPaddyCrop() || !hoeDirt.paddyWaterCheck(environment, tileLocation)) && ((int)((NetFieldBase <int, NetInt>)hoeDirt.fertilizer) != 370 || Game1.random.NextDouble() >= 0.33) && ((int)((NetFieldBase <int, NetInt>)hoeDirt.fertilizer) != 371 || Game1.random.NextDouble() >= 0.66))
            {
                hoeDirt.state.Value = 0;
            }
            if (!environment.IsGreenhouse)
            {
                return;
            }
            hoeDirt.isGreenhouseDirt.Value = true;
            SpaceCore.instance.Helper.Reflection.GetField <NetColor>(hoeDirt, "c").GetValue().Value = Color.White;
        }
Ejemplo n.º 4
0
        /// <summary>The method to call before <see cref="HoeDirt.plant"/>.</summary>
        /// <remarks>This patch allows planting crops out of season when near a Tempus Globe.</remarks>
        private static bool Before_Plant(HoeDirt __instance, int index, int tileX, int tileY, Farmer who, bool isFertilizer, GameLocation location, ref bool __result)
        {
            if (isFertilizer)
            {
                return(true);
            }

            int seasonalDelimiter = Mod.Ja.GetBigCraftableId("Tempus Globe");

            bool foundDelimiter = false;

            for (int ix = -2; ix <= 2; ++ix)
            {
                for (int iy = -2; iy <= 2; ++iy)
                {
                    var key = new Vector2(tileX + ix, tileY + iy);
                    if (location.objects.ContainsKey(key))
                    {
                        var obj = location.objects[key];
                        if (obj.bigCraftable.Value && obj.ParentSheetIndex == seasonalDelimiter)
                        {
                            foundDelimiter = true;
                        }
                    }
                }
            }

            // Now for the original method
            Crop c = new Crop(index, tileX, tileY);

            if (c.seasonsToGrowIn.Count == 0)
            {
                return(false);
            }
            if (!who.currentLocation.IsFarm && !who.currentLocation.IsGreenhouse && !who.currentLocation.CanPlantSeedsHere(index, tileX, tileY) && who.currentLocation.IsOutdoors)
            {
                Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:HoeDirt.cs.13919"));
                return(false);
            }
            if (foundDelimiter || !who.currentLocation.IsOutdoors || who.currentLocation.IsGreenhouse || c.seasonsToGrowIn.Contains(location.GetSeasonForLocation()) || who.currentLocation.SeedsIgnoreSeasonsHere())
            {
                __instance.crop = c;
                if (c.raisedSeeds.Value)
                {
                    location.playSound("stoneStep");
                }
                location.playSound("dirtyHit");
                Game1.stats.SeedsSown++;
                PatchHelper.RequireMethod <HoeDirt>("applySpeedIncreases").Invoke(__instance, new object[] { who });
                __instance.nearWaterForPaddy.Value = -1;
                if (__instance.hasPaddyCrop() && __instance.paddyWaterCheck(location, new Vector2(tileX, tileY)))
                {
                    __instance.state.Value = 1;
                    __instance.updateNeighbors(location, new Vector2(tileX, tileY));
                }
                __result = true;
                return(false);
            }
            if (c.seasonsToGrowIn.Count > 0 && !c.seasonsToGrowIn.Contains(location.GetSeasonForLocation()))
            {
                Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:HoeDirt.cs.13924"));
            }
            else
            {
                Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:HoeDirt.cs.13925"));
            }
            return(false);
        }
Ejemplo n.º 5
0
        public static bool Prefix(HoeDirt __instance, int index, int tileX, int tileY, Farmer who, bool isFertilizer, GameLocation location, ref bool __result)
        {
            if (isFertilizer)
            {
                return(true);
            }

            int seasonalDelimiter = Mod.ja.GetBigCraftableId("Tempus Globe");

            bool foundDelimiter = false;

            for (int ix = -2; ix <= 2; ++ix)
            {
                for (int iy = -2; iy <= 2; ++iy)
                {
                    var key = new Vector2(tileX + ix, tileY + iy);
                    if (location.objects.ContainsKey(key))
                    {
                        var obj = location.objects[key];
                        if (obj.bigCraftable.Value && obj.ParentSheetIndex == seasonalDelimiter)
                        {
                            foundDelimiter = true;
                        }
                    }
                }
            }

            // Now for the original method
            Crop crop = new Crop(index, tileX, tileY);

            if (crop.seasonsToGrowIn.Count == 0)
            {
                return(false);
            }
            if (!(bool)((NetFieldBase <bool, NetBool>)who.currentLocation.isFarm) && !who.currentLocation.IsGreenhouse && who.currentLocation.IsOutdoors)
            {
                Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:HoeDirt.cs.13919"));
                return(false);
            }
            if (foundDelimiter || !(bool)((NetFieldBase <bool, NetBool>)who.currentLocation.isOutdoors) || who.currentLocation.IsGreenhouse || crop.seasonsToGrowIn.Contains(Game1.currentSeason))
            {
                __instance.crop = crop;
                if ((bool)((NetFieldBase <bool, NetBool>)crop.raisedSeeds))
                {
                    location.playSound("stoneStep", NetAudio.SoundContext.Default);
                }
                location.playSound("dirtyHit", NetAudio.SoundContext.Default);
                ++Game1.stats.SeedsSown;
                AccessTools.Method(__instance.GetType(), "applySpeedIncreases").Invoke(__instance, new object[] { who });
                __instance.nearWaterForPaddy.Value = -1;
                if (__instance.hasPaddyCrop() && __instance.paddyWaterCheck(location, new Vector2((float)tileX, (float)tileY)))
                {
                    __instance.state.Value = 1;
                    __instance.updateNeighbors(location, new Vector2((float)tileX, (float)tileY));
                }
                __result = true;
                return(false);
            }
            if (crop.seasonsToGrowIn.Count > 0 && !crop.seasonsToGrowIn.Contains(Game1.currentSeason))
            {
                Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:HoeDirt.cs.13924"));
            }
            else
            {
                Game1.showRedMessage(Game1.content.LoadString("Strings\\StringsFromCSFiles:HoeDirt.cs.13925"));
            }
            __result = false;
            return(false);
        }