1
This commit is contained in:
@@ -9,72 +9,104 @@ namespace BITFALL
|
||||
{
|
||||
public class EntityPropsDisplay : EntityComponent
|
||||
{
|
||||
[SerializeField] private SerializedDictionary<string, GameObject> equipments = new();
|
||||
[SerializeField] private SerializedDictionary<string, GameObject> unEquipDictionary = new();
|
||||
[SerializeField] private SerializedDictionary<string, GameObject> equipDictionary = new();
|
||||
[SerializeField] private SerializedDictionary<string, GameObject> equipped = new();
|
||||
[SerializeField] private SerializedDictionary<string, GameObject> bodyEquips = new();
|
||||
[SerializeField] private SerializedDictionary<string, GameObject> holsteredEquips = new();
|
||||
|
||||
[Inject] private IEntityEquipment _entityEquipment;
|
||||
[Inject] private IEntityEquipmentContainer _playerEquipContainer;
|
||||
[Inject] private IPlayerEquipSelector _playerEquipSelector;
|
||||
[Inject(true)] private IEntityEquipment _entityEquipment;
|
||||
[Inject(true)] private IEntityEquipmentContainer _playerEquipContainer;
|
||||
[Inject(true)] private IPlayerEquipSelector _playerEquipSelector;
|
||||
|
||||
public override void OnStart()
|
||||
{
|
||||
_playerEquipContainer.OnEquip += OnEquip;
|
||||
_playerEquipContainer.OnDeEquip += OnDeEquip;
|
||||
if (_entityEquipment is not null)
|
||||
{
|
||||
_entityEquipment.OnEquip += OnEquippedEquip;
|
||||
_entityEquipment.OnUnEquip += OnEquippedUnEquip;
|
||||
_entityEquipment.OnEquipAddressable+=OnEquippedEquipAddressable;
|
||||
_entityEquipment.OnUnEquipAddressable+=OnUnEquippedEquipAddressable;
|
||||
}
|
||||
|
||||
if (_playerEquipSelector is not null)
|
||||
{
|
||||
_playerEquipSelector.OnUpdateEquip += OnUpdateHolsteredEquip;
|
||||
}
|
||||
|
||||
_entityEquipment.OnEquip += OnEquip;
|
||||
_entityEquipment.OnDeEquip += OnDeEquip;
|
||||
_playerEquipSelector.OnUpdateEquip += OnUpdateEquip;
|
||||
if (_playerEquipContainer is not null)
|
||||
{
|
||||
_playerEquipContainer.OnEquip += OnEquipBodyEquip;
|
||||
_playerEquipContainer.OnDeEquip += OnUnEquipBodyEquip;
|
||||
}
|
||||
|
||||
foreach (var x in equipments)
|
||||
foreach (var x in equipped)
|
||||
{
|
||||
x.Value.SetActive(false);
|
||||
}
|
||||
foreach (var x in unEquipDictionary)
|
||||
foreach (var x in bodyEquips)
|
||||
{
|
||||
x.Value.SetActive(false);
|
||||
}
|
||||
foreach (var x in equipDictionary)
|
||||
foreach (var x in holsteredEquips)
|
||||
{
|
||||
x.Value.SetActive(false);
|
||||
}
|
||||
}
|
||||
private void OnDeEquip(IEquipmentSlot slot, IBasicItem item)
|
||||
|
||||
private void OnUnEquippedEquipAddressable(string obj)
|
||||
{
|
||||
var asset = item.GetAssetable();
|
||||
if (equipments.TryGetValue(asset.AddressablePath, out GameObject prop))
|
||||
if (string.IsNullOrEmpty(obj) is false && equipped.TryGetValue(obj, out var go))
|
||||
{
|
||||
prop.SetActive(false);
|
||||
go.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEquip(IEquipmentSlot slot, IBasicItem item)
|
||||
private void OnEquippedEquipAddressable(string obj)
|
||||
{
|
||||
var asset = item.GetAssetable();
|
||||
if(equipments.TryGetValue(asset.AddressablePath, out GameObject prop)) {
|
||||
prop.SetActive(true);
|
||||
if (string.IsNullOrEmpty(obj) is false && equipped.TryGetValue(obj, out var go))
|
||||
{
|
||||
go.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEquip(IBasicItem item)
|
||||
private void OnUnEquipBodyEquip(IEquipmentSlot arg1, IBasicItem arg2)
|
||||
{
|
||||
if(item is null) return;
|
||||
if (equipDictionary.TryGetValue(item.AddressablePath, out var model))
|
||||
if (bodyEquips.TryGetValue(arg2.AddressablePath, out var go))
|
||||
{
|
||||
model.SetActive(true);
|
||||
go.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDeEquip(IBasicItem item)
|
||||
private void OnEquipBodyEquip(IEquipmentSlot arg1, IBasicItem arg2)
|
||||
{
|
||||
foreach (var x in equipDictionary)
|
||||
if (bodyEquips.TryGetValue(arg2.AddressablePath, out var go))
|
||||
{
|
||||
x.Value.gameObject.SetActive(false);
|
||||
go.SetActive(true);
|
||||
}
|
||||
}
|
||||
private void OnUpdateEquip(IDictionary<int, IBasicItem> maps)
|
||||
|
||||
private void OnUpdateHolsteredEquip(IDictionary<int, IBasicItem> obj)
|
||||
{
|
||||
|
||||
foreach (var x in holsteredEquips)
|
||||
{
|
||||
x.Value.SetActive(false);
|
||||
}
|
||||
foreach (var x in obj)
|
||||
{
|
||||
if (holsteredEquips.TryGetValue(x.Value.AddressablePath, out var go))
|
||||
{
|
||||
go.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEquippedUnEquip(IBasicItem obj)
|
||||
{
|
||||
OnUnEquippedEquipAddressable(obj?.AddressablePath);
|
||||
}
|
||||
|
||||
private void OnEquippedEquip(IBasicItem obj)
|
||||
{
|
||||
OnEquippedEquipAddressable(obj?.AddressablePath);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user