mirror of
https://github.com/MikuLeaks/MikuSB.git
synced 2026-06-04 11:03:59 +00:00
The character displayed on the lobby screen can now be changed.
PlayerSetting_ChangeShowCard
This commit is contained in:
@@ -15,6 +15,7 @@ public class PlayerGameData : BaseDatabaseDataHelper
|
|||||||
public long LastActiveTime { get; set; }
|
public long LastActiveTime { get; set; }
|
||||||
public Sex Gender { get; set; } = Sex.Female;
|
public Sex Gender { get; set; } = Sex.Female;
|
||||||
[SugarColumn(IsJson = true)] public List<PlayerAttr> Attrs { get; set; } = [];
|
[SugarColumn(IsJson = true)] public List<PlayerAttr> Attrs { get; set; } = [];
|
||||||
|
[SugarColumn(IsJson = true)] public List<ulong> ShowItems { get; set; } = [];
|
||||||
|
|
||||||
public static PlayerGameData? GetPlayerByUid(long uid)
|
public static PlayerGameData? GetPlayerByUid(long uid)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -188,9 +188,22 @@ public class PlayerInstance(PlayerGameData data)
|
|||||||
proto.Attrs[ToShiftedAttrKey(gid, sid)] = val;
|
proto.Attrs[ToShiftedAttrKey(gid, sid)] = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
proto.ShowItems.AddRange(Data.ShowItems);
|
||||||
|
|
||||||
return proto;
|
return proto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetShowItem(int index, ulong itemId)
|
||||||
|
{
|
||||||
|
if (index <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
while (Data.ShowItems.Count < index)
|
||||||
|
Data.ShowItems.Add(0);
|
||||||
|
|
||||||
|
Data.ShowItems[index - 1] = itemId;
|
||||||
|
}
|
||||||
|
|
||||||
private static uint ToPackedAttrKey(uint gid, uint sid)
|
private static uint ToPackedAttrKey(uint gid, uint sid)
|
||||||
{
|
{
|
||||||
if (gid == 0)
|
if (gid == 0)
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
using MikuSB.Database;
|
||||||
|
using MikuSB.Proto;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace MikuSB.GameServer.Server.CallGS.Handlers.Misc;
|
||||||
|
|
||||||
|
[CallGSApi("PlayerSetting_ChangeShowCard")]
|
||||||
|
public class PlayerSetting_ChangeShowCard : ICallGSHandler
|
||||||
|
{
|
||||||
|
private const int ShowItemGirlIndex = 4;
|
||||||
|
|
||||||
|
public async Task Handle(Connection connection, string param, ushort seqNo)
|
||||||
|
{
|
||||||
|
var player = connection.Player!;
|
||||||
|
var req = JsonSerializer.Deserialize<ChangeShowCardParam>(param);
|
||||||
|
if (req == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var card = player.CharacterManager.GetCharacterByGUID(req.Id);
|
||||||
|
if (card == null)
|
||||||
|
{
|
||||||
|
await CallGSRouter.SendScript(connection, "PlayerSetting_ChangeShowCard", "{}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.SetShowItem(ShowItemGirlIndex, card.Guid);
|
||||||
|
DatabaseHelper.SaveDatabaseType(player.Data);
|
||||||
|
|
||||||
|
var sync = new NtfSyncPlayer();
|
||||||
|
sync.ShowItems.AddRange(player.Data.ShowItems);
|
||||||
|
|
||||||
|
await CallGSRouter.SendScript(connection, "PlayerSetting_ChangeShowCard", "{}", sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal sealed class ChangeShowCardParam
|
||||||
|
{
|
||||||
|
[JsonPropertyName("nID")]
|
||||||
|
public uint Id { get; set; }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user