Bit more cleanup

This commit is contained in:
2025-05-06 16:21:22 -05:00
parent 85a7ed99bf
commit 0dfb9743f6
51 changed files with 15 additions and 41 deletions

View File

@@ -0,0 +1,9 @@
extends Node
const Battle = preload("res://scripts/Battle/Battle.gd");
var battle:Battle = null;
func startBattle(battle:Battle) -> void:
print("start battle");
self.battle = battle;

View File

@@ -0,0 +1 @@
uid://2ejo2auklqhu

View File

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

View File

@@ -0,0 +1,5 @@
extends Node
const CookingGame = preload("res://scripts/Cooking/CookingGame.gd");
var game:CookingGame = null;

View File

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

View File

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

View File

@@ -0,0 +1,22 @@
extends Node
var currentCutscene:Cutscene = null;
func _process(delta: float) -> void:
if PAUSE.getPauseState() == PAUSE.PauseType.FULLY_PAUSED:
return;
if currentCutscene != null:
currentCutscene.update(delta);
func _exit_tree() -> void:
if currentCutscene != null:
currentCutscene.clear();
func setCurrentCutscene(cutscene:Cutscene) -> void:
if currentCutscene != null:
currentCutscene.clear();
currentCutscene = cutscene;
cutscene.cutsceneSystem = self;
currentCutscene.setupCutscene();

View File

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

View File

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

View File

@@ -0,0 +1,22 @@
extends Node
var debugMenu:DebugMenu
func _ready() -> void:
debugMenu = $SubsceneUI/DebugMenu;
debugMenu.hide()
func _process(delta: float) -> void:
if Input.is_action_just_pressed("debug"):
print("Debug key pressed")
if debugMenu.is_visible():
hideMenu()
else:
showMenu()
func showMenu() -> void:
debugMenu.show()
print("Debug menu shown")
func hideMenu() -> void:
debugMenu.hide()

View File

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

106
scripts/Singleton/Item.gd Normal file
View File

@@ -0,0 +1,106 @@
extends Node
const Item = preload("res://scripts/Item/Item.gd");
const ItemStack = preload("res://scripts/Item/ItemStack.gd");
enum ItemSortType {
NAME,
TYPE
};
class ItemStackNameComparator:
static func _sort(a, b):
return a.item.getName().to_lower() < b.item.getName().to_lower()
class ItemStackTypeComparator:
static func _sort(a, b):
return a.item.getCategory() < b.item.getCategory()
# Constants
const ITEM_STACK_SIZE_MAX = 99;
static var ITEM_POTION = preload("res://scripts/Item/Potion.gd").new();
# Class
var inventory:Array[ItemStack] = [];
# Methods
func addItem(item: Item, quantity: int = 1) -> void:
print("Adding ", quantity, "x ", item.getName());
if !item.isStackable():
# Item cannot be stacked, add each item to inv
for i in range(quantity):
inventory.append(ItemStack.new(item, 1))
return
# Check for existing stacks
for stack in inventory:
if stack.item != item or stack.quantity >= ITEM_STACK_SIZE_MAX:
continue
var spaceAvailable = ITEM_STACK_SIZE_MAX - stack.quantity
if quantity <= spaceAvailable:
stack.quantity += quantity;
return
stack.quantity = ITEM_STACK_SIZE_MAX;
quantity -= spaceAvailable;
# Add any remaining inventory as new stack.
while quantity > 0:
var newStackQuantity = min(quantity, ITEM_STACK_SIZE_MAX);
inventory.append(ItemStack.new(item, newStackQuantity));
quantity -= newStackQuantity;
func removeItem(item: Item, quantity: int) -> void:
var totalQuantity = 0
# Calculate total quantity of the item in the inventory
for stack in inventory:
if stack.item != item:
continue
totalQuantity += stack.quantity
if totalQuantity < quantity:
push_error("Not enough quantity to remove");
return
# Remove the quantity from the stacks
for stack in inventory:
if stack.item != item:
continue
if stack.quantity < quantity:
quantity -= stack.quantity
inventory.erase(stack)
stack.quantity -= quantity
if stack.quantity == 0:
inventory.erase(stack)
if quantity == 0:
return
func removeStack(stack: ItemStack) -> void:
self.removeItem(stack.item, stack.quantity);
func hasItem(item: Item, quantity: int = 1) -> bool:
var totalQuantity = 0
for stack in inventory:
if stack.item != item:
continue
totalQuantity += stack.quantity
if totalQuantity >= quantity:
return true
return false
func sortBy(by:ItemSortType) -> void:
match by:
ItemSortType.NAME:
inventory.sort_custom(ItemStackNameComparator._sort)
ItemSortType.TYPE:
inventory.sort_custom(ItemStackTypeComparator._sort)

View File

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

View File

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

View File

@@ -0,0 +1,13 @@
extends Node
const MAPS:Dictionary[String, String] = {
"TestMap": "res://scenes/Maps/TestMap.tscn"
};
var currentMap:String = "";
func setMap(map:String) -> void:
if MAPS.has(map):
currentMap = map
else:
push_error("Map not found: " + map)

View File

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

View File

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

View File

@@ -0,0 +1,37 @@
class_name PauseSystem extends Node
enum PauseType {
# Completely unpaused
NOT_PAUSED,
# Fully paused, with no exceptions to anything
FULLY_PAUSED,
# Specific entities are paused
ENTITY_PAUSED,
# All entities are paused unless specified
CUTSCENE_PAUSED
};
var pauseType:PauseType = PauseType.NOT_PAUSED;
var entities:Array = [];
var playerPaused:bool = false;
func getPauseState() -> PauseType:
if isPlayerPaused():
return PauseType.FULLY_PAUSED;
return pauseType;
func pause(
pauseType:PauseType,
entities:Array = [],
) -> void:
self.pauseType = pauseType;
self.entities = entities;
func unpause() -> void:
self.pauseType = PauseType.NOT_PAUSED;
func isPlayerPaused() -> bool:
return playerPaused;
func playerPauseToggle() -> void:
playerPaused = !playerPaused;

View File

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

View File

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

View File

@@ -0,0 +1 @@
class_name QuestSystem extends Node

View File

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

View File

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

View File

@@ -0,0 +1,34 @@
class_name SceneManager extends Node
const MainMenu = preload("res://scenes/MainMenu.tscn");
const OverworldScene = preload("res://scenes/Overworld.tscn");
const SCENES:Dictionary[String, PackedScene] = {
"Initial": MainMenu,
"MainMenu": MainMenu,
"Overworld": OverworldScene
};
var scene = "Initial";
var currentScene:Node = null;
func _ready() -> void:
currentScene = get_tree().root.get_child(-1);
func setScene(newScene:String) -> void:
print("Setting scene to " + str(newScene));
scene = newScene;
if not SCENES.has(newScene):
push_error("Scene not found: " + newScene);
return;
var root = get_tree().root;
print("Current scene: " + str(currentScene));
if currentScene:
currentScene.queue_free();
var newSceneInstance = SCENES[newScene].instantiate();
if newSceneInstance:
root.add_child(newSceneInstance);
currentScene = newSceneInstance;

View File

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

View File

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

View File

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

25
scripts/Singleton/UI.gd Normal file
View File

@@ -0,0 +1,25 @@
class_name UISystem extends Control
enum Layer {
Game,
VN,
Test,
Debug
}
func addSubscene(subscene:Control, layer:Layer) -> void:
subscene.originalParent.remove_child.call_deferred(subscene)
match layer:
Layer.Game:
$LayerGame.add_child.call_deferred(subscene)
Layer.Debug:
$LayerDebug.add_child.call_deferred(subscene)
Layer.VN:
$LayerVN.add_child.call_deferred(subscene)
_:
push_error("Invalid layer: " + str(layer))
return
func removeSubscene(subscene:Control) -> void:
subscene.get_parent().remove_child(subscene)

View File

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

10
scripts/Singleton/VN.gd Normal file
View File

@@ -0,0 +1,10 @@
class_name VNSystem extends Node
const VNTextbox = preload("res://scripts/UI/VNTextbox.gd")
var vnTextbox:VNTextbox = null
func _ready() -> void:
vnTextbox = $SubsceneUI/VNTextbox
func getTextbox() -> VNTextbox:
return vnTextbox

View File

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

View File

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