derexsv
Cowpoke
Question about changing the entry warps to the main farm.
I'm trying to avoid using Harmony.
My mod gives each farmhand their own map based on the "New Farm" type.
The goal is that whenever a farmhand tries to enter the main farm from locations such as "BusStop", "Backwoods", "Forest", or "FarmCave", they are redirected to their respective personal farm map.
As far as I know, these are the most common locations that contain warps leading to the main farm.
What I want is simple: each farmhand should be sent to their own farm.
The problem is that I’m not sure what the recommended or cleanest flow would be for implementing this.
For example, SMAPI doesn’t provide an event that fires before a warp happens, or while the warp is in progress.
There is `helper.Events.Player.Warped`, which provides `StardewModdingAPI.Events.WarpedEventArgs`. However, this event is triggered only after the warp has already occurred. While it could technically solve my problem, I’m not happy with that approach because it would always result in two warps.
And to me, that feels very wrong.
Another approach I investigated — and one that matches exactly what I want — is to edit the maps "BusStop", "Backwoods", "Forest", and "FarmCave", removing from their Warp properties any warps that lead to "Farm".
Then, for the tiles that previously had warps to the farm, I collected their X/Y positions so I could assign a "TouchAction" to those tiles instead.
However, some of those tiles required extra handling because a few of them are outside the visible map boundaries.
Also, for a TouchAction to trigger, the player must interact with the tile.
After handling those issues, inside the function that processes the TouchAction I check whether the player interacting with the tile is the MainPlayer. If so, I send them to the original farm.
If the player is a farmhand, I send them to the personal map assigned by the mod.
As I said, this solution works 100% the way I want.
But it required a huge amount of effort and careful handling for something that should be simple.
So my question is:
Is there a simpler and more efficient solution, without depending on Harmony, and that avoids causing double warps?
I'm trying to avoid using Harmony.
My mod gives each farmhand their own map based on the "New Farm" type.
The goal is that whenever a farmhand tries to enter the main farm from locations such as "BusStop", "Backwoods", "Forest", or "FarmCave", they are redirected to their respective personal farm map.
As far as I know, these are the most common locations that contain warps leading to the main farm.
What I want is simple: each farmhand should be sent to their own farm.
The problem is that I’m not sure what the recommended or cleanest flow would be for implementing this.
For example, SMAPI doesn’t provide an event that fires before a warp happens, or while the warp is in progress.
There is `helper.Events.Player.Warped`, which provides `StardewModdingAPI.Events.WarpedEventArgs`. However, this event is triggered only after the warp has already occurred. While it could technically solve my problem, I’m not happy with that approach because it would always result in two warps.
And to me, that feels very wrong.
Another approach I investigated — and one that matches exactly what I want — is to edit the maps "BusStop", "Backwoods", "Forest", and "FarmCave", removing from their Warp properties any warps that lead to "Farm".
Then, for the tiles that previously had warps to the farm, I collected their X/Y positions so I could assign a "TouchAction" to those tiles instead.
However, some of those tiles required extra handling because a few of them are outside the visible map boundaries.
Also, for a TouchAction to trigger, the player must interact with the tile.
After handling those issues, inside the function that processes the TouchAction I check whether the player interacting with the tile is the MainPlayer. If so, I send them to the original farm.
If the player is a farmhand, I send them to the personal map assigned by the mod.
As I said, this solution works 100% the way I want.
But it required a huge amount of effort and careful handling for something that should be simple.
So my question is:
Is there a simpler and more efficient solution, without depending on Harmony, and that avoids causing double warps?