BlockLinesIterator
Note: This feature is for ZScript only. |
BlockLinesIterator is a type of iterator used to search for lines in the Blockmap. Contrary to the name, this does not grab only blocking lines but all lines. Instead it gets any line that exists in a blockmap square within the given radius. You can use this to get nearby lines instead of having to iterate through all of them. If you wish to get only blocking lines you'll have to manually check the flags on each line found in the iterator.
While iterating, you should take care not to call any function that refers to the validcount variable, such as other iterators or actor spawning functions. Doing so would interfere with the operation of the iterator, causing lines to be skipped or counted several times. Cf. this forum link.
Contents
Members
Type | Variables | Use |
---|---|---|
Line | CurLine | The line the iterator is currently checking. |
Vector3 | position | The xy map position for the origin of the check relative to the line. The z value is the radius that was given. |
int | portalflags | Used to signify what Portal-related flags were used when getting the line. |
Functions
Return Type | Function | Arguments (first to last) | Use/Arguments |
---|---|---|---|
BlockLinesIterator | Create |
|
Initializes the iterator upon a pointer. Either this or CreateFromPos can be used.
Note: this function is static and should be called off the class name, i.e. BlockLinesIterator.Create(...). |
BlockLinesIterator | CreateFromPos |
|
Initializes the iterator upon a vector. Either this or Create can be used.
Note: this function is static and should be called off the class name, i.e. BlockLinesIterator.CreateFromPos(...). |
bool | Next | None | Iterates through the list of found lines. Returns false when at the end of the list. |
Examples
This function returns how many blocking lines there are within approximately rad distance.
int CountBlockingLines(double rad) { // Create the iterator BlockLinesIterator it = BlockLinesIterator.Create(self, rad); Line ln; int blocking; while (it.Next()) { ln = it.CurLine; // Get the line it's currently on if (!(ln.flags & Line.ML_BLOCKING)) continue; ++blocking; } return blocking; }