Class PlayerMachine
Represents a Machine.
Namespace: Modding.Blocks
Assembly: Assembly-CSharp.dll
Syntax
public class PlayerMachine
Properties
BlockCount
The total amount of blocks in this machine.
Declaration
public int BlockCount { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
Bounds
The bounds of this machine.
Declaration
public Bounds Bounds { get; }
Property Value
| Type | Description |
|---|---|
| UnityEngine.Bounds |
BuildingBlocks
The building blocks of this machine.
Declaration
public ReadOnlyCollection<Block> BuildingBlocks { get; }
Property Value
| Type | Description |
|---|---|
| ReadOnlyCollection<Block> |
BuildingMachine
Parent transform of the building blocks of this machine.
Declaration
public Transform BuildingMachine { get; }
Property Value
| Type | Description |
|---|---|
| UnityEngine.Transform |
ClusterCount
The total number of clusters in this machine.
Declaration
public int ClusterCount { get; }
Property Value
| Type | Description |
|---|---|
| Int32 |
CurtainMode
Whether this machine is in Curtain mode.
Declaration
public bool CurtainMode { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
ExplodingCannonballs
Whether this machine is in Exploding Cannonballs mode.
Declaration
public bool ExplodingCannonballs { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
GhostMode
Whether this machine is currently displayed as ghost on the local instance.
Declaration
public bool GhostMode { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
Remarks
Machines of other players who are in local simulation are displayed in ghost mode.
Health
The health of this machine.
0 if the health system is not turned on for this level/machine.
0 in singleplayer.
Declaration
public float Health { get; }
Property Value
| Type | Description |
|---|---|
| Single |
InfiniteAmmo
Whether this machine is in Infinite Ammo mode.
Declaration
public bool InfiniteAmmo { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
InternalObject
The internal representation of this machine.
WARNING: This is not part of the stable API and subject to change!
Declaration
public Machine InternalObject { get; }
Property Value
| Type | Description |
|---|---|
| Machine |
InternalObjectServer
Internal representation of this machine.
WARNING: This is not part of the stable API and subject to change!
Declaration
public ServerMachine InternalObjectServer { get; }
Property Value
| Type | Description |
|---|---|
| ServerMachine |
MachineData
Custom data associated to the machine.
Declaration
public XDataHolder MachineData { get; }
Property Value
| Type | Description |
|---|---|
| XDataHolder |
Remarks
The keys for the data here are not automatically seperated by mod, a unique prefix for each mod is advisable here.
Keep in mind that one can't rely on any data begin present here, as machines may have been saved without the mod installed and should still load.
Mass
The total mass of this machine.
Declaration
public float Mass { get; }
Property Value
| Type | Description |
|---|---|
| Single |
MiddlePosition
The middle of this machine.
Declaration
public Vector3 MiddlePosition { get; }
Property Value
| Type | Description |
|---|---|
| UnityEngine.Vector3 |
Name
Name of the machine.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| String |
Player
The Player that this machine belongs to.
Null in single player.
Declaration
public Player Player { get; }
Property Value
| Type | Description |
|---|---|
| Player |
Position
Position of this machine in world-space.
Declaration
public Vector3 Position { get; }
Property Value
| Type | Description |
|---|---|
| UnityEngine.Vector3 |
Rotation
Rotation of this machine.
Declaration
public Quaternion Rotation { get; }
Property Value
| Type | Description |
|---|---|
| UnityEngine.Quaternion |
SimulationBlocks
The simulation clones of the blocks of this machine.
Declaration
public ReadOnlyCollection<Block> SimulationBlocks { get; }
Property Value
| Type | Description |
|---|---|
| ReadOnlyCollection<Block> |
SimulationMachine
Parent transform the simulation clone of this machine.
Declaration
public Transform SimulationMachine { get; }
Property Value
| Type | Description |
|---|---|
| UnityEngine.Transform |
Size
The size of this machine.
Declaration
public Vector3 Size { get; }
Property Value
| Type | Description |
|---|---|
| UnityEngine.Vector3 |
Unbreakable
Whether this machine is in Invincibility mode.
Declaration
public bool Unbreakable { get; }
Property Value
| Type | Description |
|---|---|
| Boolean |
Methods
AddBlock(BlockType, Vector3, Quaternion, Boolean)
Adds an official block to this machine. Can only be used on the instance that owns this machine.
Declaration
public Block AddBlock(BlockType type, Vector3 position, Quaternion rotation, bool flipped = false)
Parameters
| Type | Name | Description |
|---|---|---|
| BlockType | type | The type of the block. |
| UnityEngine.Vector3 | position | Position of the block. |
| UnityEngine.Quaternion | rotation | Rotation of the block. |
| Boolean | flipped | Whether the block should be flipped. |
Returns
| Type | Description |
|---|---|
| Block | A Block on success, null on failure. |
Remarks
Valid values for the type parameter are the entries in the BlockType enum.
Position and Rotation are considered to be local to the machine.
Note: Adding draggable blocks like braces using this will not work correctly.
AddBlock(Guid, Int32, Vector3, Quaternion, Boolean)
Adds a modded block to this machine. Can only be used on the instance that owns this machine.
Declaration
public Block AddBlock(Guid mod, int localId, Vector3 position, Quaternion rotation, bool flipped = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | mod | Id of the mod. |
| Int32 | localId | Id of the block within the mod. |
| UnityEngine.Vector3 | position | Position of the block. |
| UnityEngine.Quaternion | rotation | Rotation of the block. |
| Boolean | flipped | Whether the block should be flipped. |
Returns
| Type | Description |
|---|---|
| Block | A Block on success, null on failure. |
Remarks
Modded blocks are uniquely identified by the pair (modId, blockId) where blockId is unique within the mod itself. The block will be added if the corresponding mod is loaded, otherwise null is returned.
Position and Rotation are considered to be local to the machine.
Note: Adding draggable blocks like braces using this will not work correctly.
AddBlock(Int32, Vector3, Quaternion, Boolean)
Adds a block to this machine. Can only be used on the instance that owns this machine.
Declaration
public Block AddBlock(int type, Vector3 position, Quaternion rotation, bool flipped = false)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | type | Id of the block type. |
| UnityEngine.Vector3 | position | Position of the block. |
| UnityEngine.Quaternion | rotation | Rotation of the block. |
| Boolean | flipped | Whether the block should be flipped. |
Returns
| Type | Description |
|---|---|
| Block | A Block on success, null on failure. |
Remarks
The Id parameters is in terms of the internal Ids. These are the same values given by BlockPrefab.Type. Note that the Ids of modded blocks may change at any time. Use the overload with seperate modId and localId for reliable placement of modded blocks.
Position and Rotation are considered to be local to the machine.
Note: Adding draggable blocks like braces using this will not work correctly.
Equals(PlayerMachine)
Declaration
protected bool Equals(PlayerMachine other)
Parameters
| Type | Name | Description |
|---|---|---|
| PlayerMachine | other |
Returns
| Type | Description |
|---|---|
| Boolean |
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| Object | obj |
Returns
| Type | Description |
|---|---|
| Boolean |
Overrides
From(Machine)
Create a Machine from its internal representation.
Declaration
public static PlayerMachine From(Machine machine)
Parameters
| Type | Name | Description |
|---|---|---|
| Machine | machine |
Returns
| Type | Description |
|---|---|
| PlayerMachine |
From(GameObject)
Create a Machine from its GameObject. Null if the game object is not a machine.
Declaration
public static PlayerMachine From(GameObject go)
Parameters
| Type | Name | Description |
|---|---|---|
| UnityEngine.GameObject | go |
Returns
| Type | Description |
|---|---|
| PlayerMachine |
GetBlockBehavioursOfType<T>(Guid, Int32)
Gets a list of the behaviours attached to all the blocks with the specified modded block type that are part of this machine.
Returns simulation blocks if the machine is currently simulating and building blocks if not.
If T is not a correct behaviour type for the specified block type, an InvalidCastException will be thrown.
Note: The returned objects are not part of the stable API.
Declaration
public ReadOnlyCollection<T> GetBlockBehavioursOfType<T>(Guid modId, int localId)
where T : BlockBehaviour
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | modId | Guid of the mod adding the block type. |
| Int32 | localId | Local ID of the block type within the mod. |
Returns
| Type | Description |
|---|---|
| ReadOnlyCollection<T> | Collection of block behaviours. |
Type Parameters
| Name | Description |
|---|---|
| T | BlockBehaviour type associated to the block type. |
GetBlockBehavioursOfType<T>(Guid, Int32, Boolean)
Gets a list of the behaviours attached to all the blocks with the specified modded block type that are part of this machine.
The last argument controls whether to return simulation or building blocks.
If T is not a correct behaviour type for the specified block type, an InvalidCastException will be thrown.
Note: The returned objects are not part of the stable API.
Declaration
public ReadOnlyCollection<T> GetBlockBehavioursOfType<T>(Guid modId, int localId, bool simulation)
where T : BlockBehaviour
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | modId | Guid of the mod adding the block type. |
| Int32 | localId | Local ID of the block type within the mod. |
| Boolean | simulation | True to return simulation blocks, false to return building blocks. |
Returns
| Type | Description |
|---|---|
| ReadOnlyCollection<T> | Collection of block behaviours. |
Type Parameters
| Name | Description |
|---|---|
| T | BlockBehaviour type associated to the block type. |
GetBlockBehavioursOfType<T>(Int32)
Gets a list of the behaviours attached to all the blocks with the specified type that are part of this machine.
Returns simulation blocks if the machine is currently simulating and building blocks if not.
If T is not a correct behaviour type for the specified block type, an InvalidCastException will be thrown.
Note: The returned objects are not part of the stable API.
Declaration
public ReadOnlyCollection<T> GetBlockBehavioursOfType<T>(int type)
where T : BlockBehaviour
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | type | ID of the block type. |
Returns
| Type | Description |
|---|---|
| ReadOnlyCollection<T> | Collection of block behaviours. |
Type Parameters
| Name | Description |
|---|---|
| T | BlockBehaviour type associated to the block type. |
GetBlockBehavioursOfType<T>(Int32, Boolean)
Gets a list of the behaviours attached to all the blocks with the specified type that are part of this machine.
The last argument controls whether simulation or building blocks are returned.
If T is not a correct behaviour type for the specified block type, an InvalidCastException will be thrown.
Note: The returned objects are not part of the stable API.
Declaration
public ReadOnlyCollection<T> GetBlockBehavioursOfType<T>(int type, bool simulation)
where T : BlockBehaviour
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | type | ID of the block type. |
| Boolean | simulation | True to return simulation blocks, false to return building blocks. |
Returns
| Type | Description |
|---|---|
| ReadOnlyCollection<T> | Collection of block behaviours. |
Type Parameters
| Name | Description |
|---|---|
| T | BlockBehaviour type associated to the block type. |
GetBlocksOfType(BlockType)
Gets all blocks of the specified type that are part of this machine. Returns simulation blocks if the machine is currently in simulation, buildings blocks if not.
Declaration
public ReadOnlyCollection<Block> GetBlocksOfType(BlockType type)
Parameters
| Type | Name | Description |
|---|---|---|
| BlockType | type | Block type. |
Returns
| Type | Description |
|---|---|
| ReadOnlyCollection<Block> | Collection of blocks. |
GetBlocksOfType(BlockType, Boolean)
Gets all blocks of the specified type that are part of this machine. The last arguments controls whether simulation or building blocks are returned.
Declaration
public ReadOnlyCollection<Block> GetBlocksOfType(BlockType type, bool simulation)
Parameters
| Type | Name | Description |
|---|---|---|
| BlockType | type | Block type. |
| Boolean | simulation | True to return simulation blocks, false to return building blocks. |
Returns
| Type | Description |
|---|---|
| ReadOnlyCollection<Block> | Collection of blocks. |
GetBlocksOfType(Guid, Int32)
Gets all blocks of the specified modded type that are part of this machine. Returns simulation blocks if the machine is currently in simulation, buildings blocks if not.
Declaration
public ReadOnlyCollection<Block> GetBlocksOfType(Guid modId, int localId)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | modId | ID of the mod that adds the block type. |
| Int32 | localId | Local ID of the block type within the mod. |
Returns
| Type | Description |
|---|---|
| ReadOnlyCollection<Block> | Collection of blocks. |
GetBlocksOfType(Guid, Int32, Boolean)
Gets all blocks of the specified modded type that are part of this machine. The last argument controls whether simulation or building blocks are returned.
Declaration
public ReadOnlyCollection<Block> GetBlocksOfType(Guid modId, int localId, bool simulation)
Parameters
| Type | Name | Description |
|---|---|---|
| Guid | modId | ID of the mod that adds the block type. |
| Int32 | localId | Local ID of the block type within the mod. |
| Boolean | simulation | True to return simulation blocks, false to return building blocks. |
Returns
| Type | Description |
|---|---|
| ReadOnlyCollection<Block> | Collection of blocks. |
GetBlocksOfType(Int32)
Gets all blocks of the specified type that are part of this machine. Returns simulation blocks if the machine is currently in simulation, buildings blocks if not.
Declaration
public ReadOnlyCollection<Block> GetBlocksOfType(int type)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | type | Internal ID of the block type. |
Returns
| Type | Description |
|---|---|
| ReadOnlyCollection<Block> | Collection of blocks. |
GetBlocksOfType(Int32, Boolean)
Gets all blocks of the specified type that are part of this machine. The last argument controls whether simulation or building blocks are returned.
Declaration
public ReadOnlyCollection<Block> GetBlocksOfType(int type, bool simulation)
Parameters
| Type | Name | Description |
|---|---|---|
| Int32 | type | Internal ID of the block type. |
| Boolean | simulation | True to return simulation blocks, false to return building blocks. |
Returns
| Type | Description |
|---|---|
| ReadOnlyCollection<Block> | Collection of blocks. |
GetHashCode()
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| Int32 |
Overrides
GetLocal()
Returns the machine of the local player in multiplayer, or the local singleplayer machine. Can return null if the local player does not currently have a machine.
Declaration
public static PlayerMachine GetLocal()
Returns
| Type | Description |
|---|---|
| PlayerMachine |
RemoveBlock(Block)
Removes a block from this machine. Can only be used on the instance that owns this machine.
Declaration
public void RemoveBlock(Block block)
Parameters
| Type | Name | Description |
|---|---|---|
| Block | block | The block to remove. |
ToString()
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| String |
Overrides
Operators
Equality(PlayerMachine, PlayerMachine)
Declaration
public static bool operator ==(PlayerMachine left, PlayerMachine right)
Parameters
| Type | Name | Description |
|---|---|---|
| PlayerMachine | left | |
| PlayerMachine | right |
Returns
| Type | Description |
|---|---|
| Boolean |
Inequality(PlayerMachine, PlayerMachine)
Declaration
public static bool operator !=(PlayerMachine left, PlayerMachine right)
Parameters
| Type | Name | Description |
|---|---|---|
| PlayerMachine | left | |
| PlayerMachine | right |
Returns
| Type | Description |
|---|---|
| Boolean |