![]() |
TechbloxModdingAPI
v2.2.0
The unofficial Techblox modding API
|
Common implementation for blocks that support wiring. More...
Public Member Functions | |
SignalingBlock (EGID id) | |
SignalingBlock (uint id) | |
Wire | Connect (byte sourcePort, SignalingBlock destination, byte destinationPort) |
Connect an output on this block to an input on another block. More... | |
Wire[] | ConnectedToOutput (byte port) |
All wires connected to the output port. These wires will always be wired output -> input. 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 () |
string | InputPortName (byte port) |
The input port's name. More... | |
string | PortName (byte port, bool input) |
The port's name. This is localized to the user's language, so this is not reliable for port identification. More... | |
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... | |
Protected Member Functions | |
OptionalRef< ChannelDataStruct > | GetChannelData (EGID portId) |
[EXPERIMENTAL] Gets the channel data. More... | |
ref WireEntityStruct | GetConnectedWire (PortEntityStruct port, out bool connected) |
Gets the connected wire. More... | |
EGID[] | GetInputIds () |
Generates the input port identifiers. More... | |
EGID[] | GetOutputIds () |
Generates the output port identifiers. 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, EcsObjectBase > | GetInstances (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] |
uint | InputCount [get] |
The input port count. More... | |
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] |
uint | OutputCount [get] |
The output port count. More... | |
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... | |
BlockIDs? | Type [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< BlockPlacedRemovedEventArgs > | Placed [add, remove] |
An event that fires each time a block is placed. More... | |
static EventHandler< BlockPlacedRemovedEventArgs > | Removed [add, remove] |
An event that fires each time a block is removed. More... | |
Common implementation for blocks that support wiring.
|
inline |
|
inline |
|
inline |
Connect an output on this block to an input on another block.
sourcePort | Output port number. |
destination | Input block. |
destinationPort | Input port number. |
WiringException | The wire could not be created. |
|
inline |
All wires connected to the output port. These wires will always be wired output -> input.
port | Port number. |
|
inlineinherited |
Creates a copy of the block in the game with the same properties, stats and wires.
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineprotected |
[EXPERIMENTAL] Gets the channel data.
portId | Port identifier. |
|
inlineinherited |
Returns an array of blocks that are connected to this one. Returns an empty array if the block doesn't exist.
|
inlineprotected |
Gets the connected wire.
portId | Port identifier. |
connected | Whether the port has a wire connected to it. |
|
inlineinherited |
|
inlineprotected |
Generates the input port identifiers.
|
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.
egid | The EGID of the entity |
constructor | The constructor to construct the object |
T | The object type |
T | : | EcsObjectBase |
|
inlinestaticpackageinherited |
|
inlinestaticinherited |
Returns the most recently placed block.
|
inlineprotected |
Generates the output port identifiers.
|
inlinestaticinherited |
|
inline |
The input port's name.
port | Input port number. |
|
inlinestaticpackageinherited |
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.
egid | The EGID of the block |
signaling | Whether the block is definitely a signaling block |
|
inlinestaticinherited |
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.
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 |
|
inline |
The port's name. This is localized to the user's language, so this is not reliable for port identification.
port | Port number. |
input | Whether the port is an input (true) or an output (false). |
|
inlineinherited |
|
staticprotectedinherited |
|
staticpackageinherited |
|
staticprotectedinherited |
|
inherited |
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.
|
packageinherited |
|
staticprotectedinherited |
|
staticprotectedinherited |
|
staticprotectedinherited |
|
staticprotectedinherited |
|
staticprotectedinherited |
|
staticprotectedinherited |
|
getsetinherited |
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).
|
getsetinherited |
The block's color. Returns BlockColors.Default if the block no longer exists.
|
getsetinherited |
Block complexity used for build rules. Determines the 'cost' of the block.
|
getsetinherited |
The block's exact color. Gets reset to the palette color (Color property) after reentering the game.
|
getsetinherited |
Whether the block is flipped.
|
getinherited |
|
get |
The input port count.
|
getsetinherited |
The text displayed on the block if applicable, or null. Setting it is temporary to the session, it won't be saved.
|
getinherited |
The mass of the block.
|
getsetinherited |
The block's material.
|
get |
The output port count.
|
getsetinherited |
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.
|
getsetinherited |
The block's current rotation in degrees or zero if the block doesn't exist.
|
getsetinherited |
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.
|
getsetinherited |
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.
|
getinherited |
The block's type (ID). Returns BlockIDs.Invalid if the block doesn't exist anymore.
|
getsetinherited |
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.
|
staticaddremoveinherited |
An event that fires each time a block is placed.
|
staticaddremoveinherited |
An event that fires each time a block is removed.