This commit is contained in:
CortexCore
2025-03-10 20:36:11 +08:00
parent 1cfc881d92
commit ad7065fa02
23 changed files with 11465 additions and 277274 deletions

View File

@@ -3,8 +3,11 @@ using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using BITKit;
using BITKit.Entities;
using BITKit.UX;
using Cysharp.Threading.Tasks;
using Net.Project.B.Cosmetics;
using Net.Project.B.UX;
using Project.B.Entities;
using Project.B.Map;
@@ -16,18 +19,45 @@ namespace Net.Like.Xue.Tokyo.UX
{
public class UXMenu : UIToolKitPanel,IUXLobby
{
private readonly IEntitiesService _entitiesService;
private readonly IGameMapService _gameMapService;
private readonly IWrapper<CosmeticsCustomizeComponent> _cosmeticsCustomize;
protected override string DocumentPath => "ux_menu";
public override bool AllowInput => false;
public override bool AllowCursor => true;
[UXBindPath("play-button")]
private Button _playButton;
public UXMenu(IUXService uxService, IGameMapService gameMapService) : base(uxService)
[UXBindPath("avatar-image")]
private VisualElement _avatarImage;
[UXBindPath("player-name")]
private Label _playerName;
public UXMenu(IUXService uxService, IGameMapService gameMapService, IWrapper<CosmeticsCustomizeComponent> cosmeticsCustomize, IEntitiesService entitiesService) : base(uxService)
{
_gameMapService = gameMapService;
_cosmeticsCustomize = cosmeticsCustomize;
_entitiesService = entitiesService;
OnInitiated += Initiated;
_gameMapService.OnMapChanged += OnMapChanged;
_cosmeticsCustomize.OnValueChanged += OnValueChanged;
}
private void OnValueChanged(CosmeticsCustomizeComponent arg1, CosmeticsCustomizeComponent arg2)
{
var cosmetics = _entitiesService.QueryComponents<ScriptableCosmetics>().ToArray()
.ToDictionary(x => x.ScriptableId, x => x);
foreach (var id in arg2.ComponentIds)
{
if (cosmetics.TryGetValue(id,out var cosmetic))
{
if (cosmetic.CosmeticsClass is CosmeticsModel)
{
_avatarImage.style.backgroundImage = new(cosmetic.Icon);
_playerName.text = cosmetic.Name;
}
}
}
}
private void OnMapChanged(Guid arg1, string arg2)