aboutsummaryrefslogtreecommitdiff
path: root/game/src/Game/GameSession
diff options
context:
space:
mode:
Diffstat (limited to 'game/src/Game/GameSession')
-rw-r--r--game/src/Game/GameSession/GameSession.gd1
-rw-r--r--game/src/Game/GameSession/ModelManager.gd19
2 files changed, 20 insertions, 0 deletions
diff --git a/game/src/Game/GameSession/GameSession.gd b/game/src/Game/GameSession/GameSession.gd
index a07ce32..843ecd8 100644
--- a/game/src/Game/GameSession/GameSession.gd
+++ b/game/src/Game/GameSession/GameSession.gd
@@ -9,6 +9,7 @@ func _ready() -> void:
push_error("Failed to setup game")
_model_manager.generate_units()
+ _model_manager.generate_buildings()
func _process(_delta : float) -> void:
GameSingleton.try_tick()
diff --git a/game/src/Game/GameSession/ModelManager.gd b/game/src/Game/GameSession/ModelManager.gd
index 17d2c1e..8cec49d 100644
--- a/game/src/Game/GameSession/ModelManager.gd
+++ b/game/src/Game/GameSession/ModelManager.gd
@@ -61,6 +61,25 @@ func _generate_unit(unit_dict : Dictionary) -> void:
add_child(model)
+func generate_buildings() -> void:
+ for building : Dictionary in ModelSingleton.get_buildings():
+ _generate_building(building)
+
+func _generate_building(building_dict : Dictionary) -> void:
+ const model_key : StringName = &"model"
+ const position_key : StringName = &"position"
+ const rotation_key : StringName = &"rotation"
+
+ var model : Node3D = _generate_model(building_dict[model_key])
+ if not model:
+ return
+
+ model.scale *= MODEL_SCALE
+ model.rotate_y(PI + building_dict.get(rotation_key, 0.0))
+ model.set_position(_map_view._map_to_world_coords(building_dict[position_key]) + Vector3(0, 0.1 * MODEL_SCALE, 0))
+
+ add_child(model)
+
func _generate_model(model_dict : Dictionary, culture : String = "", is_unit : bool = false) -> Node3D:
const file_key : StringName = &"file"
const scale_key : StringName = &"scale"