Empeld
Empeld plugin documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
essentials.Blocks.Physics.CascadingBlock Class Reference
Inheritance diagram for essentials.Blocks.Physics.CascadingBlock:
essentials.Blocks.Physics.IBlockPhysics

Public Member Functions

bool Simulate (IWorld world, IWorldBlock src, IBlock spawnBlock)
 
bool Simulate (IWorld world, IWorldBlock src)
 

Static Public Member Functions

static CascadingBlock BuildCascade (int size, bool infinite=false)
 

Protected Member Functions

 CascadingBlock (Vector3i[] cascade, bool infinite)
 

Constructor & Destructor Documentation

essentials.Blocks.Physics.CascadingBlock.CascadingBlock ( Vector3i[]  cascade,
bool  infinite 
)
protected
15  {
16  this._cascade = cascade;
17  this._infinite = infinite;
18  }

Member Function Documentation

static CascadingBlock essentials.Blocks.Physics.CascadingBlock.BuildCascade ( int  size,
bool  infinite = false 
)
static
46  {
47  var cascade = new List<Vector3i>();
48 
49  for (int l=0; l<=size; ++l)
50  {
51  for (int x=-l; x<=l; ++x)
52  {
53  for (int y=-l; y<=l; ++y)
54  {
55  Vector3i pt = new Vector3i(x, y, -1);
56  if (!cascade.Contains(pt))
57  {
58  cascade.Add(pt);
59  }
60  }
61  }
62  }
63 
64  return new CascadingBlock(cascade.ToArray(), infinite);
65  }
CascadingBlock(Vector3i[] cascade, bool infinite)
Definition: CascadingBlock.cs:14
static readonly Vector3i
All directions, including diagnols
Definition: Vector3i.cs:111
A class representing a 3D coordinate of integers
Definition: Vector3i.cs:13
bool essentials.Blocks.Physics.CascadingBlock.Simulate ( IWorld  world,
IWorldBlock  src,
IBlock  spawnBlock 
)

Attribute: i

;

Attribute: targetCoord

;

Implements essentials.Blocks.Physics.IBlockPhysics.

22  {
23  for (int i=0; i<_cascade.Length; ++i)
24  {
25  var targetCoord = src.Coordinate + _cascade[i];
26  var target = world[targetCoord];
27 
28  if (target.Generated && !target.Block.Solid && !target.Block.IsLiquid && target.Block != src.Block)
29  {
30  target.Block = spawnBlock ?? src.Block;
31  if (!_infinite)
32  src.Block = world.BlockLookup.EmptyBlock;
33  return true;
34  }
35  }
36  return false;
37  }
new IBlock Block
Block setter for this position
Definition: IWorldBlock.cs:14
Vector3i Coordinate
Coordinate
Definition: IWorldReadonlyBlock.cs:24
bool essentials.Blocks.Physics.CascadingBlock.Simulate ( IWorld  world,
IWorldBlock  src 
)

Implements essentials.Blocks.Physics.IBlockPhysics.

40  {
41  return Simulate(world, src, null);
42  }
bool Simulate(IWorld world, IWorldBlock src, IBlock spawnBlock)
Definition: CascadingBlock.cs:21

The documentation for this class was generated from the following file: