]> git.r.bdr.sh - rbdr/sumo/blame_incremental - lib/components/control_map.js
Add Naive Game Rules (#11)
[rbdr/sumo] / lib / components / control_map.js
... / ...
CommitLineData
1import { Component } from '@serpentity/serpentity';
2
3/**
4 * The contorl mapping object, holds a source and target for the action.
5 *
6 * @typedef tControlMap
7 * @type object
8 *
9 * @property {tControlSource} source the source input for the action
10 * @property {tControlTarget} target the target property for the action
11 */
12
13/**
14 * The definition of an input source
15 *
16 * @typedef tControlSource
17 * @type object
18 *
19 * @property {string} type type of input, can be keyboard or gamepad
20 * @property {number} gamepadNumber the number of gamepad to use
21 * @property {string} gamepadInputSource either axes or buttons
22 * @property {number} index the input index or keycode
23 */
24
25/**
26 * The definition of an input target
27 *
28 * @typedef tControlTarget
29 * @type object
30 *
31 * @property {external:Serpentity:Component} component the component affected by this
32 * @property {string} property property to affect. For nested properties use dot.notation
33 * @property {[function]} value a function that takes in the input and outputs a transformed value
34 */
35
36/**
37 * Component that stores the state of motion controls to properties
38 *
39 * @extends {external:Serpentity.Component}
40 * @class ControlMapComponent
41 * @param {object} config a configuration object to extend.
42 */
43export default class ControlMapComponent extends Component {
44 constructor(config) {
45
46 super(config);
47
48 /**
49 * The map of actions and controls. An array of mappings
50 *
51 * @property {Array<tControlMap>} map
52 * @instance
53 * @memberof ControlMapComponent
54 */
55 this.map = this.map || [];
56 }
57};