1
This commit is contained in:
@@ -6,15 +6,23 @@ using AYellowpaper.SerializedCollections;
|
||||
|
||||
namespace BITFALL
|
||||
{
|
||||
public class EntityPropsDisplay : EntityComponent,IEquipSelectorCallback,IPlayerEquipCallback
|
||||
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();
|
||||
public override void OnStart()
|
||||
{
|
||||
entity.RegisterCallback<IPlayerEquipCallback>(this);
|
||||
entity.RegisterCallback<IEquipSelectorCallback>(this);
|
||||
var playerEquipContainer = entity.Get<IPlayerEquipContainer>();
|
||||
var equipSelector = entity.Get<IPlayerEquipSelector>();
|
||||
|
||||
playerEquipContainer.OnEquip += OnEquip;
|
||||
playerEquipContainer.OnDeEquip += OnDeEquip;
|
||||
|
||||
equipSelector.OnEquip += OnEquip;
|
||||
equipSelector.OnDeEquip += OnDeEquip;
|
||||
equipSelector.OnUpdateEquip += OnUpdateEquip;
|
||||
|
||||
foreach (var x in equipments)
|
||||
{
|
||||
x.Value.SetActive(false);
|
||||
@@ -28,39 +36,40 @@ namespace BITFALL
|
||||
x.Value.SetActive(false);
|
||||
}
|
||||
}
|
||||
public void DeEquip(IEquipmentSlot slot, IBasicItem item)
|
||||
private void OnDeEquip(IEquipmentSlot slot, IBasicItem item)
|
||||
{
|
||||
var asset = item.GetAssetable();
|
||||
if (equipments.TryGetValue(asset.AdressablePath, out GameObject prop))
|
||||
if (equipments.TryGetValue(asset.AddressablePath, out GameObject prop))
|
||||
{
|
||||
prop.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnEquip(IEquipmentSlot slot, IBasicItem item)
|
||||
private void OnEquip(IEquipmentSlot slot, IBasicItem item)
|
||||
{
|
||||
var asset = item.GetAssetable();
|
||||
if(equipments.TryGetValue(asset.AdressablePath, out GameObject prop)) {
|
||||
if(equipments.TryGetValue(asset.AddressablePath, out GameObject prop)) {
|
||||
prop.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnEquip(IBasicItem item)
|
||||
private void OnEquip(IBasicItem item)
|
||||
{
|
||||
if (equipDictionary.TryGetValue(item.AdressablePath, out var model))
|
||||
if(item is null) return;
|
||||
if (equipDictionary.TryGetValue(item.AddressablePath, out var model))
|
||||
{
|
||||
model.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDeEquip(IBasicItem item)
|
||||
private void OnDeEquip(IBasicItem item)
|
||||
{
|
||||
foreach (var x in equipDictionary)
|
||||
{
|
||||
x.Value.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
public void OnUpdateEquip(IDictionary<int, IBasicItem> maps)
|
||||
private void OnUpdateEquip(IDictionary<int, IBasicItem> maps)
|
||||
{
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user