removed old stuff
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using R3;
|
||||
using RebootKit.Engine.Extensions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using Logger = RebootKit.Engine.Foundation.Logger;
|
||||
@@ -14,32 +13,41 @@ namespace RebootReality.jelycho.Player.HUD {
|
||||
[field: SerializeField] public PlayerInventoryUI InventoryUI { get; private set; }
|
||||
|
||||
PlayerActor m_PlayerActor;
|
||||
DisposableBag m_ActorBag;
|
||||
|
||||
void OnEnable() {
|
||||
}
|
||||
|
||||
void OnDisable() {
|
||||
InventoryUI.CleanUp();
|
||||
m_ActorBag.Dispose();
|
||||
}
|
||||
|
||||
public void SetPlayerActor(PlayerActor actor) {
|
||||
m_ActorBag.Dispose();
|
||||
|
||||
if (actor == null) {
|
||||
m_PlayerActor = null;
|
||||
InventoryUI.CleanUp();
|
||||
UnsetPlayerActor();
|
||||
|
||||
if (actor.OrNull() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_ActorBag = new DisposableBag();
|
||||
m_PlayerActor = actor;
|
||||
InventoryUI.Configure(m_MainDocument.rootVisualElement.Q("player-hud__inventory-slots"), actor.Inventory);
|
||||
|
||||
actor.SelectedInventorySlot.Subscribe(x => {
|
||||
InventoryUI.SetSelectedSlot(x);
|
||||
}).AddTo(ref m_ActorBag);
|
||||
actor.OnSelectedInventorySlotChanged += OnInventorySelectedSlotChanged;
|
||||
InventoryUI.SetSelectedSlot(actor.SelectedInventorySlot);
|
||||
}
|
||||
|
||||
void UnsetPlayerActor() {
|
||||
if (m_PlayerActor.OrNull() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_PlayerActor.OnSelectedInventorySlotChanged -= OnInventorySelectedSlotChanged;
|
||||
|
||||
m_PlayerActor = null;
|
||||
InventoryUI.CleanUp();
|
||||
}
|
||||
|
||||
void OnInventorySelectedSlotChanged(int newIndex) {
|
||||
InventoryUI.SetSelectedSlot(newIndex);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user