Basic events system started.

This commit is contained in:
2025-05-06 11:07:16 -05:00
parent 4ad63b8c41
commit b9f0295722
22 changed files with 325 additions and 103 deletions

View File

@@ -1,21 +1,12 @@
class_name BasicNPCEntity extends "res://scripts/Entities/OverworldEntity.gd"
const Cutscene = preload("res://scripts/Cutscene/Cutscene.gd");
const OverworldConversationEvent = preload("res://scripts/Cutscene/Scene/OverworldConversationEvent.gd");
enum BasicNPCInteractType {
NONE,
CUTSCENE,
TEXTS
};
const Event = preload("res://scripts/Events/Event.gd");
enum BasicNPCMoveType {
STILL,
RANDOM_LOOK
};
@export var interactType:BasicNPCInteractType = BasicNPCInteractType.NONE;
@export var interactCutscene:GDScript;
@export var interactTexts:Array[String];
@export var interactEvent:Event;
@export var moveType:BasicNPCMoveType = BasicNPCMoveType.STILL;
@@ -24,22 +15,10 @@ enum BasicNPCMoveType {
var randomLookTimer:float = 0.0;
func interact(interactor:OverworldEntity) -> void:
if interactType == BasicNPCInteractType.NONE:
if interactEvent == null:
push_error("BasicNPCEntity: interactType EVENT but no event set");
return
if interactType == BasicNPCInteractType.CUTSCENE:
# Cutscene in this manner must take two entities
# (self, speaker, and interactor, player)
var cs:Cutscene = interactCutscene.new(self, interactor);
CUTSCENE.setCurrentCutscene(cs);
return
if interactType == BasicNPCInteractType.TEXTS:
var cs:Cutscene = OverworldConversationEvent.new(self, interactor, interactTexts);
CUTSCENE.setCurrentCutscene(cs);
return
pass
interactEvent.onEntityInteract(interactor, self);
func updateMovement(delta:float) -> void:
if moveType == BasicNPCMoveType.STILL:

View File

@@ -7,7 +7,8 @@ enum Direction {
EAST,
}
var speed:float = 150;
var speed:float = 200;
var runSpeed:float = 400;
var friction:float = 8.5;
var gravity:float = 30;

View File

@@ -1,6 +1,6 @@
extends Camera3D
const PIXEL_SCALE:float = 4.0;
const PIXEL_SCALE:float = 2.0;
const WORLD_UNITS:float = 32.0;
func _ready() -> void:

View File

@@ -27,9 +27,16 @@ func updateOverworldLogic(delta) -> void:
func updateMovement(delta) -> void:
# User movement
var dir:Vector2 = Input.get_vector("left", "right", "up", "down");
var moveSpeed:float;
if Input.is_action_pressed("run"):
moveSpeed = runSpeed;
else:
moveSpeed = speed;
if(dir.x != 0 or dir.y != 0):
velocity.x = dir.x * speed * delta;
velocity.z = dir.y * speed * delta;
velocity.x = dir.x * moveSpeed * delta;
velocity.z = dir.y * moveSpeed * delta;
# Update direction
if(dir.x >= abs(dir.y) and(
@@ -48,4 +55,3 @@ func updateMovement(delta) -> void:
direction = Direction.SOUTH;
elif (dir.y < 0):
direction = Direction.NORTH;
pass