UNPKG

seed-engine

Version:

A Lightweight 2D game engine using WebGL2. The engine is designed on the focus of creating a bridge between creating and publishing games to the Seed Network as modules.

1,412 lines (1,411 loc) 225 kB
{ "type": "File", "start": 0, "end": 2430, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 105, "column": 1 } }, "program": { "type": "Program", "start": 0, "end": 2430, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 105, "column": 1 } }, "sourceType": "module", "body": [ { "type": "ImportDeclaration", "start": 0, "end": 61, "loc": { "start": { "line": 1, "column": 0 }, "end": { "line": 1, "column": 61 } }, "specifiers": [ { "type": "ImportDefaultSpecifier", "start": 7, "end": 24, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 24 } }, "local": { "type": "Identifier", "start": 7, "end": 24, "loc": { "start": { "line": 1, "column": 7 }, "end": { "line": 1, "column": 24 }, "identifierName": "UpdateableManager" }, "name": "UpdateableManager" } } ], "source": { "type": "StringLiteral", "start": 30, "end": 60, "loc": { "start": { "line": 1, "column": 30 }, "end": { "line": 1, "column": 60 } }, "extra": { "rawValue": "../manager/UpdateableManager", "raw": "'../manager/UpdateableManager'" }, "value": "../manager/UpdateableManager" }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Baseclass for objects that follow the same ECS pattern of the seed engine.\n * \n * Used in anything that should follow a create, update, end loop \n * handled by the Engine.\n * \n * Many things will need to update/start/end. If you derive something that\n * has the start()/update()/end()... functions, the children should fill in\n * their respective callbacks (onStart()/onUpdate()/onEnd()/...).\n ", "start": 63, "end": 466, "loc": { "start": { "line": 3, "column": 0 }, "end": { "line": 12, "column": 3 } } } ] }, { "type": "ExportDefaultDeclaration", "start": 467, "end": 2430, "loc": { "start": { "line": 13, "column": 0 }, "end": { "line": 105, "column": 1 } }, "declaration": { "type": "ClassDeclaration", "start": 482, "end": 2430, "loc": { "start": { "line": 13, "column": 15 }, "end": { "line": 105, "column": 1 } }, "id": { "type": "Identifier", "start": 488, "end": 498, "loc": { "start": { "line": 13, "column": 21 }, "end": { "line": 13, "column": 31 }, "identifierName": "Updateable" }, "name": "Updateable", "leadingComments": null }, "superClass": null, "body": { "type": "ClassBody", "start": 499, "end": 2430, "loc": { "start": { "line": 13, "column": 32 }, "end": { "line": 105, "column": 1 } }, "body": [ { "type": "ClassMethod", "start": 505, "end": 683, "loc": { "start": { "line": 14, "column": 4 }, "end": { "line": 19, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 505, "end": 516, "loc": { "start": { "line": 14, "column": 4 }, "end": { "line": 14, "column": 15 }, "identifierName": "constructor" }, "name": "constructor" }, "kind": "constructor", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 519, "end": 683, "loc": { "start": { "line": 14, "column": 18 }, "end": { "line": 19, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 529, "end": 553, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 15, "column": 32 } }, "expression": { "type": "AssignmentExpression", "start": 529, "end": 552, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 15, "column": 31 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 529, "end": 544, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 15, "column": 23 } }, "object": { "type": "ThisExpression", "start": 529, "end": 533, "loc": { "start": { "line": 15, "column": 8 }, "end": { "line": 15, "column": 12 } } }, "property": { "type": "Identifier", "start": 534, "end": 544, "loc": { "start": { "line": 15, "column": 13 }, "end": { "line": 15, "column": 23 }, "identifierName": "hasStarted" }, "name": "hasStarted" }, "computed": false }, "right": { "type": "BooleanLiteral", "start": 547, "end": 552, "loc": { "start": { "line": 15, "column": 26 }, "end": { "line": 15, "column": 31 } }, "value": false } } }, { "type": "ExpressionStatement", "start": 562, "end": 585, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 31 } }, "expression": { "type": "AssignmentExpression", "start": 562, "end": 584, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 30 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 562, "end": 576, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 22 } }, "object": { "type": "ThisExpression", "start": 562, "end": 566, "loc": { "start": { "line": 16, "column": 8 }, "end": { "line": 16, "column": 12 } } }, "property": { "type": "Identifier", "start": 567, "end": 576, "loc": { "start": { "line": 16, "column": 13 }, "end": { "line": 16, "column": 22 }, "identifierName": "hasPaused" }, "name": "hasPaused" }, "computed": false }, "right": { "type": "BooleanLiteral", "start": 579, "end": 584, "loc": { "start": { "line": 16, "column": 25 }, "end": { "line": 16, "column": 30 } }, "value": false } } }, { "type": "ExpressionStatement", "start": 594, "end": 607, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 21 } }, "expression": { "type": "AssignmentExpression", "start": 594, "end": 606, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 20 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 594, "end": 601, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 15 } }, "object": { "type": "ThisExpression", "start": 594, "end": 598, "loc": { "start": { "line": 17, "column": 8 }, "end": { "line": 17, "column": 12 } } }, "property": { "type": "Identifier", "start": 599, "end": 601, "loc": { "start": { "line": 17, "column": 13 }, "end": { "line": 17, "column": 15 }, "identifierName": "id" }, "name": "id" }, "computed": false }, "right": { "type": "UnaryExpression", "start": 604, "end": 606, "loc": { "start": { "line": 17, "column": 18 }, "end": { "line": 17, "column": 20 } }, "operator": "-", "prefix": true, "argument": { "type": "NumericLiteral", "start": 605, "end": 606, "loc": { "start": { "line": 17, "column": 19 }, "end": { "line": 17, "column": 20 } }, "extra": { "rawValue": 1, "raw": "1" }, "value": 1 }, "extra": { "parenthesizedArgument": false } } } }, { "type": "ExpressionStatement", "start": 616, "end": 677, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 69 } }, "expression": { "type": "AssignmentExpression", "start": 616, "end": 676, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 68 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 616, "end": 631, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 23 } }, "object": { "type": "ThisExpression", "start": 616, "end": 620, "loc": { "start": { "line": 18, "column": 8 }, "end": { "line": 18, "column": 12 } } }, "property": { "type": "Identifier", "start": 621, "end": 631, "loc": { "start": { "line": 18, "column": 13 }, "end": { "line": 18, "column": 23 }, "identifierName": "deregister" }, "name": "deregister" }, "computed": false }, "right": { "type": "CallExpression", "start": 634, "end": 676, "loc": { "start": { "line": 18, "column": 26 }, "end": { "line": 18, "column": 68 } }, "callee": { "type": "MemberExpression", "start": 634, "end": 670, "loc": { "start": { "line": 18, "column": 26 }, "end": { "line": 18, "column": 62 } }, "object": { "type": "Identifier", "start": 634, "end": 651, "loc": { "start": { "line": 18, "column": 26 }, "end": { "line": 18, "column": 43 }, "identifierName": "UpdateableManager" }, "name": "UpdateableManager" }, "property": { "type": "Identifier", "start": 652, "end": 670, "loc": { "start": { "line": 18, "column": 44 }, "end": { "line": 18, "column": 62 }, "identifierName": "registerUpdateable" }, "name": "registerUpdateable" }, "computed": false }, "arguments": [ { "type": "ThisExpression", "start": 671, "end": 675, "loc": { "start": { "line": 18, "column": 63 }, "end": { "line": 18, "column": 67 } } } ] } } } ], "directives": [], "trailingComments": null }, "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Base call function for when this Updateable is to be started.\n ", "start": 689, "end": 769, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 23, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 774, "end": 845, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 27, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 774, "end": 779, "loc": { "start": { "line": 24, "column": 4 }, "end": { "line": 24, "column": 9 }, "identifierName": "start" }, "name": "start", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 782, "end": 845, "loc": { "start": { "line": 24, "column": 12 }, "end": { "line": 27, "column": 5 } }, "body": [ { "type": "ExpressionStatement", "start": 792, "end": 807, "loc": { "start": { "line": 25, "column": 8 }, "end": { "line": 25, "column": 23 } }, "expression": { "type": "CallExpression", "start": 792, "end": 806, "loc": { "start": { "line": 25, "column": 8 }, "end": { "line": 25, "column": 22 } }, "callee": { "type": "MemberExpression", "start": 792, "end": 804, "loc": { "start": { "line": 25, "column": 8 }, "end": { "line": 25, "column": 20 } }, "object": { "type": "ThisExpression", "start": 792, "end": 796, "loc": { "start": { "line": 25, "column": 8 }, "end": { "line": 25, "column": 12 } } }, "property": { "type": "Identifier", "start": 797, "end": 804, "loc": { "start": { "line": 25, "column": 13 }, "end": { "line": 25, "column": 20 }, "identifierName": "onStart" }, "name": "onStart" }, "computed": false }, "arguments": [] } }, { "type": "ExpressionStatement", "start": 816, "end": 839, "loc": { "start": { "line": 26, "column": 8 }, "end": { "line": 26, "column": 31 } }, "expression": { "type": "AssignmentExpression", "start": 816, "end": 838, "loc": { "start": { "line": 26, "column": 8 }, "end": { "line": 26, "column": 30 } }, "operator": "=", "left": { "type": "MemberExpression", "start": 816, "end": 831, "loc": { "start": { "line": 26, "column": 8 }, "end": { "line": 26, "column": 23 } }, "object": { "type": "ThisExpression", "start": 816, "end": 820, "loc": { "start": { "line": 26, "column": 8 }, "end": { "line": 26, "column": 12 } } }, "property": { "type": "Identifier", "start": 821, "end": 831, "loc": { "start": { "line": 26, "column": 13 }, "end": { "line": 26, "column": 23 }, "identifierName": "hasStarted" }, "name": "hasStarted" }, "computed": false }, "right": { "type": "BooleanLiteral", "start": 834, "end": 838, "loc": { "start": { "line": 26, "column": 26 }, "end": { "line": 26, "column": 30 } }, "value": true } } } ], "directives": [], "trailingComments": null }, "leadingComments": [ { "type": "CommentBlock", "value": "*\n * Base call function for when this Updateable is to be started.\n ", "start": 689, "end": 769, "loc": { "start": { "line": 21, "column": 4 }, "end": { "line": 23, "column": 7 } } } ], "trailingComments": [ { "type": "CommentBlock", "value": "*\n * Base call function for when this Updateable is to be updated.\n ", "start": 851, "end": 931, "loc": { "start": { "line": 29, "column": 4 }, "end": { "line": 31, "column": 7 } } } ] }, { "type": "ClassMethod", "start": 936, "end": 1123, "loc": { "start": { "line": 32, "column": 4 }, "end": { "line": 42, "column": 5 } }, "static": false, "computed": false, "key": { "type": "Identifier", "start": 936, "end": 942, "loc": { "start": { "line": 32, "column": 4 }, "end": { "line": 32, "column": 10 }, "identifierName": "update" }, "name": "update", "leadingComments": null }, "kind": "method", "id": null, "generator": false, "expression": false, "async": false, "params": [], "body": { "type": "BlockStatement", "start": 945, "end": 1123, "loc": { "start": { "line": 32, "column": 13 }, "end": { "line": 42, "column": 5 } }, "body": [ { "type": "IfStatement", "start": 955, "end": 994, "loc": { "start": { "line": 33, "column": 8 }, "end": { "line": 34, "column": 19 } }, "test": { "type": "MemberExpression", "start": 959, "end": 973, "loc": { "start": { "line": 33, "column": 12 }, "end": { "line": 33, "column": 26 } }, "object": { "type": "ThisExpression", "start": 959, "end": 963, "loc": { "start": { "line": 33, "column": 12 }, "end": { "line": 33, "column": 16 } } }, "property": { "type": "Identifier", "start": 964, "end": 973, "loc": { "start": { "line": 33, "column": 17 }, "end": { "line": 33, "column": 26 }, "identifierName": "hasPaused" }, "name": "hasPaused" }, "computed": false }, "consequent": { "type": "ReturnStatement", "start": 987, "end": 994, "loc": { "start": { "line": 34, "column": 12 }, "end": { "line": 34, "column": 19 } }, "argument": null }, "alternate": null }, { "type": "IfStatement", "start": 1012, "end": 1091, "loc": { "start": { "line": 36, "column": 8 }, "end": { "line": 39, "column": 9 } }, "test": { "type": "UnaryExpression", "start": 1016, "end": 1032, "loc": { "start": { "line": 36, "column": 12 }, "end": { "line": 36, "column": 28 } }, "operator": "!", "prefix": true, "argument": { "type": "MemberExpression", "start": 1017, "end": 1032, "loc": { "start": { "line": 36, "column": 13 }, "end": { "line": 36, "column": 28 } }, "object": { "type": "ThisExpression", "start": 1017, "end": 1021, "loc": { "start": { "line": 36, "column": 13 }, "end": { "line": 36, "column": 17 } } }, "property": { "type": "Identifier", "start": 1022, "end": 1032, "loc": { "start": { "line": 36, "column": 18 }, "end": { "line": 36, "column": 28 }, "identifierName": "hasStarted" }, "name": "hasStarted" }, "computed": false }, "extra": { "parenthesizedArgument": false } }, "consequent": { "type": "BlockStatement", "start": 1034, "end": 1091, "loc": { "start": { "line": 36, "column": 30 }, "end": { "line": 39, "column": 9 } }, "body": [ { "type": "ExpressionStatement", "start": 1048, "end": 1061, "loc": { "start": { "line": 37, "column": 12 }, "end": { "line": 37, "column": 25 } }, "expression": { "type": "CallExpression", "start": 1048, "end": 1060, "loc": { "start": { "line": 37, "column": 12 }, "end": { "line": 37, "column": 24 } }, "callee": { "type": "MemberExpression", "start": 1048, "end": 1058, "loc": { "start": { "line": 37, "column": 12 }, "end": { "line": 37, "column": 22 } }, "object": { "type": "ThisExpression", "start": 1048, "end": 1052, "loc": { "start": { "line": 37, "column": 12 }, "end": { "line": 37, "column": 16 } } }, "property": { "type": "Identifier", "start": 1053, "end": 1058, "loc": { "start": { "line": 37, "column": 17 }, "end": { "line": 37, "column": 22 }, "identifierName": "start" }, "name": "start" }, "computed": false }, "arguments": [] } }, { "type": "ReturnStatement", "start": 1074, "end": 1081, "loc": { "start": { "line": 38, "column": 12 }, "end": { "line": 38, "column": 19 } }, "argument": null } ], "directives": [] }, "alternate": null }, { "type": "ExpressionStatement", "start": 1101, "end": 1117, "loc": { "start": { "line": 41, "column": 8 }, "end": { "line": 41, "column": 24 } }, "expression": { "type": "CallExpression", "start": 1101, "end": 1116, "loc": { "start": { "line": 41, "column": 8 }, "end": { "line": 41, "column": 23 } }, "callee": { "type": "MemberExpression", "start": 1101, "end": 1114, "loc": { "start": { "line": 41, "column": 8 }, "end": { "line": 41, "column": 21 } }, "object": { "type": "ThisExpression", "start": 1101, "end": 1105, "loc": { "start": { "line": 41, "column": 8 }, "end": { "line": 41, "column": 12 } } }, "property": { "type": "Identifier", "start": 1106, "end": 1114, "loc": { "start": { "line": 41, "column": 13 }, "end": { "line": 41, "column": 21 }, "identifierName": "onUpdate" }, "name": "onUpdate" }, "computed": false }, "arguments": [] } } ], "directives": [], "trailingComments": null },