WuhuIslandTesting/Library/PackageCache/com.stresslevelzero.marrow.sdk@1.2.0/Scripts/SLZ.Marrow/SLZ.Marrow.Warehouse/DataCardReference.cs

120 lines
2.7 KiB
C#
Raw Normal View History

2025-01-07 02:06:59 +01:00
using System;
using UnityEngine;
namespace SLZ.Marrow.Warehouse
{
[Serializable]
public class DataCardReference : ScannableReference<DataCard>
{
public DataCardReference() : base(Warehouse.Barcode.EmptyBarcode())
{
}
public DataCardReference(Barcode barcode) : base(barcode)
{
}
public DataCardReference(string barcode) : base(barcode)
{
}
public DataCard DataCard
{
get
{
TryGetDataCard(out var retDataCard);
return retDataCard;
}
}
public bool TryGetDataCard(out DataCard dataCard)
{
dataCard = null;
bool success = false;
if (AssetWarehouse.ready)
{
success = AssetWarehouse.Instance.TryGetDataCard(Barcode, out dataCard);
}
return success;
}
public static bool IsValid(DataCardReference dataCardReference)
{
return dataCardReference != null && Barcode.IsValid(dataCardReference.Barcode);
}
}
[Serializable]
public class DataCardReference<T> : ScannableReference<DataCard> where T : DataCard
{
public DataCardReference() : base(Warehouse.Barcode.EmptyBarcode())
{
}
public DataCardReference(Barcode barcode) : base(barcode)
{
}
public DataCardReference(string barcode) : base(barcode)
{
}
public new T DataCard
{
get
{
TryGetDataCard(out var retDataCard);
return retDataCard;
}
}
public bool TryGetDataCard(out T dataCard)
{
dataCard = null;
bool success = false;
if (AssetWarehouse.ready)
{
success = AssetWarehouse.Instance.TryGetDataCard<T>(Barcode, out dataCard);
}
return success;
}
}
[Serializable]
public class BoneTagReference : DataCardReference<BoneTag>
{
public BoneTagReference() : base(Warehouse.Barcode.EmptyBarcode())
{
}
public BoneTagReference(Barcode barcode) : base(barcode)
{
}
public BoneTagReference(string barcode) : base(barcode)
{
}
}
[Serializable]
public class MonoDiscReference : DataCardReference<MonoDisc>
{
public MonoDiscReference() : base(Warehouse.Barcode.EmptyBarcode())
{
}
public MonoDiscReference(Barcode barcode) : base(barcode)
{
}
public MonoDiscReference(string barcode) : base(barcode)
{
}
}
}