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
|
|
@ -34,14 +34,6 @@ public static partial class EventSink
|
|||
public static event Action<Mobile> Disconnected;
|
||||
public static void InvokeDisconnected(Mobile m) => Disconnected?.Invoke(m);
|
||||
|
||||
public static event Action<Mobile> PlayerDeath;
|
||||
public static void InvokePlayerDeath(Mobile m) => PlayerDeath?.Invoke(m);
|
||||
|
||||
public static event Action<Mobile, int> VirtueMacroRequest;
|
||||
|
||||
public static void InvokeVirtueMacroRequest(Mobile mobile, int virtueID) =>
|
||||
VirtueMacroRequest?.Invoke(mobile, virtueID);
|
||||
|
||||
public static event Action<Mobile, Mobile> PaperdollRequest;
|
||||
|
||||
public static void InvokePaperdollRequest(Mobile beholder, Mobile beheld) =>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Buffers;
|
||||
using System.Runtime.CompilerServices;
|
||||
using ModernUO.Serialization;
|
||||
using Server.Network;
|
||||
|
||||
|
|
|
|||
|
|
@ -2847,6 +2847,7 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
Layer.FacialHair
|
||||
);
|
||||
}
|
||||
|
||||
ourState.Send(facialHairPacket);
|
||||
}
|
||||
|
||||
|
|
@ -2984,6 +2985,7 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
Layer.FacialHair
|
||||
);
|
||||
}
|
||||
|
||||
state.Send(facialHairPacket);
|
||||
}
|
||||
|
||||
|
|
@ -3429,7 +3431,6 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
Skills[mod.Skill]?.Update();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public virtual void AddSkillMod(SkillMod mod)
|
||||
|
|
@ -4826,37 +4827,34 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
if (!m_Player)
|
||||
{
|
||||
Delete();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_NetState.SendDeathStatus();
|
||||
|
||||
Warmode = false;
|
||||
m_NetState.SendDeathStatus();
|
||||
|
||||
BodyMod = 0;
|
||||
// Body = this.Female ? 0x193 : 0x192;
|
||||
Body = Race.GhostBody(this);
|
||||
Warmode = false;
|
||||
|
||||
var deathShroud = new Item(0x204E) { Movable = false, Layer = Layer.OuterTorso };
|
||||
BodyMod = 0;
|
||||
// Body = this.Female ? 0x193 : 0x192;
|
||||
Body = Race.GhostBody(this);
|
||||
|
||||
AddItem(deathShroud);
|
||||
var deathShroud = new Item(0x204E) { Movable = false, Layer = Layer.OuterTorso };
|
||||
|
||||
Items.Remove(deathShroud);
|
||||
Items.Insert(0, deathShroud);
|
||||
AddItem(deathShroud);
|
||||
|
||||
Poison = null;
|
||||
Combatant = null;
|
||||
Items.Remove(deathShroud);
|
||||
Items.Insert(0, deathShroud);
|
||||
|
||||
Hits = 0;
|
||||
Stam = 0;
|
||||
Mana = 0;
|
||||
Poison = null;
|
||||
Combatant = null;
|
||||
|
||||
EventSink.InvokePlayerDeath(this);
|
||||
Hits = 0;
|
||||
Stam = 0;
|
||||
Mana = 0;
|
||||
|
||||
ProcessDelta();
|
||||
ProcessDelta();
|
||||
|
||||
CheckStatTimers();
|
||||
}
|
||||
CheckStatTimers();
|
||||
}
|
||||
|
||||
public virtual bool CheckTarget(Mobile from, Target targ, object targeted) => true;
|
||||
|
|
@ -5070,7 +5068,8 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
{
|
||||
var rootItem = root as Item;
|
||||
|
||||
Span<byte> buffer = stackalloc byte[OutgoingPlayerPackets.DragEffectPacketLength].InitializePacket();
|
||||
Span<byte> buffer = stackalloc byte[OutgoingPlayerPackets.DragEffectPacketLength]
|
||||
.InitializePacket();
|
||||
|
||||
foreach (var ns in map.GetClientsInRange(from.Location))
|
||||
{
|
||||
|
|
@ -5588,7 +5587,8 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
ProcessDelta();
|
||||
|
||||
Span<byte> regBuffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(text)].InitializePacket();
|
||||
Span<byte> mutBuffer = stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(mutatedText)].InitializePacket();
|
||||
Span<byte> mutBuffer =
|
||||
stackalloc byte[OutgoingMessagePackets.GetMaxMessageLength(mutatedText)].InitializePacket();
|
||||
|
||||
// TODO: Should this be sorted like onSpeech is below?
|
||||
for (var i = 0; i < hears.Count; ++i)
|
||||
|
|
@ -5598,7 +5598,16 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
if (mutatedArgs == null || !CheckHearsMutatedSpeech(heard, mutateContext))
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
regBuffer, Serial, Body, type, hue, 3, false, m_Language, Name, text
|
||||
regBuffer,
|
||||
Serial,
|
||||
Body,
|
||||
type,
|
||||
hue,
|
||||
3,
|
||||
false,
|
||||
m_Language,
|
||||
Name,
|
||||
text
|
||||
);
|
||||
|
||||
if (length != regBuffer.Length)
|
||||
|
|
@ -5612,7 +5621,16 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
else
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
mutBuffer, Serial, Body, type, hue, 3, false, m_Language, Name, mutatedText
|
||||
mutBuffer,
|
||||
Serial,
|
||||
Body,
|
||||
type,
|
||||
hue,
|
||||
3,
|
||||
false,
|
||||
m_Language,
|
||||
Name,
|
||||
mutatedText
|
||||
);
|
||||
|
||||
if (length != mutBuffer.Length)
|
||||
|
|
@ -6899,10 +6917,12 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
}
|
||||
}
|
||||
|
||||
var range = new Rectangle2D(m_Location.X - Core.GlobalMaxUpdateRange,
|
||||
var range = new Rectangle2D(
|
||||
m_Location.X - Core.GlobalMaxUpdateRange,
|
||||
m_Location.Y - Core.GlobalMaxUpdateRange,
|
||||
Core.GlobalMaxUpdateRange * 2 + 1,
|
||||
Core.GlobalMaxUpdateRange * 2 + 1);
|
||||
Core.GlobalMaxUpdateRange * 2 + 1
|
||||
);
|
||||
|
||||
foreach (var multi in m_Map.GetMultisInBounds(range))
|
||||
{
|
||||
|
|
@ -8072,7 +8092,8 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
m_Map == null ? Map.MobileBoundsEnumerable<T>.Empty : m_Map.GetMobilesInRange<T>(m_Location, range);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Map.ClientAtEnumerable GetClientsAt() => m_Map == null ? Map.ClientAtEnumerable.Empty : Map.GetClientsAt(m_Location);
|
||||
public Map.ClientAtEnumerable GetClientsAt() =>
|
||||
m_Map == null ? Map.ClientAtEnumerable.Empty : Map.GetClientsAt(m_Location);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public Map.ClientBoundsEnumerable GetClientsInRange(int range) =>
|
||||
|
|
@ -8852,7 +8873,16 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
)
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer, Serial, Body, type, hue, 3, ascii, Language, Name, text
|
||||
buffer,
|
||||
Serial,
|
||||
Body,
|
||||
type,
|
||||
hue,
|
||||
3,
|
||||
ascii,
|
||||
Language,
|
||||
Name,
|
||||
text
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
|
|
@ -8879,7 +8909,15 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
if (state.Mobile.CanSee(this) && (noLineOfSight || state.Mobile.InLOS(this)))
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessageLocalized(
|
||||
buffer, Serial, Body, type, hue, 3, number, Name, args
|
||||
buffer,
|
||||
Serial,
|
||||
Body,
|
||||
type,
|
||||
hue,
|
||||
3,
|
||||
number,
|
||||
Name,
|
||||
args
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
|
|
@ -8915,7 +8953,17 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
)
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessageLocalizedAffix(
|
||||
buffer, Serial, Body, type, hue, 3, number, Name, affixType, affix, args
|
||||
buffer,
|
||||
Serial,
|
||||
Body,
|
||||
type,
|
||||
hue,
|
||||
3,
|
||||
number,
|
||||
Name,
|
||||
affixType,
|
||||
affix,
|
||||
args
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
|
|
@ -8959,7 +9007,15 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
if (state != m_NetState && state.Mobile.CanSee(this))
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessageLocalized(
|
||||
buffer, Serial, Body, type, hue, 3, number, Name, args
|
||||
buffer,
|
||||
Serial,
|
||||
Body,
|
||||
type,
|
||||
hue,
|
||||
3,
|
||||
number,
|
||||
Name,
|
||||
args
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
|
|
@ -8986,7 +9042,16 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
if (state != m_NetState && state.Mobile.CanSee(this))
|
||||
{
|
||||
var length = OutgoingMessagePackets.CreateMessage(
|
||||
buffer, Serial, Body, type, hue, 3, ascii, Language, Name, text
|
||||
buffer,
|
||||
Serial,
|
||||
Body,
|
||||
type,
|
||||
hue,
|
||||
3,
|
||||
ascii,
|
||||
Language,
|
||||
Name,
|
||||
text
|
||||
);
|
||||
|
||||
if (length != buffer.Length)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue