Bit more cleanup
This commit is contained in:
9
scripts/Singleton/Battle.gd
Normal file
9
scripts/Singleton/Battle.gd
Normal 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;
|
1
scripts/Singleton/Battle.gd.uid
Normal file
1
scripts/Singleton/Battle.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://2ejo2auklqhu
|
1
scripts/Singleton/BattleSystem.gd.uid
Normal file
1
scripts/Singleton/BattleSystem.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://mr6i8copcn37
|
5
scripts/Singleton/Cooking.gd
Normal file
5
scripts/Singleton/Cooking.gd
Normal file
@@ -0,0 +1,5 @@
|
||||
extends Node
|
||||
|
||||
const CookingGame = preload("res://scripts/Cooking/CookingGame.gd");
|
||||
|
||||
var game:CookingGame = null;
|
1
scripts/Singleton/Cooking.gd.uid
Normal file
1
scripts/Singleton/Cooking.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dnnr0o0af78jl
|
1
scripts/Singleton/CookingSystem.gd.uid
Normal file
1
scripts/Singleton/CookingSystem.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://drcaiuyla2psa
|
22
scripts/Singleton/Cutscene.gd
Normal file
22
scripts/Singleton/Cutscene.gd
Normal 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();
|
1
scripts/Singleton/Cutscene.gd.uid
Normal file
1
scripts/Singleton/Cutscene.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b83dwcvh76qs7
|
1
scripts/Singleton/CutsceneSystem.gd.uid
Normal file
1
scripts/Singleton/CutsceneSystem.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://d2b7r3t5ownc5
|
22
scripts/Singleton/Debug.gd
Normal file
22
scripts/Singleton/Debug.gd
Normal 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()
|
1
scripts/Singleton/Debug.gd.uid
Normal file
1
scripts/Singleton/Debug.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://d36d3fnpi8y30
|
106
scripts/Singleton/Item.gd
Normal file
106
scripts/Singleton/Item.gd
Normal 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)
|
1
scripts/Singleton/Item.gd.uid
Normal file
1
scripts/Singleton/Item.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://1vd57s0j3b2o
|
1
scripts/Singleton/ItemSystem.gd.uid
Normal file
1
scripts/Singleton/ItemSystem.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bc4c4eqfrnegb
|
13
scripts/Singleton/Overworld.gd
Normal file
13
scripts/Singleton/Overworld.gd
Normal 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)
|
1
scripts/Singleton/Overworld.gd.uid
Normal file
1
scripts/Singleton/Overworld.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cnc1qkusjrf3k
|
1
scripts/Singleton/OverworldSystem.gd.uid
Normal file
1
scripts/Singleton/OverworldSystem.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://btowswycywrgc
|
37
scripts/Singleton/Pause.gd
Normal file
37
scripts/Singleton/Pause.gd
Normal 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;
|
1
scripts/Singleton/Pause.gd.uid
Normal file
1
scripts/Singleton/Pause.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cr0ne40l5jf7m
|
1
scripts/Singleton/PauseSystem.gd.uid
Normal file
1
scripts/Singleton/PauseSystem.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bontk8ex2kxkb
|
1
scripts/Singleton/Quest.gd
Normal file
1
scripts/Singleton/Quest.gd
Normal file
@@ -0,0 +1 @@
|
||||
class_name QuestSystem extends Node
|
1
scripts/Singleton/Quest.gd.uid
Normal file
1
scripts/Singleton/Quest.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://d0060jeyftia7
|
1
scripts/Singleton/QuestSystem.gd.uid
Normal file
1
scripts/Singleton/QuestSystem.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dnlg1e8une55l
|
34
scripts/Singleton/SceneManager.gd
Normal file
34
scripts/Singleton/SceneManager.gd
Normal 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;
|
1
scripts/Singleton/SceneManager.gd.uid
Normal file
1
scripts/Singleton/SceneManager.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ciexpxnj51uux
|
1
scripts/Singleton/SceneSystem.gd.uid
Normal file
1
scripts/Singleton/SceneSystem.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bbd8gcx6byjhf
|
1
scripts/Singleton/Systems.gd.uid
Normal file
1
scripts/Singleton/Systems.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cj8athi16655p
|
25
scripts/Singleton/UI.gd
Normal file
25
scripts/Singleton/UI.gd
Normal 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)
|
1
scripts/Singleton/UI.gd.uid
Normal file
1
scripts/Singleton/UI.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dahhuhiu8u88b
|
10
scripts/Singleton/VN.gd
Normal file
10
scripts/Singleton/VN.gd
Normal 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
|
1
scripts/Singleton/VN.gd.uid
Normal file
1
scripts/Singleton/VN.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://benvf7v4p4i2l
|
1
scripts/Singleton/VNSystem.gd.uid
Normal file
1
scripts/Singleton/VNSystem.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://chux5imw4pse6
|
Reference in New Issue
Block a user