70 lines
2.2 KiB
C#
70 lines
2.2 KiB
C#
using BITKit;
|
|
using BITKit.Entities;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using System.Linq;
|
|
using RotaryHeart.Lib.SerializableDictionary;
|
|
namespace BITFALL
|
|
{
|
|
public class EntityPropsDisplay : EntityComponent,IPlayerEquipCallback,IEquipSelectorCallback
|
|
{
|
|
public SerializableDictionaryBase<string, GameObject> equipments = new();
|
|
public SerializableDictionaryBase<string, GameObject> unequipdDictionary = new();
|
|
public SerializableDictionaryBase<string, GameObject> equipedDictionary = new();
|
|
public override void OnStart()
|
|
{
|
|
base.OnStart();
|
|
entity.RegisterCallback<IPlayerEquipCallback>(this);
|
|
entity.RegisterCallback<IEquipSelectorCallback>(this);
|
|
foreach (var x in equipments)
|
|
{
|
|
x.Value.SetActive(false);
|
|
}
|
|
foreach (var x in unequipdDictionary)
|
|
{
|
|
x.Value.SetActive(false);
|
|
}
|
|
foreach (var x in equipedDictionary)
|
|
{
|
|
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 (equipedDictionary.TryGetValue(item.AdressablePath, out var model))
|
|
{
|
|
model.SetActive(true);
|
|
}
|
|
}
|
|
|
|
public void OnDeEquip(IBasicItem item)
|
|
{
|
|
foreach (var x in equipedDictionary)
|
|
{
|
|
x.Value.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
public void OnUpdateEquiped(IDictionary<int, IBasicItem> maps)
|
|
{
|
|
|
|
}
|
|
}
|
|
} |