48
scripts/Battle/Battle.gd
Normal file
48
scripts/Battle/Battle.gd
Normal file
@@ -0,0 +1,48 @@
|
||||
class_name Battle
|
||||
const BattleFighter = preload("res://scripts/Battle/BattleFighter.gd");
|
||||
|
||||
enum FighterPosition {
|
||||
LEFT_TOP = 0,
|
||||
LEFT_CENTER = 1,
|
||||
LEFT_BOTTOM = 2,
|
||||
|
||||
CENTER_TOP = 3,
|
||||
CENTER_CENTER = 4,
|
||||
CENTER_BOTTOM = 5,
|
||||
|
||||
RIGHT_TOP = 6,
|
||||
RIGHT_CENTER = 7,
|
||||
RIGHT_BOTTOM = 8,
|
||||
|
||||
ENEMY_DEFAULT = LEFT_CENTER,
|
||||
PLAYER_DEFAULT = RIGHT_CENTER,
|
||||
};
|
||||
|
||||
var fighters:Array = [];
|
||||
|
||||
func addFighter(fighter:BattleFighter, position:FighterPosition):
|
||||
if fighters.has(position):
|
||||
push_error("Fighter already exists at position");
|
||||
return
|
||||
fighters[position] = fighter;
|
||||
|
||||
func moveFighter(fighter:BattleFighter, position:FighterPosition):
|
||||
if fighters.has(position):
|
||||
push_error("Fighter already exists at position");
|
||||
return
|
||||
if not fighters.has(fighter):
|
||||
push_error("Fighter does not exist");
|
||||
return
|
||||
removeFighter(fighter);
|
||||
addFighter(fighter, position);
|
||||
|
||||
func getFightersOfTeam(team:BattleFighter.BattleFighterTeam):
|
||||
var result = [];
|
||||
for fighter in fighters:
|
||||
if fighter.team != team:
|
||||
continue
|
||||
result.append(fighter);
|
||||
return result;
|
||||
|
||||
func removeFighter(fighter:BattleFighter):
|
||||
fighters.erase(fighter);
|
1
scripts/Battle/Battle.gd.uid
Normal file
1
scripts/Battle/Battle.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://kwijyojokkpm
|
10
scripts/Battle/BattleFighter.gd
Normal file
10
scripts/Battle/BattleFighter.gd
Normal file
@@ -0,0 +1,10 @@
|
||||
class_name BattleFighter
|
||||
|
||||
enum BattleFighterTeam {
|
||||
PLAYER,
|
||||
ENEMY
|
||||
};
|
||||
|
||||
var team:BattleFighterTeam;
|
||||
var health:int = 100;
|
||||
var maxHealth:int = 100;
|
1
scripts/Battle/BattleFighter.gd.uid
Normal file
1
scripts/Battle/BattleFighter.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://daksbecm02l3t
|
7
scripts/Cooking/CookingGame.gd
Normal file
7
scripts/Cooking/CookingGame.gd
Normal file
@@ -0,0 +1,7 @@
|
||||
class_name CookingGame
|
||||
const VerticalSlice = preload("res://scripts/Cooking/Recipe/VerticalSlice.gd");
|
||||
|
||||
var recipe:CookingRecipe = null;
|
||||
|
||||
func _init(recipe:CookingRecipe) -> void:
|
||||
self.recipe = recipe;
|
1
scripts/Cooking/CookingGame.gd.uid
Normal file
1
scripts/Cooking/CookingGame.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://nsqcafdni4vc
|
8
scripts/Cooking/Recipe/CookingRecipe.gd
Normal file
8
scripts/Cooking/Recipe/CookingRecipe.gd
Normal file
@@ -0,0 +1,8 @@
|
||||
class_name CookingRecipe
|
||||
const ItemStack = preload("res://scripts/Item/ItemStack.gd")
|
||||
|
||||
func _init() -> void:
|
||||
pass
|
||||
|
||||
func getIngredients() -> Array[ItemStack]:
|
||||
return []
|
1
scripts/Cooking/Recipe/CookingRecipe.gd.uid
Normal file
1
scripts/Cooking/Recipe/CookingRecipe.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bqnancnrbmk5n
|
10
scripts/Cooking/Recipe/VerticalSlice.gd
Normal file
10
scripts/Cooking/Recipe/VerticalSlice.gd
Normal file
@@ -0,0 +1,10 @@
|
||||
class_name VerticalSlice extends "res://scripts/Cooking/Recipe/CookingRecipe.gd"
|
||||
const ItemSystem = preload("res://scripts/System/ItemSystem.gd")
|
||||
|
||||
func _init() -> void:
|
||||
super._init();
|
||||
|
||||
func getIngredients() -> Array[ItemStack]:
|
||||
return [
|
||||
ItemStack.new(ItemSystem.ITEM_POTION, 1)
|
||||
];
|
1
scripts/Cooking/Recipe/VerticalSlice.gd.uid
Normal file
1
scripts/Cooking/Recipe/VerticalSlice.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c2x1lbdtbtd00
|
11
scripts/Cutscene/Battle/BattleStartEvent.gd
Normal file
11
scripts/Cutscene/Battle/BattleStartEvent.gd
Normal file
@@ -0,0 +1,11 @@
|
||||
class_name BattleStartEvent extends "res://scripts/Cutscene/CutsceneEvent.gd"
|
||||
|
||||
var battle:Battle;
|
||||
|
||||
func _init(battle:Battle):
|
||||
super._init();
|
||||
self.battle = battle;
|
||||
|
||||
func start() -> void:
|
||||
super.start();
|
||||
getSystems().BATTLE.startBattle(self.battle);
|
1
scripts/Cutscene/Battle/BattleStartEvent.gd.uid
Normal file
1
scripts/Cutscene/Battle/BattleStartEvent.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://e3ybjhvx0u1j
|
11
scripts/Cutscene/Cooking/CookingStartEvent.gd
Normal file
11
scripts/Cutscene/Cooking/CookingStartEvent.gd
Normal file
@@ -0,0 +1,11 @@
|
||||
class_name CookingStartEvent extends "res://scripts/Cutscene/CutsceneEvent.gd"
|
||||
const CookingGame = preload("res://scripts/Cooking/CookingGame.gd");
|
||||
|
||||
var cook:CookingGame;
|
||||
|
||||
func _init(cook:CookingGame) -> void:
|
||||
self.cook = cook;
|
||||
|
||||
func start() -> void:
|
||||
getSystems().COOKING.setCookingGame(self.cook);
|
||||
getSystems().SCENE.setScene(SceneSystem.DawnScene.COOKING);
|
1
scripts/Cutscene/Cooking/CookingStartEvent.gd.uid
Normal file
1
scripts/Cutscene/Cooking/CookingStartEvent.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cvgjwamgxd47o
|
42
scripts/Cutscene/Cutscene.gd
Normal file
42
scripts/Cutscene/Cutscene.gd
Normal file
@@ -0,0 +1,42 @@
|
||||
class_name Cutscene
|
||||
const CutsceneEvent = preload("res://scripts/Cutscene/CutsceneEvent.gd");
|
||||
|
||||
var queue:Array[CutsceneEvent] = [];
|
||||
var cutsceneSystem = null;
|
||||
|
||||
func setupCutscene() -> void:
|
||||
print_debug("Cutscene setup has not been overriden");
|
||||
pass
|
||||
|
||||
func update(delta:float) -> void:
|
||||
if queue.size() == 0:
|
||||
return
|
||||
|
||||
var item = queue[0]
|
||||
if !item.started:
|
||||
item.start()
|
||||
item.started = true
|
||||
|
||||
item.update(delta)
|
||||
|
||||
if item.isDone():
|
||||
item.end()
|
||||
queue.erase(item)
|
||||
|
||||
pass
|
||||
|
||||
func add(items:Array[CutsceneEvent]) -> void:
|
||||
for item in items:
|
||||
item.cutscene = self
|
||||
queue.append(item)
|
||||
|
||||
func clear() -> void:
|
||||
if queue.size() == 0:
|
||||
return
|
||||
|
||||
var item = queue[0]
|
||||
if item.started:
|
||||
item.end()
|
||||
item.started = false
|
||||
|
||||
queue.clear()
|
1
scripts/Cutscene/Cutscene.gd.uid
Normal file
1
scripts/Cutscene/Cutscene.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dyjbgcpycptxj
|
32
scripts/Cutscene/CutsceneEvent.gd
Normal file
32
scripts/Cutscene/CutsceneEvent.gd
Normal file
@@ -0,0 +1,32 @@
|
||||
class_name CutsceneEvent
|
||||
const Systems = preload("res://scripts/System/Systems.gd")
|
||||
|
||||
var started:bool = false;
|
||||
var cutscene = null;
|
||||
|
||||
func _init() -> void:
|
||||
pass
|
||||
|
||||
func start() -> void:
|
||||
started = true
|
||||
|
||||
func update(delta:float) -> void:
|
||||
pass
|
||||
|
||||
func isDone() -> bool:
|
||||
return true
|
||||
|
||||
func end() -> void:
|
||||
pass
|
||||
|
||||
func reset() -> void:
|
||||
started = false
|
||||
|
||||
func getCutscene():
|
||||
return cutscene
|
||||
|
||||
func getCutsceneSystem():
|
||||
return cutscene.cutsceneSystem;
|
||||
|
||||
func getSystems() -> Systems:
|
||||
return getCutsceneSystem().get_node("..") as Systems;
|
1
scripts/Cutscene/CutsceneEvent.gd.uid
Normal file
1
scripts/Cutscene/CutsceneEvent.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://chb6031ke0xeg
|
17
scripts/Cutscene/Event/CutsceneChangeEvent.gd
Normal file
17
scripts/Cutscene/Event/CutsceneChangeEvent.gd
Normal file
@@ -0,0 +1,17 @@
|
||||
class_name CutsceneChangeEvent extends "res://scripts/Cutscene/CutsceneEvent.gd"
|
||||
|
||||
var getCutscene:Callable
|
||||
var cutsceneNext:Cutscene
|
||||
|
||||
func _init(getCutscene:Callable) -> void:
|
||||
super._init();
|
||||
self.getCutscene = getCutscene;
|
||||
|
||||
func start() -> void:
|
||||
super.start();
|
||||
self.cutsceneNext = self.getCutscene.call(self);
|
||||
|
||||
func end() -> void:
|
||||
self.cutsceneNext.setupCutscene();
|
||||
self.cutsceneNext.start();
|
||||
getSystems().CUTSCENE.setCurrentCutscene(self.cutsceneNext);
|
1
scripts/Cutscene/Event/CutsceneChangeEvent.gd.uid
Normal file
1
scripts/Cutscene/Event/CutsceneChangeEvent.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://crnwlun27bocw
|
73
scripts/Cutscene/Event/CutsceneConcurrentEvent.gd
Normal file
73
scripts/Cutscene/Event/CutsceneConcurrentEvent.gd
Normal file
@@ -0,0 +1,73 @@
|
||||
class_name CutsceneConcurrentEvent extends "res://scripts/Cutscene/CutsceneEvent.gd"
|
||||
|
||||
enum ConcurrentType {
|
||||
SEQUENTIAL,
|
||||
PARALLEL,
|
||||
FIRST_DONE
|
||||
}
|
||||
|
||||
var events:Array[CutsceneEvent] = []
|
||||
var type:ConcurrentType = ConcurrentType.SEQUENTIAL
|
||||
var current:int = 0
|
||||
|
||||
func _init(t:ConcurrentType, evts:Array[CutsceneEvent]) -> void:
|
||||
super._init();
|
||||
self.events = evts;
|
||||
self.type = t;
|
||||
|
||||
func update(delta:float) -> void:
|
||||
if self.type == ConcurrentType.PARALLEL:
|
||||
for event in self.events:
|
||||
if !event.started:
|
||||
event.start()
|
||||
event.started = true
|
||||
|
||||
if !event.isDone():
|
||||
event.update(delta)
|
||||
|
||||
if event.isDone():
|
||||
event.end()
|
||||
|
||||
elif self.type == ConcurrentType.FIRST_DONE:
|
||||
for event in self.events:
|
||||
if !event.started:
|
||||
event.start()
|
||||
event.started = true
|
||||
|
||||
event.update(delta)
|
||||
|
||||
if event.isDone():
|
||||
event.end()
|
||||
break
|
||||
|
||||
elif self.type == ConcurrentType.SEQUENTIAL:
|
||||
if self.current >= self.events.size():
|
||||
return;
|
||||
|
||||
var evt = self.events[self.current]
|
||||
if !evt.started:
|
||||
evt.start()
|
||||
evt.started = true
|
||||
|
||||
evt.update(delta)
|
||||
|
||||
if evt.isDone():
|
||||
evt.end()
|
||||
self.current += 1
|
||||
|
||||
func isDone() -> bool:
|
||||
if self.type == ConcurrentType.SEQUENTIAL:
|
||||
return self.current >= self.events.size();
|
||||
elif self.type == ConcurrentType.PARALLEL:
|
||||
for evt in self.events:
|
||||
if !evt.isDone():
|
||||
return false;
|
||||
return true;
|
||||
elif self.type == ConcurrentType.FIRST_DONE:
|
||||
for evt in self.events:
|
||||
if evt.isDone():
|
||||
return true;
|
||||
return false;
|
||||
|
||||
printerr("Invalid ConcurrentType")
|
||||
return false;
|
1
scripts/Cutscene/Event/CutsceneConcurrentEvent.gd.uid
Normal file
1
scripts/Cutscene/Event/CutsceneConcurrentEvent.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bwait88cm8pvd
|
32
scripts/Cutscene/Event/CutsceneIfEvent.gd
Normal file
32
scripts/Cutscene/Event/CutsceneIfEvent.gd
Normal file
@@ -0,0 +1,32 @@
|
||||
class_name CutsceneIfEvent extends "res://scripts/Cutscene/CutsceneEvent.gd"
|
||||
|
||||
var eventTrue:CutsceneEvent
|
||||
var eventFalse:CutsceneEvent
|
||||
var condition:Callable
|
||||
var result:bool = false
|
||||
|
||||
func _init(cond:Callable, evtTrue:CutsceneEvent, evtFalse:CutsceneEvent) -> void:
|
||||
super._init();
|
||||
condition = cond;
|
||||
eventTrue = evtTrue;
|
||||
eventFalse = evtFalse;
|
||||
|
||||
func start() -> void:
|
||||
super.start();
|
||||
result = self.condition.call(self);
|
||||
|
||||
if result:
|
||||
eventTrue.start();
|
||||
else:
|
||||
eventFalse.start();
|
||||
|
||||
func getEvent() -> CutsceneEvent:
|
||||
if result:
|
||||
return eventTrue;
|
||||
return eventFalse;
|
||||
|
||||
func update(delta:float) -> void:
|
||||
getEvent().update(delta);
|
||||
|
||||
func isDone() -> bool:
|
||||
return getEvent().isDone();
|
1
scripts/Cutscene/Event/CutsceneIfEvent.gd.uid
Normal file
1
scripts/Cutscene/Event/CutsceneIfEvent.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://2txg4eswrh0q
|
16
scripts/Cutscene/Event/CutscenePauseEvent.gd
Normal file
16
scripts/Cutscene/Event/CutscenePauseEvent.gd
Normal file
@@ -0,0 +1,16 @@
|
||||
class_name CutscenePauseEvent extends "res://scripts/Cutscene/CutsceneEvent.gd"
|
||||
const PauseSystem = preload("res://scripts/System/PauseSystem.gd")
|
||||
|
||||
var pauseType:PauseSystem.PauseType;
|
||||
var pauseEntities:Array = [];
|
||||
|
||||
func _init(
|
||||
type:PauseSystem.PauseType,
|
||||
entities:Array = [],
|
||||
) -> void:
|
||||
super._init();
|
||||
self.pauseType = type;
|
||||
self.pauseEntities = entities;
|
||||
|
||||
func start() -> void:
|
||||
getSystems().PAUSE.pause(self.pauseType, self.pauseEntities);
|
1
scripts/Cutscene/Event/CutscenePauseEvent.gd.uid
Normal file
1
scripts/Cutscene/Event/CutscenePauseEvent.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dj1kkm2vvvr2d
|
10
scripts/Cutscene/Event/CutscenePrintEvent.gd
Normal file
10
scripts/Cutscene/Event/CutscenePrintEvent.gd
Normal file
@@ -0,0 +1,10 @@
|
||||
class_name CutscenePrintEvent extends "res://scripts/Cutscene/CutsceneEvent.gd"
|
||||
|
||||
var text:String = ""
|
||||
|
||||
func _init(text:String) -> void:
|
||||
super._init()
|
||||
self.text = text
|
||||
|
||||
func start() -> void:
|
||||
print(self.text)
|
1
scripts/Cutscene/Event/CutscenePrintEvent.gd.uid
Normal file
1
scripts/Cutscene/Event/CutscenePrintEvent.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cknkpwqllg7nc
|
13
scripts/Cutscene/Event/CutsceneWaitEvent.gd
Normal file
13
scripts/Cutscene/Event/CutsceneWaitEvent.gd
Normal file
@@ -0,0 +1,13 @@
|
||||
class_name CutsceneWaitEvent extends "res://scripts/Cutscene/CutsceneEvent.gd"
|
||||
|
||||
var wait:float = 0.0
|
||||
|
||||
func _init(time:float) -> void:
|
||||
super._init()
|
||||
self.wait = time
|
||||
|
||||
func update(delta:float) -> void:
|
||||
self.wait -= delta
|
||||
|
||||
func isDone() -> bool:
|
||||
return self.wait <= 0.0
|
1
scripts/Cutscene/Event/CutsceneWaitEvent.gd.uid
Normal file
1
scripts/Cutscene/Event/CutsceneWaitEvent.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cskwko5oqqq4m
|
43
scripts/Cutscene/Event/CutsceneWhileEvent.gd
Normal file
43
scripts/Cutscene/Event/CutsceneWhileEvent.gd
Normal file
@@ -0,0 +1,43 @@
|
||||
class_name CutsceneWhileEvent extends "res://scripts/Cutscene/CutsceneEvent.gd"
|
||||
|
||||
var events:Array[CutsceneEvent] = []
|
||||
var callback:Callable
|
||||
var current:int = 0
|
||||
|
||||
func _init(callback:Callable, evt:Array[CutsceneEvent]) -> void:
|
||||
super._init();
|
||||
self.events = evt;
|
||||
self.callback = callback;
|
||||
|
||||
func shouldLoop() -> bool:
|
||||
return self.callback.call(self)
|
||||
|
||||
func update(delta:float) -> void:
|
||||
if self.current >= self.events.size():
|
||||
return;
|
||||
|
||||
var evt = self.events[self.current]
|
||||
if !evt.started:
|
||||
evt.start()
|
||||
evt.started = true
|
||||
|
||||
evt.update(delta)
|
||||
|
||||
if evt.isDone():
|
||||
evt.end()
|
||||
self.current += 1
|
||||
|
||||
if self.current < self.events.size():
|
||||
return
|
||||
|
||||
if !self.shouldLoop():
|
||||
return
|
||||
|
||||
self.current = 0
|
||||
for event in self.events:
|
||||
event.reset()
|
||||
|
||||
func isDone() -> bool:
|
||||
if self.shouldLoop():
|
||||
return false;
|
||||
return self.current >= self.events.size();
|
1
scripts/Cutscene/Event/CutsceneWhileEvent.gd.uid
Normal file
1
scripts/Cutscene/Event/CutsceneWhileEvent.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cx4uqll85m28i
|
@@ -0,0 +1,13 @@
|
||||
class_name OverworldChangeDirectionEvent extends "res://scripts/Cutscene/Event/Entity/OverworldEntityEvent.gd"
|
||||
|
||||
var direction:OverworldEntity.Direction;
|
||||
|
||||
func _init(
|
||||
entity:OverworldEntity,
|
||||
direction:OverworldEntity.Direction,
|
||||
) -> void:
|
||||
super._init(entity);
|
||||
self.direction = direction;
|
||||
|
||||
func start() -> void:
|
||||
entity.direction = direction;
|
@@ -0,0 +1 @@
|
||||
uid://cu82did0twmkm
|
10
scripts/Cutscene/Event/Entity/OverworldEntityEvent.gd
Normal file
10
scripts/Cutscene/Event/Entity/OverworldEntityEvent.gd
Normal file
@@ -0,0 +1,10 @@
|
||||
class_name OverworldEntityEvent extends "res://scripts/Cutscene/CutsceneEvent.gd"
|
||||
const OverworldEntity = preload("res://scripts/Entities/OverworldEntity.gd");
|
||||
|
||||
var entity:OverworldEntity;
|
||||
|
||||
func _init(
|
||||
entity:OverworldEntity,
|
||||
) -> void:
|
||||
super._init();
|
||||
self.entity = entity;
|
@@ -0,0 +1 @@
|
||||
uid://dmmguqphbe34j
|
15
scripts/Cutscene/Event/VisualNovel/TextboxEvent.gd
Normal file
15
scripts/Cutscene/Event/VisualNovel/TextboxEvent.gd
Normal file
@@ -0,0 +1,15 @@
|
||||
class_name TextboxEvent extends "res://scripts/Cutscene/CutsceneEvent.gd"
|
||||
|
||||
var text:String;
|
||||
|
||||
func _init(
|
||||
text:String
|
||||
) -> void:
|
||||
super._init();
|
||||
self.text = text;
|
||||
|
||||
func start() -> void:
|
||||
getSystems().VN.getTextbox().setText(self.text);
|
||||
|
||||
func isDone() -> bool:
|
||||
return getSystems().VN.getTextbox().isClosed;
|
1
scripts/Cutscene/Event/VisualNovel/TextboxEvent.gd.uid
Normal file
1
scripts/Cutscene/Event/VisualNovel/TextboxEvent.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dypv7erj66kbs
|
29
scripts/Cutscene/Scene/OverworldConversationEvent.gd
Normal file
29
scripts/Cutscene/Scene/OverworldConversationEvent.gd
Normal file
@@ -0,0 +1,29 @@
|
||||
class_name OverworldConversationEvent extends "res://scripts/Cutscene/Cutscene.gd"
|
||||
const OverworldEntity = preload("res://scripts/Entities/OverworldEntity.gd");
|
||||
const TextboxEvent = preload("res://scripts/Cutscene/Event/VisualNovel/TextboxEvent.gd");
|
||||
const PauseEvent = preload("res://scripts/Cutscene/Event/CutscenePauseEvent.gd");
|
||||
const OverworldChangeDirectionEvent = preload("res://scripts/Cutscene/Event/Entity/OverworldChangeDirectionEvent.gd");
|
||||
|
||||
var speaker:OverworldEntity;
|
||||
var interacted:OverworldEntity;
|
||||
var texts:Array[String];
|
||||
|
||||
func _init(speaker:OverworldEntity, interacted:OverworldEntity, texts:Array[String]) -> void:
|
||||
self.speaker = speaker;
|
||||
self.interacted = interacted;
|
||||
self.texts = texts;
|
||||
|
||||
func setupCutscene() -> void:
|
||||
var dirSpeaker = speaker.getDirectionToFace(interacted.position);
|
||||
var dirInteracted = interacted.getDirectionToFace(speaker.position);
|
||||
|
||||
add([
|
||||
OverworldChangeDirectionEvent.new(speaker, dirSpeaker),
|
||||
OverworldChangeDirectionEvent.new(interacted, dirInteracted),
|
||||
PauseEvent.new(PauseSystem.PauseType.ENTITY_PAUSED, [ speaker, interacted ]),
|
||||
]);
|
||||
|
||||
for text in texts:
|
||||
add([ TextboxEvent.new(text) ]);
|
||||
|
||||
add([ PauseEvent.new(PauseSystem.PauseType.NOT_PAUSED) ]);
|
1
scripts/Cutscene/Scene/OverworldConversationEvent.gd.uid
Normal file
1
scripts/Cutscene/Scene/OverworldConversationEvent.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cywuvoi5v4fe3
|
10
scripts/Cutscene/TestCutscene.gd
Normal file
10
scripts/Cutscene/TestCutscene.gd
Normal file
@@ -0,0 +1,10 @@
|
||||
class_name TestCutscene extends "res://scripts/Cutscene/Scene/OverworldConversationEvent.gd"
|
||||
|
||||
func _init(speaker:OverworldEntity, interacted:OverworldEntity ) -> void:
|
||||
super(
|
||||
speaker,
|
||||
interacted,
|
||||
[
|
||||
"Hello"
|
||||
]
|
||||
);
|
1
scripts/Cutscene/TestCutscene.gd.uid
Normal file
1
scripts/Cutscene/TestCutscene.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://btxgv85qst1jy
|
55
scripts/Entities/BasicNPCEntity.gd
Normal file
55
scripts/Entities/BasicNPCEntity.gd
Normal file
@@ -0,0 +1,55 @@
|
||||
class_name BasicNPCEntity extends "res://scripts/Entities/OverworldEntity.gd"
|
||||
const Cutscene = preload("res://scripts/Cutscene/Cutscene.gd");
|
||||
const OverworldConversationEvent = preload("res://scripts/Cutscene/Scene/OverworldConversationEvent.gd");
|
||||
|
||||
enum BasicNPCInteractType {
|
||||
NONE,
|
||||
CUTSCENE,
|
||||
TEXTS
|
||||
};
|
||||
|
||||
enum BasicNPCMoveType {
|
||||
STILL,
|
||||
RANDOM_LOOK
|
||||
};
|
||||
|
||||
@export var interactType:BasicNPCInteractType = BasicNPCInteractType.NONE;
|
||||
@export var interactCutscene:GDScript;
|
||||
@export var interactTexts:Array[String];
|
||||
|
||||
@export var moveType:BasicNPCMoveType = BasicNPCMoveType.STILL;
|
||||
|
||||
@export var randomLookMinTime:float = 1.5;
|
||||
@export var randomLookMaxTime:float = 4.0;
|
||||
var randomLookTimer:float = 0.0;
|
||||
|
||||
func interact(interactor:OverworldEntity) -> void:
|
||||
if interactType == BasicNPCInteractType.NONE:
|
||||
return
|
||||
|
||||
if interactType == BasicNPCInteractType.CUTSCENE:
|
||||
# Cutscene in this manner must take two entities
|
||||
# (self, speaker, and interactor, player)
|
||||
var cs:Cutscene = interactCutscene.new(self, interactor);
|
||||
getSystems().CUTSCENE.setCurrentCutscene(cs);
|
||||
return
|
||||
|
||||
if interactType == BasicNPCInteractType.TEXTS:
|
||||
var cs:Cutscene = OverworldConversationEvent.new(self, interactor, interactTexts);
|
||||
getSystems().CUTSCENE.setCurrentCutscene(cs);
|
||||
return
|
||||
|
||||
pass
|
||||
|
||||
func updateMovement(delta:float) -> void:
|
||||
if moveType == BasicNPCMoveType.STILL:
|
||||
return
|
||||
|
||||
if moveType == BasicNPCMoveType.RANDOM_LOOK:
|
||||
randomLookTimer -= delta;
|
||||
if randomLookTimer <= 0:
|
||||
randomLookTimer = randf_range(randomLookMinTime, randomLookMaxTime);
|
||||
self.direction = randi_range(0, 3);
|
||||
return
|
||||
|
||||
pass
|
1
scripts/Entities/BasicNPCEntity.gd.uid
Normal file
1
scripts/Entities/BasicNPCEntity.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://d23qg1ovkbxst
|
176
scripts/Entities/OverworldEntity.gd
Normal file
176
scripts/Entities/OverworldEntity.gd
Normal file
@@ -0,0 +1,176 @@
|
||||
class_name OverworldEntity extends CharacterBody3D
|
||||
|
||||
const PauseSystem = preload("res://scripts/System/PauseSystem.gd")
|
||||
|
||||
enum Direction {
|
||||
NORTH,
|
||||
EAST,
|
||||
SOUTH,
|
||||
WEST,
|
||||
}
|
||||
|
||||
var speed:float = 150;
|
||||
var friction:float = 8.5;
|
||||
var gravity:float = 30;
|
||||
|
||||
@export var direction = Direction.SOUTH:
|
||||
set(newDirection):
|
||||
direction = newDirection;
|
||||
_updateMaterial();
|
||||
|
||||
var meshInstance:MeshInstance3D;
|
||||
var underFootTile:int = -1;
|
||||
var underFootPosition:Vector3;
|
||||
|
||||
var withinMapBounds:MapBounds;
|
||||
var withinBoundsLastFrame:bool = true;
|
||||
|
||||
func _updateMaterial():
|
||||
if !meshInstance:
|
||||
return
|
||||
var material:ShaderMaterial = meshInstance.get_surface_override_material(0)
|
||||
if !material:
|
||||
return
|
||||
material.set_shader_parameter("direction", direction)
|
||||
|
||||
func getSystems() -> Systems:
|
||||
return get_tree().current_scene.get_node("Systems") as Systems;
|
||||
|
||||
func getDirectionVector() -> Vector3:
|
||||
match direction:
|
||||
Direction.NORTH:
|
||||
return Vector3(0, 0, -1);
|
||||
Direction.SOUTH:
|
||||
return Vector3(0, 0, 1);
|
||||
Direction.WEST:
|
||||
return Vector3(-1, 0, 0);
|
||||
Direction.EAST:
|
||||
return Vector3(1, 0, 0);
|
||||
return Vector3(0, 0, 0);
|
||||
|
||||
func getDirectionToFace(position:Vector3) -> Direction:
|
||||
var diff = position - self.position;
|
||||
if abs(diff.x) > abs(diff.z):
|
||||
if diff.x > 0:
|
||||
return Direction.EAST;
|
||||
else:
|
||||
return Direction.WEST;
|
||||
else:
|
||||
if diff.z > 0:
|
||||
return Direction.SOUTH;
|
||||
else:
|
||||
return Direction.NORTH;
|
||||
return Direction.SOUTH;
|
||||
|
||||
# Virtual Methods
|
||||
func updateMovement(delta) -> void:
|
||||
pass
|
||||
|
||||
func updateOverworldLogic(delta) -> void:
|
||||
pass
|
||||
|
||||
func isPaused() -> bool:
|
||||
var pause = getSystems().PAUSE;
|
||||
var ps = pause.getPauseState();
|
||||
|
||||
if ps == PauseSystem.PauseType.NOT_PAUSED:
|
||||
return false;
|
||||
elif ps == PauseSystem.PauseType.FULLY_PAUSED:
|
||||
return true;
|
||||
elif ps == PauseSystem.PauseType.ENTITY_PAUSED:
|
||||
if pause.entities.find(self) != -1:
|
||||
return true;
|
||||
return false
|
||||
elif ps == PauseSystem.PauseType.CUTSCENE_PAUSED:
|
||||
if pause.entities.find(self) != -1:
|
||||
return false;
|
||||
return true;
|
||||
return false;
|
||||
|
||||
# Private methods
|
||||
func _updateTileData() -> void:
|
||||
# ray cast down
|
||||
var offset = Vector3(0, 0, 0.426);
|
||||
var query = PhysicsRayQueryParameters3D.create(
|
||||
position + offset,
|
||||
position + Vector3(0, -1, 0) + offset
|
||||
)
|
||||
query.collide_with_areas = true
|
||||
query.exclude = [self]
|
||||
|
||||
var result = get_world_3d().direct_space_state.intersect_ray(query)
|
||||
if !result or !result.collider:
|
||||
return;
|
||||
|
||||
var collider = result.collider;
|
||||
var colliderMesh = collider.get_node("../");
|
||||
if !colliderMesh or !(colliderMesh is ArrayMesh) or !colliderMesh.mesh or colliderMesh.mesh.get_surface_count() == 0:
|
||||
return;
|
||||
|
||||
# Get the face index (triangle)
|
||||
var arrays = colliderMesh.mesh.surface_get_arrays(0);
|
||||
var indiceIdx = result.face_index * 3;
|
||||
|
||||
# Get each indice of the triangle
|
||||
var index0 = arrays[Mesh.ARRAY_INDEX][indiceIdx+0];
|
||||
var index1 = arrays[Mesh.ARRAY_INDEX][indiceIdx+1];
|
||||
var index2 = arrays[Mesh.ARRAY_INDEX][indiceIdx+2];
|
||||
|
||||
# Get each uv of each indice
|
||||
var uv0:Vector2 = arrays[Mesh.ARRAY_TEX_UV][index0];
|
||||
var uv1:Vector2 = arrays[Mesh.ARRAY_TEX_UV][index1];
|
||||
var uv2:Vector2 = arrays[Mesh.ARRAY_TEX_UV][index2];
|
||||
|
||||
# Determine the lowest texture coordinate
|
||||
var min = Vector2(min(uv0.x, uv1.x, uv2.x), min(uv0.y, uv1.y, uv2.y));
|
||||
|
||||
# Convert to column/row
|
||||
var w = 256;
|
||||
var h = w;
|
||||
var tw = 48;
|
||||
var th = tw;
|
||||
var column = int(roundf(min.x * w)) / tw;
|
||||
var row = int(roundf(min.y * h)) / th;
|
||||
var columns = 768 / tw;
|
||||
underFootPosition = result.position;
|
||||
underFootTile = column % columns + row * columns;
|
||||
|
||||
# Events
|
||||
func _ready() -> void:
|
||||
meshInstance = get_node("MeshInstance3D")
|
||||
_updateTileData();
|
||||
_updateMaterial();
|
||||
pass
|
||||
|
||||
func _process(delta:float) -> void:
|
||||
if isPaused():
|
||||
return;
|
||||
|
||||
# Handle entity leaving map bounds
|
||||
if !withinMapBounds:
|
||||
if !withinBoundsLastFrame:
|
||||
print("Entity ", self.name, " was out of map bounds for two frames");
|
||||
withinBoundsLastFrame = false;
|
||||
else:
|
||||
withinBoundsLastFrame = true;
|
||||
|
||||
# Update logic
|
||||
updateOverworldLogic(delta)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if isPaused():
|
||||
return;
|
||||
|
||||
# Update movement
|
||||
updateMovement(delta);
|
||||
|
||||
# Gravity and friction
|
||||
if !is_on_floor():
|
||||
velocity.y -= gravity * delta;
|
||||
else:
|
||||
velocity += -(velocity * friction * delta);
|
||||
if velocity.length() != 0:
|
||||
_updateTileData();
|
||||
|
||||
# Update character controller.
|
||||
move_and_slide();
|
1
scripts/Entities/OverworldEntity.gd.uid
Normal file
1
scripts/Entities/OverworldEntity.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bpwbaptqu4bm5
|
24
scripts/Entities/RosaCamera.gd
Normal file
24
scripts/Entities/RosaCamera.gd
Normal file
@@ -0,0 +1,24 @@
|
||||
extends Camera3D
|
||||
|
||||
const PIXEL_SCALE:float = 4.0;
|
||||
const WORLD_UNITS:float = 32.0;
|
||||
|
||||
func _ready() -> void:
|
||||
pass
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
var z:float = (
|
||||
tan((deg_to_rad(180) - deg_to_rad(fov)) / 2.0) *
|
||||
(get_viewport().size.y / 2.0)
|
||||
) / PIXEL_SCALE / WORLD_UNITS;
|
||||
|
||||
var rosa = get_node("..");
|
||||
var look = rosa.position;
|
||||
var position = Vector3(0, 0, 2) + look;
|
||||
look_at_from_position(
|
||||
Vector3(position.x, position.y + z, position.z),
|
||||
look
|
||||
);
|
||||
|
||||
pass
|
1
scripts/Entities/RosaCamera.gd.uid
Normal file
1
scripts/Entities/RosaCamera.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://jd50n00bo05y
|
51
scripts/Entities/RosaController.gd
Normal file
51
scripts/Entities/RosaController.gd
Normal file
@@ -0,0 +1,51 @@
|
||||
class_name RosaController extends "res://scripts/Entities/OverworldEntity.gd"
|
||||
|
||||
var interactRange = 0.7;
|
||||
|
||||
func updateOverworldLogic(delta) -> void:
|
||||
# Check if interact button is pressed
|
||||
if(Input.is_action_just_pressed("interact")):
|
||||
var rayDirection = getDirectionVector();
|
||||
# cast ray
|
||||
|
||||
var query = PhysicsRayQueryParameters3D.create(
|
||||
position,
|
||||
position + (rayDirection * interactRange)
|
||||
)
|
||||
query.collide_with_areas = true
|
||||
query.exclude = [self]
|
||||
|
||||
var result = get_world_3d().direct_space_state.intersect_ray(query)
|
||||
if result and result.collider:
|
||||
var collider = result.collider
|
||||
if(collider.has_method("interact")):
|
||||
collider.interact(self)
|
||||
|
||||
if Input.is_action_just_pressed("pause"):
|
||||
getSystems().PAUSE.playerPauseToggle();
|
||||
|
||||
func updateMovement(delta) -> void:
|
||||
# User movement
|
||||
var dir:Vector2 = Input.get_vector("left", "right", "up", "down");
|
||||
if(dir.x != 0 or dir.y != 0):
|
||||
velocity.x = dir.x * speed * delta;
|
||||
velocity.z = dir.y * speed * delta;
|
||||
|
||||
# Update direction
|
||||
if(dir.x >= abs(dir.y) and(
|
||||
dir.y == 0 or
|
||||
(dir.y > 0 and direction != Direction.SOUTH) or
|
||||
(dir.y < 0 and direction != Direction.NORTH)
|
||||
)):
|
||||
direction = Direction.EAST;
|
||||
elif (dir.x <= -abs(dir.y) and (
|
||||
dir.y == 0 or
|
||||
(dir.y > 0 and direction != Direction.SOUTH) or
|
||||
(dir.y < 0 and direction != Direction.NORTH)
|
||||
)):
|
||||
direction = Direction.WEST;
|
||||
elif (dir.y > 0):
|
||||
direction = Direction.SOUTH;
|
||||
elif (dir.y < 0):
|
||||
direction = Direction.NORTH;
|
||||
pass
|
1
scripts/Entities/RosaController.gd.uid
Normal file
1
scripts/Entities/RosaController.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ixwikdguyhf0
|
36
scripts/Item/Item.gd
Normal file
36
scripts/Item/Item.gd
Normal file
@@ -0,0 +1,36 @@
|
||||
class_name Item
|
||||
|
||||
enum ItemCategory {
|
||||
MEDICINE,
|
||||
KEY_ITEM,
|
||||
INGREDIENT
|
||||
};
|
||||
|
||||
func getName() -> String:
|
||||
push_error("getName() must be overridden in derived classes");
|
||||
return "";
|
||||
|
||||
func isStackable() -> bool:
|
||||
return true;
|
||||
|
||||
func isDroppable() -> bool:
|
||||
return true;
|
||||
|
||||
func isSellable() -> bool:
|
||||
return true;
|
||||
|
||||
func getSellPrice() -> int:
|
||||
return 0;
|
||||
|
||||
func getBuyPrice() -> int:
|
||||
return 0;
|
||||
|
||||
func isConsumable() -> bool:
|
||||
return false;
|
||||
|
||||
func consume() -> void:
|
||||
pass
|
||||
|
||||
func getCategory() -> ItemCategory:
|
||||
push_error("getCategory() must be overriden in derived class");
|
||||
return ItemCategory.MEDICINE;
|
1
scripts/Item/Item.gd.uid
Normal file
1
scripts/Item/Item.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c6t5tprnd23t0
|
8
scripts/Item/ItemStack.gd
Normal file
8
scripts/Item/ItemStack.gd
Normal file
@@ -0,0 +1,8 @@
|
||||
class_name ItemStack
|
||||
|
||||
var item:Item;
|
||||
var quantity:int;
|
||||
|
||||
func _init(item:Item, quantity:int = 1):
|
||||
self.item = item;
|
||||
self.quantity = quantity;
|
1
scripts/Item/ItemStack.gd.uid
Normal file
1
scripts/Item/ItemStack.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://re7dg4hpp804
|
13
scripts/Item/Potion.gd
Normal file
13
scripts/Item/Potion.gd
Normal file
@@ -0,0 +1,13 @@
|
||||
class_name Potion extends "res://scripts/Item/Item.gd"
|
||||
|
||||
func getName() -> String:
|
||||
return "Potion"
|
||||
|
||||
func getCategory() -> ItemCategory:
|
||||
return ItemCategory.MEDICINE;
|
||||
|
||||
func isConsumable() -> bool:
|
||||
return true;
|
||||
|
||||
func consume() -> void:
|
||||
print("Consuming Potion");
|
1
scripts/Item/Potion.gd.uid
Normal file
1
scripts/Item/Potion.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dpns5iesd08rl
|
15
scripts/MapBounds.gd
Normal file
15
scripts/MapBounds.gd
Normal file
@@ -0,0 +1,15 @@
|
||||
extends Area3D
|
||||
class_name MapBounds
|
||||
|
||||
func _ready() -> void:
|
||||
pass
|
||||
|
||||
func _on_body_entered(body: Node3D) -> void:
|
||||
if (!body is OverworldEntity):
|
||||
return
|
||||
(body as OverworldEntity).withinMapBounds = self;
|
||||
|
||||
func _on_body_exited(body: Node3D) -> void:
|
||||
if (!body is OverworldEntity):
|
||||
return
|
||||
(body as OverworldEntity).withinMapBounds = null;
|
1
scripts/MapBounds.gd.uid
Normal file
1
scripts/MapBounds.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dbah1pmk8jola
|
1
scripts/OverworldEntity.gd.uid
Normal file
1
scripts/OverworldEntity.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dr3asofxu1pep
|
8
scripts/Quest/Objective/QuestObjective.gd
Normal file
8
scripts/Quest/Objective/QuestObjective.gd
Normal file
@@ -0,0 +1,8 @@
|
||||
class_name QuestObjective
|
||||
|
||||
var name:String
|
||||
|
||||
func _init(
|
||||
name:String
|
||||
):
|
||||
self.name = name;
|
1
scripts/Quest/Objective/QuestObjective.gd.uid
Normal file
1
scripts/Quest/Objective/QuestObjective.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bakmt6ufpq33o
|
36
scripts/Quest/Quest.gd
Normal file
36
scripts/Quest/Quest.gd
Normal file
@@ -0,0 +1,36 @@
|
||||
class_name Quest
|
||||
const QuestObjective = preload("res://scripts/Quest/Objective/QuestObjective.gd");
|
||||
|
||||
enum QuestState {
|
||||
NOT_STARTED,
|
||||
ACTIVE,
|
||||
INACTIVE,
|
||||
FINISHED
|
||||
};
|
||||
|
||||
var questName:String;
|
||||
var questState:QuestState = QuestState.NOT_STARTED;
|
||||
var objectives:Array[QuestObjective] = [];
|
||||
var currentObjective = -1;
|
||||
|
||||
func _init(
|
||||
questName:String,
|
||||
objectives:Array[QuestObjective]
|
||||
) -> void:
|
||||
self.questName = questName;
|
||||
self.objectives = objectives;
|
||||
|
||||
func getState() -> QuestState:
|
||||
return questState;
|
||||
|
||||
func start():
|
||||
print("Starting quest: " + questName);
|
||||
questState = QuestState.ACTIVE;
|
||||
currentObjective = 0;
|
||||
|
||||
func nextObjective():
|
||||
currentObjective = currentObjective + 1;
|
||||
if currentObjective >= objectives.size():
|
||||
questState = QuestState.FINISHED;
|
||||
return null;
|
||||
return objectives[currentObjective];
|
1
scripts/Quest/Quest.gd.uid
Normal file
1
scripts/Quest/Quest.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://kuxak18kbjr5
|
6
scripts/Quest/QuestExample.gd
Normal file
6
scripts/Quest/QuestExample.gd
Normal file
@@ -0,0 +1,6 @@
|
||||
class_name QuestExample extends "res://scripts/Quest/Quest.gd"
|
||||
|
||||
func _init() -> void:
|
||||
super("Example Quest", [
|
||||
QuestObjective.new("Test")
|
||||
]);
|
1
scripts/Quest/QuestExample.gd.uid
Normal file
1
scripts/Quest/QuestExample.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cg3piglr8rbfs
|
1
scripts/RosaCamera.gd.uid
Normal file
1
scripts/RosaCamera.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cubx2asrudfyp
|
1
scripts/RosaController.gd.uid
Normal file
1
scripts/RosaController.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dnls1370w0gr4
|
1
scripts/Scenes/CookingScene.gd
Normal file
1
scripts/Scenes/CookingScene.gd
Normal file
@@ -0,0 +1 @@
|
||||
class_name CookingScene extends Node3D
|
1
scripts/Scenes/CookingScene.gd.uid
Normal file
1
scripts/Scenes/CookingScene.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ckxjs4wty6sju
|
1
scripts/Scenes/CuttingScene.gd
Normal file
1
scripts/Scenes/CuttingScene.gd
Normal file
@@ -0,0 +1 @@
|
||||
class_name CuttingScene extends Node3D
|
1
scripts/Scenes/CuttingScene.gd.uid
Normal file
1
scripts/Scenes/CuttingScene.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://kwnx0enmgk54
|
1
scripts/Scenes/OverworldScene.gd
Normal file
1
scripts/Scenes/OverworldScene.gd
Normal file
@@ -0,0 +1 @@
|
||||
class_name OverworldScene extends Node3D
|
1
scripts/Scenes/OverworldScene.gd.uid
Normal file
1
scripts/Scenes/OverworldScene.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://pcncoc6wum4q
|
10
scripts/Scenes/RootScene.gd
Normal file
10
scripts/Scenes/RootScene.gd
Normal file
@@ -0,0 +1,10 @@
|
||||
class_name RootScene extends Node3D
|
||||
const Systems = preload("res://scripts/System/Systems.gd");
|
||||
const SceneSystem = preload("res://scripts/System/SceneSystem.gd");
|
||||
|
||||
var systems:Systems;
|
||||
|
||||
func _ready() -> void:
|
||||
print("Game started");
|
||||
systems = $Systems;
|
||||
systems.SCENE.setScene(SceneSystem.DawnScene.OVERWORLD);
|
1
scripts/Scenes/RootScene.gd.uid
Normal file
1
scripts/Scenes/RootScene.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cj4jxqpykhteg
|
1
scripts/Scenes/UIScene.gd
Normal file
1
scripts/Scenes/UIScene.gd
Normal file
@@ -0,0 +1 @@
|
||||
class_name UIScene extends Control
|
1
scripts/Scenes/UIScene.gd.uid
Normal file
1
scripts/Scenes/UIScene.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://vjr7s045ri4a
|
11
scripts/System/BattleSystem.gd
Normal file
11
scripts/System/BattleSystem.gd
Normal file
@@ -0,0 +1,11 @@
|
||||
class_name BattleSystem extends Node
|
||||
const Battle = preload("res://scripts/Battle/Battle.gd");
|
||||
|
||||
var battle:Battle = null;
|
||||
|
||||
func getSystems():
|
||||
return get_tree().current_scene.get_node("Systems");
|
||||
|
||||
func startBattle(battle:Battle) -> void:
|
||||
print("start battle");
|
||||
self.battle = battle;
|
1
scripts/System/BattleSystem.gd.uid
Normal file
1
scripts/System/BattleSystem.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://mr6i8copcn37
|
11
scripts/System/CookingSystem.gd
Normal file
11
scripts/System/CookingSystem.gd
Normal file
@@ -0,0 +1,11 @@
|
||||
class_name CookingSystem extends Node;
|
||||
const CookingGame = preload("res://scripts/Cooking/CookingGame.gd");
|
||||
|
||||
var game:CookingGame = null;
|
||||
|
||||
func getSystems():
|
||||
return get_tree().current_scene.get_node("Systems");
|
||||
|
||||
func setCookingGame(game:CookingGame):
|
||||
self.game = game;
|
||||
print("CookingSystem: CookingGame set");
|
1
scripts/System/CookingSystem.gd.uid
Normal file
1
scripts/System/CookingSystem.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://drcaiuyla2psa
|
27
scripts/System/CutsceneSystem.gd
Normal file
27
scripts/System/CutsceneSystem.gd
Normal file
@@ -0,0 +1,27 @@
|
||||
class_name CutsceneSystem extends Node
|
||||
const Cutscene = preload("res://scripts/Cutscene/Cutscene.gd");
|
||||
const PauseSystem = preload("res://scripts/System/PauseSystem.gd");
|
||||
|
||||
var currentCutscene:Cutscene = null;
|
||||
|
||||
func getSystems():
|
||||
return get_tree().current_scene.get_node("Systems");
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if getSystems().PAUSE.getPauseState() == PauseSystem.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/System/CutsceneSystem.gd.uid
Normal file
1
scripts/System/CutsceneSystem.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://d2b7r3t5ownc5
|
105
scripts/System/ItemSystem.gd
Normal file
105
scripts/System/ItemSystem.gd
Normal file
@@ -0,0 +1,105 @@
|
||||
class_name ItemSystem 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/System/ItemSystem.gd.uid
Normal file
1
scripts/System/ItemSystem.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bc4c4eqfrnegb
|
37
scripts/System/PauseSystem.gd
Normal file
37
scripts/System/PauseSystem.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/System/PauseSystem.gd.uid
Normal file
1
scripts/System/PauseSystem.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bontk8ex2kxkb
|
7
scripts/System/QuestSystem.gd
Normal file
7
scripts/System/QuestSystem.gd
Normal file
@@ -0,0 +1,7 @@
|
||||
class_name QuestSystem extends Node
|
||||
|
||||
static var QUEST_EXAMPLE = preload("res://scripts/Quest/QuestExample.gd").new();
|
||||
|
||||
static var ALL_QUESTS = [
|
||||
QUEST_EXAMPLE
|
||||
]
|
1
scripts/System/QuestSystem.gd.uid
Normal file
1
scripts/System/QuestSystem.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dnlg1e8une55l
|
45
scripts/System/SceneSystem.gd
Normal file
45
scripts/System/SceneSystem.gd
Normal file
@@ -0,0 +1,45 @@
|
||||
class_name SceneSystem extends Node
|
||||
const MainMenu = preload("res://scenes/MainMenu.tscn");
|
||||
const OverworldScene = preload("res://scenes/Meta/Overworld.tscn");
|
||||
|
||||
enum DawnScene {
|
||||
MAIN_MENU,
|
||||
OVERWORLD,
|
||||
BATTLE,
|
||||
COOKING
|
||||
};
|
||||
|
||||
var scene:DawnScene = DawnScene.OVERWORLD;
|
||||
|
||||
func getMainMenuScene():
|
||||
return get_tree().current_scene.get_node("MainMenu");
|
||||
|
||||
func setScene(newScene:DawnScene) -> void:
|
||||
print("Setting scene to " + str(newScene));
|
||||
scene = newScene;
|
||||
|
||||
if newScene == DawnScene.MAIN_MENU:
|
||||
# Remove all non essential scenes
|
||||
|
||||
# Add Main menu scene if not present
|
||||
var mainMenu = getMainMenuScene();
|
||||
if mainMenu == null:
|
||||
var instance = MainMenu.instantiate(PackedScene.GEN_EDIT_STATE_DISABLED);
|
||||
get_tree().current_scene.add_child(instance);
|
||||
return
|
||||
|
||||
if newScene == DawnScene.OVERWORLD:
|
||||
# Remove all non essential scenes
|
||||
var mainMenuScene = getMainMenuScene();
|
||||
if mainMenuScene != null:
|
||||
mainMenuScene.queue_free();
|
||||
|
||||
# Add Overworld scene if not present
|
||||
var overworld = get_tree().current_scene.get_node("OverworldScene");
|
||||
if overworld == null:
|
||||
var instance = OverworldScene.instantiate(PackedScene.GEN_EDIT_STATE_DISABLED);
|
||||
get_tree().current_scene.add_child(instance);
|
||||
return
|
||||
|
||||
# error
|
||||
print("Scene not found: " + str(newScene));
|
1
scripts/System/SceneSystem.gd.uid
Normal file
1
scripts/System/SceneSystem.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bbd8gcx6byjhf
|
31
scripts/System/Systems.gd
Normal file
31
scripts/System/Systems.gd
Normal file
@@ -0,0 +1,31 @@
|
||||
class_name Systems extends Node
|
||||
const ItemSystem = preload("res://scripts/System/ItemSystem.gd");
|
||||
const CutsceneSystem = preload("res://scripts/System/CutsceneSystem.gd");
|
||||
const QuestSystem = preload("res://scripts/System/QuestSystem.gd");
|
||||
const VNSystem = preload("res://scripts/System/VNSystem.gd");
|
||||
const PauseSystem = preload("res://scripts/System/PauseSystem.gd");
|
||||
const BattleSystem = preload("res://scripts/System/BattleSystem.gd");
|
||||
const CookingSystem = preload("res://scripts/System/CookingSystem.gd");
|
||||
const SceneSystem = preload("res://scripts/System/SceneSystem.gd");
|
||||
|
||||
var ITEM:ItemSystem;
|
||||
var CUTSCENE:CutsceneSystem;
|
||||
var QUEST:QuestSystem;
|
||||
var VN:VNSystem;
|
||||
var PAUSE:PauseSystem;
|
||||
var BATTLE:BattleSystem;
|
||||
var COOKING:CookingSystem;
|
||||
var SCENE:SceneSystem;
|
||||
|
||||
func _ready():
|
||||
ITEM = $Item;
|
||||
CUTSCENE = $Cutscene;
|
||||
QUEST = $Quest;
|
||||
VN = $VN;
|
||||
PAUSE = $Pause;
|
||||
BATTLE = $Battle;
|
||||
COOKING = $Cooking;
|
||||
SCENE = $Scene;
|
||||
|
||||
func _process(delta):
|
||||
pass
|
1
scripts/System/Systems.gd.uid
Normal file
1
scripts/System/Systems.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cj8athi16655p
|
8
scripts/System/VNSystem.gd
Normal file
8
scripts/System/VNSystem.gd
Normal file
@@ -0,0 +1,8 @@
|
||||
class_name VNSystem extends Node
|
||||
const VNTextbox = preload("res://scripts/UI/VNTextbox.gd")
|
||||
|
||||
func getSystems():
|
||||
return get_tree().current_scene.get_node("Systems");
|
||||
|
||||
func getTextbox() -> VNTextbox:
|
||||
return get_tree().current_scene.get_node("UI/VNTextbox") as VNTextbox;
|
1
scripts/System/VNSystem.gd.uid
Normal file
1
scripts/System/VNSystem.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://chux5imw4pse6
|
1
scripts/TestNPCController.gd.uid
Normal file
1
scripts/TestNPCController.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dq7mgokmvo80u
|
121
scripts/UI/VNTextbox.gd
Normal file
121
scripts/UI/VNTextbox.gd
Normal file
@@ -0,0 +1,121 @@
|
||||
class_name VNTextbox extends PanelContainer
|
||||
|
||||
const VN_REVEAL_TIME = 0.01
|
||||
const VISIBLE_LINES:int = 4
|
||||
|
||||
var label:RichTextLabel;
|
||||
var text:String = ""
|
||||
var parsedOutText = ""
|
||||
var visibleCharacters:int = 0;
|
||||
var revealTimer:float = 0;
|
||||
|
||||
var lineStarts:Array[int] = [];
|
||||
var newlineIndexes:Array[int] = [];
|
||||
var wrappedText:String = "";
|
||||
var currentLine = 0;
|
||||
var currentViewScrolled = true;
|
||||
var isSpeedupDown = false;
|
||||
var isMoreViews = false;
|
||||
var isClosed = true;
|
||||
|
||||
func _ready() -> void:
|
||||
label = $MarginContainer/Label
|
||||
self.visible = false;
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if text == "":
|
||||
return;
|
||||
|
||||
if currentViewScrolled:
|
||||
if Input.is_action_just_pressed("interact"):
|
||||
if isMoreViews:
|
||||
visibleCharacters = 0;
|
||||
currentLine += VISIBLE_LINES;
|
||||
currentViewScrolled = false;
|
||||
recalculateWrapping();
|
||||
return
|
||||
isClosed = true;
|
||||
setText("");
|
||||
return;
|
||||
|
||||
if visibleCharacters >= getCountOfCharactersToScrollInView():
|
||||
currentViewScrolled = true;
|
||||
#print("Scrolled view");
|
||||
#if isMoreViews:
|
||||
#print("More views");
|
||||
return;
|
||||
|
||||
if Input.is_action_just_pressed("interact"):
|
||||
isSpeedupDown = true;
|
||||
elif Input.is_action_just_released("interact"):
|
||||
isSpeedupDown = false;
|
||||
elif !Input.is_action_pressed("interact"):
|
||||
isSpeedupDown = false;
|
||||
|
||||
revealTimer += delta;
|
||||
if isSpeedupDown:
|
||||
revealTimer += delta;
|
||||
|
||||
if revealTimer > VN_REVEAL_TIME:
|
||||
revealTimer = 0;
|
||||
visibleCharacters += 1;
|
||||
label.visible_characters = visibleCharacters;
|
||||
|
||||
func getCountOfCharactersToScrollInView() -> int:
|
||||
if lineStarts.size() <= VISIBLE_LINES:
|
||||
return wrappedText.length();
|
||||
if currentLine + VISIBLE_LINES >= lineStarts.size():
|
||||
return wrappedText.length() - lineStarts[currentLine];
|
||||
return lineStarts[min(lineStarts.size(), currentLine + VISIBLE_LINES)] - lineStarts[currentLine];
|
||||
|
||||
func recalculateWrapping():
|
||||
# Reset label to default.
|
||||
label.text = text;
|
||||
label.visible_characters = -1;
|
||||
label.fit_content = true;
|
||||
isMoreViews = false;
|
||||
|
||||
# Determine where the wrapped newlines are
|
||||
lineStarts = [ 0 ];
|
||||
var line = 0;
|
||||
var wasNewLine = false;
|
||||
for i in range(0, text.length()):
|
||||
var tLine = label.get_character_line(i);
|
||||
if tLine == line:
|
||||
wasNewLine = false
|
||||
if text[i] == "\n":
|
||||
wasNewLine = true
|
||||
continue;
|
||||
if !wasNewLine:
|
||||
newlineIndexes.append(i);
|
||||
lineStarts.append(i);
|
||||
line = tLine;
|
||||
|
||||
# Create fake pre-wrapped text.
|
||||
wrappedText = "";
|
||||
for i in range(lineStarts[currentLine], text.length()):
|
||||
if newlineIndexes.find(i) != -1 and i != lineStarts[currentLine]:
|
||||
wrappedText += "\n";
|
||||
wrappedText += text[i];
|
||||
|
||||
label.text = wrappedText;
|
||||
label.fit_content = false;
|
||||
label.visible_characters = 0;
|
||||
|
||||
if lineStarts.size() > currentLine + VISIBLE_LINES:
|
||||
isMoreViews = true;
|
||||
|
||||
func setText(text:String) -> void:
|
||||
self.text = text;
|
||||
if text == "":
|
||||
isClosed = true;
|
||||
self.visible = false;
|
||||
return;
|
||||
|
||||
isClosed = false;
|
||||
revealTimer = 0;
|
||||
visibleCharacters = 0;
|
||||
currentLine = 0;
|
||||
currentViewScrolled = false;
|
||||
recalculateWrapping();
|
||||
self.visible = true;
|
1
scripts/UI/VNTextbox.gd.uid
Normal file
1
scripts/UI/VNTextbox.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ck62jug2gl4wk
|
Reference in New Issue
Block a user