ESCObjectManager
Extends: Resource
Description
A manager for ESC objects.
Constants
CAMERA
const CAMERA = "_camera"
Reserved camera object.
MUSIC
const MUSIC = "_music"
Reserved music player object.
SOUND
const SOUND = "_sound"
Reserved sound player object.
SPEECH
const SPEECH = "_speech"
Reserved speech player object.
AMBIENT
const AMBIENT = "_ambient"
Reserved ambient player object.
RESERVED_OBJECTS
const RESERVED_OBJECTS = ["_music", "_sound", "_speech", "_ambient"]
Array of objects that are reserved and automatically created when Escoria starts up.
Members
room_objects
var room_objects: Array
The array of registered objects (organized by room, so each entry is a structure representing a room and its registered objects). This also includes one “room” for reserved objects; that is, we use one entry of the array to hold all reserved objects. This entry can be identified by the “is_reserved” property being set to true.
“Reserved objects” are those which are named in the RESERVED_OBJECTS const array and include objects that are used internally by Escoria in every room, e.g. a music player, a sound player, a speech player, the main camera.
In almost all cases, the reserved objects’ entry doesn’t need updating once created.
Example structure:
[ { is_reserved: true, # Indicates this is the “reserved objects” entry room: “”, room_instance_id: “”, objects: { “_camera”: camera }, }, { is_reserved: false, # Indicates this an entry for a room’s objects room_global_id: “<room_global_id>”, room_instance_id: “<room_object_instance_id>”, objects: { “obj1”: val1, “obj2”: val2 } } ]
room_terrains
var room_terrains: Array
Array containing the encountered terrains so they can be properly saved in savegames.
current_room_key
var current_room_key: ESCRoomObjectsKey
We also store the current room’s ids for retrieving the right objects.
reserved_objects_container
var reserved_objects_container: ESCRoomObjects
To avoid having to look this up all the time, we hold a reference.
Methods
reset_game_state
func reset_game_state() -> void
Clears all room-specific object and terrain state while preserving reserved objects managed by Escoria itself.
Parameters
None.
Returns
Returns nothing.
set_current_room
func set_current_room(room: ESCRoom) -> void
Updates which object manager room is to be treated as the currently active one.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
room |
|
Room to register objects with in the object manager. |
yes |
Returns
Returns nothing.
register_object
func register_object(object: ESCObject, room: ESCRoom, force: bool, auto_unregister: bool) -> void
Registers the object in the manager.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
object |
|
The object to register. |
yes |
room |
|
(optional) Room to register the object with in the object manager; if not specified, the object manager will attempt to register the object with the current room if one has been specified. |
no |
force |
|
(optional) Register the object, even if it has already been registered (default: |
no |
auto_unregister |
|
(optional) Automatically unregister the object when its node exits the scene tree (default: |
no |
Returns
Returns nothing.
register_terrain
func register_terrain(object: ESCObject, room: ESCRoom) -> void
Registers the terrain with the manager.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
object |
|
The object containing the terrain to register. |
yes |
room |
|
(optional) Room to register the object with in the object manager; if not specified, the object manager will attempt to register the terrain with the current room if one has been specified. |
no |
Returns
Returns nothing.
has
func has(global_id: String, room: ESCRoom) -> bool
Checks whether an object has been registered.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
global_id |
|
The global ID of the object. |
yes |
room |
|
(optional) |
no |
Returns
Returns a bool value. (bool)
get_object
func get_object(global_id: String, room: ESCRoom) -> ESCObject
Retrieves the object from the object registry.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
global_id |
|
The global id of the object to retrieve. |
yes |
room |
|
The |
no |
Returns
Returns a ESCObject value. (ESCObject)
unregister_object
func unregister_object(object: ESCObject, room_key: ESCRoomObjectsKey) -> void
Removes an object from the registry.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
object |
|
The object to unregister. |
yes |
room_key |
|
The room under which the object should be unregistered. |
yes |
Returns
Returns nothing.
unregister_object_by_global_id
func unregister_object_by_global_id(global_id: String, room_key: ESCRoomObjectsKey) -> void
Removes an object from the registry by its global_id.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
global_id |
|
The global id` of the object to unregister. |
yes |
room_key |
|
The room under which the object should be unregistered. |
yes |
Returns
Returns nothing.
save_game
func save_game(p_savegame: ESCSaveGame) -> void
Inserts data to save into savegame. For now, we only save the current room’s objects.
Parameters
Name |
Type |
Description |
Required? |
|---|---|---|---|
p_savegame |
|
The savegame resource. |
yes |
Returns
Returns nothing.
get_start_location
func get_start_location() -> ESCLocation
The current room’s starting location. If more than one exists, the first one encountered is returned. or null if no ESCLocation with is_start_location enabled can be found.
Parameters
None.
Returns
Returns the current room’s starting location. If more than one exists, the first one encountered is returned. or null if no ESCLocation with is_start_location enabled can be found. (ESCLocation)