Created
May 22, 2020 11:00
-
-
Save fernandojsg/61e5cc76849075840d98595968ca6944 to your computer and use it in GitHub Desktop.
ECSY snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"ECSY System": { | |
"scope": "javascript", | |
"prefix": "sys", | |
"body": [ | |
"export class ${1:SystemName} extends System {", | |
" execute(delta, time) {", | |
" const ${2:entities} = this.queries.${2:entities}.results;", | |
"", | |
" for (let i = 0; i < ${2:entities}.length; i++) {" | |
" const entity = ${2:entities}[i];", | |
" const component = entity.getComponent(${3:Component});", | |
" }", | |
" }", | |
"}", | |
"", | |
"${1:SystemName}.queries = {", | |
" ${2:entities}: {" | |
" components: [${3:Component}],", | |
" listen: {", | |
" added: true," | |
" removed: true," | |
" changed: true // [${3:Component}]" | |
" }", | |
" }", | |
"}" | |
], | |
"description": "Create an ECSY system" | |
}, | |
"ECSY TagComponent": { | |
"scope": "javascript", | |
"prefix": "tag", | |
"body": [ | |
"export class ${1:ComponentName} extends TagComponent {}" | |
], | |
"description": "Create an ECSY TagComponent" | |
}, | |
"ECSY Component": { | |
"scope": "javascript", | |
"prefix": "comp", | |
"body": [ | |
"export class ${1:ComponentName} {", | |
" constructor() {", | |
" this.${2:attribute} = ${3:'value'};", | |
" }", | |
"", | |
" reset() {", | |
" this.${2:attribute} = ${3:'value'};", | |
" }", | |
"}" | |
], | |
"description": "Create an ECSY TagComponent" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment