Working missions based on adjustments for unit 1.02

pull/18/head
Wade 2025-04-18 13:42:44 +07:00
parent 234337a0e4
commit ee149159c5
20 changed files with 76 additions and 496 deletions

@ -1,6 +1,6 @@
extends Node
signal population_update(new_population:int)
signal population_update(count:int)
var current_scene = null

@ -0,0 +1,17 @@
extends Node
@export var population: int = 0
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
func set_population_count(count: int) -> void:
# Update the population count
population += count
# Emit the signal to notify other nodes
EventBus.population_update.emit(population)
# Print the updated population for debugging

@ -1,78 +0,0 @@
[gd_resource type="Resource" script_class="MissionData" load_steps=4 format=3 uid="uid://p3xwn2mp6bm6"]
[ext_resource type="Script" path="res://scripts/mission/mission_objective.gd" id="1_dhx01"]
[ext_resource type="Script" path="res://scripts/mission/mission_data.gd" id="2_mum3p"]
[sub_resource type="Resource" id="Resource_c06be"]
script = ExtResource("1_dhx01")
type = 7
target_count = 1
current_count = 0
description = "Calculate how many power plants are needed to supply electricity to 40 houses."
completed = false
[resource]
script = ExtResource("2_mum3p")
id = "5"
title = "Residential Energy Usage"
description = ""
objectives = Array[ExtResource("1_dhx01")]([SubResource("Resource_c06be")])
rewards = {
"cash": 0
}
next_mission_id = "6"
graph_path = ""
full_screen_path = ""
intro_text = "A neighborhood is calculating energy usage from gaming consoles and TVs.
At House A, they ran 2 gaming consoles and 3 TVs and used a total of 660 kilowatt-hours (kWh) of electricity.
At House B, they ran 4 gaming consoles and 1 TV and used 760 kWh of electricity."
question_text = ""
correct_answer = "150,70"
feedback_text = "Correct! You've accurately calculated that gaming consoles use 150 kWh and TVs use 70 kWh. Using a system of equations: 2x + 3y = 660 and 4x + y = 760, you can solve by substitution to find x = 150 and y = 70."
incorrect_feedback = "Not quite right. Try setting up a system of equations:
- House A: 2 gaming consoles + 3 TVs = 660 kWh
- House B: 4 gaming consoles + 1 TV = 760 kWh
Let x be the kWh for gaming consoles and y be the kWh for TVs.
So we have: 2x + 3y = 660 and 4x + y = 760"
company_data = ""
power_math_content = ""
num_of_user_inputs = 2
input_labels = Array[String](["Gaming Consoles", "TVs"])
companion_dialog = {
"correct_answer": {
"animation": "celebration",
"duration": 5000,
"text": "Excellent work! You correctly determined that gaming consoles use 150 kWh and TVs use 70 kWh."
},
"hint_request": {
"animation": "thinking",
"duration": 5000,
"text": "Try setting up two equations: 2x + 3y = 660 for House A and 4x + y = 760 for House B, where x is the energy used by consoles and y is the energy used by TVs."
},
"hint_second": {
"animation": "thinking",
"duration": 5000,
"text": "You can solve this by substitution. Rearrange the second equation to find y = 760 - 4x, then substitute this into the first equation."
},
"incorrect_answer": {
"animation": "sad",
"duration": 5000,
"text": "Not quite right. Let's try setting up the equations again. Remember, we have 2 consoles and 3 TVs using 660 kWh at House A, and 4 consoles and 1 TV using 760 kWh at House B."
},
"mission_completed": {
"animation": "happy",
"duration": 5000,
"text": "Now that we know the energy usage, we can plan our city's power needs much better. Well done!"
},
"mission_started": {
"animation": "greeting",
"duration": 5000,
"text": "Let's tackle a challenging energy problem! We need to figure out how much electricity gaming consoles and TVs use."
},
"question_shown": {
"animation": "thinking",
"duration": 5000,
"text": "This is a system of equations problem. We have two houses with different combinations of gaming consoles and TVs."
}
}
unlocked_items = Array[String](["res://models/power_plant.glb"])

@ -1,64 +0,0 @@
[gd_resource type="Resource" script_class="MissionData" load_steps=5 format=3 uid="uid://x5h4xutbldq3"]
[ext_resource type="Script" path="res://scripts/mission/mission_data.gd" id="1_nv6c6"]
[ext_resource type="Script" path="res://scripts/mission/mission_objective.gd" id="1_yfbrc"]
[ext_resource type="Resource" uid="uid://dv14kkhb6umkv" path="res://structures/road-straight.tres" id="2_d0ffl"]
[sub_resource type="Resource" id="Resource_ywws1"]
script = ExtResource("1_yfbrc")
type = 0
target_count = 3
current_count = 0
description = "Build 3 connecting roads"
completed = false
structure = ExtResource("2_d0ffl")
[resource]
script = ExtResource("1_nv6c6")
id = "1"
title = "Census Planning"
description = "As the new city planner, you need to establish a baseline understanding of your growing community. The mayor has requested a comprehensive census to guide future development."
objectives = Array[ExtResource("1_yfbrc")]([SubResource("Resource_ywws1")])
rewards = {
"cash": 250
}
next_mission_id = "2"
graph_path = ""
full_screen_path = ""
intro_text = "Welcome to Stem City! Let's learn how to build a city from the ground up. Start by building a road."
question_text = ""
correct_answer = ""
feedback_text = ""
incorrect_feedback = ""
company_data = ""
power_math_content = ""
num_of_user_inputs = 1
input_labels = Array[String]([])
companion_dialog = {
"correct_answer": {
"animation": "happy",
"duration": 5000,
"text": ["Great job! That's the right answer!", "Perfect! You got it right!"]
},
"incorrect_answer": {
"animation": "sad",
"duration": 5000,
"text": ["Hmm, that doesn't look right. Let's try again.", "Not quite right. Don't worry, you can try again!"]
},
"mission_completed": {
"animation": "happy",
"duration": 6000,
"text": ["You've completed your first mission! Great job building your first road!"]
},
"mission_started": {
"animation": "excited",
"duration": 6000,
"text": ["Welcome to Stem City! I'm your learning companion. Let's build a city together!", "Time to start our adventure in Stem City! I'll help you build your first city."]
},
"objective_completed_2": {
"animation": "happy",
"duration": 5000,
"text": ["You built a road! Now your citizens can move around the city.", "Nice work on that road! Roads help connect different parts of your city."]
}
}
unlocked_items = Array[String](["res://models/building-small-a.glb"])

@ -1,67 +0,0 @@
[gd_resource type="Resource" script_class="MissionData" load_steps=4 format=3 uid="uid://bho4qh41asyk1"]
[ext_resource type="Script" path="res://scripts/mission/mission_objective.gd" id="1_dhx01"]
[ext_resource type="Script" path="res://scripts/mission/mission_data.gd" id="2_mum3p"]
[sub_resource type="Resource" id="Resource_c06be"]
script = ExtResource("1_dhx01")
type = 3
target_count = 40
current_count = 0
description = "Build 40 residential buildings with construction workers"
completed = false
[resource]
script = ExtResource("2_mum3p")
id = "4"
title = "City Expansion Project"
description = "Your city needs to grow! Build 40 residential buildings using your team of construction workers. Watch as they construct each building from the ground up!"
objectives = Array[ExtResource("1_dhx01")]([SubResource("Resource_c06be")])
rewards = {
"cash": 0
}
next_mission_id = "5"
graph_path = ""
full_screen_path = ""
intro_text = "Your city is expanding rapidly! Now that you've learned which construction company is more efficient, it's time to put them to work."
question_text = ""
correct_answer = ""
feedback_text = ""
incorrect_feedback = ""
company_data = ""
power_math_content = ""
num_of_user_inputs = 1
input_labels = Array[String]([])
companion_dialog = {
"hint_request": {
"animation": "thinking",
"duration": 5000,
"text": "Try placing the construction workers near where you want to build. They'll automatically start constructing buildings!"
},
"mission_completed": {
"animation": "celebration",
"duration": 5000,
"text": "Amazing job! You've successfully built all 40 residential buildings. The city looks fantastic!"
},
"mission_progress_25": {
"animation": "happy",
"duration": 5000,
"text": "Great progress! You've completed 25% of the buildings. Keep it up!"
},
"mission_progress_50": {
"animation": "excited",
"duration": 5000,
"text": "Halfway there! The city is really taking shape now."
},
"mission_progress_75": {
"animation": "excited",
"duration": 5000,
"text": "Almost there! Just a few more buildings to go."
},
"mission_started": {
"animation": "greeting",
"duration": 5000,
"text": "Welcome to the City Expansion Project! We need to build 40 residential buildings using our construction workers."
}
}
unlocked_items = Array[String]([])

@ -1,64 +0,0 @@
[gd_resource type="Resource" script_class="MissionData" load_steps=5 format=3 uid="uid://cjr36hqnmyn0x"]
[ext_resource type="Script" path="res://scripts/mission/mission_objective.gd" id="1_dhx01"]
[ext_resource type="Resource" uid="uid://cntgl86ianngh" path="res://structures/building-small-a.tres" id="2_em5vq"]
[ext_resource type="Script" path="res://scripts/mission/mission_data.gd" id="2_mum3p"]
[sub_resource type="Resource" id="Resource_7c02e"]
script = ExtResource("1_dhx01")
type = 0
target_count = 3
current_count = 0
description = "Build a residential building"
completed = false
structure = ExtResource("2_em5vq")
[resource]
script = ExtResource("2_mum3p")
id = "2"
title = "Census Planning"
description = "Now that we have a road, let's build a residential building for our citizens!"
objectives = Array[ExtResource("1_dhx01")]([SubResource("Resource_7c02e")])
rewards = {
"cash": 250
}
next_mission_id = "3"
graph_path = ""
full_screen_path = ""
intro_text = "Great job on the road! Now let's build a residential building where our citizens can live."
question_text = ""
correct_answer = ""
feedback_text = ""
incorrect_feedback = ""
company_data = ""
power_math_content = ""
num_of_user_inputs = 1
input_labels = Array[String]([])
companion_dialog = {
"correct_answer": {
"animation": "happy",
"duration": 5000,
"text": ["Great job! That's the right answer!", "Perfect! You got it right!"]
},
"incorrect_answer": {
"animation": "sad",
"duration": 5000,
"text": ["Hmm, that doesn't look right. Let's try again.", "Not quite right. Don't worry, you can try again!"]
},
"mission_completed": {
"animation": "happy",
"duration": 6000,
"text": ["You've completed your second mission! Great job building your first residential building!"]
},
"mission_started": {
"animation": "excited",
"duration": 6000,
"text": ["Now it's time to build homes for our citizens!", "Let's add a residential building to our city!"]
},
"objective_completed_3": {
"animation": "excited",
"duration": 5000,
"text": ["Amazing! You built your first residential building where people can live.", "You just built a home for your city residents! The population is growing."]
}
}
unlocked_items = Array[String](["res://models/grass-trees.glb", "res://models/grass.glb"])

@ -1,67 +0,0 @@
[gd_resource type="Resource" script_class="MissionData" load_steps=4 format=3 uid="uid://bv4r7ebpjdce4"]
[ext_resource type="Script" path="res://scripts/mission/mission_objective.gd" id="1_nxtw6"]
[ext_resource type="Script" path="res://scripts/mission/mission_data.gd" id="2_83mjp"]
[sub_resource type="Resource" id="Resource_power_plant"]
script = ExtResource("1_nxtw6")
type = 10
target_count = 1
current_count = 0
description = "Build a power plant to provide electricity to your city"
completed = false
[resource]
script = ExtResource("2_83mjp")
id = "6"
title = "Powering Your City"
description = "Now that you've calculated how many power plants you need, it's time to build one to power your growing city of 40 houses."
objectives = Array[ExtResource("1_nxtw6")]([SubResource("Resource_power_plant")])
rewards = {
"cash": 1000
}
next_mission_id = ""
graph_path = ""
full_screen_path = ""
intro_text = "Your calculations showed that one power plant will be sufficient to power all 40 houses in your city. Let's build that power plant now to keep your residents happy!"
question_text = ""
correct_answer = ""
feedback_text = ""
incorrect_feedback = ""
company_data = ""
power_math_content = ""
num_of_user_inputs = 1
input_labels = Array[String]([])
companion_dialog = {
"building_selected": {
"animation": "happy",
"duration": 5000,
"text": "Great choice! The power plant will supply all the energy our residents need."
},
"hint_request": {
"animation": "thinking",
"duration": 5000,
"text": "Click on the power plant in your building menu and then place it in an open area of your city."
},
"mission_completed": {
"animation": "celebration",
"duration": 5000,
"text": "Congratulations! Your city now has power for all residents. You've learned how to use systems of equations to solve real-world problems!"
},
"mission_started": {
"animation": "greeting",
"duration": 5000,
"text": "Time to power up our city! Based on our calculations, we need to build a power plant to provide electricity to all 40 houses."
},
"placement_hint": {
"animation": "thinking",
"duration": 5000,
"text": "Try to place the power plant away from residential areas but close enough to supply power efficiently."
},
"placement_success": {
"animation": "excited",
"duration": 5000,
"text": "Perfect placement! Now the power plant can distribute electricity to all the houses in your city."
}
}
unlocked_items = Array[String]([])

@ -1,62 +0,0 @@
[gd_resource type="Resource" script_class="MissionData" load_steps=4 format=3 uid="uid://dykbopx8n3c3v"]
[ext_resource type="Script" path="res://scripts/mission/mission_objective.gd" id="1_l3spi"]
[ext_resource type="Script" path="res://scripts/mission/mission_data.gd" id="2_b4llw"]
[sub_resource type="Resource" id="Resource_c06be"]
script = ExtResource("1_l3spi")
type = 2
target_count = 50
current_count = 0
description = "Reach a population of 50 citizens"
completed = false
[resource]
script = ExtResource("2_b4llw")
id = "3"
title = "Census Planning"
description = "As your city grows, you need to choose the most efficient construction company."
objectives = Array[ExtResource("1_l3spi")]([SubResource("Resource_c06be")])
rewards = {
"cash": 500
}
next_mission_id = "4"
graph_path = "res://images/mission_2.png"
full_screen_path = ""
intro_text = "Your city is rapidly growing, and you need to build houses to accommodate new residents! Two different construction companies offer to help. Study the company data below, find the unit rates (houses per worker), and determine which company would require fewer workers to build 40 houses in a week. Which company requires fewer workers to build 40 houses in a week? (A or B)"
question_text = "Which company requires fewer workers to build 40 houses in a week? (A or B)"
correct_answer = "A"
feedback_text = "Correct! Company A (City Builders Inc.) would require fewer workers to build 40 houses. Company A builds at a rate of 4 houses per worker per week, while Company B builds at a rate of 3 houses per worker per week. For 40 houses, Company A needs 10 workers while Company B needs about 13.33 workers."
incorrect_feedback = "Not quite right. Look carefully at the data for both companies. Compare their rates: Company A builds 4 houses per worker per week, while Company B builds 3 houses per worker per week. Calculate how many workers each would need for 40 houses."
company_data = ""
power_math_content = ""
num_of_user_inputs = 1
input_labels = Array[String]([])
companion_dialog = {
"correct_answer": {
"animation": "happy",
"duration": 5000,
"text": ["Perfect! Company A is more efficient because each worker builds more houses per week.", "Exactly right! You found the company that can build the houses with fewer workers."]
},
"incorrect_answer": {
"animation": "sad",
"duration": 5000,
"text": ["Let's think about this differently. Look at how many houses each worker can build per week and calculate from there.", "Not quite right. Check the rates carefully: how many houses can one worker build in a week for each company?"]
},
"mission_completed": {
"animation": "happy",
"duration": 6000,
"text": "Great job selecting the most efficient construction company! Your city will grow faster now."
},
"mission_started": {
"animation": "excited",
"duration": 6000,
"text": ["It's time to expand our city! We need to choose the most efficient construction company.", "We have two construction companies offering their services. Let's analyze which one is better!"]
},
"objective_completed_7": {
"animation": "happy",
"duration": 5000,
"text": ["You've solved the construction company problem! That's good mathematical thinking.", "You've made a wise decision based on the data. That's how city planners work!"]
}
}
unlocked_items = Array[String](["res://models/road-corner.glb"])

Binary file not shown.

@ -1,36 +0,0 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://h0vrvst3cumo"
path="res://.godot/imported/building-small-d.glb-5e1b608dc43429cd8ce16f120ad53455.scn"
[deps]
source_file="res://models/building-small-d.glb"
dest_files=["res://.godot/imported/building-small-d.glb-5e1b608dc43429cd8ce16f120ad53455.scn"]
[params]
nodes/root_type="Node3D"
nodes/root_name="Scene Root"
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
_subresources={}
gltf/naming_version=0
gltf/embedded_image_handling=1

@ -26,6 +26,7 @@ general/default_playback_type.web=0
SoundManager="*res://scripts/sound_manager.gd"
EventBus="*res://global/event_bus.gd"
Globals="*res://global/globals.gd"
[display]

@ -1,4 +1,4 @@
[gd_scene load_steps=33 format=3 uid="uid://vgwrcfy1qawf"]
[gd_scene load_steps=34 format=3 uid="uid://vgwrcfy1qawf"]
[ext_resource type="Script" path="res://scripts/builder.gd" id="1_jybm7"]
[ext_resource type="Environment" uid="uid://jbptgqvstei3" path="res://scenes/main-environment.tres" id="1_yndf3"]
@ -8,24 +8,25 @@
[ext_resource type="Resource" uid="uid://cntgl86ianngh" path="res://structures/building-small-a.tres" id="5_v5o2m"]
[ext_resource type="Resource" uid="uid://ccb475jeg7ym5" path="res://structures/grass-trees.tres" id="6_fwsy4"]
[ext_resource type="Script" path="res://scripts/view.gd" id="8_yovpv"]
[ext_resource type="Resource" uid="uid://tm532uesguhk" path="res://structures/grass.tres" id="9_2t3p4"]
[ext_resource type="Resource" uid="uid://d2jplegnkl6u2" path="res://structures/road-corner.tres" id="10_ii8xx"]
[ext_resource type="Script" path="res://scripts/mission/mission_manager.gd" id="10_oe3re"]
[ext_resource type="PackedScene" uid="uid://dmsy06s02tcw4" path="res://scenes/generic_text_panel.tscn" id="13_7i6dj"]
[ext_resource type="Script" path="res://scripts/mission/mission_ui.gd" id="13_xvw5w"]
[ext_resource type="Script" path="res://resources/generic_text_panel.resource.gd" id="14_76jlq"]
[ext_resource type="Script" path="res://scripts/mission/learning_panel.gd" id="14_q2ymb"]
[ext_resource type="Script" path="res://scripts/mission/mission_data.gd" id="14_vcrh8"]
[ext_resource type="Resource" uid="uid://x5h4xutbldq3" path="res://mission/first_mission.tres" id="15_obmwc"]
[ext_resource type="Resource" uid="uid://cjr36hqnmyn0x" path="res://mission/second_mission.tres" id="16_rl54y"]
[ext_resource type="Resource" uid="uid://dykbopx8n3c3v" path="res://mission/third_mission.tres" id="17_rrdy6"]
[ext_resource type="Resource" uid="uid://x5h4xutbldq3" path="res://mission/unit_1.02/census_planning_1.tres" id="15_obmwc"]
[ext_resource type="Resource" uid="uid://cjr36hqnmyn0x" path="res://mission/unit_1.02/census_planning_2.tres" id="16_rl54y"]
[ext_resource type="Resource" uid="uid://dykbopx8n3c3v" path="res://mission/unit_1.02/census_planning_3.tres" id="17_rrdy6"]
[ext_resource type="FontFile" uid="uid://d0cxd77jybrcn" path="res://fonts/lilita_one_regular.ttf" id="17_vlub6"]
[ext_resource type="PackedScene" uid="uid://b4gkfwf4i3ydl" path="res://scenes/character.tscn" id="18_8lrh8"]
[ext_resource type="Resource" uid="uid://bho4qh41asyk1" path="res://mission/fourth_mission.tres" id="18_h4fpv"]
[ext_resource type="PackedScene" uid="uid://cgk66f6rg03mj" path="res://scenes/hud.tscn" id="18_hud"]
[ext_resource type="PackedScene" uid="uid://bqjnp7uypupog" path="res://scenes/controls_panel.tscn" id="19_controls"]
[ext_resource type="Resource" uid="uid://p3xwn2mp6bm6" path="res://mission/fifth_mission.tres" id="19_e8sub"]
[ext_resource type="Script" path="res://scripts/game_manager.gd" id="20_game_manager"]
[ext_resource type="Resource" uid="uid://bv4r7ebpjdce4" path="res://mission/sixth_mission.tres" id="20_r0ysx"]
[ext_resource type="Resource" uid="uid://442cwthak2pa" path="res://mission/unit_1.03_1.05/market_research_1.tres" id="20_ngu16"]
[ext_resource type="PackedScene" uid="uid://b4s46k58ddpyc" path="res://scenes/sound_panel.tscn" id="21_sound_panel"]
[ext_resource type="Resource" uid="uid://dtal0tl2ee336" path="res://structures/store.tres" id="21_y11qv"]
[sub_resource type="Resource" id="Resource_1gdbm"]
script = ExtResource("14_76jlq")
@ -119,7 +120,7 @@ outro_text_resource = SubResource("Resource_ja86h")
[node name="Builder" type="Node3D" parent="." node_paths=PackedStringArray("selector", "selector_container", "view_camera", "gridmap", "cash_display")]
script = ExtResource("1_jybm7")
structures = Array[ExtResource("2_54v6r")]([ExtResource("2_bwyku"), ExtResource("5_v5o2m"), ExtResource("6_fwsy4")])
structures = Array[ExtResource("2_54v6r")]([ExtResource("2_bwyku"), ExtResource("5_v5o2m"), ExtResource("6_fwsy4"), ExtResource("21_y11qv"), ExtResource("9_2t3p4"), ExtResource("10_ii8xx")])
selector = NodePath("Selector")
selector_container = NodePath("Selector/Container")
view_camera = NodePath("../View/Camera")
@ -168,7 +169,7 @@ resource_data = ExtResource("14_76jlq")
[node name="MissionManager" type="Node" parent="." node_paths=PackedStringArray("mission_ui", "builder")]
script = ExtResource("10_oe3re")
missions = Array[ExtResource("14_vcrh8")]([ExtResource("15_obmwc"), ExtResource("16_rl54y"), ExtResource("17_rrdy6"), ExtResource("18_h4fpv"), ExtResource("19_e8sub"), ExtResource("20_r0ysx")])
missions = Array[ExtResource("14_vcrh8")]([ExtResource("15_obmwc"), ExtResource("16_rl54y"), ExtResource("17_rrdy6"), ExtResource("20_ngu16")])
mission_ui = NodePath("MissionPanel")
builder = NodePath("../Builder")
character_scene = ExtResource("18_8lrh8")

@ -36,7 +36,6 @@ func _ready() -> void:
func _start_initial_movement():
await get_tree().process_frame
pick_random_target()
print("Initial movement target set for character at ", global_position)
# Force movement to a specific target
func _unhandled_input(event: InputEvent) -> void:

@ -66,7 +66,7 @@ func _ready():
if structure.model.resource_path.contains("power_plant"):
# Scale power plant model to be much smaller (0.5x)
transform = transform.scaled(Vector3(0.5, 0.5, 0.5))
elif structure.type == Structure.StructureType.RESIDENTIAL_BUILDING or structure.type == Structure.StructureType.ROAD:
else:
# Scale buildings and roads to be consistent (3x)
transform = transform.scaled(Vector3(3.0, 3.0, 3.0))
@ -493,16 +493,10 @@ func update_structure():
_model.scale = Vector3(0.5, 0.5, 0.5)
# Center the power plant model within the selector
_model.position = Vector3(-3.0, 0.0, 3.0) # Reset position
elif (structures[index].type == Structure.StructureType.RESIDENTIAL_BUILDING
or structures[index].type == Structure.StructureType.ROAD
or structures[index].type == Structure.StructureType.TERRAIN
or structures[index].model.resource_path.contains("grass")):
else:
# Scale buildings, roads, and decorative terrain to match (3x)
_model.scale = Vector3(3.0, 3.0, 3.0)
_model.position.y += 0.0 # No need for Y adjustment with scaling
else:
# Standard positioning for other structures
_model.position.y += 0.25
# Get the selector scale from the structure resource
var scale_factor = structures[index].selector_scale

@ -28,7 +28,7 @@ func _ready():
builder.structure_removed.connect(_on_structure_removed)
EventBus.population_update.connect(set_population_count)
# EventBus.population_update.connect(set_population_count)
# Initialize UI elements
population_label = $HBoxContainer/PopulationItem/PopulationLabel
@ -36,6 +36,8 @@ func _ready():
electricity_indicator = $HBoxContainer/ElectricityItem/ElectricityValues/ElectricityIndicator
population_tooltip = $PopulationTooltip
electricity_tooltip = $ElectricityTooltip
# Ensure electricity indicator starts with red color
if electricity_indicator:
@ -60,7 +62,15 @@ func _ready():
electricity_tooltip.visible = false
# Update HUD
update_hud()
update_hud()
func _process(delta):
# Update the population label if it changes
if population_label and Globals.population != total_population:
total_population = Globals.population
population_label.text = str(total_population)
# Called when a structure is placed
func _on_structure_placed(structure_index, position):

@ -266,7 +266,7 @@ func _on_worker_construction_ended():
# Forward the signal for mission managers/other systems that need it
worker_construction_ended.emit()
func update_population(count: int):
EventBus.population_update.emit(count)
Globals.set_population_count(count)

@ -216,24 +216,21 @@ func loop_construction_sound():
# Play the sound again
construction_sound.play()
print("DEBUG: Looping sound for worker " + str(my_sound_id))
else:
print("DEBUG: Cannot loop sound - either worker not active or sound not set up")
func finish_construction():
print("DEBUG: Worker " + str(my_sound_id) + " finishing construction")
is_construction_active = false
construction_finished = true
# Stop the construction sound
if construction_sound and construction_sound.playing:
construction_sound.stop()
print("DEBUG: Stopped sound for worker " + str(my_sound_id))
# Stop the sound loop timer
if loop_timer and loop_timer.is_inside_tree():
loop_timer.stop()
print("DEBUG: Stopped timer for worker " + str(my_sound_id))
# Emit signal for compatibility
construction_ended.emit()

@ -6,7 +6,6 @@ class_name MissionManager
const JSBridge = preload("res://scripts/javascript_bridge.gd")
const ObjectiveType = preload("res://configs/data.config.gd").ObjectiveType
signal mission_started(mission: MissionData)
signal mission_completed(mission: MissionData)
signal objective_completed(objective: MissionObjective)
@ -42,7 +41,8 @@ var learning_panel
var fullscreen_learning_panel
func _ready():
EventBus.population_update.connect(population_updated)
if builder:
# Connect to builder signals
builder.connect("structure_placed", _on_structure_placed)
@ -282,19 +282,32 @@ func complete_mission(mission_id: String):
# Send the "end" event to the companion
await get_tree().create_timer(2.0).timeout
func update_objective_progress(mission_id,count_change = 1):
func update_objective_progress(mission_id,count_change=1):
if not active_missions.has(mission_id):
return
current_objective.current_count += count_change
match current_objective.type:
ObjectiveType.BUILD_RESIDENTIAL,ObjectiveType.BUILD_STRUCTURE:
current_objective.current_count += count_change
if current_objective.target_count <= current_objective.current_count:
current_objective.completed = true
objective_completed.emit(current_objective)
var dialog_key = "objective_completed_" + str(current_objective.type)
_send_companion_dialog(dialog_key, current_mission) ## So Companion can react
update_current_objective(current_mission) # Go ahead and progress to nex objective if it exists.
ObjectiveType.REACH_POPULATION:
if Globals.population >= current_objective.target_count:
current_objective.completed = true
objective_completed.emit(current_objective)
var dialog_key = "objective_completed_" + str(current_objective.type)
_send_companion_dialog(dialog_key, current_mission) ## So Companion can react
update_current_objective(current_mission) # Go ahead and progress to nex objective if it exists.
# IF this is true then objectives are completed
if current_objective.target_count <= current_objective.current_count:
current_objective.completed = true
objective_completed.emit(current_objective)
var dialog_key = "objective_completed_" + str(current_objective.type)
_send_companion_dialog(dialog_key, current_mission) ## So Companion can react
update_current_objective(current_mission) # Go ahead and progress to nex objective if it exists.
update_mission_ui()
@ -1112,5 +1125,5 @@ func _force_learning_companion_connection():
_on_mission_started_for_companion(current_mission)
func _on_hud_population_updated(new_population: Variant) -> void:
update_objective_progress(current_mission.id, new_population)
func population_updated(new_population: Variant) -> void:
update_objective_progress(current_mission.id)

@ -54,11 +54,11 @@ func update_mission_display(mission: MissionData):
label.autowrap_mode = TextServer.AUTOWRAP_WORD_SMART
# Format the objective text
var progress = ""
if objective.target_count > 1:
progress = " (%d/%d)" % [objective.current_count, objective.target_count]
# var progress = ""
# if objective.target_count && objective.type > 1:
# progress = " (%d/%d)" % [objective.current_count, objective.target_count]
label.text = "%s%s" % [objective.description, progress]
label.text = objective.description
# Style completed objectives differently
if objective.completed:

@ -1,14 +0,0 @@
[gd_resource type="Resource" script_class="Structure" load_steps=3 format=3 uid="uid://dtal0tl2ee336"]
[ext_resource type="PackedScene" uid="uid://h0vrvst3cumo" path="res://models/building-small-d.glb" id="1_164xq"]
[ext_resource type="Script" uid="uid://smbpvh2nwds4" path="res://scripts/structure.gd" id="2_8ewai"]
[resource]
script = ExtResource("2_8ewai")
model = ExtResource("1_164xq")
type = 1
price = 70
population_count = 1
kW_usage = 1.0
kW_production = 0.0
selector_scale = 2.8