fix event priority sorting

This commit is contained in:
Jesse Plamondon-Willard 2020-06-21 11:36:35 -04:00
parent e64ecc89f9
commit c8f7269966
No known key found for this signature in database
GPG Key ID: CF8B1456B3E29F49
2 changed files with 4 additions and 1 deletions

View File

@ -7,6 +7,9 @@
* Migrated to Harmony 2.0 (see [_migrate to Harmony 2.0_](https://stardewvalleywiki.com/Modding:Migrate_to_Harmony_2.0) for more info). * Migrated to Harmony 2.0 (see [_migrate to Harmony 2.0_](https://stardewvalleywiki.com/Modding:Migrate_to_Harmony_2.0) for more info).
--> -->
## Upcoming release
* Fixed event priority sorting.
## 3.6 ## 3.6
Released 20 June 2020 for Stardew Valley 1.4.1 or later. Released 20 June 2020 for Stardew Valley 1.4.1 or later.

View File

@ -47,7 +47,7 @@ namespace StardewModdingAPI.Framework.Events
if (!(obj is ManagedEventHandler<TEventArgs> other)) if (!(obj is ManagedEventHandler<TEventArgs> other))
throw new ArgumentException("Can't compare to an unrelated object type."); throw new ArgumentException("Can't compare to an unrelated object type.");
int priorityCompare = this.Priority.CompareTo(other.Priority); int priorityCompare = -this.Priority.CompareTo(other.Priority); // higher value = sort first
return priorityCompare != 0 return priorityCompare != 0
? priorityCompare ? priorityCompare
: this.RegistrationOrder.CompareTo(other.RegistrationOrder); : this.RegistrationOrder.CompareTo(other.RegistrationOrder);