新增被动系统与协调系统 完善matcher
This commit is contained in:
@@ -7,12 +7,21 @@ abstract class EntityProcessingSystem extends EntitySystem {
|
||||
super(matcher);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理特定的实体
|
||||
* @param entity
|
||||
*/
|
||||
public abstract processEntity(entity: Entity);
|
||||
|
||||
public lateProcessEntity(entity: Entity) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 遍历这个系统的所有实体并逐个处理它们
|
||||
* @param entities
|
||||
*/
|
||||
protected process(entities: Entity[]) {
|
||||
entities.forEach(entity => this.processEntity(entity));
|
||||
}
|
||||
|
||||
11
source/src/ECS/Systems/PassiveSystem.ts
Normal file
11
source/src/ECS/Systems/PassiveSystem.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
abstract class PassiveSystem extends EntitySystem {
|
||||
public onChanged(entity: Entity){
|
||||
|
||||
}
|
||||
|
||||
protected process(entities: Entity[]){
|
||||
// 我们用我们自己的不考虑实体的基本实体系统来代替
|
||||
this.begin();
|
||||
this.end();
|
||||
}
|
||||
}
|
||||
15
source/src/ECS/Systems/ProcessingSystem.ts
Normal file
15
source/src/ECS/Systems/ProcessingSystem.ts
Normal file
@@ -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();
|
||||
}
|
||||
@@ -7,6 +7,18 @@ class Matcher{
|
||||
return new Matcher();
|
||||
}
|
||||
|
||||
public getAllSet(){
|
||||
return this.allSet;
|
||||
}
|
||||
|
||||
public getExclusionSet(){
|
||||
return this.exclusionSet;
|
||||
}
|
||||
|
||||
public getOneSet(){
|
||||
return this.oneSet;
|
||||
}
|
||||
|
||||
public IsIntersted(e: Entity){
|
||||
if (!this.allSet.isEmpty()){
|
||||
for (let i = this.allSet.nextSetBit(0); i >= 0; i = this.allSet.nextSetBit(i + 1)){
|
||||
@@ -23,4 +35,28 @@ class Matcher{
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user