package Group import NoWurst import Vectors import Player /** Use this group for your non-nested group enum calls and then iterate through the group via **for from** or clear the group after use */ public constant ENUM_GROUP = CreateGroup() public function group.enumUnitsInRange(vec2 pos, real range) GroupEnumUnitsInRange(this, pos.x, pos.y, range, null) public function group.enumUnitsInRange(vec2 pos, real range, boolexpr filter) GroupEnumUnitsInRange(this, pos.x, pos.y, range, filter) public function group.enumUnitsInRect(rect rec) this.enumUnitsInRect(rec, null) public function group.enumUnitsInRect(rect rec, boolexpr filter) GroupEnumUnitsInRect(this, rec, filter) public function group.enumUnitsSelected(player p, boolexpr filter) GroupEnumUnitsSelected(this, p, filter) public function group.enumUnitsOfPlayer(player p, boolexpr filter) GroupEnumUnitsOfPlayer(this, p, filter) public function group.enumUnitsOfType(string unitname, boolexpr filter) GroupEnumUnitsOfType(this, unitname, filter) public function group.enumUnitsOfType(int id, boolexpr filter) GroupEnumUnitsOfType(this, UnitId2String(id), filter) public function group.enumUnitsAll(boolexpr filter) for i = 0 to bj_MAX_PLAYER_SLOTS - 1 ENUM_GROUP.enumUnitsOfPlayer(players[i], filter) this.add(ENUM_GROUP) ENUM_GROUP.clear() public function group.clear() GroupClear(this) /** Returns the number of added units. */ public function group.add(vararg unit units) returns int var i = 0 for u in units if GroupAddUnit(this, u) i += 1 return i /** Retruns the number of removed units. */ public function group.remove(vararg unit units) returns int var i = 0 for u in units if GroupRemoveUnit(this, u) i += 1 return i public function group.destr() DestroyGroup(this) public function group.has(unit u) returns bool return IsUnitInGroup(u, this) public function group.size() returns int return BlzGroupGetSize(this) public function group.isEmpty() returns bool return not this.hasNext() /** Returns a random unit from this group without removing it or null if the group is empty */ public function group.getRandom() returns unit let size = this.size() if size > 0 return this.get(GetRandomInt(0, size - 1)) return null public function group.immediateOrder(string order) returns bool return GroupImmediateOrder(this, order) public function group.immediateOrderById(int order) returns bool return GroupImmediateOrderById(this, order) public function group.pointOrder(string order, vec2 point) returns bool return GroupPointOrder(this, order, point.x, point.y) public function group.pointOrderById(int order, vec2 point) returns bool return GroupPointOrderById(this, order, point.x, point.y) public function group.targetOrder(string order, widget targetWidget) returns bool return GroupTargetOrder(this, order, targetWidget) public function group.targetOrder(int order, widget targetWidget) returns bool return GroupTargetOrderById(this, order, targetWidget) public function group.add(vararg group groups) returns int var i = 0 for g in groups i += BlzGroupAddGroupFast(g, this) return i public function group.remove(vararg group groups) returns int var i = 0 for g in groups i += BlzGroupRemoveGroupFast(g, this) return i public function group.get(int index) returns unit return BlzGroupUnitAt(this, index) /* Group iterator */ group iterGroup /** Creates a new iterator for this group. */ public function group.iterator() returns group iterGroup = CreateGroup() iterGroup.add(this) return iterGroup /** Returns whether the iterator has the next item */ public function group.hasNext() returns bool return FirstOfGroup(this) != null /** Returns the next item from the iterator */ public function group.next() returns unit let iterUnit = FirstOfGroup(this) GroupRemoveUnit(this, iterUnit) return iterUnit /** Closes the iterator, releaseing the group */ public function group.close() this.clear() this.destr()