Class Block
Represents a specific Block placed in the game. Can be a building or simulation block.
Namespace: Modding.Blocks
Assembly: Assembly-CSharp.dll
Syntax
public class Block
Properties
BlockScript
BlockScript attached to this block.
Always null for non-modded blocks. Can also be null for modded blocks, depending on whether the block has one.
Declaration
public BlockScript BlockScript { get; }
Property Value
Type | Description |
---|---|
BlockScript |
BuildingBlock
A reference to the building version of the current block.
This returns the same object when accessed on a building block.
Declaration
public Block BuildingBlock { get; }
Property Value
Type | Description |
---|---|
Block |
GameObject
The game object of this block.
Declaration
public GameObject GameObject { get; }
Property Value
Type | Description |
---|---|
UnityEngine.GameObject |
Guid
Unique identifier for each block. This value is the same for a building block and its simulation clone.
MP: This value is consistent across all instances in MP.
Declaration
public Guid Guid { get; }
Property Value
Type | Description |
---|---|
Guid |
Health
The health of this block, 0 if the block doesn't support health.
Declaration
public float Health { get; }
Property Value
Type | Description |
---|---|
Single |
InternalObject
The internal representation of this block.
WARNING: This is not part of the stable API and subject to change!
Declaration
public BlockBehaviour InternalObject { get; }
Property Value
Type | Description |
---|---|
BlockBehaviour |
InWind
Whether this block is currently affected by wind.
Declaration
public bool InWind { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsArmor
Whether this block is an armor block.
Declaration
public bool IsArmor { get; }
Property Value
Type | Description |
---|---|
Boolean |
IsBurning
Whether this block is currently burning.
Declaration
public bool IsBurning { get; }
Property Value
Type | Description |
---|---|
Boolean |
Machine
The machine that this block is a part of.
Declaration
public PlayerMachine Machine { get; }
Property Value
Type | Description |
---|---|
PlayerMachine |
MaxHealth
Maximum health of this block, 0 if the block doesn't support health.
Declaration
public float MaxHealth { get; }
Property Value
Type | Description |
---|---|
Single |
Prefab
An object representing the type of this block.
Declaration
public BlockPrefabInfo Prefab { get; }
Property Value
Type | Description |
---|---|
BlockPrefabInfo |
SimBlock
A reference to the simulation clone of the current block.
This is null in building mode and returns the same object when accessed on a simulation block.
Declaration
public Block SimBlock { get; }
Property Value
Type | Description |
---|---|
Block |
Team
The team that the player this block belongs to is a part of.
Declaration
public MPTeam Team { get; }
Property Value
Type | Description |
---|---|
MPTeam |
Methods
Equals(Object)
Determines if the other object refers to the same block.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | Object to compare with this object. |
Returns
Type | Description |
---|---|
Boolean | True if the other object refers to the same block. |
Overrides
From(BlockBehaviour)
Returns a Block instance from its internal representation.
Declaration
public static Block From(BlockBehaviour behaviour)
Parameters
Type | Name | Description |
---|---|---|
BlockBehaviour | behaviour |
Returns
Type | Description |
---|---|
Block |
From(BlockScript)
Returns a Block instance from the behaviour of a modded block.
Declaration
public static Block From(BlockScript script)
Parameters
Type | Name | Description |
---|---|---|
BlockScript | script |
Returns
Type | Description |
---|---|
Block |
From(Guid)
Returns a Block instance from a Guid.
This returns the building block corresponding to the Guid.
Declaration
public static Block From(Guid guid)
Parameters
Type | Name | Description |
---|---|---|
Guid | guid |
Returns
Type | Description |
---|---|
Block |
From(GameObject)
Returns a Block instance from a block GameObject.
Null if the game object is not a block.
Declaration
public static Block From(GameObject obj)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.GameObject | obj |
Returns
Type | Description |
---|---|
Block |
GetHashCode()
Computes a hash code.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | A hash code for this object. |
Overrides
SetOnFire(Boolean)
Sets the "on fire" status of this block.
No-op if the block does not support burning.
Declaration
public void SetOnFire(bool onFire)
Parameters
Type | Name | Description |
---|---|---|
Boolean | onFire | Whether or not the block should be on fire. |
ToString()
Returns a string identifiying this block.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | String containing the block type and the block's GUID. |
Overrides
Operators
Equality(Block, Block)
Compares two blocks for equality.
This tests whether objects refer to the same block, not if they are the same object.
Declaration
public static bool operator ==(Block left, Block right)
Parameters
Type | Name | Description |
---|---|---|
Block | left | |
Block | right |
Returns
Type | Description |
---|---|
Boolean |
Inequality(Block, Block)
Declaration
public static bool operator !=(Block left, Block right)
Parameters
Type | Name | Description |
---|---|---|
Block | left | |
Block | right |
Returns
Type | Description |
---|---|
Boolean |