GamecraftModdingAPI
v1.8.0
The unofficial Gamecraft modding API
|
Experimental support for adding custom blocks to the game. More...
Classes | |
class | CubeRegistrationPatch |
struct | DataStruct |
class | MaterialCopyPatch |
Public Member Functions | |
CustomBlock (EGID id) | |
CustomBlock (uint id) | |
T | Copy< T > () |
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 () |
T | Specialise< T > () |
Convert the block to a specialised block class. More... | |
override string | ToString () |
Static Public Member Functions | |
static void | ChangeExistingBlock (ushort id, Action< CubeListData > modifier) |
A low-level method for changing any property of an existing block. Use with caution. More... | |
static Block | GetLastPlacedBlock () |
Returns the most recently placed block. More... | |
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... | |
static T | PlaceNew< T > (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... | |
static void | RegisterCustomBlock< T > () |
Register a custom block type. Call it as soon as possible (in OnApplicationStart()). You need a Unity project with Addressables and Havok installed and need a prefab added as an addressable asset. Build the addressables and the project and copy the catalog.json from StreamingAssets, you'll need to reference this file. Also copy the asset files from the subfolder to the same path in 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 new void | Init () |
Package Attributes | |
BlockEngine.BlockInitData | 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. 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... | |
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... | |
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... | |
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... | |
Experimental support for adding custom blocks to the game.
|
inline |
|
inline |
|
inlinestatic |
A low-level method for changing any property of an existing block. Use with caution.
id | The block ID |
modifier | An action that modifies a property of the block |
|
inlineinherited |
Creates a copy of the block in the game with the same properties, stats and wires.
T | : | Block |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
Returns an array of blocks that are connected to this one. Returns an empty array if the block doesn't exist.
|
inlineinherited |
|
inlinestaticinherited |
Returns the most recently placed block.
|
inlinestaticpackage |
|
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 |
color | The block's color |
material | The block's material |
position | The block's position - default block size is 0.2 |
rotation | The block's rotation in degrees |
uscale | The block's uniform scale - default scale is 1 (with 0.2 width) |
scale | The block's non-uniform scale - 0 means uscale is used |
isFlipped | Whether the block should be flipped |
autoWire | Whether the block should be auto-wired (if functional) |
player | The player who placed the 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 |
color | The block's color |
material | The block's materialr |
position | The block's position - default block size is 0.2 |
rotation | The block's rotation in degrees |
uscale | The block's uniform scale - default scale is 1 (with 0.2 width) |
scale | The block's non-uniform scale - 0 means uscale is used |
isFlipped | Whether the block should be flipped |
autoWire | Whether the block should be auto-wired (if functional) |
player | The player who placed the block |
T | : | Block |
|
inlinestatic |
Register a custom block type. Call it as soon as possible (in OnApplicationStart()).
You need a Unity project with Addressables and Havok installed and need a prefab added as an addressable asset. Build the addressables and the project and copy the catalog.json from StreamingAssets, you'll need to reference this file. Also copy the asset files from the subfolder to the same path in the game.
T | The custom block type |
T | : | CustomBlock |
|
inlineinherited |
Convert the block to a specialised block class.
T | The specialised block type. |
T | : | Block |
|
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.
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 |
The block's exact color. Gets reset to the palette color (Color property) after reentering the game.
|
getsetinherited |
Whether the block is flipped.
|
getinherited |
|
getsetinherited |
The text displayed on the block if applicable, or null. Setting it is temporary to the session, it won't be saved.
|
getsetinherited |
The block's material.
|
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.
|
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.