Interior Maps #13
BIN
local_player.scn (Stored with Git LFS)
BIN
local_player.scn (Stored with Git LFS)
Binary file not shown.
BIN
map_editor.scn (Stored with Git LFS)
BIN
map_editor.scn (Stored with Git LFS)
Binary file not shown.
|
@ -1,5 +1,14 @@
|
|||
class_name PlayerController extends Node3D
|
||||
|
||||
##
|
||||
##
|
||||
##
|
||||
enum SelectAction {
|
||||
kayomn marked this conversation as resolved
Outdated
|
||||
NONE,
|
||||
PRIMARY,
|
||||
SECONDARY,
|
||||
}
|
||||
|
||||
##
|
||||
## Supported selection input devices.
|
||||
##
|
||||
|
@ -54,7 +63,7 @@ var _cursor_point := Vector2.ZERO
|
|||
|
||||
var _is_drag_panning := false
|
||||
|
||||
var _is_selecting := false
|
||||
var _select_action := SelectAction.NONE
|
||||
|
||||
var _select_mode := SelectMode.NONE
|
||||
|
||||
|
@ -77,12 +86,25 @@ func _input(event: InputEvent) -> void:
|
|||
_is_drag_panning else Input.MOUSE_MODE_VISIBLE
|
||||
|
||||
MOUSE_BUTTON_LEFT:
|
||||
_is_selecting = event.is_pressed()
|
||||
if event.is_pressed():
|
||||
_select_action = SelectAction.PRIMARY
|
||||
|
||||
if _is_selecting:
|
||||
selection_started.emit()
|
||||
|
||||
else:
|
||||
_select_action = SelectAction.NONE
|
||||
|
||||
selection_stopped.emit()
|
||||
|
||||
MOUSE_BUTTON_RIGHT:
|
||||
if event.is_pressed():
|
||||
_select_action = SelectAction.SECONDARY
|
||||
|
||||
selection_started.emit()
|
||||
|
||||
else:
|
||||
_select_action = SelectAction.NONE
|
||||
|
||||
selection_stopped.emit()
|
||||
|
||||
return
|
||||
|
@ -173,14 +195,11 @@ func in_select_area() -> bool:
|
|||
return _select_mode != SelectMode.NONE
|
||||
|
||||
##
|
||||
## Returns [code]true[/code] if the player controller is currently selecting a location on the
|
||||
## screen, otherwise [code]false[/code].
|
||||
## Returns the [code]SelectAction[/code] currently being performed, or
|
||||
## [code]SelectAction.NONE[/code] if no action is currently being performed.
|
||||
##
|
||||
## *Note* that it is discouraged that this be continuously polled for single-fire events. Instead,
|
||||
## see [signal selection_started] and [signal selection_stopped].
|
||||
##
|
||||
func is_selecting() -> bool:
|
||||
return _is_selecting
|
||||
func get_select_action() -> SelectAction:
|
||||
return _select_action
|
||||
|
||||
##
|
||||
##
|
||||
|
|
Loading…
Reference in New Issue
Missing doc comment.