1
This commit is contained in:
@@ -32,6 +32,8 @@ namespace bitfall.UX
|
||||
[UXBindPath("equipSelector-container")]
|
||||
private VisualElement _equipSelectorContainerElement;
|
||||
|
||||
private VisualElement _currentEquipElement;
|
||||
|
||||
private readonly ConcurrentDictionary<string, VisualElement> _equipmentContainerDictionary = new();
|
||||
private readonly ConcurrentDictionary<int,VisualElement> _equipSelectorContainerDictionary=new();
|
||||
|
||||
@@ -42,6 +44,8 @@ namespace bitfall.UX
|
||||
|
||||
_playerService.OnPlayerInitialized += OnStartLocalPlayer;
|
||||
destroyCancellationToken.Register(() => _playerService.OnPlayerInitialized -= OnStartLocalPlayer);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void OnStartLocalPlayer(Entity obj)
|
||||
@@ -50,6 +54,8 @@ namespace bitfall.UX
|
||||
|
||||
_equipmentContainerElement.Clear();
|
||||
_equipSelectorContainerElement.Clear();
|
||||
|
||||
|
||||
|
||||
_playerEquipSelector.OnUpdateEquip += OnUpdateEquip;
|
||||
_equipmentContainer.OnEquip += OnEquip;
|
||||
@@ -83,6 +89,8 @@ namespace bitfall.UX
|
||||
_equipSelectorContainerElement.Clear();
|
||||
_equipSelectorContainerDictionary.Clear();
|
||||
|
||||
|
||||
|
||||
foreach (var (index,x) in obj)
|
||||
{
|
||||
var element =_equipSelectorContainerDictionary.GetOrAdd(index,CreateEquipSelectorContainer(x.AddressablePath));
|
||||
@@ -109,11 +117,12 @@ namespace bitfall.UX
|
||||
var container =
|
||||
_equipSelectorContainerElement.Create<VisualElement>(() => equipSelectorVisualTreeAsset.CloneTree());
|
||||
var element = BITFALL.UX.UXUtils.CreateItemContainer(container, item);
|
||||
|
||||
element.icon.style.backgroundImage = item.RectangleIcon;
|
||||
|
||||
|
||||
if (item.RectangleIcon)
|
||||
element.icon.style.backgroundImage = item.RectangleIcon;
|
||||
|
||||
element.visualElement.userData = addressablePath;
|
||||
|
||||
|
||||
return element;
|
||||
}
|
||||
|
||||
@@ -122,16 +131,32 @@ namespace bitfall.UX
|
||||
var current = _equipment.CurrentItem?.AddressablePath ?? string.Empty;
|
||||
const string active = "active";
|
||||
|
||||
_currentEquipElement?.RemoveFromHierarchy();
|
||||
_currentEquipElement =
|
||||
_equipSelectorContainerElement.Create<VisualElement>(equipSelectorVisualTreeAsset.CloneTree);
|
||||
_currentEquipElement.SetActive(false);
|
||||
|
||||
var list = new List<VisualElement>();
|
||||
list.AddRange(_equipmentContainerElement.Children());
|
||||
list.AddRange(_equipSelectorContainerElement.Children());
|
||||
foreach (var visualElement in list)
|
||||
list.Add(_currentEquipElement);
|
||||
foreach (var visualElement in list.Where(visualElement => visualElement.userData is not null))
|
||||
{
|
||||
visualElement.EnableInClassList(active,current == (string)visualElement.userData);
|
||||
var item = ItemExtensions.GetAssetable((string)visualElement.userData);
|
||||
visualElement.SetEnabled(
|
||||
!_knockdown.IsKnockdown || item.AllowUseWhileKnocked
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
if (_equipment.CurrentItem is not null && _playerEquipSelector.Equipped.Values.All(x => x.AddressablePath != _equipment.CurrentItem.AddressablePath))
|
||||
{
|
||||
BITFALL.UX.UXUtils.CreateItemContainer(_currentEquipElement, _equipment.CurrentItem);
|
||||
_currentEquipElement.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentEquipElement.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user