1
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user