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

Method getRestingPosition

game/state/tilemap/tile.cpp:39–74  ·  view source on GitHub ↗

Position for items and units to be located on

Source from the content-addressed store, hash-verified

37
38// Position for items and units to be located on
39Vec3<float> Tile::getRestingPosition(bool large, bool overlay)
40{
41 if (large)
42 {
43 if (position.x < 1 || position.y < 1)
44 {
45 LogError(
46 "Trying to get resting position for a large unit when it can't fit! %d, %d, %d",
47 position.x, position.y, position.z);
48 return Vec3<float>{position.x + 0.5, position.y + 0.5, position.z};
49 }
50 float maxHeight = overlay ? overlayHeight : height;
51 if (overlay)
52 {
53 maxHeight = std::max(
54 maxHeight, map.getTile(position.x - 1, position.y, position.z)->overlayHeight);
55 maxHeight = std::max(
56 maxHeight, map.getTile(position.x, position.y - 1, position.z)->overlayHeight);
57 maxHeight = std::max(
58 maxHeight, map.getTile(position.x - 1, position.y - 1, position.z)->overlayHeight);
59 }
60 else
61 {
62 maxHeight =
63 std::max(maxHeight, map.getTile(position.x - 1, position.y, position.z)->height);
64 maxHeight =
65 std::max(maxHeight, map.getTile(position.x, position.y - 1, position.z)->height);
66 maxHeight = std::max(maxHeight,
67 map.getTile(position.x - 1, position.y - 1, position.z)->height);
68 }
69
70 return Vec3<float>{position.x, position.y, position.z + maxHeight};
71 }
72 return Vec3<float>{position.x + 0.5f, position.y + 0.5f,
73 position.z + (overlay ? overlayHeight : height)};
74}
75
76sp<BattleMapPart> Tile::getItemSupportingObject() { return supportProviderForItems; }
77

Callers 9

startMethod · 0.80
advanceAlongPathMethod · 0.80
updateFallingMethod · 0.80
initialUnitSpawnMethod · 0.80
updateMovementFallingMethod · 0.80
updateMovementNormalMethod · 0.80
startMethod · 0.80
advanceAlongPathMethod · 0.80
renderMethod · 0.80

Calls 1

getTileMethod · 0.80

Tested by

no test coverage detected