using System;
using System.IO;
namespace BITKit
{
#region 物品枚举
public enum ItemQuality
{
///
/// 常见的
///
Common,
///
/// 罕见的
///
Uncommon,
///
/// 稀有的
///
Rare,
///
/// 史诗的
///
Epic,
///
/// 传奇的
///
Legendary,
///
/// 神话的
///
Mythical,
///
/// 开发者
///
Develop,
}
#endregion
#region 物品接口
///
/// 基础物品
///
public interface IBasicItem :IPropertable
{
///
/// 唯一Id
///
int Id { get; }
///
/// 物品名,一般用于查找物品的主键
///
string Name { get; }
///
/// 可寻址路径,该路径用于查找物品
///
string AdressablePath { get; }
///
/// 物品描述
///
string Description { get; }
///
/// 物品品质
///
ItemQuality Quality { get; }
bool CopyItemsFrom(IBasicItem item);
}
///
/// 可配置化物品,通常用于配置
///
public interface IAssetableItem: IBasicItem
{
}
#endregion
#region 物品实现
///
/// 可序列化的物品
///
[Serializable]
public record SerializableItem : IBasicItem
{
#region 字段
public int Id;
public string Name;
public string AdressablePath { get; set; }
public string Description;
public ItemQuality Quality;
///
/// 本地属性
///
Property property = new();
#endregion
#region 接口的隐式实现
int IBasicItem.Id => Id;
string IBasicItem.Name => Name;
string IBasicItem.Description => Description;
ItemQuality IBasicItem.Quality => Quality;
#endregion
#region 接口的显式实现
public bool Contains() => property.Contains();
public T GetOrAddProperty(Func addFactory) => property.GetOrAddProperty(addFactory);
public T GetOrCreateProperty() => property.GetOrCreateProperty();
public object[] GetProperties() => property.GetProperties();
public bool TryGetProperty(out T value) => property.TryGetProperty(out value);
public bool TryRemoveProperty() => property.TryRemoveProperty();
public bool TrySetProperty(T value) => property.TrySetProperty(value);
public void Read(BinaryReader r)
{
throw new NotImplementedException();
}
public void Write(BinaryWriter w)
{
throw new NotImplementedException();
}
public bool CopyItemsFrom(IBasicItem item)
{
Id=item.Id;
Name = item.Name;
AdressablePath = item.AdressablePath;
Description = item.Description;
Quality=item.Quality;
CopyPropertiesFrom(item);
return true;
}
public bool ClearProperties()=>property.ClearProperties();
public bool CopyPropertiesFrom(IPropertable propertable)
{
return property.CopyPropertiesFrom(propertable);
}
#endregion
}
#endregion
}