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

Method drawStatic

game/state/tilemap/tileobject_vehicle.cpp:31–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29}
30
31void TileObjectVehicle::drawStatic(Renderer &r, sp<Vehicle> vehicle, TileTransform &transform,
32 Vec2<float> screenPosition, TileViewMode mode, bool, int,
33 bool friendly, bool hostile)
34{
35 static const Colour COLOUR_TRANSPARENT = {255, 255, 255, 95};
36
37 static const Colour COLOUR_STUNNED = {128, 128, 255, 255};
38
39 static const int offset_arrow = 5;
40 static const int offset_large = 1;
41
42 static const std::map<float, int> offset_dir_map = {
43 {0.0f, 0},
44 {0.25f * (float)M_PI, 1},
45 {0.5f * (float)M_PI, 2},
46 {0.75f * (float)M_PI, 3},
47 {(float)M_PI, 4},
48 {1.25f * (float)M_PI, 5},
49 {1.5f * (float)M_PI, 6},
50 {1.75f * (float)M_PI, 7},
51 };
52
53 std::ignore = transform;
54
55 switch (mode)
56 {
57 case TileViewMode::Isometric:
58 {
59 sp<Image> closestImage;
60
61 if (vehicle->type->type == VehicleType::Type::UFO)
62 {
63 if (vehicle->crashed)
64 {
65 closestImage = vehicle->type->crashed_sprite;
66 }
67 else
68 {
69 closestImage = *vehicle->animationFrame;
70 }
71 }
72 else
73 {
74 closestImage =
75 vehicle->type->directional_sprites.at(vehicle->banking).at(vehicle->direction);
76 }
77
78 if (!closestImage)
79 {
80 LogError("No image found for vehicle");
81 return;
82 }
83 if (vehicle->isCloaked())
84 {
85 r.drawTinted(closestImage, screenPosition - vehicle->type->image_offset,
86 COLOUR_TRANSPARENT);
87 }
88 else if (vehicle->stunTicksRemaining > 0)

Callers

nothing calls this directly

Calls 3

isCloakedMethod · 0.45
drawTintedMethod · 0.45
drawMethod · 0.45

Tested by

no test coverage detected