Refactoring

This commit is contained in:
2026-01-07 22:09:56 -06:00
parent fff088a0a7
commit b7716201d8
62 changed files with 110 additions and 78 deletions

View File

@@ -1,4 +1,5 @@
class_name Entity extends CharacterBody3D
const ConversationElement = preload("res://ConversationElement.gd")
enum MovementType {
NONE,
@@ -8,11 +9,15 @@ enum MovementType {
enum InteractType {
NONE,
CONVERSATION,
};
# Movement settings
@export_category("Movement")
@export var movementType:MovementType = MovementType.NONE
# Interaction settings
@export var interactType:InteractType = InteractType.NONE
@export_category("Interactions")
@export var interactType:InteractType = InteractType.NONE
@export var conversation:Array[ConversationElement] = []

View File

@@ -0,0 +1 @@
uid://55jotw6snoi

View File

@@ -4,13 +4,29 @@ const Entity = preload("res://overworld/entity/Entity.gd")
@export var entity:Entity
func isInteractable() -> bool:
return entity && entity.interactType != Entity.InteractType.NONE
func onInteract() -> void:
if !isInteractable():
return
if !entity:
return false
if entity.interactType == Entity.InteractType.NONE:
return
return false
print("Entity Interacted")
if entity.interactType == Entity.InteractType.CONVERSATION:
if entity.conversation.size() == 0:
return false
return true
func _onConversationInteract(_other:Entity) -> void:
print("Starting conversation with ", entity.name)
pass
func onInteract(other:Entity) -> void:
if entity.interactType == Entity.InteractType.NONE:
return
match entity.interactType:
Entity.InteractType.CONVERSATION:
_onConversationInteract(other)
return
_:
pass

View File

@@ -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)

View File

@@ -1,5 +1,6 @@
class_name EntityMovement extends Node
const GRAVITY = Vector3.DOWN * 100
const FRICTION = 0.01
const WALK_SPEED_DEFAULT = 8
const RUN_SPEED_DEFAULT = 12
@@ -18,7 +19,7 @@ const RUN_SPEED_DEFAULT = 12
#
func _applyGravity() -> void:
if !entity.is_on_floor():
entity.velocity += PHYSICS.GRAVITY * get_process_delta_time()
entity.velocity += GRAVITY * get_process_delta_time()
func _applyPlayerMovement(_delta:float):
if Input.is_action_just_pressed("interact") && interactingArea && interactingArea.hasInteraction():