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

106 lines
3.8 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;
2023-11-30 00:23:23 +08:00
using BITKit.Entities;
2023-09-01 14:33:54 +08:00
// ReSharper disable UnassignedField.Global
2023-06-08 14:09:50 +08:00
namespace BITFALL
{
2023-11-30 00:23:23 +08:00
public interface ICustomItemBehavior
{
void Inject(IEntity entity);
bool TryUse(IBasicItem item);
void OnUse(IBasicItem item);
}
2023-08-27 02:58:19 +08:00
[Serializable]
2023-06-08 14:09:50 +08:00
public record ItemWeight : IProperty
{
2023-09-01 14:33:54 +08:00
public double Weight=1;
public static implicit operator double(ItemWeight self)
2023-06-08 14:09:50 +08:00
{
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)]
2023-09-01 14:33:54 +08:00
[SerializeField] private string displayName;
[SerializeField] private string description;
[SerializeField] private string addressablePath;
2023-10-24 23:37:59 +08:00
[SerializeField] private WorldItem prefab;
2023-09-01 14:33:54 +08:00
[SerializeField] private Texture2D squareIcon;
[SerializeField] private Texture2D rectangleIcon;
[SerializeField] private ItemQuality quality;
2023-11-30 00:23:23 +08:00
/// <summary>
/// 是否为不可储存的即兴物品
/// </summary>
2023-10-29 15:27:13 +08:00
[SerializeField] private bool isImprovised;
2023-11-30 00:23:23 +08:00
/// <summary>
/// 允许被击倒时使用
/// </summary>
[SerializeField] private bool allowUseWhileKnocked;
2023-06-08 14:09:50 +08:00
[Header(Constant.Header.Property)]
[SerializeReference, SubclassSelector] public IProperty[] factoryProperties;
2023-09-01 14:33:54 +08:00
private Property property => new(factoryProperties);
2023-06-08 14:09:50 +08:00
#endregion
#region
public int Id => -1;
2023-10-29 15:27:13 +08:00
public bool IsImprovised => isImprovised;
2023-06-08 14:09:50 +08:00
public ItemQuality Quality => quality;
public string Name => displayName;
public string Description => description;
2023-09-01 14:33:54 +08:00
public string AddressablePath => addressablePath;
2023-11-30 00:23:23 +08:00
public bool AllowUseWhileKnocked => allowUseWhileKnocked;
2023-06-08 14:09:50 +08:00
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("资产不支持动态更改");
2023-09-01 14:33:54 +08:00
public bool TrySetProperty<T>(T value) => throw new NotImplementedException("资产不支持动态更改");
2023-11-30 00:23:23 +08:00
2023-06-08 14:09:50 +08:00
public void Read(BinaryReader r)
{
2023-09-01 14:33:54 +08:00
throw new NotImplementedException("资产不支持动态更改");
2023-06-08 14:09:50 +08:00
}
public void Write(BinaryWriter w)
{
2023-09-01 14:33:54 +08:00
throw new NotImplementedException("资产不支持动态更改");
2023-06-08 14:09:50 +08:00
}
public bool CopyItemsFrom(IBasicItem item)
{
2023-09-01 14:33:54 +08:00
throw new NotImplementedException("资产不支持动态更改");
2023-06-08 14:09:50 +08:00
}
public bool ClearProperties()
{
2023-09-01 14:33:54 +08:00
throw new NotImplementedException("资产不支持动态更改");
2023-06-08 14:09:50 +08:00
}
public bool CopyPropertiesFrom(IPropertable propertable)
{
2023-09-01 14:33:54 +08:00
throw new NotImplementedException("资产不支持动态更改");
2023-06-08 14:09:50 +08:00
}
#endregion
#region
2023-10-24 23:37:59 +08:00
public WorldItem GetPrefab() => prefab;
2023-06-08 14:09:50 +08:00
public Texture2D SquareIcon => squareIcon;
public Texture2D RectangleIcon=>rectangleIcon;
#endregion
}
}