68 lines
2.1 KiB
C#
68 lines
2.1 KiB
C#
using BITKit;
|
|
using BITKit.Entities;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using AYellowpaper.SerializedCollections;
|
|
|
|
namespace BITFALL
|
|
{
|
|
public class EntityPropsDisplay : EntityComponent,IEquipSelectorCallback,IPlayerEquipCallback
|
|
{
|
|
[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);
|
|
foreach (var x in equipments)
|
|
{
|
|
x.Value.SetActive(false);
|
|
}
|
|
foreach (var x in unEquipDictionary)
|
|
{
|
|
x.Value.SetActive(false);
|
|
}
|
|
foreach (var x in equipDictionary)
|
|
{
|
|
x.Value.SetActive(false);
|
|
}
|
|
}
|
|
public void DeEquip(IEquipmentSlot slot, IBasicItem item)
|
|
{
|
|
var asset = item.GetAssetable();
|
|
if (equipments.TryGetValue(asset.AdressablePath, out GameObject prop))
|
|
{
|
|
prop.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void OnEquip(IEquipmentSlot slot, IBasicItem item)
|
|
{
|
|
var asset = item.GetAssetable();
|
|
if(equipments.TryGetValue(asset.AdressablePath, out GameObject prop)) {
|
|
prop.SetActive(true);
|
|
}
|
|
}
|
|
|
|
public void OnEquip(IBasicItem item)
|
|
{
|
|
if (equipDictionary.TryGetValue(item.AdressablePath, out var model))
|
|
{
|
|
model.SetActive(true);
|
|
}
|
|
}
|
|
|
|
public void OnDeEquip(IBasicItem item)
|
|
{
|
|
foreach (var x in equipDictionary)
|
|
{
|
|
x.Value.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
public void OnUpdateEquip(IDictionary<int, IBasicItem> maps)
|
|
{
|
|
|
|
}
|
|
}
|
|
} |