BlockThingsIterator
Note: This feature is for ZScript only. |
BlockThingsIterator is a type of iterator used to search for entities that are within the Blockmap. This excludes all actors with the NOBLOCKMAP flag. Any Actor in a blockmap square within the provided radius is taken, so this does not guarantee they are at radius distance or lower (manual checking will have to be done if a strict distance is necessary). Generally they are best used for getting surrounding Actors within a small area as opposed to every Actor.
Contents
Members
Type | Variables | Use |
---|---|---|
Actor | thing | The Actor the iterator is currently checking. |
Vector3 | position | The xy map position for the origin of the check relative to the Actor. The z value is the radius that was given |
int | portalflags | Used to signify what Portal-related flags were used when getting the Actor. |
Functions
Return Type | Function | Arguments (first to last) | Use/Arguments |
---|---|---|---|
BlockThingsIterator | 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. BlockThingsIterator.Create(...). |
BlockThingsIterator | 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. BlockThingsIterator.CreateFromPos(...). |
bool | Next | None | Iterates through the list of found Actors. Returns false when at the end of the list. |
Examples
This function returns how many solid Actors there are within rad distance.
int CountPotentialBlockers(double rad) { // Create the iterator BlockThingsIterator it = BlockThingsIterator.Create(self, rad); Actor mo; int blockers; while (it.Next()) { mo = it.thing; // Get the Actor it's currently on if (!mo || !mo.bSolid || Distance2D(mo) > rad) continue; ++blockers; } return blockers; }