Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Keep current animations resource #459

Merged
merged 1 commit into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,22 @@ func validate(arguments: Array):
func run(command_params: Array) -> int:
(escoria.object_manager.get_object(command_params[0]).node as ESCPlayer)\
.animations = load(command_params[1])
if not escoria.globals_manager.has(
escoria.globals_manager.GLOBAL_ANIMATION_RESOURCES
):
escoria.globals_manager.set_global(
escoria.globals_manager.GLOBAL_ANIMATION_RESOURCES,
{},
true
)
var animations = escoria.globals_manager.get_global(
escoria.globals_manager.GLOBAL_ANIMATION_RESOURCES
)
animations[command_params[0]] = command_params[1]
escoria.globals_manager.set_global(
escoria.globals_manager.GLOBAL_ANIMATION_RESOURCES,
animations,
true
)
return ESCExecution.RC_OK

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func validate(arguments: Array):

# Run the command
func run(command_params: Array) -> int:
escoria.object_manager.get_object(command_params[1]).node.set_state(
escoria.object_manager.get_object(command_params[0]).node.set_state(
"off"
)
return ESCExecution.RC_OK
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ extends Resource
class_name ESCGlobalsManager


const GLOBAL_ANIMATION_RESOURCES = "ANIMATION_RESOURCES"


# Emitted when a global is changed
signal global_changed(global, old_value, new_value)


# A list of reserved globals which can not be overridden
const RESERVED_GLOBALS = [
"ESC_LAST_SCENE",
"BYPASS_LAST_SCENE"
"BYPASS_LAST_SCENE",
"ANIMATION_RESOURCES"
]


Expand Down Expand Up @@ -104,6 +108,4 @@ func set_global_wildcard(pattern: String, value) -> void:
func save_game(p_savegame: ESCSaveGame) -> void:
p_savegame.globals = {}
for g in _globals:
if g in RESERVED_GLOBALS:
continue
p_savegame.globals[g] = _globals[g]
1 change: 1 addition & 0 deletions addons/escoria-core/game/core-scripts/esc_exit.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export(String, FILE, "*.ogg,*.mp3,*.wav") var switch_sound = ""
func _enter_tree():
is_exit = true
player_orients_on_arrival = false
default_action = "walk"


func _ready():
Expand Down
12 changes: 12 additions & 0 deletions addons/escoria-core/game/core-scripts/esc_room.gd
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ func _ready():
),
true
)
if escoria.globals_manager.has(
escoria.globals_manager.GLOBAL_ANIMATION_RESOURCES
):
var animations = escoria.globals_manager.get_global(
escoria.globals_manager.GLOBAL_ANIMATION_RESOURCES
)

if player.global_id in animations and \
ResourceLoader.exists(animations[player.global_id]):
player.animations = ResourceLoader.load(
animations[player.global_id]
)
escoria.object_manager.get_object("_camera").node.set_target(player)

for n in get_children():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,12 @@ func load_game(id: int):

## GLOBALS
for k in save_game.globals.keys():
load_statements.append(
ESCCommand.new("set_global %s \"%s\"\n" \
% [k, save_game.globals[k]])
escoria.globals_manager.set_global(
k,
save_game.globals[k],
true
)

## ROOM
load_statements.append(
ESCCommand.new("change_scene %s true" \
Expand All @@ -197,7 +198,8 @@ func load_game(id: int):

## OBJECTS
for object_global_id in save_game.objects.keys():
if save_game.objects[object_global_id].has("active"):
if escoria.object_manager.has(object_global_id) and \
save_game.objects[object_global_id].has("active"):
load_statements.append(ESCCommand.new("set_active %s %s" \
% [object_global_id,
save_game.objects[object_global_id]["active"]])
Expand Down Expand Up @@ -230,12 +232,22 @@ func load_game(id: int):
)

if object_global_id in ["_music", "_sound", "_speech"]:
load_statements.append(
ESCCommand.new("play_snd %s %s" % [
save_game.objects[object_global_id]["state"],
object_global_id,
])
)
if save_game.objects[object_global_id]["state"] in [
"default",
"off"
]:
load_statements.append(
ESCCommand.new("stop_snd %s" % [
object_global_id,
])
)
else:
load_statements.append(
ESCCommand.new("play_snd %s %s" % [
save_game.objects[object_global_id]["state"],
object_global_id,
])
)

load_statements.append(
ESCCommand.new(
Expand Down
Loading