Merge pull request #4 from esengine/develop

新增被动系统与协调系统 完善matcher
This commit is contained in:
YHH
2020-07-01 15:16:23 +08:00
committed by GitHub
11 changed files with 22031 additions and 10120 deletions
-10
View File
@@ -1,10 +0,0 @@
---
image: restyled/restyler-prettier:v2.0.2-1
command:
- prettier
- "--write"
arguments: []
include:
- "**/*.js"
- "**/*.jsx"
interpreters: []
+15
View File
@@ -485,6 +485,15 @@ declare abstract class EntityProcessingSystem extends EntitySystem {
protected process(entities: Entity[]): void; protected process(entities: Entity[]): void;
protected lateProcess(entities: Entity[]): void; protected lateProcess(entities: Entity[]): void;
} }
declare abstract class PassiveSystem extends EntitySystem {
onChanged(entity: Entity): void;
protected process(entities: Entity[]): void;
}
declare abstract class ProcessingSystem extends EntitySystem {
onChanged(entity: Entity): void;
protected process(entities: Entity[]): void;
abstract processSystem(): any;
}
declare class BitSet { declare class BitSet {
private static LONG_MASK; private static LONG_MASK;
private _bits; private _bits;
@@ -568,7 +577,13 @@ declare class Matcher {
protected exclusionSet: BitSet; protected exclusionSet: BitSet;
protected oneSet: BitSet; protected oneSet: BitSet;
static empty(): Matcher; static empty(): Matcher;
getAllSet(): BitSet;
getExclusionSet(): BitSet;
getOneSet(): BitSet;
IsIntersted(e: Entity): boolean; IsIntersted(e: Entity): boolean;
all(...types: any[]): Matcher;
exclude(...types: any[]): this;
one(...types: any[]): this;
} }
declare class RenderableComponentList { declare class RenderableComponentList {
private _components; private _components;
File diff suppressed because it is too large Load Diff
+5250 -1
View File
File diff suppressed because one or more lines are too long
+15
View File
@@ -485,6 +485,15 @@ declare abstract class EntityProcessingSystem extends EntitySystem {
protected process(entities: Entity[]): void; protected process(entities: Entity[]): void;
protected lateProcess(entities: Entity[]): void; protected lateProcess(entities: Entity[]): void;
} }
declare abstract class PassiveSystem extends EntitySystem {
onChanged(entity: Entity): void;
protected process(entities: Entity[]): void;
}
declare abstract class ProcessingSystem extends EntitySystem {
onChanged(entity: Entity): void;
protected process(entities: Entity[]): void;
abstract processSystem(): any;
}
declare class BitSet { declare class BitSet {
private static LONG_MASK; private static LONG_MASK;
private _bits; private _bits;
@@ -568,7 +577,13 @@ declare class Matcher {
protected exclusionSet: BitSet; protected exclusionSet: BitSet;
protected oneSet: BitSet; protected oneSet: BitSet;
static empty(): Matcher; static empty(): Matcher;
getAllSet(): BitSet;
getExclusionSet(): BitSet;
getOneSet(): BitSet;
IsIntersted(e: Entity): boolean; IsIntersted(e: Entity): boolean;
all(...types: any[]): Matcher;
exclude(...types: any[]): this;
one(...types: any[]): this;
} }
declare class RenderableComponentList { declare class RenderableComponentList {
private _components; private _components;
+1604 -943
View File
File diff suppressed because it is too large Load Diff
+5250 -1
View File
File diff suppressed because one or more lines are too long
@@ -7,12 +7,21 @@ abstract class EntityProcessingSystem extends EntitySystem {
super(matcher); super(matcher);
} }
/**
*
* @param entity
*/
public abstract processEntity(entity: Entity); public abstract processEntity(entity: Entity);
public lateProcessEntity(entity: Entity) { public lateProcessEntity(entity: Entity) {
} }
/**
*
* @param entities
*/
protected process(entities: Entity[]) { protected process(entities: Entity[]) {
entities.forEach(entity => this.processEntity(entity)); entities.forEach(entity => this.processEntity(entity));
} }
+11
View File
@@ -0,0 +1,11 @@
abstract class PassiveSystem extends EntitySystem {
public onChanged(entity: Entity){
}
protected process(entities: Entity[]){
// 我们用我们自己的不考虑实体的基本实体系统来代替
this.begin();
this.end();
}
}
@@ -0,0 +1,15 @@
/** 用于协调其他系统的通用系统基类 */
abstract class ProcessingSystem extends EntitySystem {
public onChanged(entity: Entity){
}
protected process(entities: Entity[]){
this.begin();
this.processSystem();
this.end();
}
/** 处理我们的系统 每帧调用 */
public abstract processSystem();
}
+36
View File
@@ -7,6 +7,18 @@ class Matcher{
return new Matcher(); return new Matcher();
} }
public getAllSet(){
return this.allSet;
}
public getExclusionSet(){
return this.exclusionSet;
}
public getOneSet(){
return this.oneSet;
}
public IsIntersted(e: Entity){ public IsIntersted(e: Entity){
if (!this.allSet.isEmpty()){ if (!this.allSet.isEmpty()){
for (let i = this.allSet.nextSetBit(0); i >= 0; i = this.allSet.nextSetBit(i + 1)){ for (let i = this.allSet.nextSetBit(0); i >= 0; i = this.allSet.nextSetBit(i + 1)){
@@ -23,4 +35,28 @@ class Matcher{
return true; return true;
} }
public all(...types: any[]): Matcher{
types.forEach(type => {
this.allSet.set(ComponentTypeManager.getIndexFor(type));
});
return this;
}
public exclude(...types: any[]){
types.forEach(type => {
this.exclusionSet.set(ComponentTypeManager.getIndexFor(type));
});
return this;
}
public one(...types: any[]){
types.forEach(type => {
this.oneSet.set(ComponentTypeManager.getIndexFor(type));
});
return this;
}
} }