C# Class VoxelGame.Core.Logic.Block

Inheritance: IBlockBase
显示文件 Open project: pershingthesecond/VoxelGame

Private Properties

Property Type Description

Public Methods

Method Description
BlockUpdate ( World world, Vector3i position, data, BlockSide side ) : void

This method is called on blocks next to a position that was changed.

CanPlace ( World world, Vector3i position, PhysicsEntity? entity ) : bool

Override this to provide change the block placement checks.

Destroy ( World world, Vector3i position, PhysicsEntity? entity = null ) : bool

Attempt to destroy the block in the world. Will always fail if there is a different block at the given position.

EntityCollision ( PhysicsEntity entity, Vector3i position ) : void

This method is called when an entity collides with this block.

EntityInteract ( PhysicsEntity entity, Vector3i position ) : void

Called when a block and an entity collide.

GetBoundingBox ( World world, Vector3i position ) : BoundingBox

Returns the bounding box of this block if it would be at the given position.

GetMesh ( BlockMeshInfo info ) : BlockMeshData

Returns the mesh of a block side at given conditions.

Place ( World world, Vector3i position, PhysicsEntity? entity = null ) : bool

Attempt to place the block in the world.

RandomUpdate ( World world, Vector3i position, data ) : void

This method is called randomly on some blocks every update.

ToString ( ) : string

Protected Methods

Method Description
Block ( string name, string namedId, BlockFlags flags, BoundingBox boundingBox, TargetBuffer targetBuffer ) : System.Diagnostics

Create a new block.

CanDestroy ( World world, Vector3i position, data, PhysicsEntity? entity ) : bool

Override this to change the block destruction checks.

DoDestroy ( World world, Vector3i position, data, PhysicsEntity? entity ) : void

Override this to change the block destruction logic. The block destruction must always be successful. If checks are required, override CanDestroy.

DoPlace ( World world, Vector3i position, PhysicsEntity? entity ) : void

Override this to change the block placement logic. The block placement must always be successful. If checks are required, override CanPlace.

EntityCollision ( PhysicsEntity entity, Vector3i position, data ) : void

Override to provide custom entity collision logic.

EntityInteract ( PhysicsEntity entity, Vector3i position, data ) : void

Override to provide custom entity interaction logic.

GetBoundingBox ( data ) : BoundingBox

Override this to provide a custom bounding box for this block, depending on the block data.

ScheduledUpdate ( World world, Vector3i position, data ) : void

This method is called for scheduled updates.

Setup ( ITextureIndexProvider indexProvider ) : void

Called when loading blocks, meant to setup vertex data, indices etc.

Method Details

Block() protected method

Create a new block.
protected Block ( string name, string namedId, BlockFlags flags, BoundingBox boundingBox, TargetBuffer targetBuffer ) : System.Diagnostics
name string The name of the block. Can be localized.
namedId string The named ID of the block. A unique and unlocalized identifier.
flags BlockFlags The block flags setting specific options.
boundingBox BoundingBox The base bounding box for this block. Is used for placement checks.
targetBuffer TargetBuffer The target rendering buffer.
return System.Diagnostics

BlockUpdate() public method

This method is called on blocks next to a position that was changed.
public BlockUpdate ( World world, Vector3i position, data, BlockSide side ) : void
world World The containing world.
position Vector3i The block position.
data The data of the block next to the changed position.
side BlockSide The side of the block where the change happened.
return void

CanDestroy() protected method

Override this to change the block destruction checks.
protected CanDestroy ( World world, Vector3i position, data, PhysicsEntity? entity ) : bool
world World The world in which the placement occurs.
position Vector3i The position at which the placement is requested.
data The block data.
entity PhysicsEntity? The entity that performs placement.
return bool

CanPlace() public method

Override this to provide change the block placement checks.
public CanPlace ( World world, Vector3i position, PhysicsEntity? entity ) : bool
world World The world in which the placement occurs.
position Vector3i The position at which the placement is requested.
entity PhysicsEntity? The entity that performs placement.
return bool

Destroy() public method

Attempt to destroy the block in the world. Will always fail if there is a different block at the given position.
public Destroy ( World world, Vector3i position, PhysicsEntity? entity = null ) : bool
world World The world in which to destroy the block.
position Vector3i The position at which to destroy to block.
entity PhysicsEntity? The entity destroying the block.
return bool

DoDestroy() protected method

Override this to change the block destruction logic. The block destruction must always be successful. If checks are required, override CanDestroy.
protected DoDestroy ( World world, Vector3i position, data, PhysicsEntity? entity ) : void
world World The world in which the placement occurs.
position Vector3i The position at which the placement is requested.
data The block data.
entity PhysicsEntity? The entity that performs placement.
return void

DoPlace() protected method

Override this to change the block placement logic. The block placement must always be successful. If checks are required, override CanPlace.
protected DoPlace ( World world, Vector3i position, PhysicsEntity? entity ) : void
world World The world in which the placement occurs.
position Vector3i The position at which the placement is requested.
entity PhysicsEntity? The entity that performs placement.
return void

EntityCollision() public method

This method is called when an entity collides with this block.
public EntityCollision ( PhysicsEntity entity, Vector3i position ) : void
entity PhysicsEntity The entity that caused the collision.
position Vector3i The block position.
return void

EntityCollision() protected method

Override to provide custom entity collision logic.
protected EntityCollision ( PhysicsEntity entity, Vector3i position, data ) : void
entity PhysicsEntity The entity that collided with this block.
position Vector3i The position of the block.
data The block data of this block.
return void

EntityInteract() public method

Called when a block and an entity collide.
public EntityInteract ( PhysicsEntity entity, Vector3i position ) : void
entity PhysicsEntity The entity that collided with the block.
position Vector3i The block position.
return void

EntityInteract() protected method

Override to provide custom entity interaction logic.
protected EntityInteract ( PhysicsEntity entity, Vector3i position, data ) : void
entity PhysicsEntity The entity that interacted with this block.
position Vector3i The position of the block.
data The block data of this block.
return void

GetBoundingBox() protected method

Override this to provide a custom bounding box for this block, depending on the block data.
protected GetBoundingBox ( data ) : BoundingBox
data The block data.
return BoundingBox

GetBoundingBox() public method

Returns the bounding box of this block if it would be at the given position.
public GetBoundingBox ( World world, Vector3i position ) : BoundingBox
world World The world in which the block is.
position Vector3i The position of the block.
return BoundingBox

GetMesh() public abstract method

Returns the mesh of a block side at given conditions.
public abstract GetMesh ( BlockMeshInfo info ) : BlockMeshData
info BlockMeshInfo Information about the conditions the mesh should be created in.
return BlockMeshData

Place() public method

Attempt to place the block in the world.
public Place ( World world, Vector3i position, PhysicsEntity? entity = null ) : bool
world World The world in which to place the block.
position Vector3i The position at which to place the block.
entity PhysicsEntity? The entity that is placing the block.
return bool

RandomUpdate() public method

This method is called randomly on some blocks every update.
public RandomUpdate ( World world, Vector3i position, data ) : void
world World
position Vector3i
return void

ScheduledUpdate() protected method

This method is called for scheduled updates.
protected ScheduledUpdate ( World world, Vector3i position, data ) : void
world World
position Vector3i
return void

Setup() protected method

Called when loading blocks, meant to setup vertex data, indices etc.
protected Setup ( ITextureIndexProvider indexProvider ) : void
indexProvider ITextureIndexProvider
return void

ToString() public final method

public final ToString ( ) : string
return string