Add pausing
This commit is contained in:
@@ -60,6 +60,11 @@ interact={
|
||||
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null)
|
||||
]
|
||||
}
|
||||
pause={
|
||||
"deadzone": 0.5,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[rendering]
|
||||
|
||||
|
@@ -1,10 +1,11 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://iibqlagufwhm"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://iibqlagufwhm"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/System/Systems.gd" id="1_uen2c"]
|
||||
[ext_resource type="Script" path="res://scripts/System/CutsceneSystem.gd" id="2_sf62c"]
|
||||
[ext_resource type="Script" path="res://scripts/System/ItemSystem.gd" id="3_nwp6i"]
|
||||
[ext_resource type="Script" path="res://scripts/System/QuestSystem.gd" id="4_d00wi"]
|
||||
[ext_resource type="Script" path="res://scripts/System/VNSystem.gd" id="5_22p3i"]
|
||||
[ext_resource type="Script" path="res://scripts/System/PauseSystem.gd" id="6_hdi8m"]
|
||||
|
||||
[node name="Systems" type="Node3D"]
|
||||
script = ExtResource("1_uen2c")
|
||||
@@ -20,3 +21,6 @@ script = ExtResource("4_d00wi")
|
||||
|
||||
[node name="VN" type="Node3D" parent="."]
|
||||
script = ExtResource("5_22p3i")
|
||||
|
||||
[node name="Pause" type="Node3D" parent="."]
|
||||
script = ExtResource("6_hdi8m")
|
||||
|
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);
|
@@ -12,4 +12,4 @@ func start() -> void:
|
||||
getSystems().VN.getTextbox().setText(self.text);
|
||||
|
||||
func isDone() -> bool:
|
||||
return false
|
||||
return getSystems().VN.getTextbox().isClosed;
|
||||
|
@@ -5,9 +5,12 @@ const CutsceneConcurrentEvent = preload("res://scripts/Cutscene/Event/CutsceneCo
|
||||
const CutsceneIfEvent = preload("res://scripts/Cutscene/Event/CutsceneIfEvent.gd");
|
||||
const CutsceneWhileEvent = preload("res://scripts/Cutscene/Event/CutsceneWhileEvent.gd");
|
||||
const TextboxEvent = preload("res://scripts/Cutscene/Event/VisualNovel/TextboxEvent.gd");
|
||||
const PauseEvent = preload("res://scripts/Cutscene/Event/CutscenePauseEvent.gd");
|
||||
|
||||
func setupCutscene() -> void:
|
||||
add([
|
||||
TextboxEvent.new("Cumbria")
|
||||
PauseEvent.new(PauseSystem.PauseType.ENTITY_PAUSED),
|
||||
TextboxEvent.new("Cumbria"),
|
||||
PauseEvent.new(PauseSystem.PauseType.NOT_PAUSED),
|
||||
]);
|
||||
pass
|
||||
|
@@ -1,6 +1,8 @@
|
||||
extends CharacterBody3D
|
||||
class_name OverworldEntity
|
||||
|
||||
const PauseSystem = preload("res://scripts/System/PauseSystem.gd")
|
||||
|
||||
enum Direction {
|
||||
NORTH,
|
||||
SOUTH,
|
||||
@@ -42,6 +44,24 @@ func updateMovement(delta) -> void:
|
||||
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 false;
|
||||
return true
|
||||
elif ps == PauseSystem.PauseType.CUTSCENE_PAUSED:
|
||||
if pause.entities.find(self) != -1:
|
||||
return true;
|
||||
return false;
|
||||
return false;
|
||||
|
||||
# Private methods
|
||||
func _updateTileData() -> void:
|
||||
# ray cast down
|
||||
@@ -97,6 +117,9 @@ func _ready() -> void:
|
||||
pass
|
||||
|
||||
func _process(delta:float) -> void:
|
||||
if isPaused():
|
||||
return;
|
||||
|
||||
# Handle entity leaving map bounds
|
||||
if !withinMapBounds:
|
||||
if !withinBoundsLastFrame:
|
||||
@@ -113,6 +136,9 @@ func _process(delta:float) -> void:
|
||||
material.set_shader_parameter("direction", direction)
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if isPaused():
|
||||
return;
|
||||
|
||||
# Update movement
|
||||
updateMovement(delta);
|
||||
|
||||
|
@@ -21,6 +21,9 @@ func updateOverworldLogic(delta) -> void:
|
||||
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");
|
||||
|
@@ -1,9 +1,16 @@
|
||||
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);
|
||||
|
||||
|
33
scripts/System/PauseSystem.gd
Normal file
33
scripts/System/PauseSystem.gd
Normal file
@@ -0,0 +1,33 @@
|
||||
class_name PauseSystem extends Node
|
||||
|
||||
enum PauseType {
|
||||
NOT_PAUSED,
|
||||
FULLY_PAUSED,
|
||||
ENTITY_PAUSED,
|
||||
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;
|
@@ -3,17 +3,20 @@ 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");
|
||||
|
||||
var ITEM:ItemSystem;
|
||||
var CUTSCENE:CutsceneSystem;
|
||||
var QUEST:QuestSystem;
|
||||
var VN:VNSystem;
|
||||
var PAUSE:PauseSystem;
|
||||
|
||||
func _ready():
|
||||
ITEM = $Item;
|
||||
CUTSCENE = $Cutscene;
|
||||
QUEST = $Quest;
|
||||
VN = $VN;
|
||||
PAUSE = $Pause;
|
||||
|
||||
func _process(delta):
|
||||
pass
|
||||
|
@@ -1,5 +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;
|
||||
|
@@ -16,6 +16,7 @@ var currentLine = 0;
|
||||
var currentViewScrolled = true;
|
||||
var isSpeedupDown = false;
|
||||
var isMoreViews = false;
|
||||
var isClosed = true;
|
||||
|
||||
func _ready() -> void:
|
||||
label = $MarginContainer/Label
|
||||
@@ -32,7 +33,8 @@ func _process(delta: float) -> void:
|
||||
currentViewScrolled = false;
|
||||
recalculateWrapping();
|
||||
return
|
||||
print("End of view");
|
||||
isClosed = true;
|
||||
setText("");
|
||||
return;
|
||||
|
||||
if visibleCharacters >= getCountOfCharactersToScrollInView():
|
||||
@@ -104,6 +106,12 @@ func recalculateWrapping():
|
||||
|
||||
func setText(text:String) -> void:
|
||||
self.text = text;
|
||||
if text == "":
|
||||
isClosed = true;
|
||||
label.text = "closed.";
|
||||
return;
|
||||
|
||||
isClosed = false;
|
||||
revealTimer = 0;
|
||||
visibleCharacters = 0;
|
||||
currentLine = 0;
|
||||
|
Reference in New Issue
Block a user