Skip to content

Instantly share code, notes, and snippets.

@fernandojsg
Created May 22, 2020 11:00
Show Gist options
  • Save fernandojsg/61e5cc76849075840d98595968ca6944 to your computer and use it in GitHub Desktop.
Save fernandojsg/61e5cc76849075840d98595968ca6944 to your computer and use it in GitHub Desktop.
ECSY snippets
{
"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