Big project cleanup with overhaul of file responsibilities (KISS) and code (DRY, YAGNI)
This commit is contained in:
@@ -2,7 +2,7 @@ using Godot;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
|
||||
public partial class ResourceLoader
|
||||
public static class ResourceLoader
|
||||
{
|
||||
private const string LayerPrefabPath = "res://Prefabs/Layer.tscn";
|
||||
private const string RobotPrefabPath = "res://Prefabs/Robot/Robot.tscn";
|
||||
@@ -39,7 +39,7 @@ public partial class ResourceLoader
|
||||
public static Dictionary<string, MeshInstance3D> LoadTiles()
|
||||
{
|
||||
Dictionary<string, MeshInstance3D> tileMeshes = new Dictionary<string, MeshInstance3D>();
|
||||
PackedScene tileCollection = GD.Load<PackedScene>($"res://Assets/Objects/Tiles.glb");
|
||||
PackedScene tileCollection = GD.Load<PackedScene>("res://Assets/Objects/Tiles.glb");
|
||||
Node root = tileCollection.Instantiate();
|
||||
foreach (MeshInstance3D child in root.GetChildren())
|
||||
{
|
||||
@@ -52,7 +52,7 @@ public partial class ResourceLoader
|
||||
public static Dictionary<string, MeshInstance3D> LoadDecorations()
|
||||
{
|
||||
Dictionary<string, MeshInstance3D> decorationMeshes = new Dictionary<string, MeshInstance3D>();
|
||||
PackedScene decorationCollection = GD.Load<PackedScene>($"res://Assets/Objects/Decorations.glb");
|
||||
PackedScene decorationCollection = GD.Load<PackedScene>("res://Assets/Objects/Decorations.glb");
|
||||
Node root = decorationCollection.Instantiate();
|
||||
foreach (MeshInstance3D child in root.GetChildren())
|
||||
{
|
||||
@@ -114,8 +114,9 @@ public partial class ResourceLoader
|
||||
|
||||
public static SortedDictionary<string, ItemData> LoadItems()
|
||||
{
|
||||
|
||||
FileAccess file = FileAccess.Open(RecipesPath, FileAccess.ModeFlags.Read);
|
||||
if (file == null) return new SortedDictionary<string, ItemData>();
|
||||
|
||||
string json = file.GetAsText();
|
||||
|
||||
SortedDictionary<string, ItemData> result = new SortedDictionary<string, ItemData>();
|
||||
@@ -133,8 +134,9 @@ public partial class ResourceLoader
|
||||
|
||||
public static Dictionary<string, Research> LoadResearch()
|
||||
{
|
||||
|
||||
FileAccess file = FileAccess.Open(ResearchPath, FileAccess.ModeFlags.Read);
|
||||
if (file == null) return new Dictionary<string, Research>();
|
||||
|
||||
string json = file.GetAsText();
|
||||
|
||||
Dictionary<string, Research> result = new Dictionary<string, Research>();
|
||||
|
||||
Reference in New Issue
Block a user