Reorganized files, started splitting up unit

This commit is contained in:
gamer147
2026-04-08 18:28:52 -04:00
parent 24134cfa33
commit c192d48bc4
70 changed files with 528 additions and 56 deletions

View File

@@ -1,6 +1,6 @@
[gd_resource type="Resource" script_class="UnitAllegiance" format=3 uid="uid://cuc7kkknpsr1g"]
[ext_resource type="Script" uid="uid://bhglsexm8dtpj" path="res://resources/resource_definitions/unit_allegiance.gd" id="1_40cg2"]
[ext_resource type="Script" uid="uid://bhglsexm8dtpj" path="res://scripts/units/unit_allegiance.gd" id="1_40cg2"]
[resource]
script = ExtResource("1_40cg2")

View File

@@ -1,6 +1,6 @@
[gd_resource type="Resource" script_class="UnitAllegiance" format=3 uid="uid://dufi2h00j5vrq"]
[ext_resource type="Script" uid="uid://bhglsexm8dtpj" path="res://resources/resource_definitions/unit_allegiance.gd" id="1_4mkdx"]
[ext_resource type="Script" uid="uid://bhglsexm8dtpj" path="res://scripts/units/unit_allegiance.gd" id="1_4mkdx"]
[resource]
script = ExtResource("1_4mkdx")

View File

@@ -1,15 +0,0 @@
class_name HelpCommand extends ConsoleCommand
func get_command_name() -> String:
return "help"
func get_help_text() -> String:
return "Lists all available commands"
func run(args: Array, context: Dictionary) -> String:
var commands: Array = context["commands"]
var lines: PackedStringArray = []
for command: ConsoleCommand in commands:
lines.append("%s - %s" % [command.get_command_name(), command.get_help_text()])
lines.append("Any other input is evaluated as a GDScript expression.")
return "\n".join(lines)

View File

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

View File

@@ -1,14 +0,0 @@
class_name ListScenesCommand extends ConsoleCommand
func get_command_name() -> String:
return "list_scenes"
func get_help_text() -> String:
return "Lists available scenes for swapping"
func run(args: Array, context: Dictionary) -> String:
var registry: Array = context["scene_registry"]
var lines: PackedStringArray = []
for entry: Dictionary in registry:
lines.append(entry["name"])
return "\n".join(lines)

View File

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

View File

@@ -1,21 +0,0 @@
class_name SwapCommand extends ConsoleCommand
func get_command_name() -> String:
return "swap"
func get_help_text() -> String:
return "swap <name> - Swap to a scene by name (use list_scenes to see options)"
func run(args: Array, context: Dictionary) -> String:
if args.size() == 0:
return "Usage: swap <scene name>"
var search_name := " ".join(args).to_lower()
var registry: Array = context["scene_registry"]
for entry: Dictionary in registry:
if entry["name"].to_lower() == search_name:
var debug_menu: DebugMenu = context["debug_menu"]
debug_menu.swap_scene(entry)
return ""
return "Scene not found: %s" % search_name

View File

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

View File

@@ -1,5 +0,0 @@
# resources/resource_definitions/any_combat_tactic_range.gd
class_name AnyCombatTacticRange extends CombatTacticRange
func is_valid_range(distance: int, unit: Unit) -> bool:
return true

View File

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

View File

@@ -1,10 +0,0 @@
class_name AttackCombatTactic extends CombatTactic
func get_offensive_stats(unit: Unit) -> Variant:
return {"atk": unit.current_stats.phys_atk, "hit": unit.current_stats.hit}
func get_relevant_defense(unit: Unit) -> int:
return unit.current_stats.phys_def
func deals_damage() -> bool:
return true

View File

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

View File

@@ -1,16 +0,0 @@
class_name CombatProposal extends Resource
class CombatantStats:
var unit: Unit
var max_hp: int
var hp: int
var sp: int
var hit: int
var atk: int
var def: int
var spd: int
var available_tactics: Array[CombatTactic] = []
var selected_tactic: CombatTactic
var attacker: CombatantStats
var defender: CombatantStats

View File

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

View File

@@ -1,13 +0,0 @@
class_name CombatTactic extends Resource
@export var tactic_name: String = ""
@export var tactic_range: CombatTacticRange
func get_offensive_stats(unit: Unit) -> Variant:
return null
func get_relevant_defense(unit: Unit) -> int:
return unit.current_stats.phys_def
func deals_damage() -> bool:
return false

View File

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

View File

@@ -1,5 +0,0 @@
# resources/resource_definitions/combat_tactic_range.gd
class_name CombatTacticRange extends Resource
func is_valid_range(distance: int, unit: Unit) -> bool:
return false

View File

@@ -1 +0,0 @@
uid://5cr4kl14gvd7

View File

@@ -1,10 +0,0 @@
class_name ConsoleCommand extends RefCounted
func get_command_name() -> String:
return ""
func get_help_text() -> String:
return ""
func run(args: Array, context: Dictionary) -> String:
return ""

View File

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

View File

@@ -1,10 +0,0 @@
class_name DefendCombatTactic extends CombatTactic
func get_offensive_stats(unit: Unit) -> Variant:
return null
func get_relevant_defense(unit: Unit) -> int:
return unit.current_stats.phys_def
func deals_damage() -> bool:
return false

View File

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

View File

@@ -1,4 +0,0 @@
class_name DLTileset extends Resource
@export var floor_tile_coords: Vector2i
@export var wall_tile_coords: Vector2i

View File

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

View File

@@ -1,7 +0,0 @@
# resources/resource_definitions/fixed_combat_tactic_range.gd
class_name FixedCombatTacticRange extends CombatTacticRange
@export var tactic_range: int = 1
func is_valid_range(distance: int, unit: Unit) -> bool:
return distance <= tactic_range

View File

@@ -1 +0,0 @@
uid://6jxhvwrkiq6f

View File

@@ -1,81 +0,0 @@
class_name MapLayout extends Resource
@export var size: Vector2i = Vector2i.ZERO
@export var rooms: Array[Room]
## Openings are stored as a flat array of pairs: [from1, to1, from2, to2, ...].
## Each consecutive pair of Vector2i values represents a bidirectional doorway
## between two adjacent tiles in different rooms.
@export var openings: Array[Vector2i]
var _tile_room_map: Dictionary = {}
var _opening_set: Dictionary = {}
func initialize() -> void:
assert(openings.size() % 2 == 0, "Openings must be provided as pairs of Vector2i")
_tile_room_map.clear()
_opening_set.clear()
for room in rooms:
for tile in room.tiles:
_tile_room_map[tile] = room
for i in range(0, openings.size(), 2):
var a := openings[i]
var b := openings[i + 1]
_opening_set[_edge_key(a, b)] = true
static func _edge_key(a: Vector2i, b: Vector2i) -> String:
if a < b:
return "%d,%d-%d,%d" % [a.x, a.y, b.x, b.y]
return "%d,%d-%d,%d" % [b.x, b.y, a.x, a.y]
func is_tile_valid(tile: Vector2i) -> bool:
return _tile_room_map.has(tile)
func get_room_at(tile: Vector2i) -> Room:
return _tile_room_map.get(tile, null)
func is_passable(from: Vector2i, to: Vector2i) -> bool:
if not is_tile_valid(from) or not is_tile_valid(to):
return false
var room_from: Room = _tile_room_map[from]
var room_to: Room = _tile_room_map[to]
if room_from == room_to:
return true
return _opening_set.has(_edge_key(from, to))
func get_openings() -> Array:
## Returns an array of [Vector2i, Vector2i] pairs representing opening edges.
var result: Array = []
for i in range(0, openings.size(), 2):
result.append([openings[i], openings[i + 1]])
return result
func get_walls() -> Array:
## Returns an array of [Vector2i, Vector2i] pairs representing wall edges.
## A wall exists where a room tile borders void or a different room (without an opening).
var walls: Array = []
var directions := [Vector2i.RIGHT, Vector2i.DOWN, Vector2i.LEFT, Vector2i.UP]
var visited_edges: Dictionary = {}
for room in rooms:
for tile in room.tiles:
for dir in directions:
var neighbor: Vector2i = tile + dir
var key := _edge_key(tile, neighbor)
if visited_edges.has(key):
continue
visited_edges[key] = true
var neighbor_room: Room = _tile_room_map.get(neighbor, null)
if neighbor_room == room:
continue
# Neighbor is void or different room — wall unless opening
if not _opening_set.has(key):
walls.append([tile, neighbor])
return walls

View File

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

View File

@@ -1,4 +0,0 @@
class_name Room extends Resource
@export var id: int
@export var tiles: Array[Vector2i]

View File

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

View File

@@ -1,12 +0,0 @@
class_name UnitAllegiance extends Resource
enum AllegianceType {
PLAYER,
ENEMY,
PLAYER_ALLY,
ENEMY_ALLY,
UNAFFILIATED
}
@export var type: AllegianceType
@export var color: Color

View File

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

View File

@@ -1,3 +0,0 @@
class_name UnitInfo extends Resource
@export var name: String = "Unit"

View File

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

View File

@@ -1,5 +0,0 @@
# resources/resource_definitions/unit_matching_combat_tactic_range.gd
class_name UnitMatchingCombatTacticRange extends CombatTacticRange
func is_valid_range(distance: int, unit: Unit) -> bool:
return distance <= unit.current_stats.atk_range

View File

@@ -1 +0,0 @@
uid://7locjqufdkgj

View File

@@ -1,19 +0,0 @@
class_name UnitStats extends Resource
@export var max_hp: int = 10
@export var current_hp: int
@export var max_sp: int = 10
@export var current_sp: int = 10
@export var phys_atk: int = 10
@export var phys_def: int = 5
@export var magic_atk: int = 0
@export var magic_def: int = 0
@export var hit: int = 85
@export var atk_range: int = 1
@export var spd: int = 1
@export var eva: int = 1
@export var lck: int = 1
func _init(max_hp: int = 10) -> void:
self.max_hp = max_hp
current_hp = max_hp

View File

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