The class reponsible for the maps of the engine.

Constructors

Properties

Accessors

Methods

Constructors

  • Parameters

    • game: any
    • data: any
    • name: any
    • key_name: any
    • physics_names: any
    • tileset_image_url: any
    • tileset_json_url: any
    • physics_jsons_url: any
    • lazy_load: any
    • collision_embedded: any
    • bgm_key: any
    • bgm_url: any
    • expected_party_level: any
    • background_key: any
    • show_map_name: any

    Returns Map

Properties

_active_filters: {
    alpha_gray: boolean;
    color_blend: boolean;
    colorize: boolean;
    flame: boolean;
    glow: boolean;
    gray: boolean;
    hue: boolean;
    levels: boolean;
    mode7: boolean;
    outline: boolean;
    pixel_shift: boolean;
    tint: boolean;
    watery: boolean;
}

Type declaration

  • alpha_gray: boolean
  • color_blend: boolean
  • colorize: boolean
  • flame: boolean
  • glow: boolean
  • gray: boolean
  • hue: boolean
  • levels: boolean
  • mode7: boolean
  • outline: boolean
  • pixel_shift: boolean
  • tint: boolean
  • watery: boolean
_background_key: string
_big_shapes_tiles: {
    [bounding_box_id: number]: {
        [collision_index: number]: Set<number>;
    };
}

Type declaration

  • [bounding_box_id: number]: {
        [collision_index: number]: Set<number>;
    }
    • [collision_index: number]: Set<number>
_bodies_positions: {
    [bounding_box_id: number]: {
        [collision_index: number]: {
            [location_key: number]: (NPC | InteractableObjects)[];
        };
    };
}

Type declaration

_collision_layer: number
_collision_layers_number: number
_collision_sprite: Sprite
_colorize_filter: Colorize
_current_bounding_box_id: number
_encounter_cumulator: number
_events: {
    [location_key: number]: TileEvent[];
}

Type declaration

_generic_sprites: {
    [key_name: string]: Phaser.Sprite;
}

Type declaration

  • [key_name: string]: Phaser.Sprite
_gray_filter: Gray
_interactable_objects: InteractableObjects[]
_interactable_objects_label_map: {
    [label: string]: InteractableObjects;
}

Type declaration

_internal_map_objs_storage_keys: {
    interactable_objects: {
        [map_index: string]: InteractableObjects["storage_keys"];
    };
    npcs: {
        [map_index: string]: NPC["storage_keys"];
    };
}

Type declaration

_is_world_map: boolean
_key_name: string
_lazy_load: boolean
_map_name_window: Window
_mode7_filter: Mode7
_name: string
_npcs: NPC[]
_npcs_label_map: {
    [label: string]: NPC;
}

Type declaration

  • [label: string]: NPC
_paused: boolean
_processed_polygons: {
    [bounding_box_id: number]: {
        [collision_layer: number]: {
            location_key?: number;
            polygon: number[][];
            properties: any;
            sensor_active: boolean;
            sensor_active_original: boolean;
            split_polygon: boolean;
        }[];
    };
}

Type declaration

  • [bounding_box_id: number]: {
        [collision_layer: number]: {
            location_key?: number;
            polygon: number[][];
            properties: any;
            sensor_active: boolean;
            sensor_active_original: boolean;
            split_polygon: boolean;
        }[];
    }
    • [collision_layer: number]: {
          location_key?: number;
          polygon: number[][];
          properties: any;
          sensor_active: boolean;
          sensor_active_original: boolean;
          split_polygon: boolean;
      }[]
_retreat_data: {
    collision_layer: number;
    direction: directions;
    x: number;
    y: number;
}

Type declaration

  • collision_layer: number
  • direction: directions
  • x: number
  • y: number
_sand_collision_layer: number
_shapes: {
    [bounding_box_id: number]: {
        [collision_index: number]: {
            [location_key: number]: p2.Convex[];
        };
    };
}

Type declaration

  • [bounding_box_id: number]: {
        [collision_index: number]: {
            [location_key: number]: p2.Convex[];
        };
    }
    • [collision_index: number]: {
          [location_key: number]: p2.Convex[];
      }
      • [location_key: number]: p2.Convex[]
_show_footsteps: boolean
_show_map_name: boolean
_sprite: Tilemap
assets_loaded: boolean
before_camera_fade_game_events: GameEvent[]
before_config_game_events: GameEvent[]
bgm_key: string
bgm_regions: {
    bgm_keys: string[];
    rectangle: Rectangle;
    sound_objects: Sound[];
}[]

Type declaration

  • bgm_keys: string[]
  • rectangle: Rectangle
  • sound_objects: Sound[]
bgm_url: string
bounding_boxes: {
    id: number;
    rect: Rectangle;
}[]

Type declaration

  • id: number
  • rect: Rectangle
collision_embedded: boolean
data: GoldenSun
encounter_zones: {
    background_key: string;
    base_rate: number;
    parties: string[];
    rectangle: Rectangle;
}[]

Type declaration

  • background_key: string
  • base_rate: number
  • parties: string[]
  • rectangle: Rectangle
expected_party_level: number
filter_tween: {
    colorize: Tween;
    gray: Tween;
}

Generic tween object to be used to transition this map filters.

Type declaration

  • colorize: Tween
  • gray: Tween
game: Game
game_events: GameEvent[]
layer_changes: {
    [layer_name: string]: {
        layer_blend?: PIXI.blendModes;
        layer_offset?: {
            x: number;
            y: number;
        };
        opacity?: number;
        visibility?: boolean;
    };
}

Type declaration

  • [layer_name: string]: {
        layer_blend?: PIXI.blendModes;
        layer_offset?: {
            x: number;
            y: number;
        };
        opacity?: number;
        visibility?: boolean;
    }
    • Optional layer_blend?: PIXI.blendModes
    • Optional layer_offset?: {
          x: number;
          y: number;
      }
      • x: number
      • y: number
    • Optional opacity?: number
    • Optional visibility?: boolean
other_game_events: GameEvent[]
physics_jsons_url: string
physics_names: string
polygons_processed: Set<number>
sprites_sort_paused: boolean

If true, sprites in middlelayer_group won't be sorted.

tileset_image_url: string
tileset_json_url: string
CAMERA_ROTATION_STEP: 0.003 = 0.003
MAX_CAMERA_ROTATION: 0.035 = 0.035

Accessors

  • get active_filters(): {
        alpha_gray: boolean;
        color_blend: boolean;
        colorize: boolean;
        flame: boolean;
        glow: boolean;
        gray: boolean;
        hue: boolean;
        levels: boolean;
        mode7: boolean;
        outline: boolean;
        pixel_shift: boolean;
        tint: boolean;
        watery: boolean;
    }
  • An object containing which filters are active in this char.

    Returns {
        alpha_gray: boolean;
        color_blend: boolean;
        colorize: boolean;
        flame: boolean;
        glow: boolean;
        gray: boolean;
        hue: boolean;
        levels: boolean;
        mode7: boolean;
        outline: boolean;
        pixel_shift: boolean;
        tint: boolean;
        watery: boolean;
    }

    • alpha_gray: boolean
    • color_blend: boolean
    • colorize: boolean
    • flame: boolean
    • glow: boolean
    • gray: boolean
    • hue: boolean
    • levels: boolean
    • mode7: boolean
    • outline: boolean
    • pixel_shift: boolean
    • tint: boolean
    • watery: boolean
  • get background_key(): string
  • The battle background key of this map.

    Returns string

  • get body(): Body
  • Gets the map collision body for current collision layer.

    Returns Body

  • get collision_layer(): number
  • The current active collision layer.

    Returns number

  • get collision_layers_number(): number
  • The number of collision layers of this map.

    Returns number

  • get collision_sprite(): Sprite
  • The sprite without texture just responsible to enable the map collision body.

    Returns Sprite

  • get colorize_filter(): Colorize
  • The Phaser.Filter object responsible for this map texture color control.

    Returns Colorize

  • get current_bounding_box_id(): number
  • Gets the current bounding box object ID.

    Returns number

  • get encounter_cumulator(): number
  • Gets the enemy party encounter cumulator value.

    Returns number

  • get events(): {
        [location_key: number]: TileEvent[];
    }
  • The list of TileEvents of this map.

    Returns {
        [location_key: number]: TileEvent[];
    }

  • get generic_sprites(): {
        [key_name: string]: Phaser.Sprite;
    }
  • An object of generic sprites that can be created by Game Events.

    Returns {
        [key_name: string]: Phaser.Sprite;
    }

    • [key_name: string]: Phaser.Sprite
  • get gray_filter(): Gray
  • The Phaser.Filter object responsible for this map saturation control.

    Returns Gray

  • get is_world_map(): boolean
  • Whether this map is world map or not.

    Returns boolean

  • get key_name(): string
  • The map key name.

    Returns string

  • get layers(): any[]
  • The list of layers of this map.

    Returns any[]

  • get lazy_load(): boolean
  • Whether this map will load its assets only when the hero reaches it.

    Returns boolean

  • get mode7_filter(): Mode7
  • The Phaser.Filter object responsible for this map mode7.

    Returns Mode7

  • get npcs_label_map(): {
        [label: string]: NPC;
    }
  • The object that holds the NPCs of this map that have a label.

    Returns {
        [label: string]: NPC;
    }

    • [label: string]: NPC
  • get paused(): boolean
  • Whether the map is paused or not.

    Returns boolean

  • get retreat_data(): {
        collision_layer: number;
        direction: directions;
        x: number;
        y: number;
    }
  • Gets Retreat psynergy info. Returns the x and y tile posoition to retreat and the destination collision index and direction.

    Returns {
        collision_layer: number;
        direction: directions;
        x: number;
        y: number;
    }

    • collision_layer: number
    • direction: directions
    • x: number
    • y: number
  • get sand_collision_layer(): number
  • Gets the collision layer index that sand psynergy will use.

    Returns number

  • get show_footsteps(): boolean
  • Whether this map has chars footprint system enabled.

    Returns boolean

  • get show_map_name(): boolean
  • Whether this map will show its name on teleport.

    Returns boolean

  • get sprite(): Tilemap
  • The map main sprite.

    Returns Tilemap

  • get tile_height(): any
  • The tile height of this map.

    Returns any

  • get tile_width(): any
  • The tile width of this map.

    Returns any

Methods

  • Adds a generic sprite to this map.

    Parameters

    • key_name: string

      the generic sprite key name.

    • misc_sprite_key: string
    • x: number

      the x position in px.

    • y: number

      the y position in px.

    • group: Group

      the Phaser.Group to be in.

    • Optional options: {
          action?: string;
          alpha?: number;
          anchor_x?: number;
          anchor_y?: number;
          animation?: string;
          collision_layer?: number;
          frame?: string;
          frame_rate?: number;
          loop?: boolean;
          play?: boolean;
          rotation?: number;
          scale_x?: number;
          scale_y?: number;
          send_to_back?: boolean;
      }

      some options.

      • Optional action?: string

        The animation action key.

      • Optional alpha?: number

        The sprite alpha value.

      • Optional anchor_x?: number

        The sprite ancho x value.

      • Optional anchor_y?: number

        The sprite ancho y value.

      • Optional animation?: string

        The animation key.

      • Optional collision_layer?: number

        The collision layer that the sprite will be. Important when sorting sprites.

      • Optional frame?: string

        The frame key name to be set for this sprite.

      • Optional frame_rate?: number

        The frame rate of the animation.

      • Optional loop?: boolean

        Whether the animation will loop.

      • Optional play?: boolean

        If true, an animation of this sprite will be started.

      • Optional rotation?: number

        The sprite rotation value.

      • Optional scale_x?: number

        The sprite scale x value.

      • Optional scale_y?: number

        The sprite scale y value.

      • Optional send_to_back?: boolean

        If true, the sprite will be sorted under NPC layers.

    Returns Sprite

    returns the generated sprite.

  • Update function to check whether BGMs should be played if the hero is inside the specified regions.

    Returns void

  • Checks whether a NPC or Interactable object has its body on map.

    Parameters

    Returns boolean

    whether the body is in the map or not.

  • Updates camera bounds to fit current portion of the map.

    Returns void

  • Configs map, npc and interactable objects collision bodies.

    Parameters

    • collision_layer: number

      the collsion layer index.

    Returns void

  • Creates and setups the map collision bodies. Collision bodies for maps may come from physics json file or object layers from a Tiled map.

    Parameters

    • collision_layer: number

      the collsion layer index.

    Returns void

  • Initializes all the interactable objects of this map.

    Returns void

  • Creates, initializes and organize the map layers sprites.

    Parameters

    • reorganize: boolean = false

      if true, it will only reorganize the layers. It's expected that the layers were already created.

    Returns void

  • Initializes all the NPCs of this map.

    Returns void

  • Initializes a single NPC in this map.

    Parameters

    • npc: NPC

      the npc to be initialized.

    • map_index: number

      the map unique index of this interactable object.

    • Optional custom_pos: {
          x?: number;
          y?: number;
      }

      an initial custom position for this npc in px.

      • Optional x?: number
      • Optional y?: number

    Returns void

  • Initializes some world map custom features of this map in the case it's a world map.

    Returns void

  • Creates an interactable object.

    Parameters

    • property_key: string

      the property name.

    • raw_property: string

      the properties of this interactable object still not parsed.

    • map_index: number

      the map unique index of this interactable object.

    Returns void

    returns the created interactable object.

  • Creates a NPC.

    Parameters

    • property_key: string

      the property name.

    • properties: any

      the properties of this NPC, parsed or not.

    • not_parsed: boolean = true

      whether the properties are parsed or not.

    • map_index: number

      the map unique index of this NPC.

    Returns NPC

    returns the created npc.

  • Creates a tile event.

    Parameters

    • property_key: string

      the property name.

    • raw_property: string

      the properties of this event still not parsed.

    Returns void

    returns the created event.

  • Fires this map game events.

    Parameters

    • map_event_type: map_game_event_types = map_game_event_types.REGULAR

      the set type of map events that will be fired.

    Returns void

  • Get the tiles that a ControllableChar is over.

    Parameters

    • controllable_char: ControllableChar

      the ControllableChar.

    • Optional layer: any[]

      if this is not specified, it's returned all tiles for the char position.

    Returns Tile | Tile[]

    returns a tile object: Phaser.Tile or Phaser.Tile[] if multiple layers.

  • Gets the zones that the hero is in. Zones are only available if hero is moving.

    Returns Set<{
        background_key: string;
        base_rate: number;
        parties: string[];
        rectangle: Rectangle;
    }>

    a Set of zones.

  • Creates a NPC representing the djinn to be gotten and a game event to get this djinn.

    Parameters

    • djinn_key: string

      the djinn key to be gotten.

    Returns (() => void)

    return the fire event function of the DjinnEvent instance created in this function.

      • (): void
      • Returns void

  • Get a specific layer.

    Parameters

    • name: string

      the layer name.

    Returns any

    return the layer.

  • Checks if a given tile position has IOs or NPCs, if yes return a list of them.

    Parameters

    • tile_x_pos: number

      the x tile position.

    • tile_y_pos: number

      the y tile position.

    • Optional collision_layer: number

      the collision layer of tile. If not passed, gets the current one.

    Returns (InteractableObjects | NPC)[]

    Returns a list of NPCs and IOs based on constraints given.

  • Checks whether this map has the given tile event placed somewhere.

    Parameters

    • event_id: number

      the id of the tile event.

    Returns boolean

    whether the given tile event is on the map.

  • Initializes game events of this map.

    Parameters

    • events: string

      list of input events before parse.

    • event_type: map_game_event_types = map_game_event_types.REGULAR

      the type of game event that's being intialized.

    • Optional property_key: string

      the property key name in case of "options_list" game event type.

    Returns void

  • Initializes the window that shows the map name when entering on it.

    Returns void

  • Checks if a given tile position is blocked by a collision object.

    Parameters

    • tile_x_pos: number

      the x tile position.

    • tile_y_pos: number

      the y tile position.

    • Optional collision_layer: number

      the collision layer of tile. If not passed, gets the current one.

    • also_check_npc_io: boolean = false

      if true, will also check for NPCs and IOs.

    Returns boolean

    Returns whether the given position is blocked or not.

  • Loads the map assets like tileset and background music.

    Parameters

    • force_load: boolean

      if true, forces the loading process to start.

    • Optional on_complete: (() => void)

      on load complete callback.

        • (): void
        • Returns void

    Returns void

  • Sets or unsets a Phaser.Filter in this map.

    Parameters

    • filter: Filter

      the filter you want to set.

    • set: boolean

      whether it's to set or unset the filter.

    • Optional layer: string

      specify a layer if you want that this filter management should be only for the given layer.

    Returns void

  • This is the main function of this class. It mounts the map.

    Parameters

    • collision_layer: number

      the initial collision layer.

    • encounter_cumulator: number

      the initial encounter cumulator. If not passed, it's reset.

    • hero_dest: {
          x: number;
          y: number;
      }

      an object that holds the x and y tile positions that the hero will be.

      • x: number
      • y: number
    • Optional retreat_data: {
          collision_layer: number;
          direction: directions;
          x: number;
          y: number;
      }

      retreat data that can be propagated from previous map if it has the same key name.

      • collision_layer: number
      • direction: directions
      • x: number
      • y: number

    Returns Promise<Map>

    returns the mounted map.

  • Parses the over property of a given layer.

    Parameters

    • property_value: any

      the over property value.

    Returns number

    returns -1 if under the hero or the threshold collision layer to be under.

  • Pauses map activity, like collisions, npc and interactable objects animation etc.

    Returns {
        previously_inactive_io: Set<number>;
        previously_inactive_npc: Set<number>;
        previously_not_visible_layers: Set<number>;
    }

    return the current map state.

    • previously_inactive_io: Set<number>
    • previously_inactive_npc: Set<number>
    • previously_not_visible_layers: Set<number>
  • Pre processor the map collision polygons in order to limit their size to a tile size.

    Returns void

  • Processes Tiled layers to check whether they have configs related to collision, encounter zones and bounding boxes.

    Returns void

  • Removes a NPC or an IO collision track from this map.

    Parameters

    • instance: InteractableObjects | NPC

      the NPC or IO instance.

    • Optional x_tile: number

      the x tile position.

    • Optional y_tile: number

      the y tile position.

    • Optional collision_layer: number

      the collision index.

    Returns void

  • Removes a tile event in a custom location.

    Parameters

    • location_key: number

      the LocationKey of the event.

    • event_id: number

      the id of the event.

    Returns boolean

    returns true if the event was removed.

  • Removes a generic sprite from this map.

    Parameters

    • key_name: string

      the generic sprite key name.

    Returns boolean

    return true if the sprite was removed.

  • Removes a NPC from this map.

    Parameters

    • npc: NPC

      the npc to be removed.

    • unset: boolean = true

      if true, will also unset the npc.

    Returns void

  • Resumes map activity, like collisions, npc and interactable objects animation etc.

    Parameters

    • Optional previous_state: {
          previously_inactive_io: Set<number>;
          previously_inactive_npc: Set<number>;
          previously_not_visible_layers: Set<number>;
      }

      the map state when it was paused.

      • previously_inactive_io: Set<number>
      • previously_inactive_npc: Set<number>
      • previously_not_visible_layers: Set<number>

    Returns void

  • Sets whether a tile should collide or not. Only works if there's at least on collision body in the given tile position.

    Parameters

    • tile_x_pos: number

      the x tile position.

    • tile_y_pos: number

      the y tile position.

    • collide: boolean

      whether it should collide or not.

    • Optional collision_layer: number

      the collision layer of tile. If not passed, gets the current one.

    Returns void

  • Sets a storage key identifier for a NPC or Interactable Object in order to hold values internally if this map is unmounted.

    Parameters

    • is_npc: boolean

      is true, will set the key for a NPC, otherwise for an Interactable Object.

    • property: "anchor" | "position" | "scale" | "visible" | "action" | "active" | "base_collision_layer" | "move_freely_in_event" | "movement_type" | "interaction_pattern" | "affected_by_reveal" | "enable" | "entangled_by_bush" | "animation" | "position_px"

      the storage key type.

    • storage_key: string

      the storage key.

    • obj_index: number

      the NPC or Interactable Object index in this map.

    Returns void

  • Checks what is the suitable bounding box for the given position. If no bounding box found, will fit map bounds to world size.

    Parameters

    • tile_x_pos: number

      the x tile position.

    • tile_y_pos: number

      the y tile position.

    • apply_on_camera_view: boolean = true

      if true, will apply the bounds to camera.

    Returns void

  • Sorts the sprites in the GoldenSun.middlelayer_group by y position and base_collision_layer properties. After this first sort, send_to_front [boolean], sort_function [callable], send_to_back [boolean] and sort_function_end [callable] Phaser.DisplayObject properties are checked in this order.

    Returns void

  • Calculates whether it's time to start a random battle.

    Parameters

    • zone_base_rate: number

      the encounter finding rate of the current battle zone.

    Returns boolean

    returns true if it's time to start a random battle.

  • Unsets all filters in this map.

    Returns void

  • The map update function.

    Returns void

  • Updates the new position of an IO or NPC in this map structure.

    Parameters

    • old_x: number

      the old x tile position.

    • old_y: number

      the old y tile position.

    • new_x: number

      the new x tile position.

    • new_y: number

      the new y tile position.

    • old_col_index: number

      the old collision index.

    • new_col_index: number

      the new collision index.

    • instance: InteractableObjects | NPC

      the NPC or IO instance.

    Returns void

  • If it's a world map, rotates the map on hero movement start.

    Returns void

  • Checks whether it's time to start a random battle.

    Returns void