GatoControlScheme

Inherits: InputConfig < Resource

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Description

This class is the specific implementation of a control scheme, a set of pre-configured inputs and actions that can be used to offer default controls for players. We support defining multiple control schemes so that you can offer multiple default controls, based for instance on whether a player can use some keys or not. Some players can only use a hand (either left or right), while others struggle with joysticks or shoulder/trigger buttons, so it’s a good idea to offer alternative controls for each type of player.

Properties

Array[InputAction]

input_actions

[]

Dictionary[String, Script]

type_to_script_map

{...}

Methods

bool

equals(other_scheme: GatoControlScheme)

Dictionary

get_as_dict()

InputConfig

new_from_dict(dict: Dictionary) static

Array[InputAction]

load_input_actions(input_actions: Array) static


Property Descriptions

Array[InputAction] input_actions = [] 🔗

The list of InputActions defined inside this ControlScheme.


Dictionary[String, Script] type_to_script_map = {...} 🔗

A Dictionary that maps InputAction type strings to the specific scripts holding their class implementation.


Method Descriptions

bool equals(other_scheme: GatoControlScheme) 🔗

Checks if the passed InputAction has the same value as the current instance. Returns true if so, false otherwise.


Dictionary get_as_dict() 🔗

Method used for serialization. When saving a control scheme to a file, it is first turned into a Dictionary with the data it needs (category, name, configuration…) so it can be stored as a JSON file. The configuration might include the InputEvent object that triggers the action.


InputConfig new_from_dict(dict: Dictionary) static 🔗

Method used for deserialization. When loading a control scheme from a file, new instances of InputAction classes are created with the configuration from the stored JSON file. This method uses the data in those JSON objects to create a new instance of the InputAction. The ControlScheme is used to define what input type correspond to what class in the addon scripts.


Array[InputAction] load_input_actions(input_actions: Array) static 🔗

This method is used during the creation of a new ControlScheme object from a Dictionary (see the new_from_dict() method). It receives the lis of InputActions from the stored JSON configuration and converts it to ready-to-use objects from the addons scripts.