Browse Source

Moving DBItems from singleton to autoload

pull/3/head
Ryan Reed 1 month ago
parent
commit
43f9e25dd0
15 changed files with 8 additions and 29 deletions
  1. +0
    -12
      autoloads/db_items.gd
  2. +0
    -0
      autoloads/db_items.gd.uid
  3. +0
    -6
      data_structure/db_items.tscn
  4. +1
    -1
      project.godot
  5. +0
    -0
      resources/block_resource.gd
  6. +0
    -0
      resources/block_resource.gd.uid
  7. +1
    -1
      resources/blocks/001_dirt.tres
  8. +1
    -1
      resources/blocks/002_stone.tres
  9. +1
    -1
      resources/blocks/003_wood.tres
  10. +1
    -1
      resources/blocks/004_leaves.tres
  11. +0
    -0
      resources/item_resource.gd
  12. +0
    -0
      resources/item_resource.gd.uid
  13. +1
    -4
      root.tscn
  14. +1
    -1
      scenes/blocks/block.gd
  15. +1
    -1
      scenes/ui/waila.gd

data_structure/db_items.gd → autoloads/db_items.gd View File

@ -1,18 +1,6 @@
class_name DBItems
extends Node
#region Singleton
static var ref: DBItems
func _init() -> void:
if not ref:
ref = self
else:
queue_free()
#endregion
@onready var data: Dictionary = {
"001": preload("res://resources/blocks/001_dirt.tres"),
"002": preload("res://resources/blocks/002_stone.tres"),

data_structure/db_items.gd.uid → autoloads/db_items.gd.uid View File


+ 0
- 6
data_structure/db_items.tscn View File

@ -1,6 +0,0 @@
[gd_scene load_steps=2 format=3 uid="uid://c0epfh4sqjcjq"]
[ext_resource type="Script" uid="uid://bm3oi0opccjif" path="res://data_structure/db_items.gd" id="1_jp5j0"]
[node name="DBItems" type="Node"]
script = ExtResource("1_jp5j0")

+ 1
- 1
project.godot View File

@ -20,6 +20,7 @@ config/icon="res://icon.svg"
Globals="*res://autoloads/globals.gd"
EntityManager="*res://autoloads/entity_manager.gd"
InventoryManager="*res://autoloads/inventory_manager.gd"
DBItems="*res://autoloads/db_items.gd"
[debug]
@ -34,7 +35,6 @@ folder_colors={
"res://assets/": "red",
"res://assets/ui/": "green",
"res://autoloads/": "orange",
"res://data_structure/": "blue",
"res://resources/": "blue",
"res://scenes/": "yellow",
"res://scenes/ui/": "green"


data_structure/block.gd → resources/block_resource.gd View File


data_structure/block.gd.uid → resources/block_resource.gd.uid View File


+ 1
- 1
resources/blocks/001_dirt.tres View File

@ -1,6 +1,6 @@
[gd_resource type="Resource" script_class="BlockResource" load_steps=3 format=3 uid="uid://bu0yoee1rs1se"]
[ext_resource type="Script" uid="uid://dwrmy4mx0mw18" path="res://data_structure/block.gd" id="1_ljghb"]
[ext_resource type="Script" uid="uid://dwrmy4mx0mw18" path="res://resources/block_resource.gd" id="1_ljghb"]
[ext_resource type="Material" uid="uid://uex0dq00xomt" path="res://assets/materials/dirt.tres" id="1_n1cq6"]
[resource]


+ 1
- 1
resources/blocks/002_stone.tres View File

@ -1,7 +1,7 @@
[gd_resource type="Resource" script_class="BlockResource" load_steps=3 format=3 uid="uid://cpddnknmxpohc"]
[ext_resource type="Material" uid="uid://cx7m27qa4ds4s" path="res://assets/materials/stone.tres" id="1_6chm7"]
[ext_resource type="Script" uid="uid://dwrmy4mx0mw18" path="res://data_structure/block.gd" id="1_63t5s"]
[ext_resource type="Script" uid="uid://dwrmy4mx0mw18" path="res://resources/block_resource.gd" id="1_63t5s"]
[resource]
script = ExtResource("1_63t5s")


+ 1
- 1
resources/blocks/003_wood.tres View File

@ -1,7 +1,7 @@
[gd_resource type="Resource" script_class="BlockResource" load_steps=4 format=3 uid="uid://bvudydis6w27b"]
[ext_resource type="Material" uid="uid://bnqiumcb3ixan" path="res://assets/materials/wood_ends.tres" id="1_1n8h6"]
[ext_resource type="Script" uid="uid://dwrmy4mx0mw18" path="res://data_structure/block.gd" id="2_1n8h6"]
[ext_resource type="Script" uid="uid://dwrmy4mx0mw18" path="res://resources/block_resource.gd" id="2_1n8h6"]
[ext_resource type="Material" uid="uid://h0naiw6swfkl" path="res://assets/materials/wood_side.tres" id="2_o823h"]
[resource]


+ 1
- 1
resources/blocks/004_leaves.tres View File

@ -1,7 +1,7 @@
[gd_resource type="Resource" script_class="BlockResource" load_steps=3 format=3 uid="uid://4knt6o2ohku3"]
[ext_resource type="Material" uid="uid://d15n1p3spu3jg" path="res://assets/materials/leaves.tres" id="1_dbmit"]
[ext_resource type="Script" uid="uid://dwrmy4mx0mw18" path="res://data_structure/block.gd" id="3_kuops"]
[ext_resource type="Script" uid="uid://dwrmy4mx0mw18" path="res://resources/block_resource.gd" id="3_kuops"]
[resource]
script = ExtResource("3_kuops")


data_structure/item.gd → resources/item_resource.gd View File


data_structure/item.gd.uid → resources/item_resource.gd.uid View File


+ 1
- 4
root.tscn View File

@ -1,13 +1,10 @@
[gd_scene load_steps=4 format=3 uid="uid://cgx0nawwjjj7g"]
[gd_scene load_steps=3 format=3 uid="uid://cgx0nawwjjj7g"]
[ext_resource type="PackedScene" uid="uid://c0epfh4sqjcjq" path="res://data_structure/db_items.tscn" id="1_pyidc"]
[ext_resource type="PackedScene" uid="uid://mkfitwqnerku" path="res://scenes/world/world.tscn" id="2_vvh5c"]
[ext_resource type="PackedScene" uid="uid://c7fj7wla8bd70" path="res://scenes/ui/ui.tscn" id="3_vvh5c"]
[node name="Root" type="Node"]
[node name="DBItems" parent="." instance=ExtResource("1_pyidc")]
[node name="World" parent="." instance=ExtResource("2_vvh5c")]
[node name="UI" parent="." instance=ExtResource("3_vvh5c")]

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

@ -71,4 +71,4 @@ func _load_resource_data() -> void:
printerr("Block ID was expected but was not received")
return
resource = DBItems.ref.data[id]
resource = DBItems.data[id]

+ 1
- 1
scenes/ui/waila.gd View File

@ -31,7 +31,7 @@ func get_target() -> Block:
func hook_target(id: String) -> void:
if not Globals.enable_waila: return
var item: ItemResource = DBItems.ref.data[id]
var item: ItemResource = DBItems.data[id]
name_label.text = item.name + " (" + id + ")"
description_label.text = item.description
position_label.text = str(_target.position)


Loading…
Cancel
Save