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

Method draw

game/state/tilemap/tileobject_shadow.cpp:18–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16{
17
18void TileObjectShadow::draw(Renderer &r, TileTransform &transform, Vec2<float> screenPosition,
19 TileViewMode mode, bool visible, int, bool, bool)
20{
21 if (!visible)
22 return;
23 std::ignore = transform;
24 auto vehicle = this->ownerVehicle.lock();
25 auto unit = this->ownerBattleUnit.lock();
26 auto item = this->ownerBattleItem.lock();
27 if (!vehicle && !unit && !item)
28 {
29 LogError("Called with no owning object");
30 return;
31 }
32 if (this->fellOffTheBottomOfTheMap)
33 {
34 return;
35 }
36 switch (mode)
37 {
38 case TileViewMode::Isometric:
39 {
40 if (vehicle)
41 {
42 r.draw(vehicle->type->directional_shadow_sprites[vehicle->shadowDirection],
43 screenPosition - vehicle->type->shadow_offset);
44 }
45 if (unit)
46 {
47 // Bodies on the ground drop no shadows
48 if (!unit->isConscious() && !unit->falling)
49 break;
50 unit->agent->getAnimationPack()->drawShadow(
51 r, screenPosition, unit->agent->type->shadow_pack, unit->displayedItem,
52 unit->facing, unit->current_body_state, unit->target_body_state,
53 unit->current_hand_state, unit->target_hand_state,
54 unit->usingLift ? MovementState::None : unit->current_movement_state,
55 unit->getBodyAnimationFrame(), unit->getHandAnimationFrame(),
56 unit->getDistanceTravelled(), visible);
57 }
58 if (item)
59 {
60 // Items on the ground give no shadows
61 if (!item->falling)
62 break;
63 if (item->item->type->dropped_shadow_sprite)
64 r.draw(item->item->type->dropped_shadow_sprite,
65 screenPosition - item->item->type->shadow_offset);
66 }
67 break;
68 }
69 case TileViewMode::Strategy:
70 {
71 // No shadows in strategy view
72 break;
73 }
74 default:
75 LogError("Unsupported view mode");

Callers

nothing calls this directly

Calls 6

isConsciousMethod · 0.80
drawShadowMethod · 0.80
getAnimationPackMethod · 0.80
getBodyAnimationFrameMethod · 0.80
getHandAnimationFrameMethod · 0.80
getDistanceTravelledMethod · 0.80

Tested by

no test coverage detected