56 lines
1.2 KiB
GDScript
56 lines
1.2 KiB
GDScript
extends Area2D
|
|
|
|
@onready var floorRaycast = $RaycastFloor
|
|
@onready var raycastLeft = $RaycastLeft
|
|
@onready var raycastRight = $RaycastRight
|
|
@onready var raycastTop = $RaycastTop
|
|
|
|
@export var UID = 1
|
|
|
|
var secretPosition = Vector2()
|
|
|
|
var turningPoint = false
|
|
|
|
var type = GLOBAL.BLOCKTYPES.LIGHT
|
|
|
|
func _ready() -> void:
|
|
secretPosition = position
|
|
|
|
func getCollider(direction : GLOBAL.Direction):
|
|
match direction:
|
|
GLOBAL.Direction.BOTTOM:
|
|
return floorRaycast.get_collider()
|
|
GLOBAL.Direction.LEFT:
|
|
return raycastLeft.get_collider()
|
|
GLOBAL.Direction.RIGHT:
|
|
return raycastRight.get_collider()
|
|
GLOBAL.Direction.TOP:
|
|
return raycastTop.get_collider()
|
|
|
|
func getNeighbours():
|
|
var neighbours = []
|
|
for i in get_overlapping_areas():
|
|
if i.is_in_group("Block"):
|
|
neighbours.append(i)
|
|
return neighbours
|
|
|
|
func getNeighboursUID(uid):
|
|
var neighbours = []
|
|
for i in get_overlapping_areas():
|
|
if i.is_in_group("Block"):
|
|
if i.UID == uid:
|
|
neighbours.append(i)
|
|
return neighbours
|
|
|
|
func move(x,y):
|
|
secretPosition = position
|
|
secretPosition.x += x
|
|
secretPosition.y += y
|
|
position = secretPosition.snapped(Vector2(64, 64))
|
|
|
|
func moveDown():
|
|
move(0, 64)
|
|
func moveLeft():
|
|
move(-64, 0)
|
|
func moveRight():
|
|
move(64, 0)
|