PopochiuICharacter

Inherits: Node

Description

Provides access to the project's PopochiuCharacters via the singleton C (for example: C.player.say("What a wonderful plugin")).

Use this interface to manipulate characters at runtime.

Capabilities include:

  • Accessing the Player-controlled Character (PC) directly with C.player.

  • Accessing any character by name (C.CharacterName - autocompletion supported).

  • Commanding characters to move, speak, etc.

  • Change camera ownership.

Use examples:

func on_click() -> void:
    await C.walk_to_clicked() # Make the PC move to the clicked object
    await C.face_clicked() # Make the PC look at the clicked object
    await C.player.say("It's a three-headed monkey!!!") # The PC says something
    await C.Popsy.say("Don't tell me...") # Another character says something
    C.GrumpyOldMan.say("Snort! Snarl!") # Make a character speak in background (non blocking)

Properties

Type Name Default
PopochiuCharacter camera_owner
Variant characters_states {}
PopochiuCharacter player set_player

Methods

Return Type Method
void change_camera_owner(c: PopochiuCharacter)
void face_clicked()
PopochiuCharacter get_character(script_name: String)
PopochiuCharacter get_instance(script_name: String)
PopochiuCharacter get_runtime_character(script_name: String)
bool is_valid_character(script_name: String)
Callable queue_change_camera_owner(c: PopochiuCharacter)
Callable queue_face_clicked()
Callable queue_walk_to_clicked(offset = Vector2.ZERO)
Callable queue_walk_to_clicked_blocking(offset = Vector2.ZERO)
void set_player(value: PopochiuCharacter)
void walk_to_clicked(offset = Vector2.ZERO)
void walk_to_clicked_blocking(offset = Vector2.ZERO)

Signals


Signal Descriptions

character_spoke

signal character_spoke(character: PopochiuCharacter, message: String)

Emitted when character speaks message.


player_changed

signal player_changed(old_player: PopochiuCharacter, new_player: PopochiuCharacter)

Emitted when the player character changes from old_player to new_player.


Property Descriptions

camera_owner

var camera_owner : PopochiuCharacter

The PopochiuCharacter that currently owns the camera.


characters_states

var characters_states = {}

Stores per-character runtime state. Keys are the characters' script_name values.


player

var player : PopochiuCharacter = set_player
  • Setter: set_player

The PopochiuCharacter that is the current Player-controlled Character (PC). Setting this variable updates camera_owner and emits player_changed so other systems can react to the player swap.


Method Descriptions

change_camera_owner

func change_camera_owner(c: PopochiuCharacter) -> void

Changes the camera owner to c. If [PopochiuUtils.e.cutscene_skipped] is true, the camera owner is updated immediately and a frame is yielded to ensure the change takes effect.


face_clicked

func face_clicked() -> void

Makes the Player-controlled Character (PC) look at the last clicked PopochiuClickable.


get_character

func get_character(script_name: String) -> PopochiuCharacter

Returns a PopochiuCharacter instance identified by script_name. If the instance does not already exist in _characters, it will be instantiated from project data and registered.

If the character cannot be found in project data, returns null.


get_instance

func get_instance(script_name: String) -> PopochiuCharacter

Instantiates and returns the PopochiuCharacter resource referenced by script_name as defined in the Popochiu project data. If the character does not exist in the project, logs an error and returns null.


get_runtime_character

func get_runtime_character(script_name: String) -> PopochiuCharacter

Returns the runtime instance of the PopochiuCharacter identified by script_name, or null if the character is not present in the current room.

This is used by res://game/autoloads/c.gd to populate character variables at runtime.


is_valid_character

func is_valid_character(script_name: String) -> bool

Returns true if script_name refers to the current player or exists in the room's character list.


queue_change_camera_owner

func queue_change_camera_owner(c: PopochiuCharacter) -> Callable

Changes the camera owner to c. If [PopochiuUtils.e.cutscene_skipped] is true, the camera owner is updated immediately and a frame is yielded to ensure the change takes effect.

This method is intended to be used inside a queue() of instructions.


queue_face_clicked

func queue_face_clicked() -> Callable

Makes the Player-controlled Character (PC) look at the last clicked PopochiuClickable.

This method is intended to be used inside a queue() of instructions.


queue_walk_to_clicked

func queue_walk_to_clicked(offset = Vector2.ZERO) -> Callable

Moves the Player-controlled Character (PC) non-blocking to the walk_to_point of the last clicked PopochiuClickable (for example a PopochiuProp, PopochiuHotspot, or another PopochiuCharacter) in the room. Provide an optional offset to adjust the final position.

This method is intended to be used inside a queue() of instructions.


queue_walk_to_clicked_blocking

func queue_walk_to_clicked_blocking(offset = Vector2.ZERO) -> Callable

Similar to walk_to_clicked() but blocks the GUI while the PC is moving to prevent player input.

This method is intended to be used inside a queue() of instructions.


set_player

func set_player(value: PopochiuCharacter) -> void

walk_to_clicked

func walk_to_clicked(offset = Vector2.ZERO) -> void

Moves the Player-controlled Character (PC) non-blocking to the walk_to_point of the last clicked PopochiuClickable (for example a PopochiuProp, PopochiuHotspot, or another PopochiuCharacter) in the room. Provide an optional offset to adjust the final position.


walk_to_clicked_blocking

func walk_to_clicked_blocking(offset = Vector2.ZERO) -> void

Similar to walk_to_clicked() but blocks the GUI while the PC is moving to prevent player input.