diff options
author | hop311 <hop3114@gmail.com> | 2024-05-08 01:14:00 +0200 |
---|---|---|
committer | hop311 <hop3114@gmail.com> | 2024-05-08 01:37:33 +0200 |
commit | ac29e4040fc20c50c8f0eb64b1194f6398165eb0 (patch) | |
tree | b6460c44a29fe8bac9ba125a8464c88c8b9b6e89 /game/src/Game/GameSession/ModelManager.gd | |
parent | ac1504f6fa981947bd9543d24325b3751236e925 (diff) |
Generate building modelsmodels
Diffstat (limited to 'game/src/Game/GameSession/ModelManager.gd')
-rw-r--r-- | game/src/Game/GameSession/ModelManager.gd | 19 |
1 files changed, 19 insertions, 0 deletions
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" |