feat: Adds PlayerDeathEvent and CreatureDeathEvent using code generated events (#1927)

### Summary
- Adds [Code Generated Events](https://github.com/modernuo/CodeGeneratedEvents)
- Removes EventSink.PlayerDeath
- Adds `PlayerDeathEvent` and `CreatureDeathEvent` using code generated events

> [!Important]
> **Developer Note**
> Use `[OnEvent(nameof(PlayerMobile.PlayerDeathEvent))]` instead of `EventSink.PlayerDeath` delegate
> Check this commit for examples of how to use this.
This commit is contained in:
Guyute 2024-09-06 00:23:03 -04:00 • committed by GitHub
parent d5984ce058
commit 95cd8749a3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
26 changed files with 191 additions and 135 deletions

View file

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using ModernUO.CodeGeneratedEvents;
using Server.Gumps;
using Server.Misc;
using Server.Mobiles;
@ -26,16 +27,16 @@ public class ReportMurdererGump : StaticGump<ReportMurdererGump>
public static void Initialize()
{
_recentlyReportedDelay = ServerConfiguration.GetOrUpdateSetting("murderSystem.recentlyReportedDelay", TimeSpan.FromMinutes(10));
EventSink.PlayerDeath += OnPlayerDeath;
}
public static void OnPlayerDeath(Mobile m)
[OnEvent(nameof(PlayerMobile.PlayerDeathEvent))]
public static void OnPlayerDeathEvent(PlayerMobile m)
{
List<Mobile> killers = null;
HashSet<Mobile> toGive = null;
// Guards won't take reports of the death of a thief!
bool notInThievesGuild = m is not PlayerMobile { NpcGuild: NpcGuild.ThievesGuild };
bool notInThievesGuild = m.NpcGuild != NpcGuild.ThievesGuild;
foreach (var ai in m.Aggressors)
{