mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-12-26 22:31:14 +00:00
ecs: all includes[] must be present
This commit is contained in:
parent
c022c16dc2
commit
ba73d7bb19
@ -443,6 +443,8 @@ export class EntityScope {
|
|||||||
return `${label}_${rest}`;
|
return `${label}_${rest}`;
|
||||||
case '$': // temp byte
|
case '$': // temp byte
|
||||||
return `TEMP+${this.tempOffset}+${rest}`;
|
return `TEMP+${this.tempOffset}+${rest}`;
|
||||||
|
case '=':
|
||||||
|
// TODO?
|
||||||
case '<': // low byte
|
case '<': // low byte
|
||||||
return this.generateCodeForField(sys, action, atypes, entities, rest, 0);
|
return this.generateCodeForField(sys, action, atypes, entities, rest, 0);
|
||||||
case '>': // high byte
|
case '>': // high byte
|
||||||
@ -579,25 +581,26 @@ export class EntityManager {
|
|||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
defineComponent(ctype: ComponentType) {
|
defineComponent(ctype: ComponentType) {
|
||||||
if (this.components[ctype.name]) throw new Error(`component ${name} already defined`);
|
if (this.components[ctype.name]) throw new Error(`component ${ctype.name} already defined`);
|
||||||
return this.components[ctype.name] = ctype;
|
return this.components[ctype.name] = ctype;
|
||||||
}
|
}
|
||||||
defineSystem(system: System) {
|
defineSystem(system: System) {
|
||||||
if (this.systems[system.name]) throw new Error(`system ${name} already defined`);
|
if (this.systems[system.name]) throw new Error(`system ${system.name} already defined`);
|
||||||
this.systems[system.name] = system;
|
this.systems[system.name] = system;
|
||||||
}
|
}
|
||||||
componentsMatching(q: Query, etype: EntityArchetype) {
|
componentsMatching(q: Query, etype: EntityArchetype) {
|
||||||
let list = [];
|
let list = [];
|
||||||
for (let c of etype.components) {
|
for (let c of etype.components) {
|
||||||
let cname = c.name;
|
let cname = c.name;
|
||||||
|
if (q.exclude?.includes(cname)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
// TODO: 0 includes == all entities?
|
// TODO: 0 includes == all entities?
|
||||||
if (q.include.length == 0 || q.include.includes(cname)) {
|
if (q.include.length == 0 || q.include.includes(cname)) {
|
||||||
if (!q.exclude?.includes(cname)) {
|
list.push(c);
|
||||||
list.push(c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list.length == q.include.length ? list : [];
|
||||||
}
|
}
|
||||||
archetypesMatching(q: Query) {
|
archetypesMatching(q: Query) {
|
||||||
let result: ArchetypeMatch[] = [];
|
let result: ArchetypeMatch[] = [];
|
||||||
@ -720,7 +723,7 @@ const TEMPLATE3_D = `
|
|||||||
|
|
||||||
const TEMPLATE4_S = `
|
const TEMPLATE4_S = `
|
||||||
.macro %{@KernelSetup} ent,ofs
|
.macro %{@KernelSetup} ent,ofs
|
||||||
lda #192 ; TODO: numlines
|
lda #192 ; TODO: numlinesgit
|
||||||
sec
|
sec
|
||||||
sbc ypos_ypos_b0+ent
|
sbc ypos_ypos_b0+ent
|
||||||
sta %{$5}+ofs
|
sta %{$5}+ofs
|
||||||
@ -758,6 +761,7 @@ const TEMPLATE4_S = `
|
|||||||
// https://atariage.com/forums/topic/128147-having-trouble-with-2-free-floating-player-graphics/?tab=comments#comment-1547059
|
// https://atariage.com/forums/topic/128147-having-trouble-with-2-free-floating-player-graphics/?tab=comments#comment-1547059
|
||||||
const TEMPLATE4_K = `
|
const TEMPLATE4_K = `
|
||||||
lda %{<bgcolor}
|
lda %{<bgcolor}
|
||||||
|
sta COLUBK
|
||||||
ldy %{<lines}
|
ldy %{<lines}
|
||||||
@LVScan:
|
@LVScan:
|
||||||
lda %{$4} ; height
|
lda %{$4} ; height
|
||||||
@ -951,7 +955,7 @@ function test() {
|
|||||||
name: 'frameloop',
|
name: 'frameloop',
|
||||||
emits: ['preframe', 'kernel', 'postframe'],
|
emits: ['preframe', 'kernel', 'postframe'],
|
||||||
actions: [
|
actions: [
|
||||||
{ text: TEMPLATE1, event: 'start', select: 'once', query: { include: [] } } // TODO: []?
|
{ text: TEMPLATE1, event: 'start', select: 'once', query: { include: ['kernel'] } } // TODO: []?
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
em.defineSystem({
|
em.defineSystem({
|
||||||
@ -980,7 +984,7 @@ function test() {
|
|||||||
em.defineSystem({
|
em.defineSystem({
|
||||||
name: 'SetHorizPos',
|
name: 'SetHorizPos',
|
||||||
actions: [
|
actions: [
|
||||||
{ text: SETHORIZPOS, event: 'SetHorizPos', select: 'once', query: { include: [] } }, // TODO: []?
|
{ text: SETHORIZPOS, event: 'SetHorizPos', select: 'once', query: { include: ['xpos'] } }, // TODO: []?
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1009,6 +1013,8 @@ function test() {
|
|||||||
root.setInitValue(e_player1, c_xpos, 'xpos', 100);
|
root.setInitValue(e_player1, c_xpos, 'xpos', 100);
|
||||||
root.setInitValue(e_player1, c_ypos, 'ypos', 60);
|
root.setInitValue(e_player1, c_ypos, 'ypos', 60);
|
||||||
|
|
||||||
|
//console.log(em.archetypesMatching({ include:['xpos','ypos']})[0])
|
||||||
|
|
||||||
let src = new SourceFileExport();
|
let src = new SourceFileExport();
|
||||||
root.analyzeEntities();
|
root.analyzeEntities();
|
||||||
root.generateCode();
|
root.generateCode();
|
||||||
|
Loading…
Reference in New Issue
Block a user