MCPcopy Create free account
hub / github.com/bwapi/bwapi / computePrimaryUnitSets

Method computePrimaryUnitSets

bwapi/BWAPI/Source/BWAPI/GameUnits.cpp:144–216  ·  view source on GitHub ↗

------------------------------------------ Compute Client Sets -------------------------------------------

Source from the content-addressed store, hash-verified

142 }
143 //------------------------------------------ Compute Client Sets -------------------------------------------
144 void GameImpl::computePrimaryUnitSets()
145 {
146 //this frame computes the set of accessible units and visible units.
147 accessibleUnits.clear();
148
149 //discoverUnits is the set of units that have entered the accessibleUnits set this frame
150 discoverUnits.clear();
151
152 //evadeUnits is the set of units that have left the accessibleUnits set this frame
153 evadeUnits.clear();
154
155 //computes sets, also generating UnitCreate, UnitDiscover, UnitShow, UnitDestroy, UnitEvade, and UnitHide callbacks
156 for(Unit ui : aliveUnits)
157 {
158 UnitImpl *u = static_cast<UnitImpl*>(ui);
159 if (u->canAccess())
160 {
161 if ( !u->wasAlive )
162 events.push_back(Event::UnitCreate(u));
163 if ( !u->wasCompleted && u->_isCompleted )
164 {
165 events.push_back(Event::UnitComplete(u));
166 u->wasCompleted = true;
167 }
168 if ( !u->wasAccessible )
169 {
170 discoverUnits.insert(u);
171 events.push_back(Event::UnitDiscover(u));
172 }
173 if ( u->isVisible() )
174 {
175 if ( !u->wasVisible )
176 events.push_back(Event::UnitShow(u));
177 u->wasVisible = true;
178 }
179 if (!u->isVisible())
180 {
181 if ( u->wasVisible )
182 events.push_back(Event::UnitHide(u));
183 u->wasVisible = false;
184 }
185 accessibleUnits.insert(u);
186 }
187 else
188 {
189 if (u->wasAccessible)
190 {
191 if (u->wasVisible)
192 {
193 u->wasVisible = false;
194 events.push_back(Event::UnitHide(u));
195 }
196 evadeUnits.insert(u);
197 events.push_back(Event::UnitEvade(u));
198 }
199 }
200 }
201 for(Unit ui : dyingUnits)

Callers

nothing calls this directly

Calls 3

canAccessMethod · 0.80
clearMethod · 0.45
isVisibleMethod · 0.45

Tested by

no test coverage detected