Lots of little tweaks and fixes
This commit is contained in:
@@ -22,11 +22,36 @@ func _exit_tree() -> void:
|
||||
self.area_entered.disconnect(_onAreaEntered)
|
||||
self.area_exited.disconnect(_onAreaExited)
|
||||
|
||||
func _process(_delta:float) -> void:
|
||||
if entity.movementType != Entity.MovementType.PLAYER:
|
||||
return
|
||||
if UI.INTERACT_INDICATOR and UI.INTERACT_INDICATOR.visible:
|
||||
UI.INTERACT_INDICATOR.updateWorldPosition()
|
||||
|
||||
func _getBestInteractable() -> Entity:
|
||||
for area in interactableAreas:
|
||||
if area.isInteractable():
|
||||
return area.entity
|
||||
return null
|
||||
|
||||
func _updateIndicator() -> void:
|
||||
if entity.movementType != Entity.MovementType.PLAYER:
|
||||
return
|
||||
if UI.INTERACT_INDICATOR == null:
|
||||
return
|
||||
var best:Entity = _getBestInteractable()
|
||||
if best:
|
||||
UI.INTERACT_INDICATOR.setEntity(best)
|
||||
else:
|
||||
UI.INTERACT_INDICATOR.clear()
|
||||
|
||||
func _onAreaEntered(area:Area3D) -> void:
|
||||
if area is EntityInteractableArea:
|
||||
if area.entity == entity:
|
||||
return
|
||||
interactableAreas.append(area)
|
||||
_updateIndicator()
|
||||
|
||||
func _onAreaExited(area:Area3D) -> void:
|
||||
interactableAreas.erase(area)
|
||||
_updateIndicator()
|
||||
|
||||
Reference in New Issue
Block a user