新增被动系统与协调系统 完善matcher

This commit is contained in:
yhh
2020-07-01 14:54:35 +08:00
parent 549db2fcfe
commit 5e871bc501
10 changed files with 241 additions and 2 deletions

View File

@@ -485,6 +485,15 @@ declare abstract class EntityProcessingSystem extends EntitySystem {
protected process(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 {
private static LONG_MASK;
private _bits;
@@ -568,7 +577,13 @@ declare class Matcher {
protected exclusionSet: BitSet;
protected oneSet: BitSet;
static empty(): Matcher;
getAllSet(): BitSet;
getExclusionSet(): BitSet;
getOneSet(): BitSet;
IsIntersted(e: Entity): boolean;
all(...types: any[]): Matcher;
exclude(...types: any[]): this;
one(...types: any[]): this;
}
declare class RenderableComponentList {
private _components;

View File

@@ -2294,6 +2294,33 @@ var EntityProcessingSystem = (function (_super) {
};
return EntityProcessingSystem;
}(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 () {
function BitSet(nbits) {
if (nbits === void 0) { nbits = 64; }
@@ -2765,6 +2792,15 @@ var Matcher = (function () {
Matcher.empty = function () {
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) {
if (!this.allSet.isEmpty()) {
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 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;
}());
var RenderableComponentList = (function () {

File diff suppressed because one or more lines are too long