Options
All
  • Public
  • Public/Protected
  • All
Menu

This is the class reponsible for general events of the game. Every game event class must inherit from this class. Whenever a game event is instantiated, this event receives an unique id. These ids are reset whenever a map is destroyed. In order to fire a GameEvent, calls GameEvent.fire. In order to destroy a game event, calls GameEvent.destroy. Game events can be fired from TileEvents, NPC or Interactable Objects interaction, map changes or other game events. For easy reference/example, check base/game_events/EmoticonEvent.ts. Whenever an asynchronous game event is fired, increments the GameEventManager.events_running_count, so the engine knows that there's an event going on. When the event is finished, decrements the same variable. If your event has internal states, don't forget to reset them on finish. When creating a new GameEvent class, add its instantiation in GameEventManager.get_event_instance factory method.

Hierarchy

Index

Constructors

  • new GameEvent(game: Game, data: GoldenSun, type: event_types, active: boolean, key_name: string, keep_reveal: boolean, keep_custom_psynergy: boolean): GameEvent

Properties

_active: boolean
_id: number
_keep_reveal: boolean
_key_name: string
_origin_npc: NPC
data: GoldenSun
game: Game
keep_custom_psynergy: boolean

If true, custom psynergies won't be stopped on this event fire.

events: {}

The events object where the keys are the ids.

Type declaration

id_incrementer: number

The GameEvents id incrementer.

labeled_events: {}

The events object where the keys are the events labels.

Type declaration

Accessors

  • get active(): boolean
  • get id(): number
  • get keep_reveal(): boolean
  • get key_name(): string
  • get origin_npc(): NPC

Methods

  • _destroy(): void
  • _fire(): void
  • check_custom_psynergy(): void
  • check_reveal(): void
  • destroy(): void
  • This function is the one that should be called to destroy an event. It should never be overriden. Call this function to destroy this event. This can be called whenever an associated entity is destroyed, like maps, NPCs etc.

    Returns void

  • fire(origin_npc?: NPC): void
  • This function is the one that should be called to start a event. It should never be overriden. Always before this function is called, it's checked whether Reveal psynergy is being casted, if yes, it's stopped before this event start.

    Parameters

    • Optional origin_npc: NPC

      the NPC that originated this game event.

    Returns void

    if the child class has an async fire function, returns its Promise.

  • set_event_activation(activate: boolean): void
  • get_char(data: GoldenSun, options: { is_npc?: boolean; npc_index?: number; npc_label?: string }): Hero | NPC
  • A helper function that defines the ControllableChar based on inputs. The controllable char can be a hero or a npc.

    Parameters

    • data: GoldenSun

      The GoldenSun instance.

    • options: { is_npc?: boolean; npc_index?: number; npc_label?: string }

      Some options to help defining the char.

      • Optional is_npc?: boolean

        Whether it's a npc or not.

      • Optional npc_index?: number

        The npc index number.

      • Optional npc_label?: string

        The npc unique label identifier.

    Returns Hero | NPC

    the defined char.

  • get_labeled_event(key_name: string): GameEvent
  • reset(): void

Generated using TypeDoc