feat: Add diverse game tiles, 3D wall scenes, and player movement and stop-n-go managers.

This commit is contained in:
Yogi Wiguna
2026-03-12 17:47:23 +08:00
parent 739489cd6f
commit e5e99f5853
5 changed files with 100 additions and 69 deletions
+31 -19
View File
@@ -100,9 +100,9 @@ func simple_move_to(grid_position: Vector2i) -> bool:
print("[Move] Failed: Blocked by Item %d on Floor 1" % cell_item)
return false
# PHYSICS CHECK: Ensure no static obstacles (like Stands) are blocking the path
if _is_position_blocked_by_physics(grid_position):
print("[Move] Failed: Blocked by physics raycast at %s" % grid_position)
# PHYSICS CHECK: Ensure no static obstacles (like Wall blocks or Stands) are blocking the path
if _is_path_blocked_by_physics(player.current_position, grid_position):
print("[Move] Failed: Path blocked by physics at %s" % grid_position)
return false
if player.is_position_occupied(grid_position):
@@ -512,30 +512,42 @@ func _can_push_to(pos: Vector2i) -> bool:
if _is_position_in_static_stand_area(pos):
return false
if _is_position_blocked_by_physics(pos):
if _is_path_blocked_by_physics(player.current_position, pos):
return false
return true
func _is_position_blocked_by_physics(target_pos: Vector2i) -> bool:
func _is_path_blocked_by_physics(from_grid: Vector2i, to_grid: Vector2i) -> bool:
if not player.is_inside_tree(): return false
var space_state = player.get_world_3d().direct_space_state
var center_x = target_pos.x + 0.5
var center_z = target_pos.y + 0.5
var from = Vector3(center_x, 1.0, center_z)
var to = Vector3(center_x, 0.1, center_z)
var query = PhysicsRayQueryParameters3D.create(from, to)
query.collide_with_areas = false
query.collide_with_bodies = true
# 1. Path check: Block movement if a wall exists between the current and target tile
var from_v3 = Vector3(from_grid.x + 0.5, 0.5, from_grid.y + 0.5)
var to_v3 = Vector3(to_grid.x + 0.5, 0.5, to_grid.y + 0.5)
var result = space_state.intersect_ray(query)
if result:
if result.collider != player:
# ONLY block if it's a Static Tekton Stand
# Ignore GridMap floors/walls, which are handled by get_cell_item rules
if result.collider.name.find("StaticTektonStand") != -1 or result.collider.is_in_group("StaticTektonStands") or result.collider.has_method("is_stand"):
return true
var path_query = PhysicsRayQueryParameters3D.create(from_v3, to_v3)
path_query.collide_with_areas = false
path_query.collide_with_bodies = true
var path_result = space_state.intersect_ray(path_query)
if path_result:
if path_result.collider != player:
# This correctly hits thin walls placed on tile boundaries
return true
# 2. Target tile occupancy check: Block if a static object is in the middle of the tile
var target_from = Vector3(to_grid.x + 0.5, 1.0, to_grid.y + 0.5)
var target_to = Vector3(to_grid.x + 0.5, 0.1, to_grid.y + 0.5)
var target_query = PhysicsRayQueryParameters3D.create(target_from, target_to)
target_query.collide_with_areas = false
target_query.collide_with_bodies = true
var target_result = space_state.intersect_ray(target_query)
if target_result:
if target_result.collider != player:
# This hits objects like Stands that sit in the center of the tile
return true
return false