Empeld
Empeld plugin documentation.
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...
 
static Vector3i FindGroundedSpace (this IWorldReadonly world, Volume searchArea)
 Search for a point where the ground below is solid, and not above (for standing) More...
 
static IEnumerable< Vector3iIterateGroundedSpace (this IWorldReadonly world, Volume search)
 Iterate over all possible grounded space in an area More...
 

Member Function Documentation

◆ BeforeFirst()

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

◆ FindGroundedSpace()

static Vector3i pluginbase.Objects.World.WorldHelpers.FindGroundedSpace ( this IWorldReadonly  world,
Volume  searchArea 
)
static

Search for a point where the ground below is solid, and not above (for standing)

Returns
The grounded space.
Parameters
worldWorld.
searchAreaSearch area.

Attribute: point].Solid && world[point - Vector3i.UnitZ

.Solid)

131  {
132  foreach (Vector3i point in VectorIterators.IterateSpace(searchArea.Point.X, searchArea.Point.Y, searchArea.Point.Z,
133  searchArea.Size.Width, searchArea.Size.Length, searchArea.Size.Height))
134  {
135  if (!world[point].Solid && world[point - Vector3i.UnitZ].Solid)
136  {
137  return point;
138  }
139  }
140 
141  return null;
142  }
Vector3i Point
Definition: Volume.cs:12
static IEnumerable< Vector3i > IterateSpace(int w, int l, int h)
Iterates the space.
Definition: VectorIterators.cs:51
int Height
Definition: Size3i.cs:8
Size3i Size
Definition: Volume.cs:13
int Y
The Y coordinate
Definition: Vector3i.cs:23
int Width
Definition: Size3i.cs:8
A class of helpers that iterate through vector-space
Definition: VectorIterators.cs:9
static readonly Vector3i UnitZ
Vector (0,0,1)
Definition: Vector3i.cs:79
int Length
Definition: Size3i.cs:8
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

◆ FindSpace()

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:12
static IEnumerable< Vector3i > IterateSpace(int w, int l, int h)
Iterates the space.
Definition: VectorIterators.cs:51
int Height
Definition: Size3i.cs:8
Size3i Size
Definition: Volume.cs:13
int Y
The Y coordinate
Definition: Vector3i.cs:23
int Width
Definition: Size3i.cs:8
A class of helpers that iterate through vector-space
Definition: VectorIterators.cs:9
int Length
Definition: Size3i.cs:8
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

◆ First() [1/2]

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

◆ First() [2/2]

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

◆ IterateBlocks() [1/2]

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

◆ IterateBlocks() [2/2]

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

◆ IterateGroundedSpace()

static IEnumerable<Vector3i> pluginbase.Objects.World.WorldHelpers.IterateGroundedSpace ( this IWorldReadonly  world,
Volume  search 
)
static

Iterate over all possible grounded space in an area

Returns
The grounded space.
Parameters
worldWorld.
searchSearch.

Attribute: point].Solid && world[point - Vector3i.UnitZ

.Solid)

151  {
152  foreach (Vector3i point in VectorIterators.IterateVolume(search))
153  {
154  if (!world[point].Solid && world[point - Vector3i.UnitZ].Solid)
155  yield return point;
156  }
157  }
static IEnumerable< Vector3i > IterateVolume(this Volume vol)
Enumerates all points in a volume. If volume size=0, then no points
Definition: VectorIterators.cs:93
A class of helpers that iterate through vector-space
Definition: VectorIterators.cs:9
static readonly Vector3i UnitZ
Vector (0,0,1)
Definition: Vector3i.cs:79
A class representing a 3D coordinate of integers
Definition: Vector3i.cs:13

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