mirror of
https://github.com/MikuLeaks/KianaBH3.git
synced 2025-12-13 21:34:43 +01:00
feat: add dress system
This commit is contained in:
@@ -5,16 +5,16 @@ namespace KianaBH.Data.Excel;
|
|||||||
[ResourceEntity("DressData.json")]
|
[ResourceEntity("DressData.json")]
|
||||||
public class DressDataExcel : ExcelResource
|
public class DressDataExcel : ExcelResource
|
||||||
{
|
{
|
||||||
[JsonPropertyName("dressID")] public uint DressID { get; set; }
|
[JsonPropertyName("dressID")] public int DressID { get; set; }
|
||||||
[JsonPropertyName("avatarIDList")] public List<uint> AvatarIDList { get; set; } = [];
|
[JsonPropertyName("avatarIDList")] public List<int> AvatarIDList { get; set; } = [];
|
||||||
|
|
||||||
public override int GetId()
|
public override int GetId()
|
||||||
{
|
{
|
||||||
return (int)DressID;
|
return DressID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Loaded()
|
public override void Loaded()
|
||||||
{
|
{
|
||||||
GameData.DressData.Add(GetId(), this);
|
GameData.DressData.Add(DressID, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,6 +43,7 @@ public class WordTextEN
|
|||||||
public string Banner => "Gacha";
|
public string Banner => "Gacha";
|
||||||
public string Activity => "Activity";
|
public string Activity => "Activity";
|
||||||
public string Elf => "Elf";
|
public string Elf => "Elf";
|
||||||
|
public string Dress => "Outfit";
|
||||||
|
|
||||||
// server info
|
// server info
|
||||||
public string Config => "Config File";
|
public string Config => "Config File";
|
||||||
@@ -208,7 +209,9 @@ public class GiveAllTextEN
|
|||||||
|
|
||||||
public string Usage =>
|
public string Usage =>
|
||||||
"Usage: /giveall weapon\n\n" +
|
"Usage: /giveall weapon\n\n" +
|
||||||
"Usage: /giveall stigmata";
|
"Usage: /giveall stigmata\n\n" +
|
||||||
|
"Usage: /giveall material\n\n" +
|
||||||
|
"Usage: /giveall dress\n";
|
||||||
|
|
||||||
public string GiveAllItems => "Granted all {0}";
|
public string GiveAllItems => "Granted all {0}";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,4 +44,23 @@ public class CommandGiveall : ICommands
|
|||||||
await arg.Target!.Player!.SyncInventory();
|
await arg.Target!.Player!.SyncInventory();
|
||||||
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems", I18NManager.Translate("Word.Material")));
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems", I18NManager.Translate("Word.Material")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[CommandMethod("dress")]
|
||||||
|
public async ValueTask GiveDress(CommandArg arg)
|
||||||
|
{
|
||||||
|
if (!await arg.CheckOnlineTarget()) return;
|
||||||
|
foreach (var config in GameData.DressData.Values)
|
||||||
|
{
|
||||||
|
foreach (var valkId in config.AvatarIDList)
|
||||||
|
{
|
||||||
|
var valk = arg.Target!.Player!.AvatarManager!.GetAvatar(valkId);
|
||||||
|
if (valk == null) continue;
|
||||||
|
if (valk.DressList.Contains(config.DressID)) continue;
|
||||||
|
valk.DressList.Add(config.DressID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await arg.Target!.Player!.SyncValk();
|
||||||
|
await arg.SendMsg(I18NManager.Translate("Game.Command.GiveAll.GiveAllItems", I18NManager.Translate("Word.Dress")));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
GameServer/Server/Packet/Recv/Avatar/HandlerSetDressReq.cs
Normal file
17
GameServer/Server/Packet/Recv/Avatar/HandlerSetDressReq.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using KianaBH.Proto;
|
||||||
|
|
||||||
|
namespace KianaBH.GameServer.Server.Packet.Recv.Avatar;
|
||||||
|
|
||||||
|
[Opcode(CmdIds.SetDressReq)]
|
||||||
|
public class HandlerSetDressReq : Handler
|
||||||
|
{
|
||||||
|
public override async Task OnHandle(Connection connection, byte[] header, byte[] data)
|
||||||
|
{
|
||||||
|
var req = SetDressReq.Parser.ParseFrom(data);
|
||||||
|
var player = connection.Player!;
|
||||||
|
var valk = player.AvatarManager!.GetAvatar((int)req.AvatarId);
|
||||||
|
if (valk == null) return;
|
||||||
|
valk.DressId = (int)req.DressId;
|
||||||
|
await connection.SendPacket(CmdIds.SetDressRsp);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
using KianaBH.GameServer.Server.Packet.Send.Test;
|
|
||||||
using KianaBH.Proto;
|
|
||||||
|
|
||||||
namespace KianaBH.GameServer.Server.Packet.Recv.Test;
|
|
||||||
|
|
||||||
[Opcode(CmdIds.SetDressReq)]
|
|
||||||
public class HandlerSetDressReq : Handler
|
|
||||||
{
|
|
||||||
public override async Task OnHandle(Connection connection, byte[] header, byte[] data)
|
|
||||||
{
|
|
||||||
await connection.SendPacket(new PacketSetDressRsp());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
using KianaBH.KcpSharp;
|
|
||||||
using KianaBH.Proto;
|
|
||||||
|
|
||||||
namespace KianaBH.GameServer.Server.Packet.Send.Test;
|
|
||||||
|
|
||||||
public class PacketSetDressRsp : BasePacket
|
|
||||||
{
|
|
||||||
public PacketSetDressRsp() : base(CmdIds.SetDressRsp)
|
|
||||||
{
|
|
||||||
var proto = new SetDressRsp
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
SetData(proto);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user