18 Commits

Author SHA1 Message Date
  Ryan Reed 796b623f89 chore: Bump version 0.1.2 -> 0.2.0 3 weeks ago
  Ryan Reed 207932d643 Inventory and Quickslots Rework (#24) 3 weeks ago
  Ryan Reed 5ed31e57d7 chore: Bump version 0.1.1 -> 0.1.2 3 weeks ago
  Ryan Reed 5257fa7fe1 feat: Update default night/day colors and time of day 3 weeks ago
  Ryan Reed 73fe4fa6c7 fix: Autosaves not working if saves path does not exist 3 weeks ago
  Ryan Reed 6ca52a9233 fix: default item_texture value 3 weeks ago
  Ryan Reed 89d9f46fc2 Bumping to version 0.1.1 4 weeks ago
  Ryan Reed 37849199ce Merge pull request 'Replacing Fullscreen with Window Mode' (#23) from window-mode into master 4 weeks ago
  Ryan Reed 23b303822f Replacing Fullscreen with Window Mode 4 weeks ago
  Ryan Reed eef494d646 Add LifetimeTimer to DroppedBlocks 4 weeks ago
  Ryan Reed d3c013f35c Updating is_valid_placement_target() logic 4 weeks ago
  Ryan Reed 5495d8892e Tweak is_valid_placement() 1 month ago
  Ryan Reed 25e06c7bf1 Minor cleanup 1 month ago
  Ryan Reed 5d8540003e Merge pull request 'Fix: Placing block where player is occupying' (#22) from fix-player-block-placement into master 1 month ago
  Ryan Reed 0bd79ee992 Disallow placing blocks where player is located 1 month ago
  Ryan Reed d3a651816a Updating wood texture to reduce tiling seams 1 month ago
  Ryan Reed 1688e445c5 Moving PREFABs out of Globals and removing Globals autoload 1 month ago
  Ryan Reed 13a90dfe13 Removing old variables 1 month ago
42 changed files with 702 additions and 320 deletions
Split View
  1. +1
    -0
      addons/save_load_system/autoloads/save_game_manager.gd
  2. BIN
      assets/textures/wood-block.png
  3. BIN
      assets/textures/wood.png
  4. +1
    -0
      autoloads/db_items.gd
  5. +7
    -10
      autoloads/game_settings_manager.gd
  6. +0
    -9
      autoloads/globals.gd
  7. +0
    -1
      autoloads/globals.gd.uid
  8. +186
    -9
      autoloads/inventory_manager.gd
  9. +1
    -2
      project.godot
  10. +3
    -1
      resources/blocks/005_grass.tres
  11. +3
    -1
      resources/db_item_resource.gd
  12. +3
    -2
      resources/game_settings/graphics_settings_resource.gd
  13. +40
    -7
      resources/inventory/player_inventory_testing.tres
  14. +0
    -1
      resources/inventory_resource.gd
  15. +5
    -0
      resources/item_resource.gd
  16. +1
    -0
      resources/item_resource.gd.uid
  17. +14
    -0
      resources/items/007_torch.tres
  18. +1
    -1
      resources/world/sky_horizon_color_gradient.tres
  19. +1
    -1
      resources/world/sky_top_color_gradient.tres
  20. +1
    -0
      scenes/blocks/block.gd
  21. +11
    -0
      scenes/blocks/dropped_block.gd
  22. +6
    -1
      scenes/blocks/dropped_block.tscn
  23. +23
    -0
      scenes/items/torch.tscn
  24. +31
    -10
      scenes/player/player.gd
  25. +3
    -2
      scenes/player/player.tscn
  26. +28
    -4
      scenes/player/ray_cast_look.gd
  27. +65
    -43
      scenes/ui/inventory/inventory.gd
  28. +8
    -5
      scenes/ui/inventory/inventory.tscn
  29. +30
    -4
      scenes/ui/inventory/item_rect.gd
  30. +18
    -10
      scenes/ui/inventory/item_rect.tscn
  31. +10
    -7
      scenes/ui/pause_menu/settings_menu.gd
  32. +18
    -8
      scenes/ui/pause_menu/settings_menu.tscn
  33. +0
    -157
      scenes/ui/quick_slots.tscn
  34. +34
    -20
      scenes/ui/quickslots/quick_slots.gd
  35. +0
    -0
      scenes/ui/quickslots/quick_slots.gd.uid
  36. +63
    -0
      scenes/ui/quickslots/quick_slots.tscn
  37. +40
    -0
      scenes/ui/quickslots/quickslots_slot.gd
  38. +1
    -0
      scenes/ui/quickslots/quickslots_slot.gd.uid
  39. +36
    -0
      scenes/ui/quickslots/quickslots_slot.tscn
  40. +6
    -2
      scenes/ui/ui.tscn
  41. +2
    -2
      scenes/world/world.gd
  42. +1
    -0
      scenes/world/world.tscn

+ 1
- 0
addons/save_load_system/autoloads/save_game_manager.gd View File

@ -186,6 +186,7 @@ func _rotate_autosaves() -> void:
var saves_dir = DirAccess.open(_save_game_settings.save_game_data_path)
if saves_dir == null:
DirAccess.make_dir_absolute(_save_game_settings.save_game_data_path)
saves_dir = DirAccess.open(_save_game_settings.save_game_data_path)
var autosaves: Array[String] = []
for filename in saves_dir.get_files():


BIN
assets/textures/wood-block.png View File

Before After
Width: 48  |  Height: 32  |  Size: 685 B Width: 48  |  Height: 32  |  Size: 679 B

BIN
assets/textures/wood.png View File

Before After
Width: 16  |  Height: 16  |  Size: 700 B Width: 16  |  Height: 16  |  Size: 238 B

+ 1
- 0
autoloads/db_items.gd View File

@ -8,4 +8,5 @@ extends Node
"004": preload("res://resources/blocks/004_leaves.tres"),
"005": preload("res://resources/blocks/005_grass.tres"),
"006": preload("res://resources/blocks/006_glass.tres"),
"007": preload("res://resources/items/007_torch.tres"),
}

+ 7
- 10
autoloads/game_settings_manager.gd View File

@ -12,10 +12,10 @@ signal game_options_waila_changed(waila_enabled: bool)
#region Graphics Settings Signals
signal apply_graphics_settings
signal graphics_fov_changed(fov: int)
signal graphics_resolution_changed(resolution: Vector2i, id: int)
signal graphics_fullscreen_changed(fullscreen_enabled: bool)
signal graphics_vsync_changed(vsync_enabled: bool)
signal graphics_fov_changed(fov: int)
signal graphics_window_mode_changed(mode_id: int)
#endregion
signal load_game_settings
@ -43,8 +43,8 @@ func _init() -> void:
game_options_waila_changed.connect(_on_game_options_waila_changed)
graphics_fov_changed.connect(_on_graphics_fov_changed)
graphics_fullscreen_changed.connect(_on_graphics_fullscreen_changed)
graphics_resolution_changed.connect(_on_graphics_resolution_changed)
graphics_window_mode_changed.connect(_on_graphics_window_mode_changed)
graphics_vsync_changed.connect(_on_graphics_vsync_changed)
apply_graphics_settings.connect(_on_apply_graphics_settings)
@ -80,10 +80,7 @@ func _on_game_options_waila_changed(waila_enabled: bool) -> void:
#region Graphics Settings
func _on_apply_graphics_settings() -> void:
if settings.graphics.fullscreen:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_FULLSCREEN)
else:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
DisplayServer.window_set_mode(settings.graphics.window_mode)
get_window().size = settings.graphics.resolution
@ -97,15 +94,15 @@ func _on_apply_graphics_settings() -> void:
func _on_graphics_fov_changed(fov: int) -> void:
settings.graphics.fov = fov
func _on_graphics_fullscreen_changed(fullscreen_enabled: bool) -> void:
settings.graphics.fullscreen = fullscreen_enabled
func _on_graphics_resolution_changed(resolution: Vector2i, id: int) -> void:
settings.graphics.resolution = resolution
settings.graphics.resolution_id = id
func _on_graphics_vsync_changed(vsync_enabled: bool) -> void:
settings.graphics.vsync = vsync_enabled
func _on_graphics_window_mode_changed(id: int) -> void:
settings.graphics.window_mode = id as DisplayServer.WindowMode
#endregion


+ 0
- 9
autoloads/globals.gd View File

@ -1,9 +0,0 @@
extends Node
const BLOCK_PREFAB: PackedScene = preload("res://scenes/blocks/block.tscn")
const DROPPED_BLOCK_PREFAB: PackedScene = preload("res://scenes/blocks/dropped_block.tscn")
# TODO: Move the following into the GameSettingsManager
var enable_waila: bool = true ## Enable `What Am I Looking At` UI
var enable_block_highlight: bool = true

+ 0
- 1
autoloads/globals.gd.uid View File

@ -1 +0,0 @@
uid://cp6sum1t6el0a

+ 186
- 9
autoloads/inventory_manager.gd View File

@ -1,20 +1,197 @@
extends Node
signal item_dropped(item: DBItemResource)
signal item_picked_up(item: DBItemResource)
#region Inventory Specific
signal add_to_inventory(item_id: String, amount: int)
signal clear_inventory ## Remove all items in inventory
signal item_added(item_id: String, amount: int)
signal item_removed(item_id: String, amount: int)
signal inventory_closed
signal inventory_opened
signal inventory_slot_updated(slot_index: int)
signal remove_from_inventory(item_id: String, amount: int)
signal remove_from_quickslot(amount: int)
signal remove_from_slot(slot_index: int, amount: int)
#endregion
#region Quickslots
signal next_quick_slot
signal previous_quick_slot
signal quick_slot_selected(slot_index: int)
signal select_quick_slot(slot_index: int)
signal quick_slot_item_changed(item_id: String)
signal item_picked_up(item: DBItemResource)
signal item_dropped(item: DBItemResource)
signal inventory_opened
signal inventory_closed
#endregion
var quick_slot_item_id: String = "001"
var max_inventory_items: int = 40 # 4 rows of 10
var quick_slot_count: int = 10
var selected_quick_slot: int = 0
var inventory: Array[DBItemResource] = [] ## To ensure inventory is automatically sorted, "empty" inventory cells will be replaced with null to keep positions
var _inventory_cache: Dictionary[String, Dictionary] = {} ## Used for caching certain information
func _ready() -> void:
self.quick_slot_item_changed.connect(_on_quick_slot_item_changed)
self.item_picked_up.connect(_on_item_picked_up)
self.item_dropped.connect(_on_item_dropped)
self.add_to_inventory.connect(_on_add_to_inventory)
self.clear_inventory.connect(_on_clear_inventory)
self.quick_slot_selected.connect(_on_quick_slot_selected)
self.remove_from_inventory.connect(_on_remove_from_inventory)
self.remove_from_quickslot.connect(_on_remove_from_quickslot)
self.remove_from_slot.connect(_on_remove_from_slot)
func available_space(item_id: String) -> int:
var full_stacks: int = floor(_inventory_cache[item_id].total / DBItems.data[item_id].max_stack_size)
var space_in_stacks: int = (
DBItems.data[item_id].max_stack_size - abs(
_inventory_cache[item_id].total - (DBItems.data[item_id].max_stack_size * full_stacks)
)
)
# This is a bit of a hack because I'm a math/logic noob
if space_in_stacks == DBItems.data[item_id].max_stack_size:
space_in_stacks = 0
var open_stack_amount: int = (max_inventory_items - inventory.size()) * DBItems.data[item_id].max_stack_size
return open_stack_amount + space_in_stacks
func get_inventory_item(item_slot: int = selected_quick_slot) -> DBItemResource:
if item_slot >= inventory.size() or item_slot < 0:
return null
return inventory.get(item_slot)
func get_quick_slot_item_id(item_slot: int = selected_quick_slot) -> String:
return inventory[item_slot].id
func _find_stacks_by_id(item_resource: DBItemResource, item_id: String) -> bool:
return item_resource != null and item_resource.id == item_id
## Find the stack where at least one item can be added
func _find_stacks_with_space(item_resource: DBItemResource, item_id: String) -> bool:
return (
item_resource == null or (
item_resource.id == item_id and
item_resource.amount < item_resource.max_stack_size
)
)
## Removes an amount of items from a specific slot
## If the amount exceeds the amount of the slot, will NOT remove from other stacks
func _remove_from_slot(slot_index: int, amount: int) -> void:
if slot_index >= max_inventory_items:
printerr("Slot Index ", slot_index, " out of inventory range")
return
inventory[slot_index].amount -= amount
if inventory[slot_index].amount <= 0:
inventory[slot_index] = null
inventory_slot_updated.emit(slot_index)
func _update_cache_total(item_id: String, amount: int) -> void:
if not _inventory_cache.get(item_id):
_inventory_cache[item_id] = {"total": 0}
_inventory_cache[item_id].total += amount
func _on_add_to_inventory(item_id: String, amount: int = 1) -> void:
if not DBItems.data.get(item_id):
printerr("Cannot add item, ", item_id, ", to inventory. Could not find item within DBItems.data.")
return
if amount < 1:
printerr("Cannot add item, ", item_id, ", to inventory. Amount to add cannot be less then 1.")
return
var item_resource: DBItemResource = DBItems.data[item_id]
# This logic seems overly complicated and is a mess.
# Should look into fixing/simplifying this in the future
var amount_remaining: int = amount
while amount_remaining > 0:
var first_stack_index: int = inventory.find_custom(_find_stacks_with_space.bind(item_id))
var stack_resource: DBItemResource
if first_stack_index == -1 and inventory.size() < max_inventory_items: # No existing stack and empty slots available
stack_resource = item_resource.duplicate()
inventory.append(stack_resource)
if amount_remaining <= stack_resource.max_stack_size:
_update_cache_total(item_id, amount_remaining)
inventory[-1].amount += amount_remaining
amount_remaining = 0
else:
_update_cache_total(item_id, stack_resource.max_stack_size)
inventory[-1].amount = stack_resource.max_stack_size
amount_remaining -= stack_resource.max_stack_size
inventory_slot_updated.emit(inventory.size() - 1)
elif first_stack_index > -1:
if inventory[first_stack_index] == null: # Empty slot
inventory[first_stack_index] = item_resource.duplicate()
stack_resource = inventory[first_stack_index]
var current_amount: int = stack_resource.amount
var total_amount: int = current_amount + amount_remaining
if total_amount < stack_resource.max_stack_size: # Stack not full and has space
_update_cache_total(item_id, amount_remaining)
inventory[first_stack_index].amount = total_amount
amount_remaining = 0
else:
_update_cache_total(item_id, stack_resource.max_stack_size - current_amount)
inventory[first_stack_index].amount = stack_resource.max_stack_size
amount_remaining -= stack_resource.max_stack_size
inventory_slot_updated.emit(first_stack_index)
item_added.emit(item_id, amount - amount_remaining)
func _on_remove_from_inventory(item_id: String, amount: int = 1) -> void:
var amount_remaining: int = amount
while amount_remaining > 0:
var last_stack_index: int = inventory.rfind_custom(_find_stacks_by_id.bind(item_id))
if last_stack_index > -1:
var stack_resource: DBItemResource = inventory[last_stack_index]
var current_stack_amount: int = stack_resource.amount
var total_amount: int = current_stack_amount - amount_remaining
if total_amount > 0: # Stack will not be empty after removing
_update_cache_total(item_id, -amount_remaining)
inventory[last_stack_index].amount -= amount_remaining
amount_remaining = 0
else:
var to_remove: int = stack_resource.max_stack_size - current_stack_amount
_update_cache_total(item_id, -amount_remaining)
inventory[last_stack_index] = null
amount_remaining -= to_remove
inventory_slot_updated.emit(last_stack_index)
else: # Received more to remove than we have stacks for
amount_remaining = 0
item_removed.emit(item_id, amount - amount_remaining)
func _on_clear_inventory() -> void:
inventory.clear()
_inventory_cache.clear()
func _on_item_dropped(item: DBItemResource) -> void:
_on_remove_from_inventory(item.id, 1)
func _on_item_picked_up(item: DBItemResource) -> void:
_on_add_to_inventory(item.id, 1)
func _on_quick_slot_selected(slot_index: int) -> void:
selected_quick_slot = slot_index
func _on_remove_from_slot(slot_index: int, amount: int) -> void:
_remove_from_slot(slot_index, amount)
func _on_quick_slot_item_changed(item_id: String) -> void:
quick_slot_item_id = item_id
func _on_remove_from_quickslot(amount: int) -> void:
_remove_from_slot(selected_quick_slot, amount)

+ 1
- 2
project.godot View File

@ -11,14 +11,13 @@ config_version=5
[application]
config/name="Skyblock"
config/version="0.1.0"
config/version="0.2.0"
run/main_scene="uid://cgx0nawwjjj7g"
config/features=PackedStringArray("4.4", "Forward Plus")
config/icon="uid://f6hee5t26uqt"
[autoload]
Globals="*res://autoloads/globals.gd"
EntityManager="*res://autoloads/entity_manager.gd"
InventoryManager="*res://autoloads/inventory_manager.gd"
DBItems="*res://autoloads/db_items.gd"


+ 3
- 1
resources/blocks/005_grass.tres View File

@ -9,6 +9,8 @@ material_texture = ExtResource("1_n4fyn")
id = "005"
name = "Grass"
amount = 0
max_stack_size = 999
max_number_stacks = 0
description = "Block of grass and dirt"
item_texture = "uid://li36txj7oweq"
item_texture = "uid://bgo4mb3atmbot"
metadata/_custom_type_script = "uid://dwrmy4mx0mw18"

+ 3
- 1
resources/db_item_resource.gd View File

@ -5,5 +5,7 @@ extends Resource
@export var id: String = "000"
@export var name: String = "Item Name"
@export var amount: int = 0
@export var max_stack_size: int = 999
@export var max_number_stacks: int = 0 ## 0 for unlimited stacks
@export var description: String = "Item Description"
@export_file var item_texture: String = "res://assets/icon.svg"
@export_file var item_texture: String = "res://assets/godot-icon.svg"

+ 3
- 2
resources/game_settings/graphics_settings_resource.gd View File

@ -3,8 +3,9 @@
class_name GraphicsSettingsResource
extends Resource
@export var fov: int = 75
@export var resolution: Vector2i = Vector2i(1280, 720) ## Width, Height
@export var resolution_id: int = 0 ## The ID of the item in the OptionsButton list element
@export var fullscreen: bool = false
@export var vsync: bool = false
@export var fov: int = 75
@export var window_mode: DisplayServer.WindowMode = DisplayServer.WINDOW_MODE_WINDOWED

+ 40
- 7
resources/inventory/player_inventory_testing.tres View File

@ -1,4 +1,4 @@
[gd_resource type="Resource" script_class="InventoryResource" load_steps=12 format=3 uid="uid://blfp6tiir282o"]
[gd_resource type="Resource" script_class="InventoryResource" load_steps=16 format=3 uid="uid://blfp6tiir282o"]
[ext_resource type="Script" uid="uid://becun6dj78v8d" path="res://resources/inventory_resource.gd" id="1_4v6mg"]
[ext_resource type="Script" uid="uid://bdx4q355l5ugl" path="res://resources/db_item_resource.gd" id="1_gg8jx"]
@ -6,14 +6,18 @@
[ext_resource type="Script" uid="uid://dwrmy4mx0mw18" path="res://resources/block_resource.gd" id="3_vgvac"]
[ext_resource type="Material" uid="uid://cx7m27qa4ds4s" path="res://assets/materials/stone.tres" id="4_7yuhn"]
[ext_resource type="Material" uid="uid://jearv8lmwhec" path="res://assets/materials/wood.tres" id="5_p27bu"]
[ext_resource type="Material" uid="uid://b4wrf3quiaa1b" path="res://assets/materials/grass.tres" id="7_vgvac"]
[ext_resource type="Material" uid="uid://d15n1p3spu3jg" path="res://assets/materials/leaves.tres" id="7_xd1nd"]
[ext_resource type="Material" uid="uid://b2w5ybx51vuwf" path="res://assets/materials/glass.tres" id="8_7yuhn"]
[sub_resource type="Resource" id="Resource_jaam2"]
script = ExtResource("3_vgvac")
material_texture = ExtResource("2_8w148")
id = "001"
name = "Dirt"
amount = 100
amount = 999
max_stack_size = 999
max_number_stacks = 0
description = "Block of dirt"
item_texture = "uid://li36txj7oweq"
metadata/_custom_type_script = "uid://dwrmy4mx0mw18"
@ -23,7 +27,9 @@ script = ExtResource("3_vgvac")
material_texture = ExtResource("4_7yuhn")
id = "002"
name = "Stone"
amount = 100
amount = 999
max_stack_size = 999
max_number_stacks = 0
description = "Block of stone"
item_texture = "uid://ct1iawpfkdf5l"
metadata/_custom_type_script = "uid://dwrmy4mx0mw18"
@ -33,7 +39,9 @@ script = ExtResource("3_vgvac")
material_texture = ExtResource("5_p27bu")
id = "003"
name = "Wood"
amount = 100
amount = 999
max_stack_size = 999
max_number_stacks = 0
description = "Wood log"
item_texture = "uid://0mw651622h01"
metadata/_custom_type_script = "uid://dwrmy4mx0mw18"
@ -43,13 +51,38 @@ script = ExtResource("3_vgvac")
material_texture = ExtResource("7_xd1nd")
id = "004"
name = "Leaves"
amount = 100
amount = 999
max_stack_size = 999
max_number_stacks = 0
description = "Tree leaves"
item_texture = "uid://goygbpyqhych"
metadata/_custom_type_script = "uid://dwrmy4mx0mw18"
[sub_resource type="Resource" id="Resource_viap3"]
script = ExtResource("3_vgvac")
material_texture = ExtResource("7_vgvac")
id = "005"
name = "Grass"
amount = 999
max_stack_size = 999
max_number_stacks = 0
description = "Block of grass and dirt"
item_texture = "uid://li36txj7oweq"
metadata/_custom_type_script = "uid://dwrmy4mx0mw18"
[sub_resource type="Resource" id="Resource_wqat2"]
script = ExtResource("3_vgvac")
material_texture = ExtResource("8_7yuhn")
id = "006"
name = "Glass"
amount = 999
max_stack_size = 999
max_number_stacks = 0
description = "Glass block"
item_texture = "uid://cpllegyqnfnrh"
metadata/_custom_type_script = "uid://dwrmy4mx0mw18"
[resource]
script = ExtResource("1_4v6mg")
inventory = Array[ExtResource("1_gg8jx")]([SubResource("Resource_jaam2"), SubResource("Resource_4kby3"), SubResource("Resource_byct5"), SubResource("Resource_qycqj")])
max_stack_size = 999
inventory = Array[ExtResource("1_gg8jx")]([SubResource("Resource_jaam2"), SubResource("Resource_4kby3"), SubResource("Resource_byct5"), SubResource("Resource_qycqj"), SubResource("Resource_viap3"), SubResource("Resource_wqat2")])
metadata/_custom_type_script = "uid://becun6dj78v8d"

+ 0
- 1
resources/inventory_resource.gd View File

@ -3,4 +3,3 @@ extends Resource
@export var inventory: Array[DBItemResource] = []
@export var max_stack_size: int = 999

+ 5
- 0
resources/item_resource.gd View File

@ -0,0 +1,5 @@
class_name ItemResource
extends DBItemResource
@export var resource_scene: PackedScene = null

+ 1
- 0
resources/item_resource.gd.uid View File

@ -0,0 +1 @@
uid://m32ytcig5ha5

+ 14
- 0
resources/items/007_torch.tres View File

@ -0,0 +1,14 @@
[gd_resource type="Resource" script_class="ItemResource" load_steps=3 format=3 uid="uid://dqkdgxdjb8sk5"]
[ext_resource type="PackedScene" uid="uid://ccky0w7brcf1l" path="res://scenes/items/torch.tscn" id="1_7h82o"]
[ext_resource type="Script" uid="uid://m32ytcig5ha5" path="res://resources/item_resource.gd" id="2_e6rfx"]
[resource]
script = ExtResource("2_e6rfx")
resource_scene = ExtResource("1_7h82o")
id = "007"
name = "Torch"
amount = 1
description = "A torch to light the way"
item_texture = "uid://dknv7amroftm8"
metadata/_custom_type_script = "uid://m32ytcig5ha5"

+ 1
- 1
resources/world/sky_horizon_color_gradient.tres View File

@ -2,4 +2,4 @@
[resource]
offsets = PackedFloat32Array(0.1, 0.25, 0.4, 0.6, 0.75, 0.9)
colors = PackedColorArray(0.317647, 0.333333, 0.65098, 1, 0.87451, 0.521569, 0.407843, 1, 0.584314, 0.980392, 0.980392, 1, 0.584314, 0.980392, 0.980392, 1, 0.87451, 0.521569, 0.407843, 1, 0.317647, 0.333333, 0.65098, 1)
colors = PackedColorArray(0.317647, 0.333333, 0.65098, 1, 0.87451, 0.521569, 0.407843, 1, 0.243137, 0.584314, 0.85098, 1, 0.243137, 0.584314, 0.85098, 1, 0.87451, 0.521569, 0.407843, 1, 0.317647, 0.333333, 0.65098, 1)

+ 1
- 1
resources/world/sky_top_color_gradient.tres View File

@ -2,4 +2,4 @@
[resource]
offsets = PackedFloat32Array(0.1, 0.4, 0.6, 0.9)
colors = PackedColorArray(0.317647, 0.333333, 0.65098, 1, 0.583728, 0.979416, 0.978736, 1, 0.584314, 0.980392, 0.980392, 1, 0.317647, 0.333333, 0.65098, 1)
colors = PackedColorArray(0.317647, 0.333333, 0.65098, 1, 0.243137, 0.584314, 0.85098, 1, 0.243137, 0.584314, 0.85098, 1, 0.317647, 0.333333, 0.65098, 1)

+ 1
- 0
scenes/blocks/block.gd View File

@ -1,6 +1,7 @@
class_name Block
extends StaticBody3D
const PREFAB: PackedScene = preload("res://scenes/blocks/block.tscn")
@export var block_mesh: BlockMesh
@export var collision_shape: CollisionShape3D


+ 11
- 0
scenes/blocks/dropped_block.gd View File

@ -2,11 +2,15 @@ class_name DroppedBlock
extends RigidBody3D
const PREFAB: PackedScene = preload("res://scenes/blocks/dropped_block.tscn")
## The amount of time to wait before PickupArea is set to monitorable[br]
## This is to ensure that the item isn't picked up immediately after throwing
@export var pickup_timeout: int = 1
@export var lifetime_in_seconds: int = 10 ## Lifetime before despawning
@export var animation_player: AnimationPlayer
@export var block_mesh: BlockMesh
@export var lifetime_timer: Timer
@export var pickup_area: Area3D
var id: String
@ -14,6 +18,8 @@ var impulse: Vector3 = Vector3.ZERO
func _ready() -> void:
lifetime_timer.timeout.connect(_on_lifetime_timeout)
## AnimationPlayer handles modifying BlockMesh scale, position, and rotation
## The scale is NOT applied to any other node, including RigidBody and CollisionShape
animation_player.play("start_animation")
@ -38,6 +44,8 @@ func initialize(block_id: String, start_position: Vector3, drop_direction: Vecto
impulse = drop_direction * drop_impulse
apply_central_impulse(impulse)
lifetime_timer.start(lifetime_in_seconds)
func set_id(block_id: String) -> void:
id = block_id
if id in DBItems.data:
@ -46,6 +54,9 @@ func set_id(block_id: String) -> void:
printerr("Unknown Block ID: ", id)
func _on_lifetime_timeout() -> void:
call_deferred("queue_free")
func _on_pickup_area_body_entered(body: Node3D) -> void:
if not body is Player: return


+ 6
- 1
scenes/blocks/dropped_block.tscn View File

@ -96,11 +96,12 @@ _data = {
[sub_resource type="SphereShape3D" id="SphereShape3D_5kft2"]
[node name="DroppedBlock" type="RigidBody3D" node_paths=PackedStringArray("animation_player", "block_mesh", "pickup_area")]
[node name="DroppedBlock" type="RigidBody3D" node_paths=PackedStringArray("animation_player", "block_mesh", "lifetime_timer", "pickup_area")]
collision_layer = 4
script = ExtResource("1_y8usf")
animation_player = NodePath("AnimationPlayer")
block_mesh = NodePath("BlockMesh")
lifetime_timer = NodePath("LifetimeTimer")
pickup_area = NodePath("PickupArea")
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
@ -129,4 +130,8 @@ shape = SubResource("SphereShape3D_5kft2")
[node name="SaveDataComponent" parent="." instance=ExtResource("3_ix4xk")]
save_data_resource = ExtResource("4_8xfh1")
[node name="LifetimeTimer" type="Timer" parent="."]
wait_time = 10.0
one_shot = true
[connection signal="body_entered" from="PickupArea" to="." method="_on_pickup_area_body_entered"]

+ 23
- 0
scenes/items/torch.tscn View File

@ -0,0 +1,23 @@
[gd_scene load_steps=4 format=3 uid="uid://ccky0w7brcf1l"]
[sub_resource type="BoxMesh" id="BoxMesh_ctvck"]
size = Vector3(0.1, 0.1, 0.1)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ctvck"]
emission_enabled = true
emission = Color(0.846334, 0.776792, 0.275847, 1)
emission_energy_multiplier = 8.23
[sub_resource type="BoxMesh" id="BoxMesh_vkm4o"]
size = Vector3(0.1, 0.4, 0.1)
[node name="Torch" type="Node3D"]
[node name="Head" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.449571, 0)
mesh = SubResource("BoxMesh_ctvck")
surface_material_override/0 = SubResource("StandardMaterial3D_ctvck")
[node name="Base" type="MeshInstance3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.19988, 0)
mesh = SubResource("BoxMesh_vkm4o")

+ 31
- 10
scenes/player/player.gd View File

@ -25,6 +25,7 @@ extends CharacterBody3D
@onready var collision_shape_crouching: CollisionShape3D = $CollisionShapeCrouching
@onready var ray_cast_crouch: RayCast3D = $RayCastCrouch
var current_height: float = 0.0
var current_jump_count: int = 0
var current_speed: float = walk_speed
var direction: Vector3 = Vector3.ZERO
@ -36,7 +37,9 @@ func _input(event: InputEvent) -> void:
if event is InputEventMouseMotion:
_handle_mouse_movement(event.relative)
elif event.is_action_pressed("throw_item"): # TODO: Move to state?
EntityManager.drop_block.emit(InventoryManager.quick_slot_item_id, head.global_position, -head.global_basis.z, throw_velocity)
if InventoryManager.get_inventory_item() != null:
EntityManager.drop_block.emit(InventoryManager.get_quick_slot_item_id(), head.global_position, -head.global_basis.z, throw_velocity)
InventoryManager.remove_from_quickslot.emit(1)
func _physics_process(delta: float) -> void:
is_crouching = Input.is_action_pressed("crouch") or ray_cast_crouch.is_colliding()
@ -55,14 +58,16 @@ func _physics_process(delta: float) -> void:
func _ready() -> void:
GameSettingsManager.graphics_fov_changed.connect(_on_graphics_fov_changed)
GameSettingsManager.game_options_held_block_ui_changed.connect(_on_game_options_held_block_ui_changed)
InventoryManager.quick_slot_item_changed.connect(_on_quick_slot_item_changed)
InventoryManager.quick_slot_selected.connect(_on_quick_slot_selected)
InventoryManager.add_to_inventory.connect(_on_add_to_inventory)
InventoryManager.remove_from_inventory.connect(_on_remove_from_inventory)
InventoryManager.item_picked_up.connect(_on_item_picked_up)
InventoryManager.inventory_slot_updated.connect(_on_inventory_slot_updated)
SignalManager.resume_game.connect(_on_resume_game)
SignalManager.open_pause_menu.connect(_on_open_pause_menu)
SignalManager.hide_ui.connect(_on_hide_ui)
SignalManager.show_ui.connect(_on_show_ui)
_update_held_block_mesh(InventoryManager.quick_slot_item_id)
func _apply_gravity(delta: float) -> void:
if is_on_floor(): return
@ -74,8 +79,8 @@ func _handle_crouching(delta: float) -> void:
collision_shape_crouching.disabled = !is_crouching
collision_shape_standing.disabled = is_crouching
var height: float = crouch_height if is_crouching else standing_height
head.position.y = lerp(head.position.y, height, camera_acceleration * delta)
current_height = crouch_height if is_crouching else standing_height
head.position.y = lerp(head.position.y, current_height, camera_acceleration * delta)
func _handle_jumping() -> void:
if is_on_floor():
@ -132,10 +137,15 @@ func _set_is_sprinting() -> void:
else:
is_sprinting = Input.is_action_pressed("run")
func _update_held_block_mesh(item_id: String) -> void:
func _update_held_block_mesh() -> void:
var current_item: DBItemResource = InventoryManager.get_inventory_item()
if current_item == null:
block_mesh.visible = false
return
block_mesh.visible = GameSettingsManager.settings.game_options.enable_held_block
if GameSettingsManager.settings.game_options.enable_held_block:
block_mesh.apply_material(DBItems.data[item_id].material_texture)
block_mesh.apply_material(current_item.material_texture)
func _on_game_options_held_block_ui_changed(toggled: bool) -> void:
@ -144,8 +154,8 @@ func _on_game_options_held_block_ui_changed(toggled: bool) -> void:
func _on_graphics_fov_changed(fov: int) -> void:
camera.fov = fov
func _on_quick_slot_item_changed(item_id: String) -> void:
_update_held_block_mesh(item_id)
func _on_quick_slot_selected(_slot_index: int) -> void:
_update_held_block_mesh()
func _on_open_pause_menu() -> void:
block_mesh.visible = false
@ -153,6 +163,17 @@ func _on_open_pause_menu() -> void:
func _on_resume_game() -> void:
block_mesh.visible = GameSettingsManager.settings.game_options.enable_held_block
func _on_add_to_inventory(_item_id: String, _amount: int) -> void:
_update_held_block_mesh()
func _on_inventory_slot_updated(_slot_index: int) -> void:
_update_held_block_mesh()
func _on_item_picked_up(_item: DBItemResource) -> void:
_update_held_block_mesh()
func _on_remove_from_inventory(_item_id: String, _amount: int) -> void:
_update_held_block_mesh()
func _on_hide_ui() -> void:
block_mesh.visible = false


+ 3
- 2
scenes/player/player.tscn View File

@ -35,12 +35,13 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.8, 0)
[node name="Camera3D" type="Camera3D" parent="Head"]
[node name="BlockMesh" parent="Head/Camera3D" instance=ExtResource("2_p47bc")]
transform = Transform3D(1, 0, 0, 0, 0.965926, -0.258819, 0, 0.258819, 0.965926, 0, -0.680035, -1.7196)
transform = Transform3D(1, 0, 0, 0, 0.965926, -0.258819, 0, 0.258819, 0.965926, 1.15474, -0.680035, -1.35803)
[node name="RayCastLook" type="RayCast3D" parent="Head"]
[node name="RayCastLook" type="RayCast3D" parent="Head" node_paths=PackedStringArray("player")]
target_position = Vector3(0, 0, -10)
debug_shape_custom_color = Color(0.753415, 4.77457e-05, 0.578804, 1)
script = ExtResource("2_dovo2")
player = NodePath("../..")
[node name="RayCastCrouch" type="RayCast3D" parent="."]
editor_description = "Y should be just slightly higher than the height of the standing collision shape"


+ 28
- 4
scenes/player/ray_cast_look.gd View File

@ -1,6 +1,9 @@
extends RayCast3D
@export var player: Player
func _process(_delta: float) -> void:
if is_colliding():
var collider: Object = get_collider()
@ -9,10 +12,13 @@ func _process(_delta: float) -> void:
if Input.is_action_just_pressed("right_click_interact"):
(collider as Block).destroy_block()
if Input.is_action_just_pressed("left_click_interact"):
EntityManager.create_block.emit(
InventoryManager.quick_slot_item_id,
collider.position + get_collision_normal()
)
var block_pos: Vector3i = Vector3i(collider.position + get_collision_normal())
if !is_valid_placement_target(block_pos):
return
EntityManager.create_block.emit(InventoryManager.get_quick_slot_item_id(), block_pos)
InventoryManager.remove_from_quickslot.emit(1)
if Waila.ref.get_target() == collider:
return
@ -25,6 +31,24 @@ func _process(_delta: float) -> void:
release_target()
func is_valid_placement_target(block_pos: Vector3i) -> bool:
var collision_shape_radius: float = player.collision_shape_standing.shape.radius
var collision_size_adjustments: Vector3 = Vector3(collision_shape_radius, 0, collision_shape_radius)
var player_position_min: Vector3 = player.global_position - collision_size_adjustments
var player_position_max: Vector3 = player.global_position + collision_size_adjustments
player_position_max.y += player.current_height
var _is_overlapping_player: bool = (
block_pos.x >= player_position_min.x and block_pos.x <= player_position_max.x and
block_pos.y >= player_position_min.y and block_pos.y <= player_position_max.y and
block_pos.z >= player_position_min.z and block_pos.z <= player_position_max.z
)
return !_is_overlapping_player
func hook_block(target_block: Block) -> void:
target_block.hook()
Waila.ref.set_target(target_block)


+ 65
- 43
scenes/ui/inventory/inventory.gd View File

@ -2,9 +2,11 @@ class_name Inventory
extends Control
@export var inventory_resource: InventoryResource
@export var item_rect_scene: PackedScene
@export var grid_container: GridContainer
@export var inventory_resource: InventoryResource ## A starting inventory to initialize the inventory with
@export var item_rect_scene: PackedScene ## The scene to use for each individual item stack in the inventory
@export var grid_container: GridContainer ## Container for inventory items
@export var highlight_theme: Resource ## The theme to apply on mouse_enter of the InventoryItemRect
func _input(event: InputEvent) -> void:
@ -12,58 +14,78 @@ func _input(event: InputEvent) -> void:
toggle_inventory()
func _ready() -> void:
InventoryManager.item_picked_up.connect(add_item)
InventoryManager.item_dropped.connect(subtract_item)
for item_resource: DBItemResource in inventory_resource.inventory:
add_item(item_resource)
update_inventory_with_resource()
refresh_inventory_grid()
InventoryManager.item_added.connect(_on_item_added) # Should be added after update_inventory_with_resource()
InventoryManager.item_removed.connect(_on_item_removed) # Should be added after update_inventory_with_resource()
InventoryManager.clear_inventory.connect(_on_clear_inventory)
func add_item(item_resource: DBItemResource, amount: int = 1) -> void:
var item_rect: InventoryItemRect = find_item_rect(item_resource)
if item_rect != null:
if item_rect.item_resource.amount + item_resource.amount >= inventory_resource.max_stack_size:
item_rect.on_stack_full(true)
return
item_rect.item_resource.amount += item_resource.amount
item_rect.update_rect()
else:
item_rect = item_rect_scene.instantiate()
grid_container.add_child(item_rect)
item_rect.item_resource = item_resource
item_rect.update_rect()
func find_item_rect(item_resource: DBItemResource) -> InventoryItemRect:
func create_item_cell(item_resource: DBItemResource) -> void:
var item_rect: InventoryItemRect = item_rect_scene.instantiate()
grid_container.add_child(item_rect)
item_rect.init(item_resource, highlight_theme)
func find_item_cell(item_resource: DBItemResource) -> InventoryItemRect:
var rect: InventoryItemRect = null
for container: InventoryItemRect in grid_container.get_children():
if container.item_resource.id == item_resource.id:
rect = container
for item_rect: InventoryItemRect in grid_container.get_children():
if item_rect.item_resource == null: continue
if item_rect.item_resource.id == item_resource.id:
rect = item_rect
break
return rect
func subtract_item(item_resource: DBItemResource) -> void:
var item_rect: InventoryItemRect = find_item_rect(item_resource)
func refresh_inventory_grid() -> void:
for item: InventoryItemRect in grid_container.get_children():
item.queue_free()
if item_rect != null:
if item_rect.item_resource.amount >= inventory_resource.max_stack_size:
item_rect.on_stack_full(false)
item_rect.item_resource.amount -= item_resource.amount
item_rect.update_rect()
for item: DBItemResource in InventoryManager.inventory:
create_item_cell(item)
if item_rect.item_resource.amount < 1: # Empty stack
item_rect.queue_free()
else:
push_error("Attempting to subtract amount (" + str(item_resource.amount) + " from nonexistent inventory item (" + str(item_resource.name) + ")")
var empty_cells: int = InventoryManager.max_inventory_items - InventoryManager.inventory.size()
for _i: int in range(empty_cells):
create_item_cell(null)
func toggle_inventory() -> void:
visible = not visible
if visible:
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
InventoryManager.inventory_opened.emit()
get_tree().paused = true
_close_inventory()
else:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
InventoryManager.inventory_closed.emit()
get_tree().paused = false
_open_inventory()
## Add any items from the existing inventory resource
func update_inventory_with_resource() -> void:
if inventory_resource == null:
return
InventoryManager.clear_inventory.emit()
for item_resource: DBItemResource in inventory_resource.inventory:
InventoryManager.add_to_inventory.emit(item_resource.id, item_resource.amount)
func _close_inventory() -> void:
visible = false
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
InventoryManager.inventory_closed.emit()
func _open_inventory() -> void:
refresh_inventory_grid()
visible = true
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
InventoryManager.inventory_opened.emit()
func _on_clear_inventory() -> void:
for item: InventoryItemRect in grid_container.get_children():
item.queue_free()
for _i: int in range(InventoryManager.max_inventory_items):
create_item_cell(null)
func _on_item_added(_item_id: String, _amount: int) -> void:
refresh_inventory_grid()
func _on_item_removed(_item_id: String, _amount: int) -> void:
refresh_inventory_grid()

+ 8
- 5
scenes/ui/inventory/inventory.tscn View File

@ -1,8 +1,9 @@
[gd_scene load_steps=4 format=3 uid="uid://dcr25y1lw4wjp"]
[gd_scene load_steps=5 format=3 uid="uid://dcr25y1lw4wjp"]
[ext_resource type="Script" uid="uid://dybecq130mxhn" path="res://scenes/ui/inventory/inventory.gd" id="1_s6ek7"]
[ext_resource type="Resource" uid="uid://cnpw7y1csu774" path="res://resources/inventory/player_inventory_empty.tres" id="2_avmd0"]
[ext_resource type="Resource" uid="uid://blfp6tiir282o" path="res://resources/inventory/player_inventory_testing.tres" id="2_pefhr"]
[ext_resource type="PackedScene" uid="uid://boueuk2hnfvg" path="res://scenes/ui/inventory/item_rect.tscn" id="3_xeaml"]
[ext_resource type="StyleBox" uid="uid://dlaswvta2mvim" path="res://resources/inventory/quickslot-panel-highlight-stylebox.tres" id="4_8ndef"]
[node name="Inventory" type="Control" node_paths=PackedStringArray("grid_container")]
process_mode = 3
@ -20,9 +21,10 @@ offset_bottom = 200.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_s6ek7")
inventory_resource = ExtResource("2_avmd0")
inventory_resource = ExtResource("2_pefhr")
item_rect_scene = ExtResource("3_xeaml")
grid_container = NodePath("Background/MarginContainer/VBoxContainer/GridContainer")
highlight_theme = ExtResource("4_8ndef")
[node name="Background" type="Panel" parent="."]
layout_mode = 1
@ -54,7 +56,8 @@ text = "Inventory"
[node name="GridContainer" type="GridContainer" parent="Background/MarginContainer/VBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 3
theme_override_constants/h_separation = 20
theme_override_constants/v_separation = 20
theme_override_constants/h_separation = 5
theme_override_constants/v_separation = 5
columns = 10

+ 30
- 4
scenes/ui/inventory/item_rect.gd View File

@ -4,16 +4,42 @@ extends Panel
@export var amount_label: Label
@export var item_resource: DBItemResource
@export var item_texture: TextureRect
@export var item_texture: TextureButton
var highlight_theme: Resource
func init(_item_resource: DBItemResource, _highlight_theme: Resource) -> void:
item_texture.mouse_entered.connect(_on_mouse_entered)
item_texture.mouse_exited.connect(_on_mouse_exited)
highlight_theme = _highlight_theme
item_resource = _item_resource
update_rect()
func clear_rect() -> void:
item_texture.texture_normal = null
amount_label.text = ""
item_texture.tooltip_text = ""
func update_rect() -> void:
item_texture.texture = load(item_resource.item_texture)
amount_label.text = "x" + str(item_resource.amount)
tooltip_text = item_resource.name + "\n" + item_resource.description
if not item_resource:
clear_rect()
else:
item_texture.texture_normal = load(item_resource.item_texture)
amount_label.text = "x" + str(item_resource.amount)
item_texture.tooltip_text = item_resource.name + "\n" + item_resource.description
func on_stack_full(is_full: bool) -> void:
if is_full:
amount_label.add_theme_color_override("font_color", Color(1, 0, 0))
else:
amount_label.add_theme_color_override("font_color", Color(1, 1, 1))
func _on_mouse_entered() -> void:
set("theme_override_styles/panel", highlight_theme)
func _on_mouse_exited() -> void:
set("theme_override_styles/panel", null)

+ 18
- 10
scenes/ui/inventory/item_rect.tscn View File

@ -1,6 +1,5 @@
[gd_scene load_steps=4 format=3 uid="uid://boueuk2hnfvg"]
[gd_scene load_steps=3 format=3 uid="uid://boueuk2hnfvg"]
[ext_resource type="Texture2D" uid="uid://dknv7amroftm8" path="res://assets/godot-icon.svg" id="1_o0kom"]
[ext_resource type="Script" uid="uid://cknl6i0jce5jr" path="res://scenes/ui/inventory/item_rect.gd" id="1_oderi"]
[sub_resource type="LabelSettings" id="LabelSettings_oderi"]
@ -8,21 +7,30 @@ outline_size = 3
outline_color = Color(0, 0, 0, 1)
[node name="ItemRect" type="Panel" node_paths=PackedStringArray("amount_label", "item_texture")]
custom_minimum_size = Vector2(64, 64)
custom_minimum_size = Vector2(72, 72)
offset_right = 64.0
offset_bottom = 64.0
script = ExtResource("1_oderi")
amount_label = NodePath("AmountLabel")
item_texture = NodePath("ItemTexture")
item_texture = NodePath("TextureButton")
metadata/_edit_use_anchors_ = true
[node name="ItemTexture" type="TextureRect" parent="."]
[node name="TextureButton" type="TextureButton" parent="."]
texture_filter = 1
layout_mode = 0
offset_right = 64.0
offset_bottom = 64.0
texture = ExtResource("1_o0kom")
expand_mode = 1
custom_minimum_size = Vector2(64, 64)
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -32.0
offset_top = -32.0
offset_right = 32.0
offset_bottom = 32.0
grow_horizontal = 2
grow_vertical = 2
ignore_texture_size = true
stretch_mode = 4
[node name="AmountLabel" type="Label" parent="."]


+ 10
- 7
scenes/ui/pause_menu/settings_menu.gd View File

@ -11,11 +11,11 @@ extends BaseMenu
@export var waila_input: CheckButton
@export_group("Graphics Settings Nodes")
@export var resolution_input: OptionButton
@export var fullscreen_input: CheckBox
@export var vsync_input: CheckBox
@export var fov_slider: HSlider
@export var fov_value_label: Label
@export var resolution_input: OptionButton
@export var vsync_input: CheckBox
@export var window_mode_input: OptionButton
func init() -> void:
@ -38,9 +38,11 @@ func apply_default_values() -> void:
#region Graphics Settings
# Changing the FOV value should trigger the value_changed signal which should update the camera and label automatically
fov_slider.value = GameSettingsManager.settings.graphics.fov
fullscreen_input.set_pressed_no_signal(GameSettingsManager.settings.graphics.fullscreen)
vsync_input.set_pressed_no_signal(GameSettingsManager.settings.graphics.vsync)
var current_mode_index: int = window_mode_input.get_item_index(GameSettingsManager.settings.graphics.window_mode)
window_mode_input.select(current_mode_index)
var current_resolution_index: int = resolution_input.get_item_index(GameSettingsManager.settings.graphics.resolution_id)
resolution_input.select(current_resolution_index)
#endregion
@ -79,10 +81,11 @@ func _on_fov_slider_changed(value: float) -> void:
func _on_graphics_apply_button_pressed() -> void:
var values: Array = resolution_input.text.split_floats("x")
var id: int = resolution_input.get_selected_id()
var resolution_id: int = resolution_input.get_selected_id()
var window_mode_id: int = window_mode_input.get_selected_id()
GameSettingsManager.graphics_resolution_changed.emit(Vector2i(values[0], values[1]), id)
GameSettingsManager.graphics_fullscreen_changed.emit(fullscreen_input.button_pressed)
GameSettingsManager.graphics_resolution_changed.emit(Vector2i(values[0], values[1]), resolution_id)
GameSettingsManager.graphics_window_mode_changed.emit(window_mode_id)
GameSettingsManager.graphics_vsync_changed.emit(vsync_input.button_pressed)
GameSettingsManager.apply_graphics_settings.emit()
#endregion


+ 18
- 8
scenes/ui/pause_menu/settings_menu.tscn View File

@ -14,7 +14,8 @@ corner_radius_top_right = 2
corner_radius_bottom_right = 2
corner_radius_bottom_left = 2
[node name="SettingsMenu" node_paths=PackedStringArray("autosaves_input", "block_highlight_input", "held_block_ui_input", "quick_slots_ui_input", "screenshot_icon_input", "waila_input", "resolution_input", "fullscreen_input", "vsync_input", "fov_slider", "fov_value_label") instance=ExtResource("1_oec81")]
[node name="SettingsMenu" node_paths=PackedStringArray("autosaves_input", "block_highlight_input", "held_block_ui_input", "quick_slots_ui_input", "screenshot_icon_input", "waila_input", "fov_slider", "fov_value_label", "resolution_input", "vsync_input", "window_mode_input") instance=ExtResource("1_oec81")]
visible = false
script = ExtResource("1_govsn")
autosaves_input = NodePath("MainContent/MenuContainer/TabContainer/Game/Autosaves/CheckButton")
block_highlight_input = NodePath("MainContent/MenuContainer/TabContainer/Game/BlockHighlight/CheckButton")
@ -22,11 +23,11 @@ held_block_ui_input = NodePath("MainContent/MenuContainer/TabContainer/Game/Held
quick_slots_ui_input = NodePath("MainContent/MenuContainer/TabContainer/Game/QuickslotsUI/CheckButton")
screenshot_icon_input = NodePath("MainContent/MenuContainer/TabContainer/Game/ScreenshotIcon/CheckButton")
waila_input = NodePath("MainContent/MenuContainer/TabContainer/Game/Waila/CheckButton")
resolution_input = NodePath("MainContent/MenuContainer/TabContainer/Graphics/Resolution/OptionButton")
fullscreen_input = NodePath("MainContent/MenuContainer/TabContainer/Graphics/Fullscreen/CheckBox")
vsync_input = NodePath("MainContent/MenuContainer/TabContainer/Graphics/VSync/CheckBox")
fov_slider = NodePath("MainContent/MenuContainer/TabContainer/Graphics/FOV/HSlider")
fov_value_label = NodePath("MainContent/MenuContainer/TabContainer/Graphics/FOV/Value")
resolution_input = NodePath("MainContent/MenuContainer/TabContainer/Graphics/Resolution/OptionButton")
vsync_input = NodePath("MainContent/MenuContainer/TabContainer/Graphics/VSync/CheckBox")
window_mode_input = NodePath("MainContent/MenuContainer/TabContainer/Graphics/WindowMode/OptionButton")
[node name="Title" parent="MainContent/MenuContainer" index="0"]
text = "Settings"
@ -150,16 +151,25 @@ popup/item_4/id = 3
popup/item_5/text = "3840 x 2160"
popup/item_5/id = 5
[node name="Fullscreen" type="HBoxContainer" parent="MainContent/MenuContainer/TabContainer/Graphics" index="1"]
[node name="WindowMode" type="HBoxContainer" parent="MainContent/MenuContainer/TabContainer/Graphics" index="1"]
layout_mode = 2
[node name="Label" type="Label" parent="MainContent/MenuContainer/TabContainer/Graphics/Fullscreen" index="0"]
[node name="Label" type="Label" parent="MainContent/MenuContainer/TabContainer/Graphics/WindowMode" index="0"]
layout_mode = 2
size_flags_horizontal = 3
text = "Fullscreen"
text = "Display Mode"
[node name="CheckBox" type="CheckBox" parent="MainContent/MenuContainer/TabContainer/Graphics/Fullscreen" index="1"]
[node name="OptionButton" type="OptionButton" parent="MainContent/MenuContainer/TabContainer/Graphics/WindowMode" index="1"]
layout_mode = 2
item_count = 4
popup/item_0/text = "Window"
popup/item_0/id = 0
popup/item_1/text = "Maximized"
popup/item_1/id = 2
popup/item_2/text = "Fullscreen"
popup/item_2/id = 3
popup/item_3/text = "Exclusive Fullscreen"
popup/item_3/id = 4
[node name="VSync" type="HBoxContainer" parent="MainContent/MenuContainer/TabContainer/Graphics" index="2"]
layout_mode = 2


+ 0
- 157
scenes/ui/quick_slots.tscn View File

@ -1,157 +0,0 @@
[gd_scene load_steps=9 format=3 uid="uid://cbiygbgpfk220"]
[ext_resource type="Script" uid="uid://bcq6vexsmyeol" path="res://scenes/ui/quick_slots.gd" id="1_cqw2g"]
[ext_resource type="Texture2D" uid="uid://li36txj7oweq" path="res://assets/textures/dirt.png" id="2_kotkb"]
[ext_resource type="StyleBox" uid="uid://dlaswvta2mvim" path="res://resources/inventory/quickslot-panel-highlight-stylebox.tres" id="2_ps55n"]
[ext_resource type="Texture2D" uid="uid://ct1iawpfkdf5l" path="res://assets/textures/stone.png" id="3_cqw2g"]
[ext_resource type="Texture2D" uid="uid://bgo4mb3atmbot" path="res://assets/textures/grass.png" id="3_yyyxx"]
[ext_resource type="Texture2D" uid="uid://0mw651622h01" path="res://assets/textures/wood.png" id="4_yyyxx"]
[ext_resource type="Texture2D" uid="uid://goygbpyqhych" path="res://assets/textures/leaves.png" id="5_ps55n"]
[ext_resource type="Texture2D" uid="uid://cpllegyqnfnrh" path="res://assets/textures/glass.png" id="8_bup65"]
[node name="QuickSlots" type="MarginContainer"]
anchors_preset = 4
anchor_top = 0.5
anchor_bottom = 0.5
offset_top = -220.0
offset_right = 80.0
offset_bottom = 220.0
grow_vertical = 2
size_flags_horizontal = 0
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
script = ExtResource("1_cqw2g")
highlight_theme = ExtResource("2_ps55n")
[node name="GridContainer" type="GridContainer" parent="."]
layout_mode = 2
theme_override_constants/h_separation = 8
theme_override_constants/v_separation = 8
[node name="Slot0" type="Panel" parent="GridContainer"]
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="GridContainer/Slot0"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
[node name="TextureRect" type="TextureRect" parent="GridContainer/Slot0/MarginContainer"]
texture_filter = 1
layout_mode = 2
texture = ExtResource("2_kotkb")
[node name="Slot1" type="Panel" parent="GridContainer"]
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="GridContainer/Slot1"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
[node name="TextureRect" type="TextureRect" parent="GridContainer/Slot1/MarginContainer"]
texture_filter = 1
layout_mode = 2
texture = ExtResource("3_yyyxx")
[node name="Slot3" type="Panel" parent="GridContainer"]
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="GridContainer/Slot3"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
[node name="TextureRect" type="TextureRect" parent="GridContainer/Slot3/MarginContainer"]
texture_filter = 1
layout_mode = 2
texture = ExtResource("3_cqw2g")
[node name="Slot4" type="Panel" parent="GridContainer"]
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="GridContainer/Slot4"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
[node name="TextureRect" type="TextureRect" parent="GridContainer/Slot4/MarginContainer"]
texture_filter = 1
layout_mode = 2
texture = ExtResource("4_yyyxx")
[node name="Slot5" type="Panel" parent="GridContainer"]
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="GridContainer/Slot5"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
[node name="TextureRect" type="TextureRect" parent="GridContainer/Slot5/MarginContainer"]
texture_filter = 1
layout_mode = 2
texture = ExtResource("5_ps55n")
[node name="Slot6" type="Panel" parent="GridContainer"]
custom_minimum_size = Vector2(64, 64)
layout_mode = 2
[node name="MarginContainer" type="MarginContainer" parent="GridContainer/Slot6"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
[node name="TextureRect" type="TextureRect" parent="GridContainer/Slot6/MarginContainer"]
texture_filter = 1
layout_mode = 2
texture = ExtResource("8_bup65")

scenes/ui/quick_slots.gd → scenes/ui/quickslots/quick_slots.gd View File

@ -3,28 +3,33 @@ extends Node
@export var highlight_theme: Resource
@export var slots_container: GridContainer
@export var quickslots_slot: PackedScene
@onready var slots_container: GridContainer = $GridContainer
var _items: Array[String] = ["001", "005", "002", "003", "004", "006"]
var _previous_selected_item: int = 0
var _selected_item: int = 0 :
set(new_item_index):
if new_item_index < 0:
new_item_index = _items.size() - 1
elif new_item_index >= _items.size():
new_item_index = InventoryManager.quick_slot_count - 1
elif new_item_index >= InventoryManager.quick_slot_count:
new_item_index = 0
_previous_selected_item = _selected_item
_selected_item = new_item_index
func _init() -> void:
InventoryManager.next_quick_slot.connect(select_next_item)
InventoryManager.previous_quick_slot.connect(select_previous_item)
InventoryManager.select_quick_slot.connect(select_quick_slot)
func _ready() -> void:
var current_slot: Panel = slots_container.get_child(_selected_item)
current_slot.set("theme_override_styles/panel", highlight_theme)
remove_slots()
generate_quick_slots()
# This doesn't quite work on ready as, for some reason, it will select
# Slot0 (one of the slots BEFORE remove_slots()) instead of the first slot
# create in generate_quick_slots()
select_quick_slot(0)
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("quickslot1"):
@ -53,26 +58,35 @@ func _unhandled_input(event: InputEvent) -> void:
select_previous_item()
func get_quickslot_index() -> int:
return _selected_item
func clear_slots() -> void:
for slot: QuickSlotsSlot in slots_container.get_children():
slot.clear()
func get_selected_item() -> String:
return _items[_selected_item]
func generate_quick_slots() -> void:
for slot_index: int in range(InventoryManager.quick_slot_count):
var slot: QuickSlotsSlot = quickslots_slot.instantiate()
slots_container.add_child(slot)
slot.init(slot_index)
func select_quick_slot(slot_index: int) -> void:
_selected_item = slot_index
update_highlighted_slot()
InventoryManager.quick_slot_item_changed.emit(get_selected_item())
func remove_slots() -> void:
for slot: QuickSlotsSlot in slots_container.get_children():
slot.queue_free()
func select_previous_item() -> void:
func select_next_item() -> void:
select_quick_slot(_selected_item + 1)
func select_next_item() -> void:
func select_previous_item() -> void:
select_quick_slot(_selected_item - 1)
func select_quick_slot(slot_index: int) -> void:
_selected_item = slot_index
InventoryManager.quick_slot_selected.emit(_selected_item)
update_highlighted_slot()
func update_highlighted_slot() -> void:
var previous_slot: Panel = slots_container.get_child(_previous_selected_item)
var current_slot: Panel = slots_container.get_child(_selected_item)
if _previous_selected_item != _selected_item:
var previous_slot: Panel = slots_container.get_child(_previous_selected_item)
previous_slot.set("theme_override_styles/panel", null)
previous_slot.set("theme_override_styles/panel", null)
var current_slot: Panel = slots_container.get_child(_selected_item)
current_slot.set("theme_override_styles/panel", highlight_theme)

scenes/ui/quick_slots.gd.uid → scenes/ui/quickslots/quick_slots.gd.uid View File


+ 63
- 0
scenes/ui/quickslots/quick_slots.tscn View File

@ -0,0 +1,63 @@
[gd_scene load_steps=4 format=3 uid="uid://cbiygbgpfk220"]
[ext_resource type="Script" uid="uid://bcq6vexsmyeol" path="res://scenes/ui/quickslots/quick_slots.gd" id="1_cqw2g"]
[ext_resource type="StyleBox" uid="uid://dlaswvta2mvim" path="res://resources/inventory/quickslot-panel-highlight-stylebox.tres" id="2_ps55n"]
[ext_resource type="PackedScene" uid="uid://c40k8ey6e54v1" path="res://scenes/ui/quickslots/quickslots_slot.tscn" id="3_bup65"]
[node name="QuickSlots" type="MarginContainer" node_paths=PackedStringArray("slots_container")]
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -364.0
offset_top = -80.0
offset_right = 364.0
grow_horizontal = 2
grow_vertical = 0
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8
script = ExtResource("1_cqw2g")
highlight_theme = ExtResource("2_ps55n")
slots_container = NodePath("SlotsContainer")
quickslots_slot = ExtResource("3_bup65")
[node name="SlotsContainer" type="GridContainer" parent="."]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
theme_override_constants/h_separation = 8
theme_override_constants/v_separation = 8
columns = 10
[node name="Slot0" parent="SlotsContainer" instance=ExtResource("3_bup65")]
layout_mode = 2
[node name="Slot1" parent="SlotsContainer" instance=ExtResource("3_bup65")]
layout_mode = 2
[node name="Slot2" parent="SlotsContainer" instance=ExtResource("3_bup65")]
layout_mode = 2
[node name="Slot3" parent="SlotsContainer" instance=ExtResource("3_bup65")]
layout_mode = 2
[node name="Slot4" parent="SlotsContainer" instance=ExtResource("3_bup65")]
layout_mode = 2
[node name="Slot5" parent="SlotsContainer" instance=ExtResource("3_bup65")]
layout_mode = 2
[node name="Slot6" parent="SlotsContainer" instance=ExtResource("3_bup65")]
layout_mode = 2
[node name="Slot7" parent="SlotsContainer" instance=ExtResource("3_bup65")]
layout_mode = 2
[node name="Slot8" parent="SlotsContainer" instance=ExtResource("3_bup65")]
layout_mode = 2
[node name="Slot9" parent="SlotsContainer" instance=ExtResource("3_bup65")]
layout_mode = 2

+ 40
- 0
scenes/ui/quickslots/quickslots_slot.gd View File

@ -0,0 +1,40 @@
class_name QuickSlotsSlot
extends Panel
@export var amount_label: Label
@export var slot_texture: TextureRect
var slot_index: int = 0
func _ready() -> void:
InventoryManager.inventory_slot_updated.connect(_on_inventory_slot_updated)
func init(_slot_index: int) -> void:
slot_index = _slot_index
refresh()
func clear() -> void:
slot_texture.texture = null
amount_label.text = ""
slot_texture.tooltip_text = ""
func refresh() -> void:
if InventoryManager.inventory.size() < 1:
return clear()
elif not InventoryManager.inventory.get(slot_index):
return clear()
elif InventoryManager.inventory[slot_index] == null:
return clear()
slot_texture.texture = load(InventoryManager.inventory[slot_index].item_texture)
amount_label.text = "x" + str(InventoryManager.inventory[slot_index].amount)
slot_texture.tooltip_text = InventoryManager.inventory[slot_index].name + "\n" + InventoryManager.inventory[slot_index].description
func _on_inventory_slot_updated(_slot_index: int) -> void:
if _slot_index != slot_index: return
refresh()

+ 1
- 0
scenes/ui/quickslots/quickslots_slot.gd.uid View File

@ -0,0 +1 @@
uid://cq3yb4beq5f4s

+ 36
- 0
scenes/ui/quickslots/quickslots_slot.tscn View File

@ -0,0 +1,36 @@
[gd_scene load_steps=3 format=3 uid="uid://c40k8ey6e54v1"]
[ext_resource type="Script" uid="uid://cq3yb4beq5f4s" path="res://scenes/ui/quickslots/quickslots_slot.gd" id="1_l6jhe"]
[sub_resource type="LabelSettings" id="LabelSettings_7oxdy"]
outline_size = 3
outline_color = Color(0, 0, 0, 1)
[node name="Slot" type="Panel" node_paths=PackedStringArray("amount_label", "slot_texture")]
custom_minimum_size = Vector2(64, 64)
script = ExtResource("1_l6jhe")
amount_label = NodePath("MarginContainer/AmountLabel")
slot_texture = NodePath("MarginContainer/TextureRect")
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 4
theme_override_constants/margin_top = 4
theme_override_constants/margin_right = 4
theme_override_constants/margin_bottom = 4
[node name="TextureRect" type="TextureRect" parent="MarginContainer"]
texture_filter = 1
layout_mode = 2
expand_mode = 2
[node name="AmountLabel" type="Label" parent="MarginContainer"]
layout_mode = 2
size_flags_horizontal = 8
size_flags_vertical = 8
label_settings = SubResource("LabelSettings_7oxdy")

+ 6
- 2
scenes/ui/ui.tscn View File

@ -1,9 +1,10 @@
[gd_scene load_steps=6 format=3 uid="uid://c7fj7wla8bd70"]
[gd_scene load_steps=7 format=3 uid="uid://c7fj7wla8bd70"]
[ext_resource type="Script" uid="uid://bslimr2y4lnvq" path="res://scenes/ui/ui.gd" id="1_aac20"]
[ext_resource type="PackedScene" uid="uid://dvogu3djluqsn" path="res://scenes/ui/waila.tscn" id="1_u7n8c"]
[ext_resource type="PackedScene" uid="uid://cbiygbgpfk220" path="res://scenes/ui/quick_slots.tscn" id="4_g5kmx"]
[ext_resource type="PackedScene" uid="uid://cbiygbgpfk220" path="res://scenes/ui/quickslots/quick_slots.tscn" id="4_g5kmx"]
[ext_resource type="PackedScene" uid="uid://by0gd600mbcr5" path="res://scenes/ui/pause_menu/pause_menu.tscn" id="5_0dwhk"]
[ext_resource type="PackedScene" uid="uid://dcr25y1lw4wjp" path="res://scenes/ui/inventory/inventory.tscn" id="6_pfayw"]
[ext_resource type="PackedScene" uid="uid://rfknvv8b0d4i" path="res://scenes/ui/autosave_notification.tscn" id="7_jcn1r"]
[node name="UI" type="CanvasLayer"]
@ -35,3 +36,6 @@ visible = false
[node name="PauseMenu" parent="." instance=ExtResource("5_0dwhk")]
visible = false
[node name="Inventory" parent="." instance=ExtResource("6_pfayw")]
visible = false

+ 2
- 2
scenes/world/world.gd View File

@ -64,14 +64,14 @@ func spawn_player(player_position: Transform3D) -> void:
func _create_block(id: String, block_position: Vector3) -> void:
var block: Block = Globals.BLOCK_PREFAB.instantiate()
var block: Block = Block.PREFAB.instantiate()
block.position = block_position
block.set_id(id)
blocks_container.add_child(block)
func _create_dropped_block(id: String, start_position: Vector3, direction: Vector3 = Vector3.ZERO, velocity: float = 0.0) -> void:
var block: DroppedBlock = Globals.DROPPED_BLOCK_PREFAB.instantiate()
var block: DroppedBlock = DroppedBlock.PREFAB.instantiate()
dropped_items_container.add_child(block)
block.initialize(id, start_position, direction, velocity)


+ 1
- 0
scenes/world/world.tscn View File

@ -13,6 +13,7 @@ player_scene = ExtResource("2_sl2e5")
spawn_position = NodePath("SpawnPosition")
[node name="DayNightCycleComponent" parent="." instance=ExtResource("3_6m72w")]
start_time = 0.4
[node name="BlocksContainer" type="Node3D" parent="."]


Loading…
Cancel
Save