|
|
@@ -99,16 +99,19 @@ namespace TechbloxModdingAPI.Blocks.Engines |
|
|
|
|
|
|
|
internal object GetBlockInfo(Block block, Type type, string name) |
|
|
|
{ |
|
|
|
var str = AccessTools.Method(typeof(BlockEngine), "GetBlockInfo", generics: new[] { type }) |
|
|
|
.Invoke(this, new object[] { block }); |
|
|
|
return AccessTools.Field(str.GetType(), name).GetValue(str); |
|
|
|
/*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)); |
|
|
|
} |
|
|
|
|
|
|
|
internal void SetBlockInfo(Block block, Type type, string name, object value) |
|
|
|
{ |
|
|
|
var str = AccessTools.Method(typeof(BlockEngine), "GetBlockInfo", generics: new[] { type }) |
|
|
|
/*var opt = AccessTools.Method(typeof(BlockEngine), "GetBlockInfoOptional", generics: new[] { type }) |
|
|
|
.Invoke(this, new object[] { block }); |
|
|
|
AccessTools.Field(str.GetType(), name).SetValue(str, value); |
|
|
|
var str = AccessTools.Method(opt.GetType(), "Get").Invoke(opt, Array.Empty<object>()); |
|
|
|
AccessTools.Field(str.GetType(), name).SetValue(str, value);*/ |
|
|
|
} |
|
|
|
|
|
|
|
public void UpdateDisplayedBlock(EGID id) |
|
|
@@ -120,7 +123,7 @@ namespace TechbloxModdingAPI.Blocks.Engines |
|
|
|
var skew = entitiesDB.QueryEntity<SkewComponent>(id); |
|
|
|
entitiesDB.QueryEntity<RenderingDataStruct>(id).matrix = |
|
|
|
math.mul(float4x4.TRS(pos.position, rot.rotation, scale.scale), skew.skewMatrix); |
|
|
|
entitiesDB.PublishEntityChange<GFXPrefabEntityStructGPUI>(id); // Signal a prefab change so it updates the render buffers |
|
|
|
entitiesDB.PublishEntityChangeDelayed<GFXPrefabEntityStructGPUI>(id); // Signal a prefab change so it updates the render buffers |
|
|
|
} |
|
|
|
|
|
|
|
internal void UpdatePrefab(Block block, byte material, bool flipped) |
|
|
@@ -141,15 +144,15 @@ namespace TechbloxModdingAPI.Blocks.Engines |
|
|
|
entitiesDB.QueryEntityOrDefault<GFXPrefabEntityStructGPUI>(block).prefabID = prefabId; |
|
|
|
if (block.Exists) |
|
|
|
{ |
|
|
|
entitiesDB.PublishEntityChange<CubeMaterialStruct>(block.Id); |
|
|
|
entitiesDB.PublishEntityChange<GFXPrefabEntityStructGPUI>(block.Id); |
|
|
|
entitiesDB.PublishEntityChangeDelayed<CubeMaterialStruct>(block.Id); |
|
|
|
entitiesDB.PublishEntityChangeDelayed<GFXPrefabEntityStructGPUI>(block.Id); |
|
|
|
|
|
|
|
ref BuildingActionComponent local = |
|
|
|
ref entitiesDB.QueryEntity<BuildingActionComponent>(BuildingDroneUtility |
|
|
|
.GetLocalBuildingDrone(entitiesDB).ToEGID(entitiesDB)); |
|
|
|
local.buildAction = BuildAction.ChangeMaterial; |
|
|
|
local.targetPosition = block.Position; |
|
|
|
this.entitiesDB.PublishEntityChange<BuildingActionComponent>(local.ID); |
|
|
|
this.entitiesDB.PublishEntityChangeDelayed<BuildingActionComponent>(local.ID); |
|
|
|
} |
|
|
|
//Phyiscs prefab: prefabAssetID, set on block creation from the CubeListData |
|
|
|
} |
|
|
|