Data Type
This commit is contained in:
@@ -1,30 +1,33 @@
|
||||
using Godot;
|
||||
using Nocturnis.DataStructures.Data;
|
||||
using Nocturnis.DataStructures.DataTypes;
|
||||
using Nocturnis.GlobalManagement.Constants;
|
||||
using Nocturnis.GlobalManagement.Providers;
|
||||
using Skeleton.DataStructure;
|
||||
|
||||
namespace Nocturnis.DataStructures;
|
||||
|
||||
public class DataCache : CacheItem<IData>
|
||||
public class DataCache : CacheItem<DataVariable>
|
||||
{
|
||||
public new static DataCache Null => new DataCache(x => (0, ""));
|
||||
public DataCache(Func<CacheItem?, IData> rec) : base(rec) => throw new Exception("CONSTRUCTION NOT ALLOWED");
|
||||
public new static DataCache Null => new (x => (0, GlobalProvider.DataStructureProvider!.NullDataType));
|
||||
public DataCache(Func<CacheItem, DataVariable> rec) : base(rec) => throw new Exception("CONSTRUCTION NOT ALLOWED");
|
||||
|
||||
public DataCache(Func<CacheItem?, (object, StringName)> rec)
|
||||
public DataCache(Func<CacheItem, (object, DataType)> rec)
|
||||
{
|
||||
Value = GlobalProvider.DataStructureProvider!.NewData(0, "");
|
||||
Value = GlobalProvider.DataStructureProvider!.NewData(0, DataTypeConstant.BaseDataTypes.Null);
|
||||
ProxyCalculator = rec;
|
||||
}
|
||||
|
||||
private new Func<CacheItem, (object, StringName)> ProxyCalculator { get; set; }
|
||||
private new Func<CacheItem, (object, DataType)> ProxyCalculator { get; set; }
|
||||
|
||||
public override IData? Get
|
||||
public override DataVariable Get
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Expired)
|
||||
{
|
||||
(object val, StringName type) = ProxyCalculator(this);
|
||||
Value!.Type = type;
|
||||
(object val, DataType type) = ProxyCalculator(this);
|
||||
Value!.Type.Assign(type);
|
||||
Value.Data = val;
|
||||
}
|
||||
|
||||
@@ -32,7 +35,7 @@ public class DataCache : CacheItem<IData>
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateCalculation(Func<CacheItem, (object, StringName)> rec)
|
||||
public void UpdateCalculation(Func<CacheItem, (object, DataType)> rec)
|
||||
{
|
||||
Expire();
|
||||
foreach (CacheItem item in Dependencies)
|
||||
|
||||
Reference in New Issue
Block a user