|
|
@@ -248,11 +248,14 @@ namespace TechbloxModdingAPI |
|
|
|
} |
|
|
|
set |
|
|
|
{ |
|
|
|
//TODO: Check if setting to 255 works |
|
|
|
if (value.Color == BlockColors.Default) |
|
|
|
value = new BlockColor(FullGameFields._dataDb.TryGetValue((int) Type, out CubeListData cld) |
|
|
|
? cld.DefaultColour |
|
|
|
: throw new BlockTypeException("Unknown block type! Could not set default color.")); |
|
|
|
ref var color = ref BlockEngine.GetBlockInfo<ColourParameterEntityStruct>(this); |
|
|
|
color.indexInPalette = value.Index; |
|
|
|
color.hasNetworkChange = true; |
|
|
|
color.paletteColour = BlockEngine.ConvertBlockColor(color.indexInPalette); |
|
|
|
color.paletteColour = BlockEngine.ConvertBlockColor(color.indexInPalette); //Setting to 255 results in black |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -282,10 +285,15 @@ namespace TechbloxModdingAPI |
|
|
|
} |
|
|
|
set |
|
|
|
{ |
|
|
|
if (!FullGameFields._dataDb.ContainsKey<MaterialPropertiesData>((byte) value)) |
|
|
|
byte val = (byte) value; |
|
|
|
if (value == BlockMaterial.Default) |
|
|
|
val = FullGameFields._dataDb.TryGetValue((int) Type, out CubeListData cld) |
|
|
|
? cld.DefaultMaterialID |
|
|
|
: throw new BlockTypeException("Unknown block type! Could not set default material."); |
|
|
|
if (!FullGameFields._dataDb.ContainsKey<MaterialPropertiesData>(val)) |
|
|
|
throw new BlockException($"Block material {value} does not exist!"); |
|
|
|
BlockEngine.GetBlockInfo<CubeMaterialStruct>(this).materialId = (byte) value; |
|
|
|
BlockEngine.UpdatePrefab(this, (byte) value, Flipped); //TODO: Test default |
|
|
|
BlockEngine.GetBlockInfo<CubeMaterialStruct>(this).materialId = val; |
|
|
|
BlockEngine.UpdatePrefab(this, val, Flipped); //The default causes the screen to go black |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -336,6 +344,15 @@ namespace TechbloxModdingAPI |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// Whether the block should be static in simulation. If set, it cannot be moved. The effect is temporary, it will not be saved with the block. |
|
|
|
/// </summary> |
|
|
|
public bool Static |
|
|
|
{ |
|
|
|
get => BlockEngine.GetBlockInfo<OverrideStaticComponent>(this).staticIfUnconnected; |
|
|
|
set => BlockEngine.GetBlockInfo<OverrideStaticComponent>(this).staticIfUnconnected = 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. |
|
|
|