Empeld
Empeld plugin documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events
pluginbase.Objects.World.WorldHelpers Class Reference

Static Public Member Functions

static IEnumerable< IWorldBlockIterateBlocks (this IWorld world, Segment segment)
 Iterate through blocks on a segment More...
 
static IEnumerable< IWorldBlockIterateBlocks (this IWorld world, Segment segment, Func< IWorldReadonlyBlock, bool > predicate)
 Iterate through blocks on a segment which match the predicate More...
 
static IWorldBlock First (this IWorld world, Segment segment, Func< IWorldReadonlyBlock, bool > predicate)
 Find the first matching block on a segment More...
 
static IWorldBlock First (this IWorld world, Segment segment, Func< IWorldReadonlyBlock, bool > predicate, int lookAhead)
 First block along a segment, with a specified offset look-ahead More...
 
static IWorldBlock BeforeFirst (this IWorld world, Segment segment, Func< IWorldReadonlyBlock, bool > predicate)
 Find the preceeding block to the first matching block on a segment More...
 
static Vector3i FindSpace (this IWorld world, Volume searchArea, Func< IWorldReadonlyBlock, bool > predicate)
 find a space which meets the given predicate More...
 

Member Function Documentation

static IWorldBlock pluginbase.Objects.World.WorldHelpers.BeforeFirst ( this IWorld  world,
Segment  segment,
Func< IWorldReadonlyBlock, bool >  predicate 
)
static

Find the preceeding block to the first matching block on a segment

Parameters
worldWorld
segmentSegment to search on
predicatePredicate to match blocks on
Returns
The block immediately before the first matching block, or null if none are found
99  {
100  return First(world, segment, predicate, 1);
101  }
static IWorldBlock First(this IWorld world, Segment segment, Func< IWorldReadonlyBlock, bool > predicate)
Find the first matching block on a segment
Definition: WorldHelpers.cs:44
static Vector3i pluginbase.Objects.World.WorldHelpers.FindSpace ( this IWorld  world,
Volume  searchArea,
Func< IWorldReadonlyBlock, bool >  predicate 
)
static

find a space which meets the given predicate

Parameters
worldWorld
searchAreaArea to search
predicatePredicate to evaluate locations
Returns
First location for which the predicate returns true

Attribute: point

))

111  {
112  foreach(Vector3i point in VectorIterators.IterateSpace(searchArea.Point.X, searchArea.Point.Y, searchArea.Point.Z,
113  searchArea.Size.Width, searchArea.Size.Length, searchArea.Size.Height))
114  {
115  if(predicate(world[point]))
116  {
117  return point;
118  }
119  }
120 
121  return null;
122  }
Vector3i Point
Definition: Volume.cs:7
static IEnumerable< Vector3i > IterateSpace(int w, int l, int h)
Iterates the space.
Definition: VectorIterators.cs:51
int Height
Definition: Size3i.cs:7
Size3i Size
Definition: Volume.cs:8
int Y
The Y coordinate
Definition: Vector3i.cs:23
int Width
Definition: Size3i.cs:7
A class of helpers that iterate through vector-space
Definition: VectorIterators.cs:9
int Length
Definition: Size3i.cs:7
A class representing a 3D coordinate of integers
Definition: Vector3i.cs:13
int X
The X coordinate
Definition: Vector3i.cs:18
int Z
The Z coordinate
Definition: Vector3i.cs:28
static IWorldBlock pluginbase.Objects.World.WorldHelpers.First ( this IWorld  world,
Segment  segment,
Func< IWorldReadonlyBlock, bool >  predicate 
)
static

Find the first matching block on a segment

Parameters
worldWorld
segmentSegment to search on
predicatePredicate to match blocks on
Returns
The first matching block, or null if none are found

Attribute: block.X, block.Y, block.Z

).FirstOrDefault(x => predicate(x));

45  {
46  return Voxels.WalkSurfaces(segment).Select(block => world[block.X, block.Y, block.Z]).FirstOrDefault(x => predicate(x));
47  }
Helper class to work with Voxels
Definition: Voxels.cs:12
static IEnumerable< Vector3d > WalkSurfaces(Segment segment, double deltaBias=0.002)
Walks the surfaces. Returns collision point on a surface of a voxel position
Definition: Voxels.cs:33
static IWorldBlock pluginbase.Objects.World.WorldHelpers.First ( this IWorld  world,
Segment  segment,
Func< IWorldReadonlyBlock, bool >  predicate,
int  lookAhead 
)
static

First block along a segment, with a specified offset look-ahead

Parameters
worldWorld.
segmentSegment.
predicatePredicate.
lookAheadThe number of blocks to "look ahead" to match a selected block

Attribute: points[i]

;

Attribute: points[i - lookAhead]

;

Attribute: points[i]

;

Attribute: points[i - lookAhead]

;

65  {
66  var points = Voxels.WalkSurfaces(segment).ToArray();
67 
68  if (lookAhead >= 0)
69  {
70  // Lookahead is positive
71  for (int i=lookAhead; i<points.Length; ++i)
72  {
73  var block = world[points[i]];
74  if (predicate(block))
75  return world[points[i - lookAhead]];
76  }
77  }
78  else
79  {
80  for (int i=0; i<points.Length + lookAhead; ++i)
81  {
82  var block = world[points[i]];
83  if (predicate(block))
84  return world[points[i - lookAhead]];
85  }
86  }
87 
88  return null;
89  }
Helper class to work with Voxels
Definition: Voxels.cs:12
static IEnumerable< Vector3d > WalkSurfaces(Segment segment, double deltaBias=0.002)
Walks the surfaces. Returns collision point on a surface of a voxel position
Definition: Voxels.cs:33
static IEnumerable<IWorldBlock> pluginbase.Objects.World.WorldHelpers.IterateBlocks ( this IWorld  world,
Segment  segment 
)
static

Iterate through blocks on a segment

Parameters
worldWorld
segmentSegment to iterate on
Returns
Enumeration of blocks on the segment

Attribute: block.X, block.Y, block.Z

);

21  {
22  return Voxels.WalkSurfaces(segment).Select(block => world[block.X, block.Y, block.Z]);
23  }
Helper class to work with Voxels
Definition: Voxels.cs:12
static IEnumerable< Vector3d > WalkSurfaces(Segment segment, double deltaBias=0.002)
Walks the surfaces. Returns collision point on a surface of a voxel position
Definition: Voxels.cs:33
static IEnumerable<IWorldBlock> pluginbase.Objects.World.WorldHelpers.IterateBlocks ( this IWorld  world,
Segment  segment,
Func< IWorldReadonlyBlock, bool >  predicate 
)
static

Iterate through blocks on a segment which match the predicate

Parameters
worldWorld
segmentSegment to iterate on
predicatePredicate to match blocks on
Returns
Enumeration of blocks on a segment which match the predicate

Attribute: block.X, block.Y, block.Z

).Where(x => predicate(x));

33  {
34  return Voxels.WalkSurfaces(segment).Select(block => world[block.X, block.Y, block.Z]).Where(x => predicate(x));
35  }
Helper class to work with Voxels
Definition: Voxels.cs:12
static IEnumerable< Vector3d > WalkSurfaces(Segment segment, double deltaBias=0.002)
Walks the surfaces. Returns collision point on a surface of a voxel position
Definition: Voxels.cs:33

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