- Introduced a new JobComponent and JobQueue to manage jobs in the game. - Created two new jobs: DigJob and InfectJob with their respective scripts. - Updated CrystalGlowComponent, FreeCameraComponent, MushroomGlowComponent, WaterEffectComponent to improve logging messages. - Adjusted camera movement limits in FreeCameraGameCameraComponent for better control. - Added FiniteStateMachine class for managing states of entities. - Implemented GlowingIdle state as an example of using the state machine. - Included a utility function to fetch file paths by extension from a directory.
57 lines
1.4 KiB
GDScript
57 lines
1.4 KiB
GDScript
extends Node
|
|
class_name JobComponent
|
|
|
|
## Constants
|
|
const JOB_FOLDER = "res://components/jobs/"
|
|
|
|
## Variables
|
|
var job_types : Dictionary = {}
|
|
|
|
@onready var queue : JobQueue = $JobQueue
|
|
|
|
|
|
func _ready() -> void:
|
|
|
|
## Get the list of job types from the job folder
|
|
load_jobs()
|
|
add_jobs_to_queue()
|
|
add_jobs_to_queue()
|
|
add_jobs_to_queue()
|
|
|
|
Log.pr("I am the job component, and I am ready.")
|
|
|
|
|
|
# Look in the JOB_FOLDER and preload all scenes into a dictionary
|
|
func load_jobs() -> void:
|
|
var job_files : Array = FileUtil.get_file_paths_by_extension(JOB_FOLDER, "tscn")
|
|
|
|
#Log.pr("Job files: ", job_files)
|
|
|
|
for file : String in job_files:
|
|
#Log.pr("Loading job: ", file)
|
|
var job_scene : PackedScene = load(file)
|
|
var job_instance : Job = job_scene.instantiate()
|
|
|
|
#Log.pr("⚒️ Job Name:", job_instance.job_name, "-- Description:", job_instance.job_description)
|
|
|
|
var job_details : Dictionary = {
|
|
'job_name': job_instance.job_name,
|
|
'job_description': job_instance.job_description,
|
|
'job_instance': job_scene
|
|
}
|
|
|
|
job_types[job_instance.job_name] = job_details
|
|
|
|
#Log.pr(job_details)
|
|
|
|
Log.pr("Job types: ", job_types)
|
|
|
|
func add_jobs_to_queue() -> void:
|
|
#Log.pr("This is a debug function!")
|
|
|
|
for job : String in job_types.keys():
|
|
#Log.pr("Adding job to queue: ", job)
|
|
if job_types[job].job_instance != null:
|
|
var job_scene : PackedScene = job_types[job].job_instance
|
|
var job_instance : Node = job_scene.instantiate()
|
|
queue.add_child(job_instance)
|