From 0d1f42829b154c172608450e3689c56cbfacb4fd Mon Sep 17 00:00:00 2001 From: Nemrav <> Date: Sun, 17 Nov 2024 17:51:35 -0400 Subject: billboards placement --- .../singletons/MapItemSingleton.cpp | 25 ++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'extension/src/openvic-extension/singletons/MapItemSingleton.cpp') diff --git a/extension/src/openvic-extension/singletons/MapItemSingleton.cpp b/extension/src/openvic-extension/singletons/MapItemSingleton.cpp index 67af22e..d62e0fd 100644 --- a/extension/src/openvic-extension/singletons/MapItemSingleton.cpp +++ b/extension/src/openvic-extension/singletons/MapItemSingleton.cpp @@ -18,6 +18,7 @@ #include "godot_cpp/variant/typed_array.hpp" #include "godot_cpp/variant/vector2.hpp" #include "openvic-simulation/interface/GFXObject.hpp" +#include "openvic-simulation/types/Vector.hpp" #include "openvic-simulation/utility/Logger.hpp" using namespace godot; @@ -32,7 +33,7 @@ void MapItemSingleton::_bind_methods() { //OV_BIND_METHOD(MapItemSingleton::get_billboard, {"name"}); OV_BIND_METHOD(MapItemSingleton::get_billboards); OV_BIND_METHOD(MapItemSingleton::get_province_positions); - + OV_BIND_METHOD(MapItemSingleton::get_province_count); } MapItemSingleton* MapItemSingleton::get_singleton() { @@ -121,9 +122,15 @@ TypedArray MapItemSingleton::get_billboards(){ return ret; } +int MapItemSingleton::get_province_count(){ + GameSingleton const* game_singleton = GameSingleton::get_singleton(); + ERR_FAIL_NULL_V(game_singleton, 0); + return game_singleton->get_definition_manager().get_map_definition().get_province_definition_count(); +} + PackedVector2Array MapItemSingleton::get_province_positions(){ GameSingleton const* game_singleton = GameSingleton::get_singleton(); - ERR_FAIL_NULL_V(game_singleton, {}); + ERR_FAIL_NULL_V(game_singleton, PackedVector2Array()); /*std::vector prov_identifiers = game_singleton->get_definition_manager().get_map_definition(). @@ -136,11 +143,17 @@ PackedVector2Array MapItemSingleton::get_province_positions(){ Logger::info("prov_count ", prov_count); for(int i = 0; i < prov_count; i++){ - ProvinceDefinition const* prov = game_singleton->get_definition_manager().get_map_definition().get_province_definition_by_index(i); - billboard_pos.push_back(Vector2(prov->get_city_position().x,prov->get_city_position().y)); - if(i % 4){ + ProvinceDefinition const* prov = game_singleton->get_definition_manager() + .get_map_definition().get_province_definition_by_index(i+1); + + fvec2_t city_pos = prov->get_city_position(); + Vector2 pos = Utilities::to_godot_fvec2(city_pos) / game_singleton->get_map_dims(); + billboard_pos.push_back(pos); + /*if(i % 4){ Logger::info("prov_x ", prov->get_city_position().x); - } + }*/ + + //province_dict[position_key] = Utilities::to_godot_fvec2(province.get_text_position()) / get_map_dims(); } return billboard_pos; -- cgit v1.2.3-56-ga3b1