1
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using BITFALL.Entities.Equipment;
|
||||
using BITFALL.Player.Inventory;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
@@ -36,7 +37,7 @@ namespace BITFALL.UX
|
||||
[Inject]
|
||||
private IPlayerInventory _playerInventory;
|
||||
[Inject]
|
||||
private IPlayerEquipContainer equipContainer;
|
||||
private IEntityEquipmentContainer equipContainer;
|
||||
private IEntity _entity;
|
||||
protected override async void Awake()
|
||||
{
|
||||
@@ -73,26 +74,36 @@ namespace BITFALL.UX
|
||||
{
|
||||
base.OnEnable();
|
||||
playerService.OnPlayerInitialized += OnPlayerInitializedLocalPlayer;
|
||||
playerService.OnPlayerDisposed += OnPlayerDisposed;
|
||||
}
|
||||
|
||||
private void OnPlayerDisposed(Entity obj)
|
||||
{
|
||||
inventory = null;
|
||||
equipContainer = null;
|
||||
_playerInventory = null;
|
||||
}
|
||||
|
||||
protected override void OnDisable()
|
||||
{
|
||||
base.OnDisable();
|
||||
playerService.OnPlayerDisposed -= OnPlayerDisposed;
|
||||
playerService.OnPlayerInitialized -= OnPlayerInitializedLocalPlayer;
|
||||
}
|
||||
private void OnPlayerInitializedLocalPlayer(IEntity entity)
|
||||
{
|
||||
entity.Inject(this);
|
||||
itemContainers.Clear();
|
||||
equipContainers.Clear();
|
||||
builder.Clear();
|
||||
|
||||
var weighted = entity.Get<IPlayerInventoryWeightable>();
|
||||
|
||||
weighted.OnWeighted += OnWeighted;
|
||||
|
||||
equipContainer = entity.Get<IPlayerEquipContainer>();
|
||||
equipContainer.OnEquip += OnEquip;
|
||||
equipContainer.OnDeEquip += DeEquip;
|
||||
|
||||
inventory = entity.Get<IBasicItemContainer>();
|
||||
|
||||
inventory.OnAdd += OnAdd;
|
||||
inventory.OnRemove += OnRemove;
|
||||
|
Reference in New Issue
Block a user