|
|
@@ -67,7 +67,7 @@ namespace TechbloxModdingAPI |
|
|
|
/// <returns>The block object or null if doesn't exist</returns> |
|
|
|
public static Block GetLastPlacedBlock() |
|
|
|
{ |
|
|
|
uint lastBlockID = (uint) AccessTools.Field(typeof(CommonExclusiveGroups), "_nextBlockEntityID").GetValue(null) - 1; |
|
|
|
uint lastBlockID = CommonExclusiveGroups.blockIDGeneratorClient.Peek() - 1; |
|
|
|
EGID? egid = BlockEngine.FindBlockEGID(lastBlockID); |
|
|
|
return egid.HasValue ? New(egid.Value) : null; |
|
|
|
} |
|
|
@@ -366,8 +366,12 @@ namespace TechbloxModdingAPI |
|
|
|
get |
|
|
|
{ |
|
|
|
if (blockGroup != null) return blockGroup; |
|
|
|
if (!GameState.IsBuildMode()) return null; // Breaks in simulation |
|
|
|
var bgec = BlockEngine.GetBlockInfo<BlockGroupEntityComponent>(this); |
|
|
|
return blockGroup = bgec.currentBlockGroup == -1 ? null : new BlockGroup(bgec.currentBlockGroup, this); |
|
|
|
return blockGroup = bgec.currentBlockGroup == -1 |
|
|
|
? null |
|
|
|
: GetInstance(new EGID((uint)bgec.currentBlockGroup, BlockGroupExclusiveGroups.BlockGroupEntityGroup), |
|
|
|
egid => new BlockGroup((int)egid.entityID, this)); |
|
|
|
} |
|
|
|
set |
|
|
|
{ |
|
|
@@ -395,6 +399,23 @@ namespace TechbloxModdingAPI |
|
|
|
set => BlockEngine.GetBlockInfo<BlockStaticComponent>(this).isStatic = value; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// The mass of the block. |
|
|
|
/// </summary> |
|
|
|
public float Mass |
|
|
|
{ |
|
|
|
get => BlockEngine.GetBlockInfo<MassStruct>(this).mass; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// Block complexity used for build rules. Determines the 'cost' of the block. |
|
|
|
/// </summary> |
|
|
|
public BlockComplexity Complexity |
|
|
|
{ |
|
|
|
get => new(BlockEngine.GetBlockInfo<BlockComplexityComponent>(this)); |
|
|
|
set => BlockEngine.GetBlockInfo<BlockComplexityComponent>(this) = value; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// Whether the block exists. The other properties will return a default value if the block doesn't exist. |
|
|
|
/// If the block was just placed, then this will also return false but the properties will work correctly. |
|
|
|