1
This commit is contained in:
@@ -14,14 +14,48 @@ namespace BITFALL
|
||||
#region 本地字段
|
||||
[Header(Constant.Header.Settings)]
|
||||
[SerializeField]private AssetableItem asset;
|
||||
|
||||
[Header(Constant.Header.Optional)]
|
||||
[SerializeReference, SubclassSelector] private IProperty[] initialProperties;
|
||||
#endregion
|
||||
#region 接口实现
|
||||
public int Id => GetInstanceID();
|
||||
public int Id { get; private set; } = Guid.NewGuid().GetHashCode();
|
||||
public string Name => asset.Name;
|
||||
public string Description => asset.Description;
|
||||
public ItemQuality Quality => asset.Quality;
|
||||
public string AddressablePath => asset.AddressablePath;
|
||||
private readonly Property property = new();
|
||||
|
||||
internal Property property
|
||||
{
|
||||
get
|
||||
{
|
||||
if (BITAppForUnity.IsPlaying is false || asset?.RuntimeProperties is null)
|
||||
{
|
||||
return (initialProperties is null)?
|
||||
new Property() : new Property(initialProperties);
|
||||
}
|
||||
|
||||
|
||||
if(_property is not null) return _property;
|
||||
|
||||
var list = new List<IProperty>();
|
||||
if (asset?.RuntimeProperties is not null)
|
||||
{
|
||||
list.AddRange(asset.RuntimeProperties);
|
||||
}
|
||||
if(initialProperties is not null)
|
||||
{
|
||||
list.AddRange(initialProperties);
|
||||
}
|
||||
return _property= new Property(list.ToArray());
|
||||
// return _property ??= (BITAppForUnity.IsPlaying && asset?.RuntimeProperties is not null)
|
||||
// ? new Property(asset.RuntimeProperties)
|
||||
// : new Property();
|
||||
}
|
||||
set=>_property=value;
|
||||
}
|
||||
|
||||
private Property _property;
|
||||
public bool Contains<T>() => property.Contains<T>();
|
||||
|
||||
public T GetOrAddProperty<T>(Func<T> addFactory) => property.GetOrAddProperty<T>(addFactory);
|
||||
@@ -47,10 +81,8 @@ namespace BITFALL
|
||||
}
|
||||
public bool CopyItemsFrom(IBasicItem item)
|
||||
{
|
||||
if(item is ManagedItem serializableItem)
|
||||
{
|
||||
asset = serializableItem.GetAssetable();
|
||||
}
|
||||
Id=item.Id;
|
||||
CopyPropertiesFrom(item);
|
||||
return true;
|
||||
}
|
||||
public bool ClearProperties()=>property.ClearProperties();
|
||||
@@ -69,6 +101,11 @@ namespace BITFALL
|
||||
Destroy(gameObject);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public object Clone()
|
||||
{
|
||||
return Pick();
|
||||
}
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
[UnityEditor.CustomEditor(typeof(WorldItem))]
|
||||
@@ -81,6 +118,14 @@ namespace BITFALL
|
||||
label.text = agent.Id.ToString();
|
||||
FillDefaultInspector();
|
||||
CreateSubTitle(Constant.Header.Debug);
|
||||
var property = root.Create<Label>();
|
||||
var stringbuilder = new System.Text.StringBuilder();
|
||||
foreach (var x in agent.property.GetProperties())
|
||||
{
|
||||
stringbuilder.AppendLine(x.ToString());
|
||||
stringbuilder.AppendLine("--------------");
|
||||
}
|
||||
property.text = stringbuilder.ToString();
|
||||
return root;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user