Refactoring
This commit is contained in:
@@ -5,11 +5,15 @@ var interactableAreas:Array[EntityInteractableArea] = []
|
||||
@export var entity:Entity
|
||||
|
||||
func hasInteraction() -> bool:
|
||||
return true
|
||||
return interactableAreas.size() > 0
|
||||
|
||||
func interact() -> void:
|
||||
for area in interactableAreas:
|
||||
area.onInteract()
|
||||
if !area.isInteractable():
|
||||
continue
|
||||
|
||||
area.onInteract(self.entity)
|
||||
break
|
||||
|
||||
func _enter_tree() -> void:
|
||||
self.area_entered.connect(_onAreaEntered)
|
||||
@@ -23,11 +27,7 @@ func _onAreaEntered(area:Area3D) -> void:
|
||||
if area is EntityInteractableArea:
|
||||
if area.entity == entity:
|
||||
return
|
||||
if !area.isInteractable():
|
||||
return
|
||||
print("EntityInteractingArea: Area Entered")
|
||||
interactableAreas.append(area)
|
||||
|
||||
func _onAreaExited(area:Area3D) -> void:
|
||||
print("EntityInteractingArea: Area Exited")
|
||||
interactableAreas.erase(area)
|
||||
Reference in New Issue
Block a user