场景搜索包含特定组件的实体列表
This commit is contained in:
Vendored
+12
@@ -655,6 +655,12 @@ declare module es {
|
|||||||
* @param type
|
* @param type
|
||||||
*/
|
*/
|
||||||
findComponentsOfType<T extends Component>(type: any): T[];
|
findComponentsOfType<T extends Component>(type: any): T[];
|
||||||
|
/**
|
||||||
|
* 返回场景中包含特定组件的实体列表
|
||||||
|
* @param type
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
findEntitiesOfComponent(...types: any[]): Entity[];
|
||||||
/**
|
/**
|
||||||
* 在场景中添加一个EntitySystem处理器
|
* 在场景中添加一个EntitySystem处理器
|
||||||
* @param processor 处理器
|
* @param processor 处理器
|
||||||
@@ -1782,6 +1788,12 @@ declare module es {
|
|||||||
* @param type
|
* @param type
|
||||||
*/
|
*/
|
||||||
findComponentsOfType<T extends Component>(type: any): T[];
|
findComponentsOfType<T extends Component>(type: any): T[];
|
||||||
|
/**
|
||||||
|
* 返回场景中包含特定组件的实体列表
|
||||||
|
* @param types
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
findEntitesOfComponent(...types: any[]): Entity[];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
declare module es {
|
declare module es {
|
||||||
|
|||||||
+113
-35
@@ -34,26 +34,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|||||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
var __extends = (this && this.__extends) || (function () {
|
|
||||||
var extendStatics = Object.setPrototypeOf ||
|
|
||||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
||||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
||||||
return function (d, b) {
|
|
||||||
extendStatics(d, b);
|
|
||||||
function __() { this.constructor = d; }
|
|
||||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
var __values = (this && this.__values) || function (o) {
|
|
||||||
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
|
||||||
if (m) return m.call(o);
|
|
||||||
return {
|
|
||||||
next: function () {
|
|
||||||
if (o && i >= o.length) o = void 0;
|
|
||||||
return { value: o && o[i++], done: !o };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
var __read = (this && this.__read) || function (o, n) {
|
var __read = (this && this.__read) || function (o, n) {
|
||||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||||
if (!m) return o;
|
if (!m) return o;
|
||||||
@@ -74,6 +54,26 @@ var __spread = (this && this.__spread) || function () {
|
|||||||
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
||||||
return ar;
|
return ar;
|
||||||
};
|
};
|
||||||
|
var __extends = (this && this.__extends) || (function () {
|
||||||
|
var extendStatics = Object.setPrototypeOf ||
|
||||||
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||||
|
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||||
|
return function (d, b) {
|
||||||
|
extendStatics(d, b);
|
||||||
|
function __() { this.constructor = d; }
|
||||||
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
var __values = (this && this.__values) || function (o) {
|
||||||
|
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
||||||
|
if (m) return m.call(o);
|
||||||
|
return {
|
||||||
|
next: function () {
|
||||||
|
if (o && i >= o.length) o = void 0;
|
||||||
|
return { value: o && o[i++], done: !o };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
var es;
|
var es;
|
||||||
(function (es) {
|
(function (es) {
|
||||||
/**
|
/**
|
||||||
@@ -1468,6 +1468,19 @@ var es;
|
|||||||
Scene.prototype.findComponentsOfType = function (type) {
|
Scene.prototype.findComponentsOfType = function (type) {
|
||||||
return this.entities.findComponentsOfType(type);
|
return this.entities.findComponentsOfType(type);
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* 返回场景中包含特定组件的实体列表
|
||||||
|
* @param type
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
Scene.prototype.findEntitiesOfComponent = function () {
|
||||||
|
var types = [];
|
||||||
|
for (var _i = 0; _i < arguments.length; _i++) {
|
||||||
|
types[_i] = arguments[_i];
|
||||||
|
}
|
||||||
|
var _a;
|
||||||
|
return (_a = this.entities).findEntitesOfComponent.apply(_a, __spread(types));
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* 在场景中添加一个EntitySystem处理器
|
* 在场景中添加一个EntitySystem处理器
|
||||||
* @param processor 处理器
|
* @param processor 处理器
|
||||||
@@ -4322,6 +4335,71 @@ var es;
|
|||||||
}
|
}
|
||||||
return comps;
|
return comps;
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* 返回场景中包含特定组件的实体列表
|
||||||
|
* @param types
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
EntityList.prototype.findEntitesOfComponent = function () {
|
||||||
|
var types = [];
|
||||||
|
for (var _i = 0; _i < arguments.length; _i++) {
|
||||||
|
types[_i] = arguments[_i];
|
||||||
|
}
|
||||||
|
var e_13, _a, e_14, _b;
|
||||||
|
var entities = [];
|
||||||
|
for (var i = 0; i < this._entities.length; i++) {
|
||||||
|
if (this._entities[i].enabled) {
|
||||||
|
var meet = true;
|
||||||
|
try {
|
||||||
|
for (var types_1 = __values(types), types_1_1 = types_1.next(); !types_1_1.done; types_1_1 = types_1.next()) {
|
||||||
|
var type = types_1_1.value;
|
||||||
|
var hasComp = this._entities[i].hasComponent(type);
|
||||||
|
if (!hasComp) {
|
||||||
|
meet = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
||||||
|
finally {
|
||||||
|
try {
|
||||||
|
if (types_1_1 && !types_1_1.done && (_a = types_1.return)) _a.call(types_1);
|
||||||
|
}
|
||||||
|
finally { if (e_13) throw e_13.error; }
|
||||||
|
}
|
||||||
|
if (meet) {
|
||||||
|
entities.push(this._entities[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (var i = 0; i < this._entitiesToAdded.getCount(); i++) {
|
||||||
|
var entity = this._entitiesToAdded.toArray()[i];
|
||||||
|
if (entity.enabled) {
|
||||||
|
var meet = true;
|
||||||
|
try {
|
||||||
|
for (var types_2 = __values(types), types_2_1 = types_2.next(); !types_2_1.done; types_2_1 = types_2.next()) {
|
||||||
|
var type = types_2_1.value;
|
||||||
|
var hasComp = entity.hasComponent(type);
|
||||||
|
if (!hasComp) {
|
||||||
|
meet = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
||||||
|
finally {
|
||||||
|
try {
|
||||||
|
if (types_2_1 && !types_2_1.done && (_b = types_2.return)) _b.call(types_2);
|
||||||
|
}
|
||||||
|
finally { if (e_14) throw e_14.error; }
|
||||||
|
}
|
||||||
|
if (meet) {
|
||||||
|
entities.push(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return entities;
|
||||||
|
};
|
||||||
return EntityList;
|
return EntityList;
|
||||||
}());
|
}());
|
||||||
es.EntityList = EntityList;
|
es.EntityList = EntityList;
|
||||||
@@ -7231,7 +7309,7 @@ var es;
|
|||||||
* @param layerMask
|
* @param layerMask
|
||||||
*/
|
*/
|
||||||
SpatialHash.prototype.overlapRectangle = function (rect, results, layerMask) {
|
SpatialHash.prototype.overlapRectangle = function (rect, results, layerMask) {
|
||||||
var e_13, _a;
|
var e_15, _a;
|
||||||
this._overlapTestBox.updateBox(rect.width, rect.height);
|
this._overlapTestBox.updateBox(rect.width, rect.height);
|
||||||
this._overlapTestBox.position = rect.location;
|
this._overlapTestBox.position = rect.location;
|
||||||
var resultCounter = 0;
|
var resultCounter = 0;
|
||||||
@@ -7262,12 +7340,12 @@ var es;
|
|||||||
return resultCounter;
|
return resultCounter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
||||||
finally {
|
finally {
|
||||||
try {
|
try {
|
||||||
if (potentials_1_1 && !potentials_1_1.done && (_a = potentials_1.return)) _a.call(potentials_1);
|
if (potentials_1_1 && !potentials_1_1.done && (_a = potentials_1.return)) _a.call(potentials_1);
|
||||||
}
|
}
|
||||||
finally { if (e_13) throw e_13.error; }
|
finally { if (e_15) throw e_15.error; }
|
||||||
}
|
}
|
||||||
return resultCounter;
|
return resultCounter;
|
||||||
};
|
};
|
||||||
@@ -7279,7 +7357,7 @@ var es;
|
|||||||
* @param layerMask
|
* @param layerMask
|
||||||
*/
|
*/
|
||||||
SpatialHash.prototype.overlapCircle = function (circleCenter, radius, results, layerMask) {
|
SpatialHash.prototype.overlapCircle = function (circleCenter, radius, results, layerMask) {
|
||||||
var e_14, _a;
|
var e_16, _a;
|
||||||
var bounds = new es.Rectangle(circleCenter.x - radius, circleCenter.y - radius, radius * 2, radius * 2);
|
var bounds = new es.Rectangle(circleCenter.x - radius, circleCenter.y - radius, radius * 2, radius * 2);
|
||||||
this._overlapTestCircle.radius = radius;
|
this._overlapTestCircle.radius = radius;
|
||||||
this._overlapTestCircle.position = circleCenter;
|
this._overlapTestCircle.position = circleCenter;
|
||||||
@@ -7312,12 +7390,12 @@ var es;
|
|||||||
return resultCounter;
|
return resultCounter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
||||||
finally {
|
finally {
|
||||||
try {
|
try {
|
||||||
if (potentials_2_1 && !potentials_2_1.done && (_a = potentials_2.return)) _a.call(potentials_2);
|
if (potentials_2_1 && !potentials_2_1.done && (_a = potentials_2.return)) _a.call(potentials_2);
|
||||||
}
|
}
|
||||||
finally { if (e_14) throw e_14.error; }
|
finally { if (e_16) throw e_16.error; }
|
||||||
}
|
}
|
||||||
return resultCounter;
|
return resultCounter;
|
||||||
};
|
};
|
||||||
@@ -11477,7 +11555,7 @@ var linq;
|
|||||||
* 创建一个Set从一个Enumerable.List< T>。
|
* 创建一个Set从一个Enumerable.List< T>。
|
||||||
*/
|
*/
|
||||||
List.prototype.toSet = function () {
|
List.prototype.toSet = function () {
|
||||||
var e_15, _a;
|
var e_17, _a;
|
||||||
var result = new Set();
|
var result = new Set();
|
||||||
try {
|
try {
|
||||||
for (var _b = __values(this._elements), _c = _b.next(); !_c.done; _c = _b.next()) {
|
for (var _b = __values(this._elements), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||||
@@ -11485,12 +11563,12 @@ var linq;
|
|||||||
result.add(x);
|
result.add(x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
||||||
finally {
|
finally {
|
||||||
try {
|
try {
|
||||||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||||
}
|
}
|
||||||
finally { if (e_15) throw e_15.error; }
|
finally { if (e_17) throw e_17.error; }
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
@@ -11739,7 +11817,7 @@ var es;
|
|||||||
* 计算可见性多边形,并返回三角形扇形的顶点(减去中心顶点)。返回的数组来自ListPool
|
* 计算可见性多边形,并返回三角形扇形的顶点(减去中心顶点)。返回的数组来自ListPool
|
||||||
*/
|
*/
|
||||||
VisibilityComputer.prototype.end = function () {
|
VisibilityComputer.prototype.end = function () {
|
||||||
var e_16, _a;
|
var e_18, _a;
|
||||||
var output = es.ListPool.obtain();
|
var output = es.ListPool.obtain();
|
||||||
this.updateSegments();
|
this.updateSegments();
|
||||||
this._endPoints.sort(this._radialComparer.compare);
|
this._endPoints.sort(this._radialComparer.compare);
|
||||||
@@ -11778,12 +11856,12 @@ var es;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
catch (e_18_1) { e_18 = { error: e_18_1 }; }
|
||||||
finally {
|
finally {
|
||||||
try {
|
try {
|
||||||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||||
}
|
}
|
||||||
finally { if (e_16) throw e_16.error; }
|
finally { if (e_18) throw e_18.error; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VisibilityComputer._openSegments.clear();
|
VisibilityComputer._openSegments.clear();
|
||||||
@@ -11899,7 +11977,7 @@ var es;
|
|||||||
* 处理片段,以便我们稍后对它们进行分类
|
* 处理片段,以便我们稍后对它们进行分类
|
||||||
*/
|
*/
|
||||||
VisibilityComputer.prototype.updateSegments = function () {
|
VisibilityComputer.prototype.updateSegments = function () {
|
||||||
var e_17, _a;
|
var e_19, _a;
|
||||||
try {
|
try {
|
||||||
for (var _b = __values(this._segments), _c = _b.next(); !_c.done; _c = _b.next()) {
|
for (var _b = __values(this._segments), _c = _b.next(); !_c.done; _c = _b.next()) {
|
||||||
var segment = _c.value;
|
var segment = _c.value;
|
||||||
@@ -11917,12 +11995,12 @@ var es;
|
|||||||
segment.p2.begin = !segment.p1.begin;
|
segment.p2.begin = !segment.p1.begin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
catch (e_19_1) { e_19 = { error: e_19_1 }; }
|
||||||
finally {
|
finally {
|
||||||
try {
|
try {
|
||||||
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
||||||
}
|
}
|
||||||
finally { if (e_17) throw e_17.error; }
|
finally { if (e_19) throw e_19.error; }
|
||||||
}
|
}
|
||||||
// 如果我们有一个聚光灯,我们需要存储前两个段的角度。
|
// 如果我们有一个聚光灯,我们需要存储前两个段的角度。
|
||||||
// 这些是光斑的边界,我们将用它们来过滤它们之外的任何顶点。
|
// 这些是光斑的边界,我们将用它们来过滤它们之外的任何顶点。
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -224,6 +224,15 @@ module es {
|
|||||||
return this.entities.findComponentsOfType<T>(type);
|
return this.entities.findComponentsOfType<T>(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回场景中包含特定组件的实体列表
|
||||||
|
* @param type
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
public findEntitiesOfComponent(...types): Entity[] {
|
||||||
|
return this.entities.findEntitesOfComponent(...types);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在场景中添加一个EntitySystem处理器
|
* 在场景中添加一个EntitySystem处理器
|
||||||
* @param processor 处理器
|
* @param processor 处理器
|
||||||
|
|||||||
@@ -269,5 +269,50 @@ module es {
|
|||||||
|
|
||||||
return comps;
|
return comps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回场景中包含特定组件的实体列表
|
||||||
|
* @param types
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
public findEntitesOfComponent(...types): Entity[] {
|
||||||
|
let entities = [];
|
||||||
|
for (let i = 0; i < this._entities.length; i++) {
|
||||||
|
if (this._entities[i].enabled) {
|
||||||
|
let meet = true;
|
||||||
|
for (let type of types) {
|
||||||
|
let hasComp = this._entities[i].hasComponent(type);
|
||||||
|
if (!hasComp) {
|
||||||
|
meet = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (meet) {
|
||||||
|
entities.push(this._entities[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < this._entitiesToAdded.getCount(); i++) {
|
||||||
|
let entity: Entity = this._entitiesToAdded.toArray()[i];
|
||||||
|
if (entity.enabled) {
|
||||||
|
let meet = true;
|
||||||
|
for (let type of types) {
|
||||||
|
let hasComp = entity.hasComponent(type);
|
||||||
|
if (!hasComp) {
|
||||||
|
meet = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (meet) {
|
||||||
|
entities.push(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return entities;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user