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,17 +1,5 @@
|
|||
class_name MapEditorMenu extends VBoxContainer
|
||||
|
||||
##
|
||||
## [code]edit_action[/code] has been activated for use when the player interacts with the map
|
||||
## editor.
|
||||
##
|
||||
signal edit_activated(edit_action: Callable)
|
||||
|
||||
##
|
||||
## Emits [signal edit_activated].
|
||||
##
|
||||
func activate_editor(edit_action: Callable) -> void:
|
||||
edit_activated.emit(edit_action)
|
||||
|
||||
##
|
||||
## Resets the state of the menu.
|
||||
##
|
||||
|
|
Binary file not shown.
|
@ -1,12 +0,0 @@
|
|||
shader_type spatial;
|
||||
render_mode unshaded, blend_add, cull_disabled;
|
||||
|
||||
uniform sampler2D source_texture;
|
||||
|
||||
uniform vec4 modulate: source_color = vec4(1.0);
|
||||
|
||||
void fragment() {
|
||||
vec4 source = texture(source_texture, UV);
|
||||
ALBEDO = (source.rgb * modulate.rgb);
|
||||
ALPHA = source.a;
|
||||
}
|
BIN
map_editor/tile_cursor.res (Stored with Git LFS)
BIN
map_editor/tile_cursor.res (Stored with Git LFS)
Binary file not shown.
Binary file not shown.
|
@ -4,7 +4,6 @@ class_name PlayerController extends Node3D
|
|||
##
|
||||
##
|
||||
enum SelectAction {
|
||||
kayomn marked this conversation as resolved
Outdated
|
||||
NONE,
|
||||
PRIMARY,
|
||||
SECONDARY,
|
||||
}
|
||||
|
@ -25,7 +24,7 @@ signal select_mode_changed(mode: SelectMode)
|
|||
##
|
||||
## Selection of a point on screenspace has started happening.
|
||||
##
|
||||
signal selection_started()
|
||||
signal selection_started(select_action: SelectAction)
|
||||
kayomn marked this conversation as resolved
Outdated
kayomn
commented
Purpose of Purpose of `select_action` is not explained in doc comment.
|
||||
|
||||
##
|
||||
## Selection of a point on screenspace has stopped happening.
|
||||
|
@ -63,8 +62,6 @@ var _cursor_point := Vector2.ZERO
|
|||
|
||||
var _is_drag_panning := false
|
||||
|
||||
var _select_action := SelectAction.NONE
|
||||
|
||||
var _select_mode := SelectMode.NONE
|
||||
|
||||
@export
|
||||
|
@ -76,58 +73,6 @@ var _target_position := position
|
|||
@onready
|
||||
var _target_orientation := global_rotation.y
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
match event.button_index:
|
||||
MOUSE_BUTTON_MIDDLE:
|
||||
_is_drag_panning = event.is_pressed() and not(is_frozen())
|
||||
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED if\
|
||||
_is_drag_panning else Input.MOUSE_MODE_VISIBLE
|
||||
|
||||
MOUSE_BUTTON_LEFT:
|
||||
if event.is_pressed():
|
||||
_select_action = SelectAction.PRIMARY
|
||||
|
||||
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
|
||||
|
||||
if (event is InputEventMouseMotion) and _is_drag_panning:
|
||||
var global_basis := global_transform.basis
|
||||
var camera_settings := GameSettings.camera_settings
|
||||
var dampened_speed := camera_settings.movement_speed_modifier * _DRAG_SPEED_BASE_MODIFIER
|
||||
|
||||
_target_position += dampened_speed.y * (-global_basis.z) *\
|
||||
event.relative.y * (-1.0 if camera_settings.is_y_inverted else 1.0)
|
||||
|
||||
_target_position += dampened_speed.x * (-global_basis.x) *\
|
||||
event.relative.x * (-1.0 if camera_settings.is_x_inverted else 1.0)
|
||||
|
||||
return
|
||||
|
||||
if event is InputEventScreenDrag:
|
||||
return
|
||||
|
||||
if event is InputEventScreenTouch:
|
||||
return
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if not(is_frozen()):
|
||||
var global_basis := global_transform.basis
|
||||
|
@ -173,6 +118,50 @@ func _ready() -> void:
|
|||
|
||||
select_mode_changed.emit(SelectMode.NONE))
|
||||
|
||||
_selection_area.gui_input.connect(func (event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
match event.button_index:
|
||||
MOUSE_BUTTON_MIDDLE:
|
||||
_is_drag_panning = event.is_pressed() and not(is_frozen())
|
||||
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED if\
|
||||
_is_drag_panning else Input.MOUSE_MODE_VISIBLE
|
||||
|
||||
MOUSE_BUTTON_LEFT:
|
||||
if event.is_pressed():
|
||||
selection_started.emit(SelectAction.PRIMARY)
|
||||
|
||||
else:
|
||||
selection_stopped.emit()
|
||||
|
||||
MOUSE_BUTTON_RIGHT:
|
||||
if event.is_pressed():
|
||||
selection_started.emit(SelectAction.SECONDARY)
|
||||
|
||||
else:
|
||||
selection_stopped.emit()
|
||||
|
||||
return
|
||||
|
||||
if (event is InputEventMouseMotion) and _is_drag_panning:
|
||||
var global_basis := global_transform.basis
|
||||
var camera_settings := GameSettings.camera_settings
|
||||
var dampened_speed := camera_settings.movement_speed_modifier * _DRAG_SPEED_BASE_MODIFIER
|
||||
|
||||
_target_position += dampened_speed.y * (-global_basis.z) *\
|
||||
event.relative.y * (-1.0 if camera_settings.is_y_inverted else 1.0)
|
||||
|
||||
_target_position += dampened_speed.x * (-global_basis.x) *\
|
||||
event.relative.x * (-1.0 if camera_settings.is_x_inverted else 1.0)
|
||||
|
||||
return
|
||||
|
||||
if event is InputEventScreenDrag:
|
||||
return
|
||||
|
||||
if event is InputEventScreenTouch:
|
||||
return)
|
||||
|
||||
##
|
||||
## Returns the position of the selection cursor with respect to the select current mode being used.
|
||||
##
|
||||
|
@ -180,8 +169,15 @@ func _ready() -> void:
|
|||
## touchscreen interactions, this will be the location of an active gesture. Finally, for all other
|
||||
## states - including gamepad - this will be the middle of screenspace at all times.
|
||||
##
|
||||
func get_cursor_point() -> Vector2:
|
||||
return _cursor_point
|
||||
func get_plane_cursor() -> Vector2:
|
||||
if _camera != null:
|
||||
var plane_cursor = Plane(Vector3.UP, 0.0).intersects_ray(
|
||||
_camera.global_position, _camera.project_ray_normal(_cursor_point))
|
||||
|
||||
if plane_cursor is Vector3:
|
||||
return Vector2(plane_cursor.x, plane_cursor.z)
|
||||
|
||||
return Vector2.ZERO
|
||||
|
||||
func is_frozen() -> bool:
|
||||
kayomn marked this conversation as resolved
Outdated
kayomn
commented
Missing doc comment. Missing doc comment.
|
||||
assert(_control_override_count > -1, "control override count cannot be less than 0")
|
||||
|
@ -194,13 +190,6 @@ func is_frozen() -> bool:
|
|||
func in_select_area() -> bool:
|
||||
kayomn marked this conversation as resolved
Outdated
kayomn
commented
Missing doc comment. Missing doc comment.
|
||||
return _select_mode != SelectMode.NONE
|
||||
|
||||
##
|
||||
## Returns the [code]SelectAction[/code] currently being performed, or
|
||||
## [code]SelectAction.NONE[/code] if no action is currently being performed.
|
||||
##
|
||||
func get_select_action() -> SelectAction:
|
||||
return _select_action
|
||||
|
||||
##
|
||||
##
|
||||
##
|
||||
|
@ -212,20 +201,3 @@ func override_controls(unlock_signal: Signal) -> void:
|
|||
unlock_signal.connect(func () -> void:
|
||||
assert(_control_override_count > 0, "control override count cannot be less than 1")
|
||||
_control_override_count -= 1, Object.CONNECT_ONE_SHOT)
|
||||
|
||||
##
|
||||
## Attempts to convert the screen coordinates in [code]screen_point[/code] into 2D worldspace
|
||||
## coordinate relative to an infinite ground plane at y offset [code]0.0[/code].
|
||||
##
|
||||
## Successful point intersection will return the plane coordinates in a [class Vector2], otherwise
|
||||
## [code]null[/code] is returned.
|
||||
##
|
||||
func screen_to_plane(screen_point: Vector2) -> Variant:
|
||||
if _camera != null:
|
||||
var plane_target = Plane(Vector3.UP, 0.0).intersects_ray(
|
||||
_camera.global_position, _camera.project_ray_normal(screen_point))
|
||||
|
||||
if plane_target is Vector3:
|
||||
return Vector2(plane_target.x, plane_target.z)
|
||||
|
||||
return null
|
||||
|
|
Loading…
Reference in New Issue
Missing doc comment.