|
@ -12,15 +12,12 @@ func _process(_delta: float) -> void: |
|
|
if Input.is_action_just_pressed("right_click_interact"): |
|
|
if Input.is_action_just_pressed("right_click_interact"): |
|
|
(collider as Block).destroy_block() |
|
|
(collider as Block).destroy_block() |
|
|
if Input.is_action_just_pressed("left_click_interact"): |
|
|
if Input.is_action_just_pressed("left_click_interact"): |
|
|
var new_block_pos: Vector3i = Vector3i(collider.position + get_collision_normal()) |
|
|
|
|
|
|
|
|
var block_pos: Vector3i = Vector3i(collider.position + get_collision_normal()) |
|
|
|
|
|
|
|
|
if !is_valid_placement_target(new_block_pos): |
|
|
|
|
|
|
|
|
if !is_valid_placement_target(block_pos): |
|
|
return |
|
|
return |
|
|
|
|
|
|
|
|
EntityManager.create_block.emit( |
|
|
|
|
|
InventoryManager.quick_slot_item_id, |
|
|
|
|
|
new_block_pos |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
EntityManager.create_block.emit(InventoryManager.quick_slot_item_id, block_pos) |
|
|
|
|
|
|
|
|
if Waila.ref.get_target() == collider: |
|
|
if Waila.ref.get_target() == collider: |
|
|
return |
|
|
return |
|
@ -33,7 +30,7 @@ func _process(_delta: float) -> void: |
|
|
release_target() |
|
|
release_target() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func is_valid_placement_target(new_block_pos: Vector3i) -> bool: |
|
|
|
|
|
|
|
|
func is_valid_placement_target(block_pos: Vector3i) -> bool: |
|
|
# This could probably use some work |
|
|
# This could probably use some work |
|
|
var collision_shape_radius: float = player.collision_shape_standing.shape.radius |
|
|
var collision_shape_radius: float = player.collision_shape_standing.shape.radius |
|
|
|
|
|
|
|
@ -42,9 +39,9 @@ func is_valid_placement_target(new_block_pos: Vector3i) -> bool: |
|
|
var position_max: Vector3i = Vector3i(player.global_position + maximums) |
|
|
var position_max: Vector3i = Vector3i(player.global_position + maximums) |
|
|
|
|
|
|
|
|
if ( |
|
|
if ( |
|
|
new_block_pos.x >= position_min.x and new_block_pos.x <= position_max.x and |
|
|
|
|
|
new_block_pos.y >= position_min.y and new_block_pos.y <= position_max.y and |
|
|
|
|
|
new_block_pos.z >= position_min.z and new_block_pos.z <= position_max.z |
|
|
|
|
|
|
|
|
block_pos.x >= position_min.x and block_pos.x <= position_max.x and |
|
|
|
|
|
block_pos.y >= position_min.y and block_pos.y <= position_max.y and |
|
|
|
|
|
block_pos.z >= position_min.z and block_pos.z <= position_max.z |
|
|
): |
|
|
): |
|
|
return false |
|
|
return false |
|
|
|
|
|
|
|
|