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

Method findSupport

game/state/battle/battlemappart.cpp:334–1006  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

332}
333
334bool BattleMapPart::findSupport(bool allowClinging)
335{
336 std::ignore = allowClinging;
337 // Initial setup and quick checks
338 providesHardSupport = true;
339 if (type->floating)
340 {
341 return true;
342 }
343 auto pos = tileObject->getOwningTile()->position;
344 if (pos.z == 0)
345 {
346 return true;
347 }
348 auto &map = tileObject->map;
349 if (pos.z == map.size.z - 1 && type->supportedByAbove)
350 {
351 return true;
352 }
353 auto tileType = tileObject->getType();
354 auto sft = shared_from_this();
355
356 // There are several ways battle map part can get supported:
357 //
358 // (following conditions provide "hard" support)
359 //
360 // Ground:
361 // - G1: Feature Below
362 // - G2: Wall Adjacent Below
363 // - G3: Feature Adjacent Below
364 //
365 // Feature:
366 // - F1: Ground Current
367 // - F2: Feature Below
368 // - F3: Feature Above (if "Above" supported by)
369 //
370 // Wall:
371 // - W2: Feature Current
372 // - W2: Ground Adjacent Current
373 // - W3: Feature Adjacent Below
374 // - W4: Wall Below
375 // - W5: Wall Above (if "Above" supported by)
376 //
377 // Then, there is a specified "Supported By Direction" condition:
378 // - Ground will get support from a Ground only
379 // - Feature will get support from a Feature or a matching perpendicular Wall
380 // (Right if N/S, Left if E/W)
381 // - Wall will get support from the same type of Wall
382 // (provided the Wall's type matches direction: Left for N/S, Right for E/W)
383 //
384 // If "Supported By Type: is also specified, then:
385 // - Ground/Wall allows support from Ground/Wall on a current level
386 // - Feature allows support from Feature on a level below
387 //
388 // (following conditions provide "soft" support)
389 //
390 // Then, object with no direction specified can cling to two adjacent objects:
391 // - Ground and Feature can cling to objects of the same type

Callers

nothing calls this directly

Calls 8

getOwningTileMethod · 0.80
getTileMethod · 0.80
emptyMethod · 0.80
getTypeMethod · 0.45
getOwnerMethod · 0.45
isAliveMethod · 0.45
sizeMethod · 0.45
willCollapseMethod · 0.45

Tested by

no test coverage detected