From 042576acff482749a14baf9a70e648c499f7aaee Mon Sep 17 00:00:00 2001 From: PfandBoss <68470553+PfandBoss@users.noreply.github.com> Date: Sat, 10 Dec 2022 02:03:09 +0100 Subject: [PATCH] Engine basic added --- Cannon.gd | 10 ++++++---- Engine.gd | 32 ++++++++++++++++++++++++++++++++ project.godot | 8 +++++++- 3 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 Engine.gd diff --git a/Cannon.gd b/Cannon.gd index c063111..4fd34bb 100644 --- a/Cannon.gd +++ b/Cannon.gd @@ -3,6 +3,7 @@ extends Module class_name Cannon enum STATE {INACTIVE, RELOADING, SHOOTING} + #------------Methods-------------# func _ready(): var root = get_tree().root.get_child(0) @@ -22,8 +23,9 @@ func interact(): return func _on_signal_shooting(): - if currentStashValue == 1: + if currentStashValue == 1 and currentState == STATE.INACTIVE: currentState = STATE.SHOOTING - #TODO: SHOOTING - currentState = STATE.INACTIVE - pass + #TODO: SHOOTING + currentState = STATE.INACTIVE + + return diff --git a/Engine.gd b/Engine.gd new file mode 100644 index 0000000..6b1b284 --- /dev/null +++ b/Engine.gd @@ -0,0 +1,32 @@ +extends Module +class_name TrainEngine + + +enum STATE {RUNNING, DEAD} + +#------------Methods-------------# +func _ready(): + var root = get_tree().root.get_child(0) + maxStashValue = 100 + currentStashValue = 100 + currentState = STATE.RUNNING +#TODO: FINISH +func interact(): + if currentState == STATE.RUNNING: + if currentStashValue < maxStashValue: + currentStashValue += 10 + if currentStashValue > maxStashValue: + currentStashValue = maxStashValue + + return + #TODO: Repair Train + currentState = STATE.RUNNING + + if currentStashValue == 1 and currentState == STATE.INACTIVE: + currentState = STATE.SHOOTING + #TODO: SHOOTING + currentState = STATE.INACTIVE + + return + + diff --git a/project.godot b/project.godot index e993081..675ee97 100644 --- a/project.godot +++ b/project.godot @@ -18,10 +18,16 @@ _global_script_classes=[{ "class": &"Module", "language": &"GDScript", "path": "res://Module.gd" +}, { +"base": "Module", +"class": &"TrainEngine", +"language": &"GDScript", +"path": "res://Engine.gd" }] _global_script_class_icons={ "Cannon": "", -"Module": "" +"Module": "", +"TrainEngine": "" } [application]