moved all build related code rom global to buildmanger
This commit is contained in:
@@ -7,6 +7,15 @@ extends Node
|
|||||||
|
|
||||||
signal build_object_selected
|
signal build_object_selected
|
||||||
|
|
||||||
|
signal exit_build_mode
|
||||||
|
signal enter_build_mode
|
||||||
|
|
||||||
|
signal preview_created
|
||||||
|
signal preview_destroyed
|
||||||
|
|
||||||
|
signal object_placed(build_postion)
|
||||||
|
|
||||||
|
var build_mode: bool = false
|
||||||
|
|
||||||
var selected_object_id: int
|
var selected_object_id: int
|
||||||
var is_object_selected: bool
|
var is_object_selected: bool
|
||||||
@@ -18,6 +27,15 @@ func _ready() -> void:
|
|||||||
is_object_selected = false
|
is_object_selected = false
|
||||||
build_object_selected.connect(_on_object_selected)
|
build_object_selected.connect(_on_object_selected)
|
||||||
|
|
||||||
|
func _input(event: InputEvent) -> void:
|
||||||
|
if event.is_action_released("enter_build_mode"):
|
||||||
|
if build_mode:
|
||||||
|
exit_build_mode.emit()
|
||||||
|
build_mode = false
|
||||||
|
else:
|
||||||
|
enter_build_mode.emit()
|
||||||
|
build_mode = true
|
||||||
|
|
||||||
func get_preview_object():
|
func get_preview_object():
|
||||||
var selected_object
|
var selected_object
|
||||||
match selected_object_id:
|
match selected_object_id:
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ var staic_body: StaticBody3D
|
|||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
Global.preview_created.connect(_on_preview_create)
|
BuildManager.preview_created.connect(_on_preview_create)
|
||||||
Global.object_placed.connect(_on_object_placed)
|
BuildManager.object_placed.connect(_on_object_placed)
|
||||||
set_default_shaders()
|
set_default_shaders()
|
||||||
|
|
||||||
staic_body = $StaticBody3D
|
staic_body = $StaticBody3D
|
||||||
|
|||||||
@@ -11,22 +11,22 @@ var is_placed = false
|
|||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
areas = get_children()
|
areas = get_children()
|
||||||
buildTransparentPreivew.visible = false
|
buildTransparentPreivew.visible = false
|
||||||
Global.exit_build_mode.connect(_on_exit_build_mode)
|
BuildManager.exit_build_mode.connect(_on_exit_build_mode)
|
||||||
Global.enter_build_mode.connect(_on_enter_build_mode)
|
BuildManager.enter_build_mode.connect(_on_enter_build_mode)
|
||||||
|
|
||||||
|
|
||||||
func _input_event(camera: Camera3D, event: InputEvent, event_position: Vector3, normal: Vector3, shape_idx: int) -> void:
|
func _input_event(camera: Camera3D, event: InputEvent, event_position: Vector3, normal: Vector3, shape_idx: int) -> void:
|
||||||
if event.is_action_pressed("mouse_click") and Global.build_mode:
|
if event.is_action_pressed("mouse_click") and BuildManager.build_mode:
|
||||||
place_object()
|
place_object()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _mouse_enter() -> void:
|
func _mouse_enter() -> void:
|
||||||
if !is_placed and Global.build_mode and BuildManager.is_object_selected:
|
if !is_placed and BuildManager.build_mode and BuildManager.is_object_selected:
|
||||||
show_preview()
|
show_preview()
|
||||||
|
|
||||||
func _mouse_exit() -> void:
|
func _mouse_exit() -> void:
|
||||||
if !is_placed and Global.build_mode:
|
if !is_placed and BuildManager.build_mode:
|
||||||
hide_preview()
|
hide_preview()
|
||||||
|
|
||||||
func show_preview():
|
func show_preview():
|
||||||
@@ -36,7 +36,7 @@ func show_preview():
|
|||||||
areas[0].add_child(previewObject)
|
areas[0].add_child(previewObject)
|
||||||
#previewObject.global_position.y = BuildManager.global_y
|
#previewObject.global_position.y = BuildManager.global_y
|
||||||
buildTransparentPreivew.visible = false
|
buildTransparentPreivew.visible = false
|
||||||
Global.preview_created.emit()
|
BuildManager.preview_created.emit()
|
||||||
|
|
||||||
func hide_preview():
|
func hide_preview():
|
||||||
if is_placed != true:
|
if is_placed != true:
|
||||||
@@ -47,7 +47,7 @@ func hide_preview():
|
|||||||
func place_object():
|
func place_object():
|
||||||
#is_placed = true
|
#is_placed = true
|
||||||
#buildTransparentPreivew.visible = false
|
#buildTransparentPreivew.visible = false
|
||||||
Global.object_placed.emit(self.position)
|
BuildManager.object_placed.emit(self.position)
|
||||||
self.queue_free()
|
self.queue_free()
|
||||||
|
|
||||||
func _on_enter_build_mode():
|
func _on_enter_build_mode():
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ func _ready() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
debugLabel.text = "Mode: " + str(Global.build_mode)
|
debugLabel.text = "Mode: " + str(BuildManager.build_mode)
|
||||||
global_delta = delta
|
global_delta = delta
|
||||||
look_at(ownRigidBody.position)
|
look_at(ownRigidBody.position)
|
||||||
self.position.y = -0.1 * pow(self.position.z,2) + zoom_pos # y axis controll for camera
|
self.position.y = -0.1 * pow(self.position.z,2) + zoom_pos # y axis controll for camera
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ var previewObject
|
|||||||
var targetPos
|
var targetPos
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
Global.object_placed.connect(_on_object_placed)
|
BuildManager.object_placed.connect(_on_object_placed)
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
func _input(event: InputEvent) -> void:
|
||||||
if event.is_action_pressed("hide_top"):
|
if event.is_action_pressed("hide_top"):
|
||||||
|
|||||||
@@ -4,25 +4,25 @@ extends Node3D
|
|||||||
|
|
||||||
@export var debugLabel1: Label
|
@export var debugLabel1: Label
|
||||||
|
|
||||||
signal exit_build_mode
|
#signal exit_build_mode
|
||||||
signal enter_build_mode
|
#signal enter_build_mode
|
||||||
|
#
|
||||||
signal preview_created
|
#signal preview_created
|
||||||
signal preview_destroyed
|
#signal preview_destroyed
|
||||||
|
#
|
||||||
signal object_placed(build_postion)
|
#signal object_placed(build_postion)
|
||||||
|
#
|
||||||
var build_mode: bool = false
|
#var build_mode: bool = false
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
print(outline_shader)
|
print(outline_shader)
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
#func _input(event: InputEvent) -> void:
|
||||||
if event.is_action_released("enter_build_mode"):
|
#if event.is_action_released("enter_build_mode"):
|
||||||
if build_mode:
|
#if build_mode:
|
||||||
exit_build_mode.emit()
|
#exit_build_mode.emit()
|
||||||
build_mode = false
|
#build_mode = false
|
||||||
else:
|
#else:
|
||||||
enter_build_mode.emit()
|
#enter_build_mode.emit()
|
||||||
build_mode = true
|
#build_mode = true
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ func _ready() -> void:
|
|||||||
meshI = $MeshInstance3D
|
meshI = $MeshInstance3D
|
||||||
shirt_shader = meshI.get_surface_override_material(1)
|
shirt_shader = meshI.get_surface_override_material(1)
|
||||||
|
|
||||||
Global.object_placed.connect(_on_object_placed)
|
BuildManager.object_placed.connect(_on_object_placed)
|
||||||
|
|
||||||
set_random_shirt()
|
set_random_shirt()
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ extends Panel
|
|||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
self.visible = false
|
self.visible = false
|
||||||
Global.enter_build_mode.connect(_on_enter_build_mode)
|
BuildManager.enter_build_mode.connect(_on_enter_build_mode)
|
||||||
Global.exit_build_mode.connect(_on_exit_build_mode)
|
BuildManager.exit_build_mode.connect(_on_exit_build_mode)
|
||||||
|
|
||||||
|
|
||||||
func _on_enter_build_mode():
|
func _on_enter_build_mode():
|
||||||
|
|||||||
Reference in New Issue
Block a user