Compare commits
3 Commits
3af575298d
...
6bf34c13c5
Author | SHA1 | Date |
---|---|---|
kayomn | 6bf34c13c5 | |
kayomn | 8d014d69a9 | |
kayomn | 821c1ac8c4 |
|
@ -5,7 +5,7 @@ const _CHUNK_SIZE := 32
|
|||
const _GRID_ORIGIN := Vector2(0.5, 0.5)
|
||||
|
||||
##
|
||||
##
|
||||
## Cardinal orientation referencing the direction of a tile.
|
||||
##
|
||||
enum Orientation {
|
||||
NORTH,
|
||||
|
@ -22,7 +22,7 @@ class Chunk:
|
|||
|
||||
var _floor_orientation := PackedInt32Array()
|
||||
|
||||
var _multimesh_instances: Array[MultiMeshInstance] = []
|
||||
var _multi_mesh_instances: Array[MultiMeshInstance] = []
|
||||
|
||||
var _wall_meshes: Array[Mesh] = []
|
||||
|
||||
|
@ -41,11 +41,11 @@ class Chunk:
|
|||
##
|
||||
func invalidate(interior_map: InteriorMap, coordinate: Vector2i) -> void:
|
||||
# TODO: Once this is all lowered into native code, look for ways to parallelize the loops.
|
||||
for multimesh_instance in _multimesh_instances:
|
||||
RenderingServer.free_rid(multimesh_instance._instance_rid)
|
||||
RenderingServer.free_rid(multimesh_instance._multimesh_rid)
|
||||
for multi_mesh_instance in _multi_mesh_instances:
|
||||
RenderingServer.free_rid(multi_mesh_instance._instance_rid)
|
||||
RenderingServer.free_rid(multi_mesh_instance._multimesh_rid)
|
||||
|
||||
_multimesh_instances.clear()
|
||||
_multi_mesh_instances.clear()
|
||||
|
||||
# Normalize mesh instance data for the chunk.
|
||||
var transforms_by_mesh := {}
|
||||
|
@ -85,11 +85,11 @@ class Chunk:
|
|||
var global_transform := interior_map.global_transform
|
||||
|
||||
for chunk_mesh in transforms_by_mesh:
|
||||
var multimesh_instance := MultiMeshInstance.new(
|
||||
var multi_mesh_instance := MultiMeshInstance.new(
|
||||
scenario_rid, chunk_mesh.get_rid(), transforms_by_mesh[chunk_mesh])
|
||||
|
||||
multimesh_instance.set_offset(global_transform)
|
||||
_multimesh_instances.append(multimesh_instance)
|
||||
multi_mesh_instance.set_offset(global_transform)
|
||||
_multi_mesh_instances.append(multi_mesh_instance)
|
||||
|
||||
##
|
||||
## Sets the floor mesh in the chunk at the location relative [code]coordinatess[/code] to
|
||||
|
@ -140,11 +140,17 @@ class MultiMeshInstance:
|
|||
RenderingServer.multimesh_instance_set_transform(_multimesh_rid, i, transforms[i])
|
||||
|
||||
##
|
||||
## Sets the parent transform of all mesh instances under it to [code]offset[/code].
|
||||
## Sets the transform of the instance to [code]offset[/code].
|
||||
##
|
||||
func set_offset(offset: Transform3D) -> void:
|
||||
RenderingServer.instance_set_transform(_instance_rid, offset)
|
||||
|
||||
##
|
||||
## Sets the visibility of the instance to [code]is_visible[/code].
|
||||
##
|
||||
func set_visible(is_visible: bool) -> void:
|
||||
RenderingServer.instance_set_visible(_instance_rid, is_visible)
|
||||
|
||||
var _chunks: Array[Chunk] = []
|
||||
|
||||
var _chunks_size := Vector2i.ZERO
|
||||
|
@ -172,11 +178,17 @@ func _notification(what: int) -> void:
|
|||
match what:
|
||||
NOTIFICATION_TRANSFORM_CHANGED:
|
||||
for chunk in _chunks:
|
||||
for multimesh_instance in chunk._multimesh_instances:
|
||||
multimesh_instance.set_offset_transform(global_transform)
|
||||
for multi_mesh_instance in chunk._multi_mesh_instances:
|
||||
multi_mesh_instance.set_offset_transform(global_transform)
|
||||
|
||||
NOTIFICATION_VISIBILITY_CHANGED:
|
||||
for chunk in _chunks:
|
||||
for multi_mesh_instance in chunk._multi_mesh_instances:
|
||||
multi_mesh_instance.set_visible(visible)
|
||||
|
||||
##
|
||||
## Clears the entirety of the tile grid to only contain [code]tile[/code].
|
||||
## Clears the entirety of the tile grid to only contain tiles of instance [code]tile[/code] pointing
|
||||
## in the orientation of [code]orientation[/code].
|
||||
##
|
||||
## For clearing a specific region of the mesh grid, see [method fill_mesh].
|
||||
##
|
||||
|
@ -218,7 +230,8 @@ func clear_tiles(orientation: Orientation, tile: InteriorTile) -> void:
|
|||
_get_chunk(chunk_coordinate).invalidate(self, chunk_coordinate)
|
||||
|
||||
##
|
||||
## Clears the region of the tile grid at [code]area[/code] to only contain [code]tile[/code].
|
||||
## Clears the region of the tile grid at [code]area[/code] to only contain instances of
|
||||
## [code]tile[/code] pointing in the orientation of [code]orientation[/code].
|
||||
##
|
||||
## *Note* that [code]area[/code] *must* be within the area of the of the mesh grid, where
|
||||
## [code]Vector2i.ZERO[/code] is the top-left and [member size] [code]- 1[/code] is the bottom-
|
||||
|
@ -282,14 +295,14 @@ func fill_tiles(area: Rect2i, orientation: Orientation, tile: InteriorTile) -> v
|
|||
_get_chunk(chunk_coordinate).invalidate(self, chunk_coordinate)
|
||||
|
||||
##
|
||||
##
|
||||
## Returns the area of the interior map based on its current size.
|
||||
##
|
||||
func get_area() -> Rect2i:
|
||||
return Rect2i(Vector2i.ZERO, size)
|
||||
|
||||
##
|
||||
## Plots a single tile at [code]coordinates[/code] to be [code]tile[/code], overwriting whatever it
|
||||
## previously contained.
|
||||
## Plots a single tile at [code]coordinates[/code] to be an instance of [code]tile[/code] pointing
|
||||
## in the orientation of [code]orientation[/code], overwriting whatever it previously contained.
|
||||
##
|
||||
## *Note* that [code]coordinates[/code] *must* be within the area of the of the mesh grid, where
|
||||
## [code]Vector2i.ZERO[/code] is the top-left and [member size] [code]- 1[/code] is the bottom-
|
||||
|
@ -324,9 +337,3 @@ func plot_tile(coordinates: Vector2i, orientation: Orientation, tile: InteriorTi
|
|||
InteriorTile.Kind.WALL:
|
||||
chunk.set_wall_mesh(coordinates % _CHUNK_SIZE, orientation, mesh)
|
||||
chunk.invalidate(self, chunk_coordinates)
|
||||
|
||||
##
|
||||
##
|
||||
##
|
||||
func world_to_grid(world_position: Vector2) -> Vector2i:
|
||||
return Vector2i((world_position + (Vector2(size) * _GRID_ORIGIN)).round())
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class_name InteriorTile extends Resource
|
||||
|
||||
##
|
||||
##
|
||||
## Identifier for the kind of interior tile.
|
||||
##
|
||||
enum Kind {
|
||||
FLOOR,
|
||||
|
@ -9,19 +9,21 @@ enum Kind {
|
|||
}
|
||||
|
||||
##
|
||||
##
|
||||
## Flag for determining if the tile is affected by orientations specified in an [InteriorMap].
|
||||
##
|
||||
@export
|
||||
var fixed_orientation := false
|
||||
|
||||
##
|
||||
## See [enum Kind].
|
||||
##
|
||||
## Interior tiles of different kinds will not conflict when placing them.
|
||||
##
|
||||
@export
|
||||
var kind := Kind.FLOOR
|
||||
|
||||
##
|
||||
##
|
||||
## Used to visualize the interior tile.
|
||||
##
|
||||
@export
|
||||
var mesh: Mesh = null
|
||||
|
|
BIN
map_editor.scn (Stored with Git LFS)
BIN
map_editor.scn (Stored with Git LFS)
Binary file not shown.
|
@ -1,7 +1,10 @@
|
|||
class_name PlayerController extends Node3D
|
||||
|
||||
##
|
||||
## Selection action performed.
|
||||
##
|
||||
## [code]PRIMARY[/code] refers to the default selection action, while [code]SECONDARY[/code] refers
|
||||
## to the secondary selection action.
|
||||
##
|
||||
enum SelectAction {
|
||||
PRIMARY,
|
||||
|
@ -22,7 +25,10 @@ enum SelectMode {
|
|||
signal select_mode_changed(mode: SelectMode)
|
||||
|
||||
##
|
||||
## Selection of a point on screenspace has started happening.
|
||||
## Selection of a point on the screen space has started happening, with [code]select_action[/code]
|
||||
## as selection action performed.
|
||||
##
|
||||
## See [enum SelectAction] for more details.
|
||||
##
|
||||
signal selection_started(select_action: SelectAction)
|
||||
|
||||
|
@ -179,19 +185,18 @@ func get_plane_cursor() -> Vector2:
|
|||
|
||||
return Vector2.ZERO
|
||||
|
||||
##
|
||||
## Returns [code]true[/code] if the player controller is currently frozen, otherwise
|
||||
## [code]false[/code].
|
||||
##
|
||||
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:
|
||||
return _select_mode != SelectMode.NONE
|
||||
|
||||
##
|
||||
##
|
||||
## Overrides the controls of the player controller. When [code]unlock_signal[/code] is emitted, the
|
||||
## override is released.
|
||||
##
|
||||
func override_controls(unlock_signal: Signal) -> void:
|
||||
assert(_control_override_count > -1, "control override count cannot be less than 0")
|
||||
|
|
|
@ -2,18 +2,21 @@
|
|||
class_name ActionPrompt extends Control
|
||||
|
||||
##
|
||||
##
|
||||
## The prompt accept button has been pressed.
|
||||
##
|
||||
signal prompt_accepted()
|
||||
|
||||
##
|
||||
##
|
||||
## The prompt has been started.
|
||||
##
|
||||
signal prompted()
|
||||
|
||||
@export
|
||||
var _accept_button: BaseButton = null
|
||||
|
||||
##
|
||||
## The initial control focused on when it is prompted or [code]null[/code] for no default.
|
||||
##
|
||||
@export
|
||||
var initial_focus: Control = null
|
||||
|
||||
|
@ -33,7 +36,9 @@ func _ready() -> void:
|
|||
hide())
|
||||
|
||||
##
|
||||
## Starts the prompt, emitting [signal prompted].
|
||||
##
|
||||
## [signal prompt_accepted] is emitted when the accept button in the action prompt is pressed.
|
||||
##
|
||||
func prompt() -> void:
|
||||
LocalPlayer.override_controls(hidden)
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
class_name SelectionPrompt extends Control
|
||||
|
||||
##
|
||||
##
|
||||
## The prompt has been started.
|
||||
##
|
||||
signal prompted()
|
||||
|
||||
##
|
||||
##
|
||||
## The item at index [code]selected_item[/code] has been selected in the prompt.
|
||||
##
|
||||
signal prompt_selected(selected_item: int)
|
||||
|
||||
|
|
|
@ -1,31 +1,33 @@
|
|||
class_name WorkerPrompt extends Control
|
||||
|
||||
##
|
||||
##
|
||||
## The work being performed by the prompt has ended.
|
||||
##
|
||||
signal prompt_completed()
|
||||
|
||||
##
|
||||
##
|
||||
## The prompt has been started.
|
||||
##
|
||||
signal prompted()
|
||||
|
||||
var _worker_thread := Thread.new()
|
||||
|
||||
##
|
||||
##
|
||||
## Used to display a message from the prompt or [code]null[/code] to not display anything.
|
||||
##
|
||||
@export
|
||||
var label: Label = null
|
||||
|
||||
##
|
||||
##
|
||||
## Used to display the progress of the prompt or [code]null[/code] to not display anything.
|
||||
##
|
||||
@export
|
||||
var progress: Range = null
|
||||
|
||||
##
|
||||
## Starts the prompt, emitting [signal prompted].
|
||||
##
|
||||
## [signal prompt_completed] is emitted when the work being performed by the prompt has ended.
|
||||
##
|
||||
func prompt(display_message: String, steps: Array) -> void:
|
||||
LocalPlayer.override_controls(hidden)
|
||||
|
|
Loading…
Reference in New Issue