‪TechbloxModdingAPI  ‪v2.2.0
‪The unofficial Techblox modding API
TechbloxModdingAPI.Block Class Reference

‪A single (perhaps scaled) block. Properties may return default values if the block is removed and then setting them is ignored. For specific block type operations, use the specialised block classes in the TechbloxModdingAPI.Blocks namespace. More...

Inheritance diagram for TechbloxModdingAPI.Block:
TechbloxModdingAPI.EcsObjectBase TechbloxModdingAPI.Blocks.SignalingBlock TechbloxModdingAPI.Blocks.DampedSpring TechbloxModdingAPI.Blocks.Engine TechbloxModdingAPI.Blocks.LogicGate TechbloxModdingAPI.Blocks.Motor TechbloxModdingAPI.Blocks.ObjectID TechbloxModdingAPI.Blocks.Piston TechbloxModdingAPI.Blocks.Seat TechbloxModdingAPI.Blocks.Servo TechbloxModdingAPI.Blocks.WheelRig

Public Member Functions

 Block (BlockIDs type, float3 position, bool autoWire=false, Player player=null)
 ‪Places a new block in the world. More...
 
 Block (EGID id)
 
 Block (uint id)
 ‪This overload searches for the correct group the block is in. It will throw an exception if the block doesn't exist. Use the EGID constructor where possible or subclasses of Block as those specify the group. More...
 
Block Copy ()
 ‪Creates a copy of the block in the game with the same properties, stats and wires. More...
 
bool Equals (Block other)
 
bool Equals (EGID other)
 
override bool Equals (object obj)
 
Block[] GetConnectedCubes ()
 ‪Returns an array of blocks that are connected to this one. Returns an empty array if the block doesn't exist. More...
 
override int GetHashCode ()
 
override string ToString ()
 

Static Public Member Functions

static Block GetLastPlacedBlock ()
 ‪Returns the most recently placed block. More...
 
static void Init ()
 
static Block PlaceNew (BlockIDs block, float3 position, bool autoWire=false, Player player=null)
 ‪Place a new block at the given position. If scaled, position means the center of the block. The default block size is 0.2 in terms of position. Place blocks next to each other to connect them. The placed block will be a complete block with a placement grid and collision which will be saved along with the game. More...
 

Public Attributes

bool Exists => BlockEngine.BlockExists(Id)
 ‪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. More...
 

Static Protected Attributes

static readonly BlockCloneEngine BlockCloneEngine = new BlockCloneEngine()
 
static readonly BlockEventsEngine BlockEventsEngine = new BlockEventsEngine()
 
static readonly MovementEngine MovementEngine = new MovementEngine()
 
static readonly PlacementEngine PlacementEngine = new PlacementEngine()
 
static readonly RemovalEngine RemovalEngine = new RemovalEngine()
 
static readonly RotationEngine RotationEngine = new RotationEngine()
 
static readonly ScalingEngine ScalingEngine = new ScalingEngine()
 
static readonly SignalEngine SignalEngine = new SignalEngine()
 

Static Package Functions

static T GetInstance< T > (EGID egid, Func< EGID, T > constructor, Type type=null)
 ‪Returns a cached instance if there's an actively used instance of the object already. Objects still get garbage collected and then they will be removed from the cache. More...
 
static WeakDictionary< EGID, EcsObjectBaseGetInstances (Type type)
 
static Block New (EGID egid, bool signaling=false)
 ‪Returns a correctly typed instance of this block. The instances are shared for a specific block. If an instance is no longer referenced a new instance is returned. More...
 

Package Attributes

EcsInitData InitData
 

Static Package Attributes

static readonly BlockEngine BlockEngine = new BlockEngine()
 

Properties

BlockGroup??????? BlockGroup [get, set]
 ‪Returns the block group this block is a part of. Block groups can also be placed using blueprints. Returns null if not part of a group, although all blocks should have their own by default.
Setting the group after the block has been initialized will not update everything properly, so you can only set this property on blocks newly placed by your code.
To set it for existing blocks, you can use the Copy() method and set the property on the resulting block (and remove this block). More...
 
BlockColor?? Color [get, set]
 ‪The block's color. Returns BlockColors.Default if the block no longer exists. More...
 
BlockComplexity Complexity [get, set]
 Block complexity used for build rules. Determines the 'cost' of the block. More...
 
float4 CustomColor [get, set]
 ‪The block's exact color. Gets reset to the palette color (Color property) after reentering the game. More...
 
bool? Flipped [get, set]
 
EGID Id [get]
 
string? Label [get, set]
 ‪The text displayed on the block if applicable, or null. Setting it is temporary to the session, it won't be saved. More...
 
float Mass [get]
 ‪The mass of the block. More...
 
BlockMaterial?? Material [get, set]
 
float3 Position [get, set]
 ‪The block's current position or zero if the block no longer exists. A block is 0.2 wide by default in terms of position. More...
 
float3 Rotation [get, set]
 ‪The block's current rotation in degrees or zero if the block doesn't exist. More...
 
float3 Scale [get, set]
 ‪The block's non-uniform scale or zero if the block's invalid. Independent of the uniform scaling. The default scale of 1 means 0.2 in terms of position. More...
 
bool Static [get, set]
 ‪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. More...
 
BlockIDsType [get]
 ‪The block's type (ID). Returns BlockIDs.Invalid if the block doesn't exist anymore. More...
 
int UniformScale [get, set]
 ‪The block's uniform scale or zero if the block's invalid. Also sets the non-uniform scale. The default scale of 1 means 0.2 in terms of position. More...
 

Events

static EventHandler< BlockPlacedRemovedEventArgsPlaced [add, remove]
 ‪An event that fires each time a block is placed. More...
 
static EventHandler< BlockPlacedRemovedEventArgsRemoved [add, remove]
 ‪An event that fires each time a block is removed. More...
 

Detailed Description

A single (perhaps scaled) block. Properties may return default values if the block is removed and then setting them is ignored. For specific block type operations, use the specialised block classes in the TechbloxModdingAPI.Blocks namespace.

Constructor & Destructor Documentation

◆ Block() [1/3]

TechbloxModdingAPI.Block.Block ( EGID  id)
inline

◆ Block() [2/3]

TechbloxModdingAPI.Block.Block ( uint  id)
inline

‪This overload searches for the correct group the block is in. It will throw an exception if the block doesn't exist. Use the EGID constructor where possible or subclasses of Block as those specify the group.

◆ Block() [3/3]

TechbloxModdingAPI.Block.Block ( BlockIDs  type,
float3  position,
bool  autoWire = false,
Player  player = null 
)
inline

‪Places a new block in the world.

Parameters
type‪The block's type
position‪The block's position (a block is 0.2 wide in terms of position)
autoWire‪Whether the block should be auto-wired (if functional)
player‪The player who placed the block

Member Function Documentation

◆ Copy()

Block TechbloxModdingAPI.Block.Copy ( )
inline

‪Creates a copy of the block in the game with the same properties, stats and wires.

Returns

◆ Equals() [1/3]

bool TechbloxModdingAPI.Block.Equals ( Block  other)
inline

◆ Equals() [2/3]

bool TechbloxModdingAPI.Block.Equals ( EGID  other)
inline

◆ Equals() [3/3]

override bool TechbloxModdingAPI.Block.Equals ( object  obj)
inline

◆ GetConnectedCubes()

Block [] TechbloxModdingAPI.Block.GetConnectedCubes ( )
inline

‪Returns an array of blocks that are connected to this one. Returns an empty array if the block doesn't exist.

◆ GetHashCode()

override int TechbloxModdingAPI.Block.GetHashCode ( )
inline

◆ GetInstance< T >()

static T TechbloxModdingAPI.EcsObjectBase.GetInstance< T > ( EGID  egid,
Func< EGID, T >  constructor,
Type  type = null 
)
inlinestaticpackageinherited

‪Returns a cached instance if there's an actively used instance of the object already. Objects still get garbage collected and then they will be removed from the cache.

Parameters
egid‪The EGID of the entity
constructor‪The constructor to construct the object
Template Parameters
T‪The object type
Returns
Type Constraints
T :EcsObjectBase 

◆ GetInstances()

static WeakDictionary<EGID, EcsObjectBase> TechbloxModdingAPI.EcsObjectBase.GetInstances ( Type  type)
inlinestaticpackageinherited

◆ GetLastPlacedBlock()

static Block TechbloxModdingAPI.Block.GetLastPlacedBlock ( )
inlinestatic

‪Returns the most recently placed block.

Returns
‪The block object or null if doesn't exist

◆ Init()

static void TechbloxModdingAPI.Block.Init ( )
inlinestatic

◆ New()

static Block TechbloxModdingAPI.Block.New ( EGID  egid,
bool  signaling = false 
)
inlinestaticpackage

‪Returns a correctly typed instance of this block. The instances are shared for a specific block. If an instance is no longer referenced a new instance is returned.

Parameters
egid‪The EGID of the block
signaling‪Whether the block is definitely a signaling block
Returns

◆ PlaceNew()

static Block TechbloxModdingAPI.Block.PlaceNew ( BlockIDs  block,
float3  position,
bool  autoWire = false,
Player  player = null 
)
inlinestatic

‪Place a new block at the given position. If scaled, position means the center of the block. The default block size is 0.2 in terms of position. Place blocks next to each other to connect them. The placed block will be a complete block with a placement grid and collision which will be saved along with the game.

Parameters
block‪The block's type
position‪The block's position - default block size is 0.2
autoWire‪Whether the block should be auto-wired (if functional)
player‪The player who placed the block
Returns
‪The placed block or null if failed

◆ ToString()

override string TechbloxModdingAPI.Block.ToString ( )
inline

Member Data Documentation

◆ BlockCloneEngine

readonly BlockCloneEngine TechbloxModdingAPI.Block.BlockCloneEngine = new BlockCloneEngine()
staticprotected

◆ BlockEngine

readonly BlockEngine TechbloxModdingAPI.Block.BlockEngine = new BlockEngine()
staticpackage

◆ BlockEventsEngine

readonly BlockEventsEngine TechbloxModdingAPI.Block.BlockEventsEngine = new BlockEventsEngine()
staticprotected

◆ Exists

bool TechbloxModdingAPI.Block.Exists => BlockEngine.BlockExists(Id)

‪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.

◆ InitData

EcsInitData TechbloxModdingAPI.EcsObjectBase.InitData
packageinherited

◆ MovementEngine

readonly MovementEngine TechbloxModdingAPI.Block.MovementEngine = new MovementEngine()
staticprotected

◆ PlacementEngine

readonly PlacementEngine TechbloxModdingAPI.Block.PlacementEngine = new PlacementEngine()
staticprotected

◆ RemovalEngine

readonly RemovalEngine TechbloxModdingAPI.Block.RemovalEngine = new RemovalEngine()
staticprotected

◆ RotationEngine

readonly RotationEngine TechbloxModdingAPI.Block.RotationEngine = new RotationEngine()
staticprotected

◆ ScalingEngine

readonly ScalingEngine TechbloxModdingAPI.Block.ScalingEngine = new ScalingEngine()
staticprotected

◆ SignalEngine

readonly SignalEngine TechbloxModdingAPI.Block.SignalEngine = new SignalEngine()
staticprotected

Property Documentation

◆ BlockGroup

BlockGroup??????? TechbloxModdingAPI.Block.BlockGroup
getset

‪Returns the block group this block is a part of. Block groups can also be placed using blueprints. Returns null if not part of a group, although all blocks should have their own by default.
Setting the group after the block has been initialized will not update everything properly, so you can only set this property on blocks newly placed by your code.
To set it for existing blocks, you can use the Copy() method and set the property on the resulting block (and remove this block).

◆ Color

BlockColor?? TechbloxModdingAPI.Block.Color
getset

‪The block's color. Returns BlockColors.Default if the block no longer exists.

◆ Complexity

BlockComplexity TechbloxModdingAPI.Block.Complexity
getset

Block complexity used for build rules. Determines the 'cost' of the block.

◆ CustomColor

float4 TechbloxModdingAPI.Block.CustomColor
getset

‪The block's exact color. Gets reset to the palette color (Color property) after reentering the game.

◆ Flipped

bool? TechbloxModdingAPI.Block.Flipped
getset

Whether the block is flipped.

◆ Id

EGID TechbloxModdingAPI.EcsObjectBase.Id
getinherited

◆ Label

string? TechbloxModdingAPI.Block.Label
getset

‪The text displayed on the block if applicable, or null. Setting it is temporary to the session, it won't be saved.

◆ Mass

float TechbloxModdingAPI.Block.Mass
get

‪The mass of the block.

◆ Material

BlockMaterial?? TechbloxModdingAPI.Block.Material
getset

The block's material.

◆ Position

float3 TechbloxModdingAPI.Block.Position
getset

‪The block's current position or zero if the block no longer exists. A block is 0.2 wide by default in terms of position.

◆ Rotation

float3 TechbloxModdingAPI.Block.Rotation
getset

‪The block's current rotation in degrees or zero if the block doesn't exist.

◆ Scale

float3 TechbloxModdingAPI.Block.Scale
getset

‪The block's non-uniform scale or zero if the block's invalid. Independent of the uniform scaling. The default scale of 1 means 0.2 in terms of position.

◆ Static

bool TechbloxModdingAPI.Block.Static
getset

‪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.

◆ Type

BlockIDs? TechbloxModdingAPI.Block.Type
get

‪The block's type (ID). Returns BlockIDs.Invalid if the block doesn't exist anymore.

◆ UniformScale

int TechbloxModdingAPI.Block.UniformScale
getset

‪The block's uniform scale or zero if the block's invalid. Also sets the non-uniform scale. The default scale of 1 means 0.2 in terms of position.

Event Documentation

◆ Placed

EventHandler< BlockPlacedRemovedEventArgs> TechbloxModdingAPI.Block.Placed
staticaddremove

‪An event that fires each time a block is placed.

◆ Removed

EventHandler< BlockPlacedRemovedEventArgs> TechbloxModdingAPI.Block.Removed
staticaddremove

‪An event that fires each time a block is removed.


The documentation for this class was generated from the following file: