BITFALL/Assets/Artists/Scripts/Core/Item/AssetableItem.cs

85 lines
2.9 KiB
C#
Raw Normal View History

2023-06-08 14:09:50 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Mathematics;
using BITKit;
using System.IO;
using System;
namespace BITFALL
{
2023-08-27 02:58:19 +08:00
[Serializable]
2023-06-08 14:09:50 +08:00
public record ItemWeight : IProperty
{
public float Weight=1;
public static implicit operator float(ItemWeight self)
{
return self.Weight;
}
}
2023-08-27 02:58:19 +08:00
[Serializable]
2023-06-08 14:09:50 +08:00
public record AddInventoryMaxWeight: IProperty
{
public float AddWeight = 1;
}
2023-08-27 02:58:19 +08:00
[Serializable]
2023-06-08 14:09:50 +08:00
public record Cellable : IProperty
{
public float2 size;
}
2023-08-12 01:43:24 +08:00
public class AssetableItem : ScriptableObject,IAssetableItem
2023-06-08 14:09:50 +08:00
{
#region
[Header(Constant.Header.Settings)]
[SerializeField] string displayName;
[SerializeField] string description;
[SerializeField] string adressablePath;
[SerializeField] WorldableItem prefab;
[SerializeField] Texture2D squareIcon;
[SerializeField] Texture2D rectangleIcon;
[SerializeField] ItemQuality quality;
[Header(Constant.Header.Property)]
[SerializeReference, SubclassSelector] public IProperty[] factoryProperties;
Property property => new(factoryProperties);
#endregion
#region
public int Id => -1;
public ItemQuality Quality => quality;
public string Name => displayName;
public string Description => description;
public string AdressablePath => adressablePath;
public bool Contains<T>() => property.Contains<T>();
public T GetOrAddProperty<T>(Func<T> addFactory) =>throw new NotImplementedException("资产不支持动态更改");
public T GetOrCreateProperty<T>() => throw new NotImplementedException("资产不支持动态更改");
public object[] GetProperties() => property.GetProperties();
public bool TryGetProperty<T>(out T value) => property.TryGetProperty(out value);
public bool TryRemoveProperty<T>() => throw new NotImplementedException("资产不支持动态更改");
public bool TrySetProperty<T>(T value) => throw new NotImplementedException();
public void Read(BinaryReader r)
{
throw new NotImplementedException();
}
public void Write(BinaryWriter w)
{
throw new NotImplementedException();
}
public bool CopyItemsFrom(IBasicItem item)
{
throw new NotImplementedException();
}
public bool ClearProperties()
{
throw new NotImplementedException();
}
public bool CopyPropertiesFrom(IPropertable propertable)
{
throw new NotImplementedException();
}
#endregion
#region
public WorldableItem GetPrefab() => prefab;
public Texture2D SquareIcon => squareIcon;
public Texture2D RectangleIcon=>rectangleIcon;
#endregion
}
}