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

Method setPosition

game/state/tilemap/tileobject_shadow.cpp:101–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99}
100
101void TileObjectShadow::setPosition(Vec3<float> newPosition)
102{
103 static const std::set<TileObject::Type> mapPartSet = {
104 TileObject::Type::Ground, TileObject::Type::LeftWall, TileObject::Type::RightWall,
105 TileObject::Type::Feature, TileObject::Type::Scenery};
106
107 // This projects a line downwards and draws places the shadow at the z of the first thing hit
108
109 auto shadowPosition = newPosition;
110 auto c =
111 map.findCollision(newPosition, Vec3<float>{newPosition.x, newPosition.y, -1}, mapPartSet);
112 if (c)
113 {
114 shadowPosition.z = c.position.z;
115 this->fellOffTheBottomOfTheMap = false;
116 }
117 else
118 {
119 shadowPosition.z = 0;
120 // Mark it as not to be drawn
121 this->fellOffTheBottomOfTheMap = true;
122 }
123
124 this->shadowPosition = shadowPosition;
125
126 auto unit = ownerBattleUnit.lock();
127 if (unit)
128 {
129 setBounds({unit->tileObject->getBounds().x, unit->tileObject->getBounds().y, 0.0f});
130 }
131 TileObject::setPosition(shadowPosition);
132}
133
134TileObjectShadow::~TileObjectShadow() = default;
135

Callers

nothing calls this directly

Calls 2

findCollisionMethod · 0.80
getBoundsMethod · 0.80

Tested by

no test coverage detected