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:
parent
d5984ce058
commit
95cd8749a3
26 changed files with 191 additions and 135 deletions
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.CodeGeneratedEvents;
|
||||
using Server.Engines.PartySystem;
|
||||
using Server.Factions;
|
||||
using Server.Gumps;
|
||||
|
|
@ -596,6 +597,9 @@ namespace Server.Engines.ConPVP
|
|||
}
|
||||
}
|
||||
|
||||
[OnEvent(nameof(PlayerMobile.PlayerDeathEvent))]
|
||||
public static void OnPlayerDeath(PlayerMobile m) => m.DuelContext?.OnDeath(m, m.Corpse);
|
||||
|
||||
public void OnDeath(Mobile mob, Container corpse)
|
||||
{
|
||||
if (!Registered || !Started)
|
||||
|
|
@ -1843,7 +1847,7 @@ namespace Server.Engines.ConPVP
|
|||
}
|
||||
|
||||
TransformationSpellHelper.RemoveContext(mob, true);
|
||||
AnimalForm.RemoveContext(mob, true);
|
||||
AnimalForm.RemoveContext(mob);
|
||||
DisguisePersistence.StopTimer(mob);
|
||||
|
||||
if (!mob.CanBeginAction<PolymorphSpell>())
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using ModernUO.CodeGeneratedEvents;
|
||||
using Server.Commands;
|
||||
using Server.Commands.Generic;
|
||||
using Server.Engines.MLQuests.Gumps;
|
||||
|
|
@ -611,6 +612,7 @@ namespace Server.Engines.MLQuests
|
|||
return context;
|
||||
}
|
||||
|
||||
[OnEvent(nameof(PlayerMobile.PlayerDeathEvent))]
|
||||
public static void HandleDeath(PlayerMobile pm)
|
||||
{
|
||||
var context = GetContext(pm);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ModernUO.CodeGeneratedEvents;
|
||||
using Server.Factions;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
using Server.Targeting;
|
||||
|
||||
|
|
@ -99,7 +101,6 @@ namespace Server.Engines.PartySystem
|
|||
public static void Configure()
|
||||
{
|
||||
EventSink.Logout += EventSink_Logout;
|
||||
EventSink.PlayerDeath += EventSink_PlayerDeath;
|
||||
|
||||
CommandSystem.Register("ListenToParty", AccessLevel.GameMaster, ListenToParty_OnCommand);
|
||||
}
|
||||
|
|
@ -135,7 +136,8 @@ namespace Server.Engines.PartySystem
|
|||
}
|
||||
}
|
||||
|
||||
public static void EventSink_PlayerDeath(Mobile from)
|
||||
[OnEvent(nameof(PlayerMobile.PlayerDeathEvent))]
|
||||
public static void OnPlayerDeathEvent(Mobile from)
|
||||
{
|
||||
var p = Get(from);
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue