forked from kanium/starcheese
36 lines
965 B
GDScript3
36 lines
965 B
GDScript3
|
|
extends Node
|
||
|
|
|
||
|
|
func _init() -> void:
|
||
|
|
var node = WeaponsSystem.new()
|
||
|
|
node.set_name("WeaponsSystem")
|
||
|
|
add_child(node)
|
||
|
|
|
||
|
|
node = DefaultEventBus.new()
|
||
|
|
node.set_name("MainEventBus")
|
||
|
|
add_child(node)
|
||
|
|
|
||
|
|
node = EventScope.new()
|
||
|
|
node.set_name("InputEventScope")
|
||
|
|
add_child(node)
|
||
|
|
|
||
|
|
# Called when the node enters the scene tree for the first time.
|
||
|
|
func _ready() -> void:
|
||
|
|
pass # Replace with function body.
|
||
|
|
|
||
|
|
|
||
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||
|
|
func _process(delta: float) -> void:
|
||
|
|
var actions = [
|
||
|
|
"ui_fire",
|
||
|
|
"ui_up",
|
||
|
|
"ui_down",
|
||
|
|
"ui_left",
|
||
|
|
"ui_right",
|
||
|
|
]
|
||
|
|
for action in actions:
|
||
|
|
if Input.is_action_pressed(action):
|
||
|
|
get_node("/root/Main/MainEventBus").publish(get_node("/root/Main/InputEventScope"), KeyboardInputEvent.new(action, true))
|
||
|
|
elif Input.is_action_just_released(action):
|
||
|
|
get_node("/root/Main/MainEventBus").publish(get_node("/root/Main/InputEventScope"), KeyboardInputEvent.new(action, false))
|
||
|
|
pass
|