You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			28 lines
		
	
	
		
			837 B
		
	
	
	
		
			GDScript
		
	
		
		
			
		
	
	
			28 lines
		
	
	
		
			837 B
		
	
	
	
		
			GDScript
		
	
| 
											2 years ago
										 | extends Node3D | ||
|  | class_name PlayerInput | ||
| 
											2 years ago
										 | 
 | ||
|  | @onready var status = (%Status as Status) | ||
| 
											2 years ago
										 | @onready var combo = (%Combo as Combo) | ||
| 
											2 years ago
										 | 
 | ||
| 
											2 years ago
										 | var action_map = {} | ||
|  | 
 | ||
| 
											2 years ago
										 | func _ready(): | ||
|  | 	SignalManager.connect("input_action_pressed",on_input_action_pressed) | ||
|  | 	SignalManager.connect("input_action_pressed",on_input_action_released) | ||
|  | 	SignalManager.connect("input_action_move",on_input_action_move) | ||
|  | 
 | ||
|  | func on_input_action_pressed(event:InputEvent): | ||
| 
											2 years ago
										 | 	for action_name in InputMap.get_actions(): | ||
|  | 		if event.is_action(action_name): | ||
| 
											2 years ago
										 | 			if not action_name in action_map: | ||
|  | 				action_map[action_name] = true | ||
|  | 				combo.add_input_action(action_name) | ||
| 
											2 years ago
										 | 	 | ||
|  | func on_input_action_released(event:InputEvent): | ||
| 
											2 years ago
										 | 	for action_name in InputMap.get_actions(): | ||
|  | 		if event.is_action(action_name): | ||
|  | 			action_map.erase(action_name) | ||
| 
											2 years ago
										 | 
 | ||
|  | func on_input_action_move(input_dir): | ||
| 
											2 years ago
										 | 	status.input_dir = input_dir |