Compare commits

..

No commits in common. "7a8225240b943a5117e883d6f6029b5ca290a78c" and "9636d23dd0e5cb84ff7de1163d3d352207cf763f" have entirely different histories.

13 changed files with 143 additions and 93 deletions

BIN
local_player.scn (Stored with Git LFS)

Binary file not shown.

BIN
map_editor.scn (Stored with Git LFS)

Binary file not shown.

BIN
map_editor/paint_selector_button_group.res (Stored with Git LFS)

Binary file not shown.

BIN
map_editor/structure_button_group.res (Stored with Git LFS)

Binary file not shown.

View File

@ -37,8 +37,6 @@ const _ROTATE_CW := "player_controller_rotate_cw"
const _DRAG_SPEED_BASE_MODIFIER := 0.15 const _DRAG_SPEED_BASE_MODIFIER := 0.15
const _MOVE_SMOOTHING := 0.5
const _MOVE_SPEED_BASE_MODIFIER := 50.0 const _MOVE_SPEED_BASE_MODIFIER := 50.0
const _ROTATE_SPEED_BASE := 5.0 const _ROTATE_SPEED_BASE := 5.0
@ -48,8 +46,6 @@ const _TRANSFORM_DELTA := 10.0
@export @export
var _camera: Camera3D = null var _camera: Camera3D = null
var _control_override_count := 0
var _cursor_point := Vector2.ZERO var _cursor_point := Vector2.ZERO
var _is_drag_panning := false var _is_drag_panning := false
@ -62,40 +58,52 @@ var _select_mode := SelectMode.NONE
var _selection_area: Control = null var _selection_area: Control = null
@onready @onready
var _target_position := position var _target_position := self.position
@onready @onready
var _target_orientation := global_rotation.y var _target_orientation := self.global_rotation.y
##
## Smoothness applies to the interpolation toward rotation and movement target values.
##
@export
var movement_smoothing := 0.5
##
## Whether or not player movement input processed by the controller should be ignored.
##
@export
var frozen := false
func _input(event: InputEvent) -> void: func _input(event: InputEvent) -> void:
if event is InputEventMouseButton: if event is InputEventMouseButton:
match event.button_index: match event.button_index:
MOUSE_BUTTON_MIDDLE: MOUSE_BUTTON_MIDDLE:
_is_drag_panning = event.is_pressed() and not(is_frozen()) self._is_drag_panning = event.is_pressed() and not(self.frozen)
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED if\ Input.mouse_mode = Input.MOUSE_MODE_CAPTURED if\
_is_drag_panning else Input.MOUSE_MODE_VISIBLE self._is_drag_panning else Input.MOUSE_MODE_VISIBLE
MOUSE_BUTTON_LEFT: MOUSE_BUTTON_LEFT:
_is_selecting = event.is_pressed() self._is_selecting = event.is_pressed()
if _is_selecting: if self._is_selecting:
selection_started.emit() self.selection_started.emit()
else: else:
selection_stopped.emit() self.selection_stopped.emit()
return return
if (event is InputEventMouseMotion) and _is_drag_panning: if (event is InputEventMouseMotion) and self._is_drag_panning:
var global_basis := global_transform.basis var global_basis := self.global_transform.basis
var camera_settings := GameSettings.camera_settings var camera_settings := GameSettings.camera_settings
var dampened_speed := camera_settings.movement_speed_modifier * _DRAG_SPEED_BASE_MODIFIER var dampened_speed := camera_settings.movement_speed_modifier * _DRAG_SPEED_BASE_MODIFIER
_target_position += dampened_speed.y * (-global_basis.z) *\ self._target_position += dampened_speed.y * (-global_basis.z) *\
event.relative.y * (-1.0 if camera_settings.is_y_inverted else 1.0) event.relative.y * (-1.0 if camera_settings.is_y_inverted else 1.0)
_target_position += dampened_speed.x * (-global_basis.x) *\ self._target_position += dampened_speed.x * (-global_basis.x) *\
event.relative.x * (-1.0 if camera_settings.is_x_inverted else 1.0) event.relative.x * (-1.0 if camera_settings.is_x_inverted else 1.0)
return return
@ -107,70 +115,55 @@ func _input(event: InputEvent) -> void:
return return
func _process(delta: float) -> void: func _process(delta: float) -> void:
if not(is_frozen()): if not(self.frozen):
var global_basis := global_transform.basis var global_basis := self.global_transform.basis
var camera_settings := GameSettings.camera_settings var camera_settings := GameSettings.camera_settings
var delta_speed :=\ var delta_speed :=\
camera_settings.movement_speed_modifier * _MOVE_SPEED_BASE_MODIFIER * delta camera_settings.movement_speed_modifier * _MOVE_SPEED_BASE_MODIFIER * delta
_target_position += delta_speed.y * (-global_basis.z) *\ self._target_position += delta_speed.y * (-global_basis.z) *\
(Input.get_action_strength(_FORWARD) - Input.get_action_strength(_BACKWARD)) *\ (Input.get_action_strength(_FORWARD) - Input.get_action_strength(_BACKWARD)) *\
(-1.0 if camera_settings.is_y_inverted else 1.0) (-1.0 if camera_settings.is_y_inverted else 1.0)
_target_position += delta_speed.x * (-global_basis.x) *\ self._target_position += delta_speed.x * (-global_basis.x) *\
(Input.get_action_strength(_LEFT) - Input.get_action_strength(_RIGHT)) *\ (Input.get_action_strength(_LEFT) - Input.get_action_strength(_RIGHT)) *\
(-1.0 if camera_settings.is_y_inverted else 1.0) (-1.0 if camera_settings.is_y_inverted else 1.0)
_target_orientation += (Input.get_action_strength(_ROTATE_CCW) -\ self._target_orientation += (Input.get_action_strength(_ROTATE_CCW) -\
Input.get_action_strength(_ROTATE_CW)) * _ROTATE_SPEED_BASE *\ Input.get_action_strength(_ROTATE_CW)) * _ROTATE_SPEED_BASE *\
camera_settings.rotation_speed_modifier * delta camera_settings.rotation_speed_modifier * delta
global_transform = global_transform.interpolate_with( self.global_transform = self.global_transform.interpolate_with(
Transform3D(Basis(Vector3.UP, _target_orientation), _target_position), Transform3D(Basis(Vector3.UP, self._target_orientation), self._target_position),
delta * _TRANSFORM_DELTA * _MOVE_SMOOTHING) delta * _TRANSFORM_DELTA * self.movement_smoothing)
match _select_mode: match self._select_mode:
SelectMode.NONE: SelectMode.NONE:
_cursor_point = get_viewport().size / 2.0 self._cursor_point = self.get_viewport().size / 2.0
SelectMode.MOUSE: SelectMode.MOUSE:
_cursor_point = get_viewport().get_mouse_position() self._cursor_point = self.get_viewport().get_mouse_position()
func _ready() -> void: func _ready() -> void:
if _selection_area != null: if self._selection_area != null:
_selection_area.mouse_entered.connect(func () -> void: self._selection_area.mouse_entered.connect(func () -> void:
if _select_mode != SelectMode.MOUSE: if self._select_mode != SelectMode.MOUSE:
_select_mode = SelectMode.MOUSE self._select_mode = SelectMode.MOUSE
select_mode_changed.emit(SelectMode.MOUSE)) self.select_mode_changed.emit(SelectMode.MOUSE))
_selection_area.mouse_exited.connect(func () -> void: self._selection_area.mouse_exited.connect(func () -> void:
if _select_mode != SelectMode.NONE: if self._select_mode != SelectMode.NONE:
_select_mode = SelectMode.NONE self._select_mode = SelectMode.NONE
select_mode_changed.emit(SelectMode.NONE)) self.select_mode_changed.emit(SelectMode.NONE))
##
## Returns the position of the selection cursor with respect to the select current mode being used.
##
## When a mouse input device is being used, this will be its location in screen coordinates. For
## 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 is_frozen() -> bool:
assert(_control_override_count > -1, "control override count cannot be less than 0")
return _control_override_count != 0
## ##
## ##
## ##
func in_select_area() -> bool: func in_select_area() -> bool:
return _select_mode != SelectMode.NONE return self._select_mode != SelectMode.NONE
## ##
## Returns [code]true[/code] if the player controller is currently selecting a location on the ## Returns [code]true[/code] if the player controller is currently selecting a location on the
@ -180,19 +173,17 @@ func in_select_area() -> bool:
## see [signal selection_started] and [signal selection_stopped]. ## see [signal selection_started] and [signal selection_stopped].
## ##
func is_selecting() -> bool: func is_selecting() -> bool:
return _is_selecting return self._is_selecting
## ##
## Returns the position of the selection cursor with respect to the select current mode being used.
## ##
## When a mouse input device is being used, this will be its location in screen coordinates. For
## 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 override_controls(unlock_signal: Signal) -> void: func get_cursor_point() -> Vector2:
assert(_control_override_count > -1, "control override count cannot be less than 0") return self._cursor_point
_control_override_count += 1
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 ## Attempts to convert the screen coordinates in [code]screen_point[/code] into 2D worldspace
@ -202,9 +193,9 @@ func override_controls(unlock_signal: Signal) -> void:
## [code]null[/code] is returned. ## [code]null[/code] is returned.
## ##
func screen_to_plane(screen_point: Vector2) -> Variant: func screen_to_plane(screen_point: Vector2) -> Variant:
if _camera != null: if self._camera != null:
var plane_target = Plane(Vector3.UP, 0.0).intersects_ray( var plane_target = Plane(Vector3.UP, 0.0).intersects_ray(
_camera.global_position, _camera.project_ray_normal(screen_point)) self._camera.global_position, self._camera.project_ray_normal(screen_point))
if plane_target is Vector3: if plane_target is Vector3:
return Vector2(plane_target.x, plane_target.z) return Vector2(plane_target.x, plane_target.z)

View File

@ -8,6 +8,76 @@
config_version=5 config_version=5
_global_script_classes=[{
"base": "Control",
"class": &"ActionPrompt",
"language": &"GDScript",
"path": "res://user_interface/action_prompt.gd"
}, {
"base": "HFlowContainer",
"class": &"ItemSelection",
"language": &"GDScript",
"path": "res://user_interface/button_selection.gd"
}, {
"base": "VBoxContainer",
"class": &"MapEditorMenu",
"language": &"GDScript",
"path": "res://map_editor/map_editor_menu.gd"
}, {
"base": "Node3D",
"class": &"MeshGrid",
"language": &"GDScript",
"path": "res://mesh_grid.gd"
}, {
"base": "Node3D",
"class": &"PlayerController",
"language": &"GDScript",
"path": "res://player_controller.gd"
}, {
"base": "Control",
"class": &"SelectionPrompt",
"language": &"GDScript",
"path": "res://user_interface/selection_prompt.gd"
}, {
"base": "Node",
"class": &"Settings",
"language": &"GDScript",
"path": "res://settings.gd"
}, {
"base": "GeometryInstance3D",
"class": &"TerrainInstance3D",
"language": &"GDScript",
"path": "res://terrain/terrain_instance_3d.gd"
}, {
"base": "Node",
"class": &"TerrainMapCanvas",
"language": &"GDScript",
"path": "res://terrain/terrain_map_canvas.gd"
}, {
"base": "Resource",
"class": &"TerrainPaint",
"language": &"GDScript",
"path": "res://terrain/paints/terrain_paint.gd"
}, {
"base": "Control",
"class": &"WorkerPrompt",
"language": &"GDScript",
"path": "res://user_interface/worker_prompt.gd"
}]
_global_script_class_icons={
"ActionPrompt": "",
"ItemSelection": "",
"MapEditorMenu": "",
"MeshGrid": "",
"PlayerController": "",
"SelectionPrompt": "",
"Settings": "",
"TerrainInstance3D": "",
"TerrainMapCanvas": "",
"TerrainPaint": "",
"WorkerPrompt": ""
}
[application] [application]
config/name="Protectorate" config/name="Protectorate"
@ -46,32 +116,32 @@ enabled=PackedStringArray()
player_controller_left={ player_controller_left={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"unicode":0,"echo":false,"script":null)
] ]
} }
player_controller_right={ player_controller_right={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"unicode":0,"echo":false,"script":null)
] ]
} }
player_controller_forward={ player_controller_forward={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"unicode":0,"echo":false,"script":null)
] ]
} }
player_controller_backward={ player_controller_backward={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"unicode":0,"echo":false,"script":null)
] ]
} }
player_controller_rotate_cw={ player_controller_rotate_cw={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"unicode":0,"echo":false,"script":null)
] ]
} }
player_controller_rotate_ccw={ player_controller_rotate_ccw={
"deadzone": 0.5, "deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":81,"key_label":0,"unicode":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":81,"unicode":0,"echo":false,"script":null)
] ]
} }
editor_paint={ editor_paint={

BIN
terrain/paints/default_terrain_paint.res (Stored with Git LFS)

Binary file not shown.

Binary file not shown.

BIN
terrain/paints/dry_mud_terrain_paint.res (Stored with Git LFS)

Binary file not shown.

View File

@ -15,13 +15,13 @@ enum PaintSlot {
PAINT_3, PAINT_3,
} }
var _albedo_maps: Array[Texture2D] = [] var _albedo_maps: Array[Texture2D] = [null, null, null, null]
var _material := ShaderMaterial.new() var _material := ShaderMaterial.new()
var _mesh := PlaneMesh.new() var _mesh := PlaneMesh.new()
var _normal_maps: Array[Texture2D] = [] var _normal_maps: Array[Texture2D] = [null, null, null, null]
## ##
## Range of the height channel value, ranging from [code]0.0[/code] to [code]100.0[/code]. ## Range of the height channel value, ranging from [code]0.0[/code] to [code]100.0[/code].
@ -54,11 +54,6 @@ var size := Vector2i.ONE:
size = value size = value
func _init() -> void: func _init() -> void:
var paint_channels := PaintSlot.values().size()
_albedo_maps.resize(paint_channels)
_normal_maps.resize(paint_channels)
_material.shader = _SHADER _material.shader = _SHADER
_mesh.surface_set_material(0, _material) _mesh.surface_set_material(0, _material)

View File

@ -36,7 +36,6 @@ func _ready() -> void:
## ##
## ##
func prompt() -> void: func prompt() -> void:
LocalPlayer.override_controls(hidden)
show() show()
prompted.emit() prompted.emit()

View File

@ -57,7 +57,6 @@ func get_button_group() -> ButtonGroup:
## [member get_button_group] ## [member get_button_group]
## ##
func prompt(initial_selection: int) -> void: func prompt(initial_selection: int) -> void:
LocalPlayer.override_controls(hidden)
assert(_button_group != null, "button group cannot be null") assert(_button_group != null, "button group cannot be null")
var selected_button := _button_group.get_buttons()[initial_selection] var selected_button := _button_group.get_buttons()[initial_selection]

View File

@ -23,7 +23,6 @@ var progress: Range = null
## ##
## ##
func prompt(display_message: String, steps: Array) -> void: func prompt(display_message: String, steps: Array) -> void:
LocalPlayer.override_controls(hidden)
show() show()
prompted.emit() prompted.emit()