|
|
@@ -98,19 +98,21 @@ namespace TechbloxModdingAPI.Blocks.Engines |
|
|
|
|
|
|
|
internal object GetBlockInfo(Block block, Type type, string name) |
|
|
|
{ |
|
|
|
/*var opt = AccessTools.Method(typeof(BlockEngine), "GetBlockInfoOptional", generics: new[] { type }) |
|
|
|
.Invoke(this, new object[] { block }); - TODO: Cannot call method with by-ref return value |
|
|
|
var str = AccessTools.Method(opt.GetType(), "Get").Invoke(opt, Array.Empty<object>()); |
|
|
|
return AccessTools.Field(str.GetType(), name).GetValue(str);*/ |
|
|
|
return AccessTools.Field(type, name).GetValue(Activator.CreateInstance(type)); |
|
|
|
var opt = AccessTools.Method(typeof(NativeApiExtensions), "QueryEntityOptional", |
|
|
|
new[] { typeof(EntitiesDB), typeof(EcsObjectBase), typeof(ExclusiveGroupStruct) }, new[] { type }) |
|
|
|
.Invoke(null, new object[] { entitiesDB, block, null }); |
|
|
|
var str = AccessTools.Property(opt.GetType(), "Value").GetValue(opt); |
|
|
|
return AccessTools.Field(str.GetType(), name).GetValue(str); |
|
|
|
} |
|
|
|
|
|
|
|
internal void SetBlockInfo(Block block, Type type, string name, object value) |
|
|
|
{ |
|
|
|
/*var opt = AccessTools.Method(typeof(BlockEngine), "GetBlockInfoOptional", generics: new[] { type }) |
|
|
|
var opt = AccessTools.Method(typeof(BlockEngine), "GetBlockInfoOptional", generics: new[] { type }) |
|
|
|
.Invoke(this, new object[] { block }); |
|
|
|
var str = AccessTools.Method(opt.GetType(), "Get").Invoke(opt, Array.Empty<object>()); |
|
|
|
AccessTools.Field(str.GetType(), name).SetValue(str, value);*/ |
|
|
|
var prop = AccessTools.Property(opt.GetType(), "Value"); |
|
|
|
var str = prop.GetValue(opt); |
|
|
|
AccessTools.Field(str.GetType(), name).SetValue(str, value); |
|
|
|
prop.SetValue(opt, str); |
|
|
|
} |
|
|
|
|
|
|
|
public void UpdateDisplayedBlock(EGID id) |
|
|
|