17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-17 21:29:19 +02:00
Files
maszyna/widgets/map_objects.cppm
maj00r b8f040e6fd propagate template headers transitively, import Console where used
AnimModel.cpp reaches cParser through the simulation core, not a direct
import, so the previous pass missed it; the propagation now follows the
whole import closure. Train.cpp, drivermode.cpp and Globals.cpp call
Console:: inside _WIN32 guards without importing eu07.console - invisible
on Linux, where those blocks are skipped.
2026-09-10 01:41:24 +02:00

115 lines
2.5 KiB
C++

module;
#include <chrono>
#include <deque>
#include <limits>
#include <mutex>
#include <ostream>
#include <sstream>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <cstddef>
#include <memory>
#include <array>
#include <map>
#include <string>
#include <vector>
export module eu07.widgets.map_objects;
import eu07.glm;
import eu07.rendering.geometrybank;
import eu07.simcore;
export {
namespace map
{
struct map_object
{
std::string name;
glm::vec3 location;
virtual ~map_object() = default;
virtual gfx::basic_vertex vertex() {
return gfx::basic_vertex(location, glm::vec3(), glm::vec2(0.0f, 0.20f));
}
};
using object_list = std::vector<std::shared_ptr<map::map_object>>;
using sorted_object_list = std::map<float, std::shared_ptr<map::map_object>>;
// semaphore description (only for minimap purposes)
struct semaphore : public map_object
{
std::vector<TAnimModel *> models;
std::vector<basic_event *> events;
TMemCell *memcell = nullptr;
virtual gfx::basic_vertex vertex() override {
bool stop_signal = memcell->IsVelocity() && (memcell->Value1() == 0.0);
return gfx::basic_vertex(location, glm::vec3(),
(!stop_signal) ? glm::vec2(0.0f, 0.2f) : glm::vec2(0.2f, 0.4f));
}
};
// event launcher description (only for minimap purposes)
struct launcher : public map_object
{
basic_event *first_event = nullptr;
basic_event *second_event = nullptr;
enum type_e {
track_switch,
level_crossing
} type;
virtual gfx::basic_vertex vertex() {
return gfx::basic_vertex(location, glm::vec3(),
type == track_switch ? glm::vec2(0.4f, 0.6f) : glm::vec2(0.6f, 0.8f));
}
};
// switch description (only for minimap purposes)
struct track_switch : public map_object
{
std::array<basic_event*, 4> action = { nullptr };
std::array<char[4], 4> preview;
std::array<TTrack*, 4> track = { nullptr };
virtual gfx::basic_vertex vertex() {
return gfx::basic_vertex(location, glm::vec3(), glm::vec2(0.4f, 0.6f));
}
};
// training obstacle description
struct obstacle : public map_object
{
std::string model_name;
virtual gfx::basic_vertex vertex() {
return gfx::basic_vertex(location, glm::vec3(), glm::vec2(0.8f, 1.0f));
}
};
// vehicle wrapper for map display
struct vehicle : public map_object
{
TDynamicObject *dynobj = nullptr;
};
struct objects
{
std::vector<std::shared_ptr<map_object>> entries;
bool poi_dirty = true;
// returns objects in range from vec3, NaN in Y ignores it
sorted_object_list find_in_range(glm::vec3 from, float distance);
};
extern objects Objects;
} // namespace map
} // export