feat: Moves network related events to UOContent using code generation (#1945)

### Summary
- Moves `CharacterCreated` event to UOContent using code generated event _CharacterCreatedEvent_.
- Moves `TargetByResourceMacro` event to UOContent using code generated event _TargetByResourceMacro_.
- Moves `GameLogin` event to UOContent using code generated event _GameLoginEvent_.
- Moves `ServerList` event to UOContent using code generated event _ServerListEvent_.
- Streamlines ProfessionInfo


> [!IMPORTANT]
> **Developer Note**
> Custom scripts that use any of these event sinks will need to be updated to use the new code generated events.
This commit is contained in:
Kamron Batman 2024-09-06 16:57:10 -07:00 committed by GitHub
parent 4110556e89
commit 47e16a03fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 207 additions and 309 deletions

View file

@ -1,93 +0,0 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2023 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: CharacterCreatedEvent.cs *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
using System.Runtime.CompilerServices;
using Server.Accounting;
using Server.Network;
namespace Server;
public class CharacterCreatedEventArgs
{
public CharacterCreatedEventArgs(
NetState state, IAccount a, string name, bool female, int hue, StatNameValue[] stats, CityInfo city,
SkillNameValue[] skills, int shirtHue, int pantsHue, int hairID, int hairHue, int beardID, int beardHue,
int profession, Race race
)
{
State = state;
Account = a;
Name = name;
Female = female;
Hue = hue;
Stats = stats;
City = city;
Skills = skills;
ShirtHue = shirtHue;
PantsHue = pantsHue;
HairID = hairID;
HairHue = hairHue;
BeardID = beardID;
BeardHue = beardHue;
Profession = profession;
Race = race;
}
public NetState State { get; }
public IAccount Account { get; }
public Mobile Mobile { get; set; }
public string Name { get; }
public bool Female { get; }
public int Hue { get; }
public StatNameValue[] Stats { get; }
public CityInfo City { get; }
public SkillNameValue[] Skills { get; }
public int ShirtHue { get; }
public int PantsHue { get; }
public int HairID { get; }
public int HairHue { get; }
public int BeardID { get; }
public int BeardHue { get; }
public int Profession { get; set; }
public Race Race { get; }
}
public readonly record struct SkillNameValue(SkillName Name, int Value);
public readonly record struct StatNameValue(StatType Name, int Value);
public static partial class EventSink
{
public static event Action<CharacterCreatedEventArgs> CharacterCreated;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void InvokeCharacterCreated(CharacterCreatedEventArgs e) => CharacterCreated?.Invoke(e);
}

View file

@ -41,9 +41,4 @@ public static partial class EventSink
public static event Action ServerStarted;
public static void InvokeServerStarted() => ServerStarted?.Invoke();
public static event Action<Mobile, Item, short> TargetByResourceMacro;
public static void InvokeTargetByResourceMacro(Mobile m, Item item, short resourceType) =>
TargetByResourceMacro?.Invoke(m, item, resourceType);
}

View file

@ -1,48 +0,0 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2023 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: GameLoginEvent.cs *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
using System.Runtime.CompilerServices;
using Server.Network;
namespace Server;
public class GameLoginEventArgs
{
public GameLoginEventArgs(NetState state, string un, string pw)
{
State = state;
Username = un;
Password = pw;
}
public NetState State { get; }
public string Username { get; }
public string Password { get; }
public bool Accepted { get; set; }
public CityInfo[] CityInfo { get; set; }
}
public static partial class EventSink
{
public static event Action<GameLoginEventArgs> GameLogin;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void InvokeGameLogin(GameLoginEventArgs e) => GameLogin?.Invoke(e);
}

View file

@ -1,59 +0,0 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2023 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: ServerListEvent.cs *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using System;
using System.Collections.Generic;
using System.Net;
using System.Runtime.CompilerServices;
using Server.Accounting;
using Server.Network;
namespace Server;
public class ServerListEventArgs
{
public ServerListEventArgs(NetState state, IAccount account)
{
State = state;
Account = account;
Servers = new List<ServerInfo>();
}
public NetState State { get; }
public IAccount Account { get; }
public bool Rejected { get; set; }
public List<ServerInfo> Servers { get; }
public void AddServer(string name, IPEndPoint address)
{
AddServer(name, 0, TimeZoneInfo.Local, address);
}
public void AddServer(string name, int fullPercent, TimeZoneInfo tz, IPEndPoint address)
{
Servers.Add(new ServerInfo(name, fullPercent, tz, address));
}
}
public static partial class EventSink
{
public static event Action<ServerListEventArgs> ServerList;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void InvokeServerList(ServerListEventArgs e) => ServerList?.Invoke(e);
}

View file

@ -59,7 +59,7 @@ public class DamageEntry
}
[Flags]
public enum StatType
public enum StatType : byte
{
Str = 1,
Dex = 2,