新增被动系统与协调系统 完善matcher
This commit is contained in:
15
demo/libs/framework/framework.d.ts
vendored
15
demo/libs/framework/framework.d.ts
vendored
@@ -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;
|
||||||
|
|||||||
@@ -2294,6 +2294,33 @@ var EntityProcessingSystem = (function (_super) {
|
|||||||
};
|
};
|
||||||
return EntityProcessingSystem;
|
return EntityProcessingSystem;
|
||||||
}(EntitySystem));
|
}(EntitySystem));
|
||||||
|
var PassiveSystem = (function (_super) {
|
||||||
|
__extends(PassiveSystem, _super);
|
||||||
|
function PassiveSystem() {
|
||||||
|
return _super !== null && _super.apply(this, arguments) || this;
|
||||||
|
}
|
||||||
|
PassiveSystem.prototype.onChanged = function (entity) {
|
||||||
|
};
|
||||||
|
PassiveSystem.prototype.process = function (entities) {
|
||||||
|
this.begin();
|
||||||
|
this.end();
|
||||||
|
};
|
||||||
|
return PassiveSystem;
|
||||||
|
}(EntitySystem));
|
||||||
|
var ProcessingSystem = (function (_super) {
|
||||||
|
__extends(ProcessingSystem, _super);
|
||||||
|
function ProcessingSystem() {
|
||||||
|
return _super !== null && _super.apply(this, arguments) || this;
|
||||||
|
}
|
||||||
|
ProcessingSystem.prototype.onChanged = function (entity) {
|
||||||
|
};
|
||||||
|
ProcessingSystem.prototype.process = function (entities) {
|
||||||
|
this.begin();
|
||||||
|
this.processSystem();
|
||||||
|
this.end();
|
||||||
|
};
|
||||||
|
return ProcessingSystem;
|
||||||
|
}(EntitySystem));
|
||||||
var BitSet = (function () {
|
var BitSet = (function () {
|
||||||
function BitSet(nbits) {
|
function BitSet(nbits) {
|
||||||
if (nbits === void 0) { nbits = 64; }
|
if (nbits === void 0) { nbits = 64; }
|
||||||
@@ -2765,6 +2792,15 @@ var Matcher = (function () {
|
|||||||
Matcher.empty = function () {
|
Matcher.empty = function () {
|
||||||
return new Matcher();
|
return new Matcher();
|
||||||
};
|
};
|
||||||
|
Matcher.prototype.getAllSet = function () {
|
||||||
|
return this.allSet;
|
||||||
|
};
|
||||||
|
Matcher.prototype.getExclusionSet = function () {
|
||||||
|
return this.exclusionSet;
|
||||||
|
};
|
||||||
|
Matcher.prototype.getOneSet = function () {
|
||||||
|
return this.oneSet;
|
||||||
|
};
|
||||||
Matcher.prototype.IsIntersted = function (e) {
|
Matcher.prototype.IsIntersted = function (e) {
|
||||||
if (!this.allSet.isEmpty()) {
|
if (!this.allSet.isEmpty()) {
|
||||||
for (var i = this.allSet.nextSetBit(0); i >= 0; i = this.allSet.nextSetBit(i + 1)) {
|
for (var i = this.allSet.nextSetBit(0); i >= 0; i = this.allSet.nextSetBit(i + 1)) {
|
||||||
@@ -2778,6 +2814,39 @@ var Matcher = (function () {
|
|||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
Matcher.prototype.all = function () {
|
||||||
|
var _this = this;
|
||||||
|
var types = [];
|
||||||
|
for (var _i = 0; _i < arguments.length; _i++) {
|
||||||
|
types[_i] = arguments[_i];
|
||||||
|
}
|
||||||
|
types.forEach(function (type) {
|
||||||
|
_this.allSet.set(ComponentTypeManager.getIndexFor(type));
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
Matcher.prototype.exclude = function () {
|
||||||
|
var _this = this;
|
||||||
|
var types = [];
|
||||||
|
for (var _i = 0; _i < arguments.length; _i++) {
|
||||||
|
types[_i] = arguments[_i];
|
||||||
|
}
|
||||||
|
types.forEach(function (type) {
|
||||||
|
_this.exclusionSet.set(ComponentTypeManager.getIndexFor(type));
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
Matcher.prototype.one = function () {
|
||||||
|
var _this = this;
|
||||||
|
var types = [];
|
||||||
|
for (var _i = 0; _i < arguments.length; _i++) {
|
||||||
|
types[_i] = arguments[_i];
|
||||||
|
}
|
||||||
|
types.forEach(function (type) {
|
||||||
|
_this.oneSet.set(ComponentTypeManager.getIndexFor(type));
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
};
|
||||||
return Matcher;
|
return Matcher;
|
||||||
}());
|
}());
|
||||||
var RenderableComponentList = (function () {
|
var RenderableComponentList = (function () {
|
||||||
|
|||||||
2
demo/libs/framework/framework.min.js
vendored
2
demo/libs/framework/framework.min.js
vendored
File diff suppressed because one or more lines are too long
15
source/bin/framework.d.ts
vendored
15
source/bin/framework.d.ts
vendored
@@ -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;
|
||||||
|
|||||||
@@ -2294,6 +2294,33 @@ var EntityProcessingSystem = (function (_super) {
|
|||||||
};
|
};
|
||||||
return EntityProcessingSystem;
|
return EntityProcessingSystem;
|
||||||
}(EntitySystem));
|
}(EntitySystem));
|
||||||
|
var PassiveSystem = (function (_super) {
|
||||||
|
__extends(PassiveSystem, _super);
|
||||||
|
function PassiveSystem() {
|
||||||
|
return _super !== null && _super.apply(this, arguments) || this;
|
||||||
|
}
|
||||||
|
PassiveSystem.prototype.onChanged = function (entity) {
|
||||||
|
};
|
||||||
|
PassiveSystem.prototype.process = function (entities) {
|
||||||
|
this.begin();
|
||||||
|
this.end();
|
||||||
|
};
|
||||||
|
return PassiveSystem;
|
||||||
|
}(EntitySystem));
|
||||||
|
var ProcessingSystem = (function (_super) {
|
||||||
|
__extends(ProcessingSystem, _super);
|
||||||
|
function ProcessingSystem() {
|
||||||
|
return _super !== null && _super.apply(this, arguments) || this;
|
||||||
|
}
|
||||||
|
ProcessingSystem.prototype.onChanged = function (entity) {
|
||||||
|
};
|
||||||
|
ProcessingSystem.prototype.process = function (entities) {
|
||||||
|
this.begin();
|
||||||
|
this.processSystem();
|
||||||
|
this.end();
|
||||||
|
};
|
||||||
|
return ProcessingSystem;
|
||||||
|
}(EntitySystem));
|
||||||
var BitSet = (function () {
|
var BitSet = (function () {
|
||||||
function BitSet(nbits) {
|
function BitSet(nbits) {
|
||||||
if (nbits === void 0) { nbits = 64; }
|
if (nbits === void 0) { nbits = 64; }
|
||||||
@@ -2765,6 +2792,15 @@ var Matcher = (function () {
|
|||||||
Matcher.empty = function () {
|
Matcher.empty = function () {
|
||||||
return new Matcher();
|
return new Matcher();
|
||||||
};
|
};
|
||||||
|
Matcher.prototype.getAllSet = function () {
|
||||||
|
return this.allSet;
|
||||||
|
};
|
||||||
|
Matcher.prototype.getExclusionSet = function () {
|
||||||
|
return this.exclusionSet;
|
||||||
|
};
|
||||||
|
Matcher.prototype.getOneSet = function () {
|
||||||
|
return this.oneSet;
|
||||||
|
};
|
||||||
Matcher.prototype.IsIntersted = function (e) {
|
Matcher.prototype.IsIntersted = function (e) {
|
||||||
if (!this.allSet.isEmpty()) {
|
if (!this.allSet.isEmpty()) {
|
||||||
for (var i = this.allSet.nextSetBit(0); i >= 0; i = this.allSet.nextSetBit(i + 1)) {
|
for (var i = this.allSet.nextSetBit(0); i >= 0; i = this.allSet.nextSetBit(i + 1)) {
|
||||||
@@ -2778,6 +2814,39 @@ var Matcher = (function () {
|
|||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
Matcher.prototype.all = function () {
|
||||||
|
var _this = this;
|
||||||
|
var types = [];
|
||||||
|
for (var _i = 0; _i < arguments.length; _i++) {
|
||||||
|
types[_i] = arguments[_i];
|
||||||
|
}
|
||||||
|
types.forEach(function (type) {
|
||||||
|
_this.allSet.set(ComponentTypeManager.getIndexFor(type));
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
Matcher.prototype.exclude = function () {
|
||||||
|
var _this = this;
|
||||||
|
var types = [];
|
||||||
|
for (var _i = 0; _i < arguments.length; _i++) {
|
||||||
|
types[_i] = arguments[_i];
|
||||||
|
}
|
||||||
|
types.forEach(function (type) {
|
||||||
|
_this.exclusionSet.set(ComponentTypeManager.getIndexFor(type));
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
Matcher.prototype.one = function () {
|
||||||
|
var _this = this;
|
||||||
|
var types = [];
|
||||||
|
for (var _i = 0; _i < arguments.length; _i++) {
|
||||||
|
types[_i] = arguments[_i];
|
||||||
|
}
|
||||||
|
types.forEach(function (type) {
|
||||||
|
_this.oneSet.set(ComponentTypeManager.getIndexFor(type));
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
};
|
||||||
return Matcher;
|
return Matcher;
|
||||||
}());
|
}());
|
||||||
var RenderableComponentList = (function () {
|
var RenderableComponentList = (function () {
|
||||||
|
|||||||
2
source/bin/framework.min.js
vendored
2
source/bin/framework.min.js
vendored
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
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();
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user