#84: move 215 root files into a folder hierarchy
Everything lived in one flat directory, so a diff gave no clue what area it touched and finding the file you wanted meant knowing its exact name. Twelve folders now, grouped by what a thing IS rather than what type it is - a vessel's definition, its component scenes and its upgrade resources sit together, because that is the set you read when you change one of them. buildings core controllers enemies logistics planets resources shaders surface ui vessels vfx world 332 files moved and every res:// reference rewritten - 306 files touched, including the autoload and main-scene paths in project.godot. Nothing renamed: this is purely where files sit, so the diff is a pile of pure moves and no behaviour is buried in it. ui_theme.tres, icon.svg and web_shell.html stay at the root, where Godot and the export preset expect them. Verified three ways, because a suite alone would not have caught all of it: the full 117 pass, the web export builds clean, and the game renders. The export is why that matters. The FIRST export after the move failed with "Attempt to open script 'res://GameState.gd'" - the old path - while project.godot on disk plainly said res://core/GameState.gd. That is this project's documented Android FUSE mtime trap: Godot served a cached copy of a file whose content had changed. A `touch` fixed it. Nothing in the test suite would have found that, because the suite runs from a copy on a native filesystem - the one place the bug cannot happen. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
baac11ae8b
commit
2f161621c3
495 changed files with 571 additions and 567 deletions
11
resources/DarkMatterResourceDefinition.tres
Normal file
11
resources/DarkMatterResourceDefinition.tres
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
[gd_resource type="Resource" script_class="ResourceDefinition" load_steps=3 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://resources/ResourceDefinition.gd" id="1"]
|
||||
[ext_resource type="PackedScene" path="res://resources/DarkMatterResourceGlyph.tscn" id="2"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
resource_id = "dark_matter"
|
||||
display_name = "Dark Matter"
|
||||
color = Color(0.55, 0.15, 0.85, 1)
|
||||
glyph_scene = ExtResource("2")
|
||||
26
resources/DarkMatterResourceGlyph.gd
Normal file
26
resources/DarkMatterResourceGlyph.gd
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
extends Control
|
||||
|
||||
@export var colour: Color = Color(0.55, 0.15, 0.85)
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
var centre: Vector2 = size * 0.5
|
||||
var radius: float = minf(size.x, size.y) * 0.34
|
||||
var points := PackedVector2Array()
|
||||
for i in range(8):
|
||||
var angle: float = TAU * float(i) / 8.0 - PI * 0.5
|
||||
points.append(centre + Vector2(cos(angle), sin(angle)) * radius)
|
||||
# Deep violet glow around a near-black core - not colour.darkened() like
|
||||
# every other glyph's core, deliberately: dark matter has to read as an
|
||||
# absence even against deep space, where a merely-darker version of the
|
||||
# glow colour would still show up as a faint fill instead of a void
|
||||
# with a rim.
|
||||
NeonDraw.draw_glowing_polygon(self, points, colour, 1.0, Color(0.04, 0.01, 0.06), maxf(0.5, radius * 0.035))
|
||||
# A tighter inner ring hints at an event horizon rather than a solid
|
||||
# body - the same outline-only idiom every glyph already uses, just
|
||||
# nested once more.
|
||||
var inner := PackedVector2Array()
|
||||
for i in range(8):
|
||||
var angle: float = TAU * float(i) / 8.0 - PI * 0.5
|
||||
inner.append(centre + Vector2(cos(angle), sin(angle)) * radius * 0.5)
|
||||
NeonDraw.draw_glowing_polygon(self, inner, colour.lightened(0.25), 0.75, Color(0.04, 0.01, 0.06), maxf(0.35, radius * 0.02))
|
||||
1
resources/DarkMatterResourceGlyph.gd.uid
Normal file
1
resources/DarkMatterResourceGlyph.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bldtveflnyu2x
|
||||
13
resources/DarkMatterResourceGlyph.tscn
Normal file
13
resources/DarkMatterResourceGlyph.tscn
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://resources/DarkMatterResourceGlyph.gd" id="1"]
|
||||
|
||||
[node name="GlyphVisual" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
script = ExtResource("1")
|
||||
11
resources/EnergyResourceDefinition.tres
Normal file
11
resources/EnergyResourceDefinition.tres
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
[gd_resource type="Resource" script_class="ResourceDefinition" load_steps=3 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://resources/ResourceDefinition.gd" id="1"]
|
||||
[ext_resource type="PackedScene" path="res://resources/EnergyResourceGlyph.tscn" id="2"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
resource_id = "energy"
|
||||
display_name = "Energy"
|
||||
color = Color(0.85, 0.95, 0.15, 1)
|
||||
glyph_scene = ExtResource("2")
|
||||
26
resources/EnergyResourceGlyph.gd
Normal file
26
resources/EnergyResourceGlyph.gd
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
extends Control
|
||||
|
||||
@export var colour: Color = Color(0.85, 0.95, 0.15)
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
var centre: Vector2 = size * 0.5
|
||||
var radius: float = minf(size.x, size.y) * 0.34
|
||||
# A cell outline (battery/reactor cell, same hexagon family as the ore
|
||||
# glyph's own outline) with a bolt struck through it, so energy reads as
|
||||
# "stored power" rather than being confused with ore's plain hexagon.
|
||||
var cell := PackedVector2Array()
|
||||
for i in range(6):
|
||||
var angle: float = TAU * float(i) / 6.0 - PI * 0.5
|
||||
cell.append(centre + Vector2(cos(angle), sin(angle)) * radius)
|
||||
NeonDraw.draw_glowing_polygon(self, cell, colour, 1.0, colour.darkened(0.78), maxf(0.5, radius * 0.035))
|
||||
|
||||
var bolt := PackedVector2Array([
|
||||
centre + Vector2(radius * 0.18, -radius * 0.75),
|
||||
centre + Vector2(-radius * 0.32, radius * 0.05),
|
||||
centre + Vector2(radius * 0.05, radius * 0.05),
|
||||
centre + Vector2(-radius * 0.18, radius * 0.75),
|
||||
centre + Vector2(radius * 0.32, -radius * 0.05),
|
||||
centre + Vector2(radius * 0.0, -radius * 0.05),
|
||||
])
|
||||
NeonDraw.draw_glowing_polygon(self, bolt, colour.lightened(0.35), 1.0, colour.darkened(0.6), maxf(0.4, radius * 0.03))
|
||||
1
resources/EnergyResourceGlyph.gd.uid
Normal file
1
resources/EnergyResourceGlyph.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b3b64pvw4y53x
|
||||
13
resources/EnergyResourceGlyph.tscn
Normal file
13
resources/EnergyResourceGlyph.tscn
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://resources/EnergyResourceGlyph.gd" id="1"]
|
||||
|
||||
[node name="GlyphVisual" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
script = ExtResource("1")
|
||||
11
resources/GasResourceDefinition.tres
Normal file
11
resources/GasResourceDefinition.tres
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
[gd_resource type="Resource" script_class="ResourceDefinition" load_steps=3 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://resources/ResourceDefinition.gd" id="1"]
|
||||
[ext_resource type="PackedScene" path="res://resources/GasResourceGlyph.tscn" id="2"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
resource_id = "gas"
|
||||
display_name = "Gas"
|
||||
color = Color(0.85, 0.52, 1, 1)
|
||||
glyph_scene = ExtResource("2")
|
||||
19
resources/GasResourceGlyph.gd
Normal file
19
resources/GasResourceGlyph.gd
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
extends Control
|
||||
|
||||
@export var colour: Color = Color(0.85, 0.52, 1.0)
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
var centre: Vector2 = size * 0.5
|
||||
var radius: float = minf(size.x, size.y) * 0.34
|
||||
var bubbles: Array = [
|
||||
[centre + Vector2(-radius * 0.38, radius * 0.12), radius * 0.46],
|
||||
[centre + Vector2(radius * 0.34, radius * 0.26), radius * 0.58],
|
||||
[centre + Vector2(radius * 0.38, -radius * 0.48), radius * 0.32],
|
||||
]
|
||||
for bubble in bubbles:
|
||||
var ring := PackedVector2Array()
|
||||
for i in range(12):
|
||||
var angle: float = TAU * float(i) / 12.0
|
||||
ring.append(bubble[0] + Vector2(cos(angle), sin(angle)) * float(bubble[1]))
|
||||
NeonDraw.draw_glowing_polygon(self, ring, colour, 1.0, colour.darkened(0.78), maxf(0.5, radius * 0.035))
|
||||
1
resources/GasResourceGlyph.gd.uid
Normal file
1
resources/GasResourceGlyph.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://d1ko6yhtjjavx
|
||||
13
resources/GasResourceGlyph.tscn
Normal file
13
resources/GasResourceGlyph.tscn
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://resources/GasResourceGlyph.gd" id="1"]
|
||||
|
||||
[node name="GlyphVisual" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
script = ExtResource("1")
|
||||
79
resources/Inventory.gd
Normal file
79
resources/Inventory.gd
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
class_name Inventory
|
||||
extends RefCounted
|
||||
|
||||
var total_capacity: int = -1
|
||||
var resource_capacities: Dictionary = {}
|
||||
var _amounts: Dictionary = {}
|
||||
|
||||
|
||||
func _init(initial: Dictionary = {}, capacity: int = -1) -> void:
|
||||
total_capacity = capacity
|
||||
for resource_id in initial:
|
||||
set_amount(String(resource_id), int(initial[resource_id]))
|
||||
|
||||
|
||||
func amount(resource_id: String) -> int:
|
||||
return int(_amounts.get(resource_id, 0))
|
||||
|
||||
|
||||
func total() -> int:
|
||||
var result: int = 0
|
||||
for value in _amounts.values():
|
||||
result += int(value)
|
||||
return result
|
||||
|
||||
|
||||
func capacity_for(resource_id: String) -> int:
|
||||
return int(resource_capacities.get(resource_id, -1))
|
||||
|
||||
|
||||
func space_for(resource_id: String) -> int:
|
||||
var space: int = 1 << 30
|
||||
if total_capacity >= 0:
|
||||
space = maxi(total_capacity - total(), 0)
|
||||
var resource_capacity: int = capacity_for(resource_id)
|
||||
if resource_capacity >= 0:
|
||||
space = mini(space, maxi(resource_capacity - amount(resource_id), 0))
|
||||
return space
|
||||
|
||||
|
||||
func set_amount(resource_id: String, value: int) -> int:
|
||||
_amounts.erase(resource_id)
|
||||
var accepted: int = mini(maxi(value, 0), space_for(resource_id))
|
||||
if accepted > 0:
|
||||
_amounts[resource_id] = accepted
|
||||
return amount(resource_id)
|
||||
|
||||
|
||||
func deposit(resource_id: String, requested: int) -> int:
|
||||
var moved: int = mini(maxi(requested, 0), space_for(resource_id))
|
||||
if moved > 0:
|
||||
_amounts[resource_id] = amount(resource_id) + moved
|
||||
return moved
|
||||
|
||||
|
||||
func withdraw(resource_id: String, requested: int) -> int:
|
||||
var moved: int = mini(maxi(requested, 0), amount(resource_id))
|
||||
if moved <= 0:
|
||||
return 0
|
||||
var remaining: int = amount(resource_id) - moved
|
||||
if remaining > 0:
|
||||
_amounts[resource_id] = remaining
|
||||
else:
|
||||
_amounts.erase(resource_id)
|
||||
return moved
|
||||
|
||||
|
||||
func transfer_to(destination: Inventory, resource_id: String, requested: int) -> int:
|
||||
if destination == null:
|
||||
return 0
|
||||
var moved: int = mini(mini(maxi(requested, 0), amount(resource_id)), destination.space_for(resource_id))
|
||||
if moved <= 0:
|
||||
return 0
|
||||
withdraw(resource_id, moved)
|
||||
destination.deposit(resource_id, moved)
|
||||
return moved
|
||||
|
||||
|
||||
func snapshot() -> Dictionary:
|
||||
return _amounts.duplicate()
|
||||
1
resources/Inventory.gd.uid
Normal file
1
resources/Inventory.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://celx1yj6cp2rf
|
||||
11
resources/OreResourceDefinition.tres
Normal file
11
resources/OreResourceDefinition.tres
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
[gd_resource type="Resource" script_class="ResourceDefinition" load_steps=3 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://resources/ResourceDefinition.gd" id="1"]
|
||||
[ext_resource type="PackedScene" path="res://resources/OreResourceGlyph.tscn" id="2"]
|
||||
|
||||
[resource]
|
||||
script = ExtResource("1")
|
||||
resource_id = "ore"
|
||||
display_name = "Ore"
|
||||
color = Color(0, 0.72, 0.82, 1)
|
||||
glyph_scene = ExtResource("2")
|
||||
14
resources/OreResourceGlyph.gd
Normal file
14
resources/OreResourceGlyph.gd
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
extends Control
|
||||
|
||||
@export var colour: Color = Color(0.0, 0.72, 0.82)
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
var centre: Vector2 = size * 0.5
|
||||
var radius: float = minf(size.x, size.y) * 0.34
|
||||
var points := PackedVector2Array()
|
||||
for i in range(6):
|
||||
var angle: float = TAU * float(i) / 6.0 - PI * 0.5
|
||||
points.append(centre + Vector2(cos(angle), sin(angle)) * radius)
|
||||
NeonDraw.draw_glowing_polygon(self, points, colour, 1.0, colour.darkened(0.78), maxf(0.5, radius * 0.035))
|
||||
NeonDraw.draw_glowing_line(self, points[5], points[2], colour, 0.55, maxf(0.4, radius * 0.025), colour.darkened(0.78))
|
||||
1
resources/OreResourceGlyph.gd.uid
Normal file
1
resources/OreResourceGlyph.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cwgkhqo4ev5ao
|
||||
13
resources/OreResourceGlyph.tscn
Normal file
13
resources/OreResourceGlyph.tscn
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://resources/OreResourceGlyph.gd" id="1"]
|
||||
|
||||
[node name="GlyphVisual" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
mouse_filter = 2
|
||||
script = ExtResource("1")
|
||||
7
resources/ResourceDefinition.gd
Normal file
7
resources/ResourceDefinition.gd
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
class_name ResourceDefinition
|
||||
extends Resource
|
||||
|
||||
@export var resource_id: String = "ore"
|
||||
@export var display_name: String = "Ore"
|
||||
@export var color: Color = Color.WHITE
|
||||
@export var glyph_scene: PackedScene
|
||||
1
resources/ResourceDefinition.gd.uid
Normal file
1
resources/ResourceDefinition.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://kvy02iu7pbyu
|
||||
22
resources/ResourceDefinitions.gd
Normal file
22
resources/ResourceDefinitions.gd
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
class_name ResourceDefinitions
|
||||
extends RefCounted
|
||||
|
||||
const ORE_ID: String = "ore"
|
||||
const GAS_ID: String = "gas"
|
||||
const ENERGY_ID: String = "energy"
|
||||
const DARK_MATTER_ID: String = "dark_matter"
|
||||
const ORDER: PackedStringArray = [ORE_ID, GAS_ID, ENERGY_ID, DARK_MATTER_ID]
|
||||
const DEFINITIONS: Dictionary = {
|
||||
ORE_ID: preload("res://resources/OreResourceDefinition.tres"),
|
||||
GAS_ID: preload("res://resources/GasResourceDefinition.tres"),
|
||||
ENERGY_ID: preload("res://resources/EnergyResourceDefinition.tres"),
|
||||
DARK_MATTER_ID: preload("res://resources/DarkMatterResourceDefinition.tres"),
|
||||
}
|
||||
|
||||
|
||||
static func get_definition(resource_id: String) -> Resource:
|
||||
return DEFINITIONS.get(resource_id)
|
||||
|
||||
|
||||
static func ids() -> PackedStringArray:
|
||||
return ORDER
|
||||
1
resources/ResourceDefinitions.gd.uid
Normal file
1
resources/ResourceDefinitions.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://ci7yyyxyd3o67
|
||||
34
resources/ResourceGlyph.gd
Normal file
34
resources/ResourceGlyph.gd
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
class_name ResourceGlyph
|
||||
extends Control
|
||||
|
||||
const RESOURCE_DEFINITIONS = preload("res://resources/ResourceDefinitions.gd")
|
||||
|
||||
# A small, non-interactive resource mark shared by tables and transfer rows.
|
||||
# Resource buttons used to borrow IconButton, which made decorative icons
|
||||
# look tappable and encouraged each screen to invent its own version.
|
||||
|
||||
@export var resource_type: String = GameState.RESOURCE_ORE: set = set_resource_type
|
||||
|
||||
|
||||
func set_resource_type(value: String) -> void:
|
||||
if resource_type == value:
|
||||
return
|
||||
resource_type = value
|
||||
if is_node_ready():
|
||||
_rebuild_visual()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
_rebuild_visual()
|
||||
|
||||
|
||||
func _rebuild_visual() -> void:
|
||||
for child in get_children():
|
||||
child.queue_free()
|
||||
var definition: Resource = RESOURCE_DEFINITIONS.get_definition(resource_type)
|
||||
if definition == null or definition.glyph_scene == null:
|
||||
return
|
||||
var visual: Control = definition.glyph_scene.instantiate()
|
||||
visual.colour = definition.color
|
||||
add_child(visual)
|
||||
1
resources/ResourceGlyph.gd.uid
Normal file
1
resources/ResourceGlyph.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://beff2kjshg4vf
|
||||
Loading…
Reference in a new issue