Add pausing
This commit is contained in:
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user