Switching to build tool does not immediately activate build system.

main
Martin Felis 2024-11-27 20:51:20 +01:00
parent e1cf80bfb0
commit 04481cefef
6 changed files with 379 additions and 62 deletions

View File

@ -12,3 +12,4 @@ icon = ExtResource("1_fe6dh")
max_stack_size = 64 max_stack_size = 64
is_tool = false is_tool = false
is_buildable = true is_buildable = true
tool_action = 0

View File

@ -69,7 +69,7 @@ func _process(_delta):
build_dialog.hide() build_dialog.hide()
if _game_scene != null: if _game_scene != null:
if _player.has_build_tool_active(): if _player.has_build_tool_active() and _game_scene.build_system.build_item != null:
_game_scene.build_system.is_active = true _game_scene.build_system.is_active = true
else: else:
_game_scene.build_system.is_active = false _game_scene.build_system.is_active = false
@ -157,7 +157,11 @@ func _on_tool_select(item_slot:ItemSlot) -> void:
func _on_build_items_container_item_selected(item_slot:ItemSlot) -> void: func _on_build_items_container_item_selected(item_slot:ItemSlot) -> void:
if _game_scene: if _game_scene:
if item_slot != null:
_game_scene.build_system.build_item = item_slot.get_item() _game_scene.build_system.build_item = item_slot.get_item()
else:
_game_scene.build_system.build_item = null
build_dialog.hide() build_dialog.hide()

View File

@ -14,7 +14,7 @@ func _ready():
# Called every frame. 'delta' is the elapsed time since the previous frame. # Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta): func _process(_delta):
if build_system.is_active and build_system.build_item != null: if build_system.is_active:
player.process_mode = Node.PROCESS_MODE_DISABLED player.process_mode = Node.PROCESS_MODE_DISABLED
else: else:
player.process_mode = Node.PROCESS_MODE_ALWAYS player.process_mode = Node.PROCESS_MODE_ALWAYS

View File

@ -1,11 +1,10 @@
[gd_scene load_steps=10 format=3 uid="uid://cqie4cy0uy1t0"] [gd_scene load_steps=9 format=3 uid="uid://cqie4cy0uy1t0"]
[ext_resource type="Script" path="res://scenes/game.gd" id="1_kl6si"] [ext_resource type="Script" path="res://scenes/game.gd" id="1_kl6si"]
[ext_resource type="PackedScene" uid="uid://ch0s3dxx3rpir" path="res://objects/player.tscn" id="2_rjgxk"] [ext_resource type="PackedScene" uid="uid://ch0s3dxx3rpir" path="res://objects/player.tscn" id="2_rjgxk"]
[ext_resource type="Script" path="res://systems/QuestSystem.gd" id="4_8oxap"] [ext_resource type="Script" path="res://systems/QuestSystem.gd" id="4_8oxap"]
[ext_resource type="Script" path="res://systems/BuildSystem.gd" id="4_iqdys"] [ext_resource type="Script" path="res://systems/BuildSystem.gd" id="4_iqdys"]
[ext_resource type="PackedScene" uid="uid://dmagdl5pi6jdj" path="res://world/level.tscn" id="6_svjo8"] [ext_resource type="PackedScene" uid="uid://dmagdl5pi6jdj" path="res://world/level.tscn" id="6_svjo8"]
[ext_resource type="Resource" uid="uid://cepy03xrewibs" path="res://data/items/floor.tres" id="6_xdkny"]
[sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_y65pc"] [sub_resource type="ProceduralSkyMaterial" id="ProceduralSkyMaterial_y65pc"]
@ -43,7 +42,6 @@ script = ExtResource("4_8oxap")
[node name="BuildSystem" type="Node" parent="."] [node name="BuildSystem" type="Node" parent="."]
unique_name_in_owner = true unique_name_in_owner = true
script = ExtResource("4_iqdys") script = ExtResource("4_iqdys")
build_item = ExtResource("6_xdkny")
[node name="BuildPreview" type="Node3D" parent="BuildSystem"] [node name="BuildPreview" type="Node3D" parent="BuildSystem"]
unique_name_in_owner = true unique_name_in_owner = true

View File

@ -75,6 +75,7 @@ func _on_slot_mouse_entered(slot:ItemSlot):
func select_slot(index:int) -> void: func select_slot(index:int) -> void:
if index < 0 or index > _slots.size(): if index < 0 or index > _slots.size():
item_selected.emit(null)
return return
_selected_slot_index = index _selected_slot_index = index

File diff suppressed because one or more lines are too long