-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added
TileScanning
helper type + v1.0.2 update
- Loading branch information
1 parent
9b91801
commit 7a619f3
Showing
5 changed files
with
80 additions
and
5 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
displayName = absoluteAquarian Utilities | ||
author = absoluteAquarian | ||
version = 1.0.1.4 | ||
version = 1.0.2 |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[h1]v1.0.1.4[/h1] | ||
You can find the DLL, PDB and XML files in the mod's [url=https://github.com/absoluteAquarian/SerousCommonLib/releases/tag/v1.0.1.4]GitHub repository[/url] | ||
[h1]v1.0.2[/h1] | ||
You can find the DLL, PDB and XML files in the mod's [url=https://github.com/absoluteAquarian/SerousCommonLib/releases/tag/v1.0.2]GitHub repository[/url] | ||
|
||
- Fixed yet another bug in EnhancedItemSlot where it used the wrong Item object for the OnItemChanged event | ||
- Added the [b]TileScanning[/b] helper class |
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 |
---|---|---|
@@ -1,10 +1,13 @@ | ||
The common library for absoluteAquarian's various mods. | ||
|
||
The DLL, PDB and XML files for this mod can be found at: | ||
https://github.com/absoluteAquarian/SerousCommonLib/releases/tag/v1.0.1.4 | ||
https://github.com/absoluteAquarian/SerousCommonLib/releases/tag/v1.0.2 | ||
|
||
Many features are included in this mod, including but not limited to: | ||
- IL/On edit helpers | ||
- Type extensions | ||
- UI element types | ||
- Easy tooltip modification | ||
- Tile scanning information | ||
- ILoot helpers | ||
- and more! |
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,30 @@ | ||
using MonoMod.RuntimeDetour.HookGen; | ||
using SerousCommonLib.API.Helpers; | ||
using System.Reflection; | ||
using Terraria.ModLoader; | ||
|
||
namespace SerousCommonLib.API.Edits { | ||
internal class NearbyEffectsBlocking : Edit { | ||
private static readonly MethodInfo TileLoader_NearbyEffects = typeof(TileLoader).GetMethod(nameof(TileLoader.NearbyEffects), BindingFlags.Public | BindingFlags.Static); | ||
|
||
private delegate void orig_TileLoader_NearbyEffects(int i, int j, int type, bool closer); | ||
private delegate void hook_TileLoader_NearbyEffects(orig_TileLoader_NearbyEffects orig, int i, int j, int type, bool closer); | ||
private static event hook_TileLoader_NearbyEffects On_TileLoader_NearbyEffects { | ||
add => HookEndpointManager.Add<hook_TileLoader_NearbyEffects>(TileLoader_NearbyEffects, value); | ||
remove => HookEndpointManager.Remove<hook_TileLoader_NearbyEffects>(TileLoader_NearbyEffects, value); | ||
} | ||
|
||
public override void LoadEdits() { | ||
On_TileLoader_NearbyEffects += Hook_TileLoader_NearbyEffects; | ||
} | ||
|
||
public override void UnloadEdits() { | ||
On_TileLoader_NearbyEffects -= Hook_TileLoader_NearbyEffects; | ||
} | ||
|
||
private void Hook_TileLoader_NearbyEffects(orig_TileLoader_NearbyEffects orig, int i, int j, int type, bool closer) { | ||
if (!TileScanning.DoBlockHooks) | ||
orig(i, j, type, closer); | ||
} | ||
} | ||
} |
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,42 @@ | ||
using Microsoft.Xna.Framework; | ||
using Terraria; | ||
|
||
namespace SerousCommonLib.API.Helpers { | ||
/// <summary> | ||
/// A helper class for retrieving biome information around a given area | ||
/// </summary> | ||
public static class TileScanning { | ||
internal static bool DoBlockHooks; | ||
|
||
/// <summary> | ||
/// Performs biome scanning with <paramref name="worldCenter"/> as the center of the scanning area | ||
/// </summary> | ||
/// <param name="worldCenter">The world coordinates for the center of the scanning area</param> | ||
/// <returns>A <see cref="SceneMetrics"/> instance containing biome information, or <see langword="null"/> if an exception was caught</returns> | ||
public static SceneMetrics Scan(Vector2 worldCenter) { | ||
try { | ||
SceneMetrics sceneMetrics = new(); | ||
|
||
SceneMetricsScanSettings settings = new SceneMetricsScanSettings { | ||
VisualScanArea = null, | ||
BiomeScanCenterPositionInWorld = worldCenter, | ||
ScanOreFinderData = false | ||
}; | ||
|
||
DoBlockHooks = true; | ||
|
||
sceneMetrics.ScanAndExportToMain(settings); | ||
|
||
DoBlockHooks = false; | ||
|
||
// Reset the player's biomes to reset | ||
Main.LocalPlayer.ForceUpdateBiomes(); | ||
|
||
return sceneMetrics; | ||
} catch { | ||
// Swallow any exceptions | ||
return null; | ||
} | ||
} | ||
} | ||
} |