feat: Converts OnLogin to a coded generated event (#2070)

This commit is contained in:
Kamron Batman 2025-01-17 15:21:45 -08:00 • committed by GitHub
parent 3b698de556
commit 66a257ece2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 127 additions and 122 deletions

View file

@ -1291,13 +1291,9 @@ namespace Server.Engines.ConPVP
return false;
}
public static void OnLogin(Mobile m)
[OnEvent(nameof(PlayerMobile.PlayerLoginEvent))]
public static void OnLogin(PlayerMobile pm)
{
if (m is not PlayerMobile pm)
{
return;
}
var dc = pm.DuelContext;
if (dc == null)

View file

@ -1,3 +1,4 @@
using ModernUO.CodeGeneratedEvents;
using Server.Mobiles;
using Server.Regions;
@ -14,12 +15,13 @@ namespace Server.Engines.Doom
Register();
}
public static void OnLogin(Mobile m)
[OnEvent(nameof(PlayerMobile.PlayerLoginEvent))]
public static void OnLogin(PlayerMobile pm)
{
var rect = LeverPuzzleController.lr_Rect;
if (m.X >= rect.X && m.X <= rect.X + 10 && m.Y >= rect.Y && m.Y <= rect.Y + 10 && m.Map == Map.Internal)
if (pm.X >= rect.X && pm.X <= rect.X + 10 && pm.Y >= rect.Y && pm.Y <= rect.Y + 10 && pm.Map == Map.Internal)
{
Timer kick = new LeverPuzzleController.LampRoomKickTimer(m);
Timer kick = new LeverPuzzleController.LampRoomKickTimer(pm);
kick.Start();
}
}

View file

@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using ModernUO.CodeGeneratedEvents;
using Server.Accounting;
using Server.Commands.Generic;
using Server.Engines.ConPVP;
@ -1259,7 +1261,9 @@ public abstract class Faction : IComparable<Faction>
}
}
public static void OnLogin(Mobile m) => CheckLeaveTimer(m);
[OnEvent(nameof(PlayerMobile.PlayerLoginEvent))]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void OnLogin(PlayerMobile pm) => CheckLeaveTimer(pm);
public static void WriteReference(IGenericWriter writer, Faction fact)
{

View file

@ -160,7 +160,8 @@ namespace Server.Engines.PartySystem
}
}
public static void OnLogin(Mobile from)
[OnEvent(nameof(PlayerMobile.PlayerLoginEvent))]
public static void OnLogin(PlayerMobile from)
{
var p = Get(from);

View file

@ -1,7 +1,9 @@
using System;
using ModernUO.CodeGeneratedEvents;
using ModernUO.Serialization;
using Server.Items;
using Server.Misc;
using Server.Mobiles;
namespace Server.Engines.Plants
{
@ -432,7 +434,8 @@ namespace Server.Engines.Plants
}
}
public static void OnLogin(Mobile from)
[OnEvent(nameof(PlayerMobile.PlayerLoginEvent))]
public static void OnLogin(PlayerMobile from)
{
Container cont = from.Backpack;
if (cont != null)

View file

@ -80,9 +80,10 @@ public class PlayerMurderSystem : GenericPersistence
UpdateMurderContext(context);
}
public static void OnLogin(Mobile m)
[OnEvent(nameof(PlayerMobile.PlayerLoginEvent))]
public static void OnLogin(PlayerMobile pm)
{
if (m is not PlayerMobile pm || !GetMurderContext(pm, out var context))
if (!GetMurderContext(pm, out var context))
{
return;
}

View file

@ -1,4 +1,5 @@
using System;
using ModernUO.CodeGeneratedEvents;
using Server.Accounting;
using Server.Gumps;
using Server.Items;
@ -562,35 +563,31 @@ namespace Server.Engines.VeteranRewards
RewardInterval = ServerConfiguration.GetOrUpdateSetting("vetRewards.rewardInterval", TimeSpan.FromDays(30.0));
}
public static void OnLogin(Mobile m)
[OnEvent(nameof(PlayerMobile.PlayerLoginEvent))]
public static void OnLogin(PlayerMobile pm)
{
if (!Enabled)
if (!Enabled || !pm.Alive)
{
return;
}
if (!m.Alive)
{
return;
}
ComputeRewardInfo(pm, out var cur, out var max, out var level);
ComputeRewardInfo(m, out var cur, out var max, out var level);
if (m.SkillsCap is 7000 or 7050 or 7100 or 7150 or 7200)
if (pm.SkillsCap is 7000 or 7050 or 7100 or 7150 or 7200)
{
level = Math.Clamp(level, 0, 4);
if (SkillCapRewards)
{
m.SkillsCap = 7000 + level * 50;
pm.SkillsCap = 7000 + level * 50;
}
else
{
m.SkillsCap = 7000;
pm.SkillsCap = 7000;
}
}
if (Core.ML && m is PlayerMobile pm && !pm.HasStatReward && HasHalfLevel(pm))
if (Core.ML && !pm.HasStatReward && HasHalfLevel(pm))
{
pm.HasStatReward = true;
pm.StatCap += 5;
@ -598,7 +595,7 @@ namespace Server.Engines.VeteranRewards
if (cur < max)
{
m.SendGump(new RewardNoticeGump(m));
pm.SendGump(new RewardNoticeGump(pm));
}
}
}