MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / grow

Method grow

game/state/battle/battleexplosion.cpp:331–400  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

329}
330
331void BattleExplosion::grow(GameState &state)
332{
333 auto &map = *state.current_battle->map;
334
335 state.current_battle->notifyAction(position);
336
337 for (int i = 0; i < 2; i++)
338 {
339 locationsToExpand.emplace_back();
340 // Deal damage and expand in four straight directions
341 for (auto &pos : locationsToExpand[0])
342 {
343 if (damageType->hazardType && damageType->explosionDoodad)
344 {
345 state.current_battle->placeHazard(
346 state, ownerOrganisation, ownerUnit, damageType, pos.first,
347 damageType->hazardType->getLifetime(state), pos.second.x);
348 }
349 if (damageInTheEnd)
350 {
351 locationsToDamage.emplace(pos.first, pos.second.x);
352 }
353 else
354 {
355 damage(state, map, pos.first, pos.second.x);
356 }
357 auto dir = pos.first - position;
358 int minX = dir.x <= 0 ? -1 : 0;
359 int maxX = dir.x >= 0 ? 1 : 0;
360 int minY = dir.y <= 0 ? -1 : 0;
361 int maxY = dir.y >= 0 ? 1 : 0;
362
363 for (int x = minX; x <= maxX; x++)
364 {
365 expand(state, map, pos.first, {pos.first.x + x, pos.first.y, pos.first.z},
366 pos.second.y);
367 }
368 for (int y = minY; y <= maxY; y++)
369 {
370 expand(state, map, pos.first, {pos.first.x, pos.first.y + y, pos.first.z},
371 pos.second.y);
372 }
373 }
374 // Expand in diagonal directions that were left, as well as vertically
375 for (auto &pos : locationsToExpand[0])
376 {
377 auto dir = pos.first - position;
378 int minX = dir.x <= 0 ? -1 : 0;
379 int maxX = dir.x >= 0 ? 1 : 0;
380 int minY = dir.y <= 0 ? -1 : 0;
381 int maxY = dir.y >= 0 ? 1 : 0;
382
383 for (int z = -1; z <= 1; z += 2)
384 {
385 expand(state, map, pos.first, {pos.first.x, pos.first.y, pos.first.z + z},
386 pos.second.y);
387 }
388 for (int x = minX; x <= maxX; x++)

Callers

nothing calls this directly

Calls 4

notifyActionMethod · 0.80
placeHazardMethod · 0.80
getLifetimeMethod · 0.80
beginMethod · 0.45

Tested by

no test coverage detected