aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Nemrav <>2024-11-17 23:10:40 +0100
committer Nemrav <>2024-11-17 23:10:40 +0100
commit0966f90f08bf2519ce862981f28877442356081b (patch)
tree1c9082d6be741bcf46b16f91d42718a14e94877b
parent0d1f42829b154c172608450e3689c56cbfacb4fd (diff)
update sim for billboardsbillboards
m---------extension/deps/openvic-simulation0
-rw-r--r--extension/src/openvic-extension/singletons/MapItemSingleton.cpp5
-rw-r--r--game/src/Game/GameSession/BillboardManager.gd28
3 files changed, 11 insertions, 22 deletions
diff --git a/extension/deps/openvic-simulation b/extension/deps/openvic-simulation
-Subproject cb1b56b0146d32c881abd48f53e85f7cf8283be
+Subproject e15bbf98879e797bf9161e0cb2a6b3a3cdf35df
diff --git a/extension/src/openvic-extension/singletons/MapItemSingleton.cpp b/extension/src/openvic-extension/singletons/MapItemSingleton.cpp
index d62e0fd..5b2127b 100644
--- a/extension/src/openvic-extension/singletons/MapItemSingleton.cpp
+++ b/extension/src/openvic-extension/singletons/MapItemSingleton.cpp
@@ -122,6 +122,7 @@ TypedArray<Dictionary> MapItemSingleton::get_billboards(){
return ret;
}
+//dont use this, it includes water provinces
int MapItemSingleton::get_province_count(){
GameSingleton const* game_singleton = GameSingleton::get_singleton();
ERR_FAIL_NULL_V(game_singleton, 0);
@@ -143,8 +144,10 @@ PackedVector2Array MapItemSingleton::get_province_positions(){
Logger::info("prov_count ", prov_count);
for(int i = 0; i < prov_count; i++){
+ //i+1 because the province indices are 1 based (0 causes an error)
ProvinceDefinition const* prov = game_singleton->get_definition_manager()
.get_map_definition().get_province_definition_by_index(i+1);
+ if(prov->is_water()) continue; //billboards dont appear over water, skip
fvec2_t city_pos = prov->get_city_position();
Vector2 pos = Utilities::to_godot_fvec2(city_pos) / game_singleton->get_map_dims();
@@ -155,6 +158,6 @@ PackedVector2Array MapItemSingleton::get_province_positions(){
//province_dict[position_key] = Utilities::to_godot_fvec2(province.get_text_position()) / get_map_dims();
}
-
+
return billboard_pos;
} \ No newline at end of file
diff --git a/game/src/Game/GameSession/BillboardManager.gd b/game/src/Game/GameSession/BillboardManager.gd
index ac1610b..298d3a8 100644
--- a/game/src/Game/GameSession/BillboardManager.gd
+++ b/game/src/Game/GameSession/BillboardManager.gd
@@ -47,32 +47,18 @@ func _ready():
multimesh.mesh.surface_set_material(0,material)
- # Need to have one instance for every province
- # need to get a list of province centers
- #GameSingleton.get_mapmode_identifier(0)
- #GameSingleton.get_mapmode_count()
-
- var positions_len = MapItemSingleton.get_province_count()
-
-
- print(positions_len)
- # Then resize (otherwise, changing the format is not allowed).
- multimesh.instance_count = positions_len
- multimesh.visible_instance_count = positions_len
- print("===============")
var positions = MapItemSingleton.get_province_positions()
- print("===============")
+
+ # Then resize (otherwise, changing the format is not allowed).
+ multimesh.instance_count = positions.size()
+ multimesh.visible_instance_count = positions.size()
+
var map_positions : PackedVector3Array = PackedVector3Array()
for pos_in in positions:
- var pos = _map_view._map_to_world_coords(pos_in)# + Vector3(0, 0.5 * SCALE_FACTOR, 0)
+ var pos = _map_view._map_to_world_coords(pos_in)
map_positions.push_back(pos)
- #print(positions)
- #print(positions.size())
- # Set the transform of the instances.
- #model.set_position(
- #_map_view._map_to_world_coords(unit_dict[position_key])
- # + Vector3(0, 0.1 * MODEL_SCALE, 0))
+
for i in multimesh.visible_instance_count:
multimesh.set_instance_transform(i, Transform3D(Basis(),
map_positions[i]