-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Allow panning spots to exist even without the boulder removed
- Loading branch information
1 parent
6d75855
commit 314f757
Showing
2 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
112 changes: 112 additions & 0 deletions
112
StardewArchipelago/GameModifications/CodeInjections/PanningSpotInjections.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
using System; | ||
using System.Linq; | ||
using KaitoKid.ArchipelagoUtilities.Net.Client; | ||
using KaitoKid.ArchipelagoUtilities.Net.Interfaces; | ||
using Microsoft.Xna.Framework; | ||
using StardewValley; | ||
using StardewValley.Extensions; | ||
using StardewValley.Locations; | ||
using StardewValley.Menus; | ||
using StardewValley.Tools; | ||
|
||
namespace StardewArchipelago.GameModifications.CodeInjections | ||
{ | ||
public static class PanningSpotInjections | ||
{ | ||
private static ILogger _logger; | ||
private static ArchipelagoClient _archipelago; | ||
|
||
public static void Initialize(ILogger logger, ArchipelagoClient archipelago) | ||
{ | ||
_logger = logger; | ||
_archipelago = archipelago; | ||
} | ||
|
||
// public virtual bool performOrePanTenMinuteUpdate(Random r) | ||
public static bool PerformOrePanTenMinuteUpdate_AllowPanningSpotsAlways_Prefix(GameLocation __instance, Random r, ref bool __result) | ||
{ | ||
try | ||
{ | ||
Point point; | ||
// No need for the glittering boulder, just the pan is enough | ||
if (__instance is not Beach) | ||
{ | ||
point = __instance.orePanPoint.Value; | ||
if (point.Equals(Point.Zero) && r.NextBool()) | ||
{ | ||
for (var index = 0; index < 8; ++index) | ||
{ | ||
var p = new Point(r.Next(0, __instance.Map.RequireLayer("Back").LayerWidth), r.Next(0, __instance.Map.RequireLayer("Back").LayerHeight)); | ||
if (!__instance.isOpenWater(p.X, p.Y) || FishingRod.distanceToLand(p.X, p.Y, __instance, true) > 1 || __instance.getTileIndexAt(p, "Buildings") != -1) | ||
{ | ||
continue; | ||
} | ||
if (Game1.player.currentLocation.Equals(__instance)) | ||
{ | ||
__instance.playSound("slosh"); | ||
} | ||
__instance.orePanPoint.Value = p; | ||
__result = true; | ||
return false; // don't run original logic | ||
} | ||
__result = false; | ||
return false; // don't run original logic | ||
} | ||
} | ||
point = __instance.orePanPoint.Value; | ||
if (!point.Equals(Point.Zero) && r.NextDouble() < 0.1) | ||
{ | ||
__instance.orePanPoint.Value = Point.Zero; | ||
} | ||
__result = false; | ||
return false; // don't run original logic | ||
} | ||
catch (Exception ex) | ||
{ | ||
_logger.LogError($"Failed in {nameof(PerformOrePanTenMinuteUpdate_AllowPanningSpotsAlways_Prefix)}:\n{ex}"); | ||
return true; // run original logic | ||
} | ||
} | ||
|
||
// public override bool performOrePanTenMinuteUpdate(Random r) | ||
public static bool PerformOrePanTenMinuteUpdateOnIslandNorth_AllowPanningSpotsAlways_Prefix(IslandNorth __instance, Random r, ref bool __result) | ||
{ | ||
try | ||
{ | ||
var point = __instance.orePanPoint.Value; | ||
if (point.Equals(Point.Zero) && r.NextBool()) | ||
{ | ||
for (var index = 0; index < 3; ++index) | ||
{ | ||
var p = new Point(r.Next(4, 15), r.Next(45, 70)); | ||
if (!__instance.isOpenWater(p.X, p.Y) || FishingRod.distanceToLand(p.X, p.Y, (GameLocation)__instance) > 1 || __instance.getTileIndexAt(p, "Buildings") != -1) | ||
{ | ||
continue; | ||
} | ||
if (Game1.player.currentLocation.Equals((GameLocation)__instance)) | ||
{ | ||
__instance.playSound("slosh"); | ||
} | ||
__instance.orePanPoint.Value = p; | ||
__result = true; | ||
return false; // don't run original logic | ||
} | ||
__result = false; | ||
return false; // don't run original logic | ||
} | ||
point = __instance.orePanPoint.Value; | ||
if (!point.Equals(Point.Zero) && r.NextDouble() < 0.2) | ||
{ | ||
__instance.orePanPoint.Value = Point.Zero; | ||
} | ||
__result = false; | ||
return false; // don't run original logic | ||
} | ||
catch (Exception ex) | ||
{ | ||
_logger.LogError($"Failed in {nameof(PerformOrePanTenMinuteUpdateOnIslandNorth_AllowPanningSpotsAlways_Prefix)}:\n{ex}"); | ||
return true; // run original logic | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters