From 38ea9fa8535a706f8fec8be8c0a6dd69b91d69d4 Mon Sep 17 00:00:00 2001 From: David Camp Date: Sun, 24 Mar 2024 14:16:38 -0700 Subject: [PATCH] Full Update for 1.6 (#3) * Replace getTileLocation to Tile and change context when pointer is drawn * Full 1.6/4.0 update --------- Co-authored-by: itsbenter <68511682+itsbenter@users.noreply.github.com> --- src/ForagePointers.csproj | 105 +++++---------------------------- src/ModEntry.cs | 34 +++-------- src/Properties/AssemblyInfo.cs | 36 ----------- src/manifest.json | 2 +- src/packages.config | 4 -- 5 files changed, 25 insertions(+), 156 deletions(-) delete mode 100644 src/Properties/AssemblyInfo.cs delete mode 100644 src/packages.config diff --git a/src/ForagePointers.csproj b/src/ForagePointers.csproj index 4e9a8fd..d1fe04b 100644 --- a/src/ForagePointers.csproj +++ b/src/ForagePointers.csproj @@ -1,91 +1,16 @@ - - - - - Debug - AnyCPU - {968FF366-CB5A-4D5D-917B-74D2BC1B13A8} - Library - Properties - ForagePointers - ForagePointers - v4.5.2 - 512 - true - - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - true - bin\x86\Debug\ - DEBUG;TRACE - full - x86 - 7.3 - prompt - - - true - bin\x86\Release\ - TRACE - true - pdbonly - x86 - 7.3 - prompt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - + + + ForagePointers + 1.1.0 + net6.0 + Latest + + + + + + + + + \ No newline at end of file diff --git a/src/ModEntry.cs b/src/ModEntry.cs index 492fa6d..6ba8db6 100644 --- a/src/ModEntry.cs +++ b/src/ModEntry.cs @@ -14,7 +14,7 @@ class ModEntry : Mod private int ScaleEveryNLevels; private int ViewScalingFactor; private int MinimumViewDistance; - private static Vector2 offset = new Vector2(0f, -33f); + private static Vector2 offset = new(0f, -33f); private static bool shouldDraw = true; private static uint frameCounter = 0; #endregion @@ -24,9 +24,9 @@ public override void Entry(IModHelper helper) { Config = Helper.ReadConfig(); - ScaleEveryNLevels = Clamp(Config.ScaleEveryNLevels, 1, 10); - ViewScalingFactor = Clamp(Config.ScalingRadius, 0, 50); - MinimumViewDistance = Clamp(Config.MinimumViewDistance, 0, 100); + ScaleEveryNLevels = Math.Clamp(Config.ScaleEveryNLevels, 1, 10); + ViewScalingFactor = Math.Clamp(Config.ScalingRadius, 0, 50); + MinimumViewDistance = Math.Clamp(Config.MinimumViewDistance, 0, 100); Helper.Events.Display.RenderingHud += OnHudRendering; if(Config.BlinkPointers) @@ -37,22 +37,6 @@ public override void Entry(IModHelper helper) } #endregion - #region helperfunctions - /// - /// Clamps an integer between an inclusive lower and upper bounds. (Because .NET Framework doesn't have this function) - /// - /// The value to clamp. - /// The inclusive minimum to clamp to. - /// The inclusive Maximum to clamp to. - /// - private int Clamp(int val, int min, int max) - { - if (val < min) return min; - if (val > max) return max; - return val; - } - #endregion - #region eventListeners private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) { @@ -64,14 +48,14 @@ private void OnUpdateTicked(object sender, UpdateTickedEventArgs e) private void OnHudRendering(object sender, RenderingHudEventArgs e) { - if (Context.IsWorldReady && shouldDraw) + if (Context.IsPlayerFree && shouldDraw) //Changing Context.IsWorldReady to Context.IsPlayerFree to avoid drawing pointer during event and when menu opened { - var loc = Game1.player.getTileLocation(); + var loc = Game1.player.Tile; //getTileLocation removed var viewDist = Math.Pow(MinimumViewDistance + (Game1.player.ForagingLevel / ScaleEveryNLevels * ViewScalingFactor), 2); foreach (var v in Game1.currentLocation.objects.Pairs) { - if ((v.Value.isSpawnedObject || (Config.ShowArtifactSpots && v.Value.ParentSheetIndex == 590)) && Utility.isOnScreen(v.Key * 64f + new Vector2(32f, 32f), 64)) + if ((v.Value.IsSpawnedObject || (Config.ShowArtifactSpots && v.Value.ParentSheetIndex == 590)) && Utility.isOnScreen(v.Key * 64f + new Vector2(32f, 32f), 64)) { bool drawArrow = false; if (Game1.player.professions.Contains(17) || Config.AlwaysShow) drawArrow = true; //They have the Tracker profession, always show arrows. @@ -80,9 +64,9 @@ private void OnHudRendering(object sender, RenderingHudEventArgs e) if (drawArrow) { //Thanks to Esca for making this portion of the renderer easier to understand - Rectangle srcRect = new Rectangle(412, 495, 5, 4); + Rectangle srcRect = new(412, 495, 5, 4); float renderScale = 5f; - Vector2 centerOfObject = new Vector2((v.Key.X * 64) + 32, (v.Key.Y * 64) + 32); + Vector2 centerOfObject = new((v.Key.X * 64) + 32, (v.Key.Y * 64) + 32); Vector2 targetPixel = centerOfObject + offset; Vector2 trackerRenderPosition = Game1.GlobalToLocal(Game1.viewport, targetPixel); //get the target pixel's position relative to the viewport diff --git a/src/Properties/AssemblyInfo.cs b/src/Properties/AssemblyInfo.cs deleted file mode 100644 index a859f33..0000000 --- a/src/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("VisibleForage")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("VisibleForage")] -[assembly: AssemblyCopyright("Copyright © 2021")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("968ff366-cb5a-4d5d-917b-74d2bc1b13a8")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/manifest.json b/src/manifest.json index c111033..039bcd2 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,7 +1,7 @@ { "Name": "Forage Pointers", "Author": "Bpendragon", - "Version": "1.0.0", + "Version": "1.1.0", "Description": "Adds little arrows over forage, radius increases with foraging level", "UniqueID": "Bpendragon.ForagePointers", "EntryDll": "ForagePointers.dll", diff --git a/src/packages.config b/src/packages.config deleted file mode 100644 index c060e12..0000000 --- a/src/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file