修复transform.setparent报错

This commit is contained in:
yhh
2021-03-30 18:02:27 +08:00
parent 0b8d752773
commit 7e94f42b10
6 changed files with 97 additions and 25 deletions

View File

@@ -1447,6 +1447,14 @@ var es;
Scene.prototype.findEntitiesWithTag = function (tag) {
return this.entities.entitiesWithTag(tag);
};
/**
* 返回提一个具有该标记的实体
* @param tag
* @returns
*/
Scene.prototype.findEntityWithTag = function (tag) {
return this.entities.entityWithTag(tag);
};
/**
* 返回类型为T的所有实体
* @param type
@@ -1775,9 +1783,12 @@ var es;
Transform.prototype.setParent = function (parent) {
if (this._parent == parent)
return this;
if (!this._parent) {
if (this._parent != null) {
var children = new es.List(this._parent._children);
children.remove(this);
}
if (parent != null) {
var children = new es.List(parent._children);
children.add(this);
}
this._parent = parent;
@@ -4260,7 +4271,6 @@ var es;
var e_12, _a;
var list = this.getTagList(tag);
var returnList = es.ListPool.obtain();
returnList.length = this._entities.length;
try {
for (var list_1 = __values(list), list_1_1 = list_1.next(); !list_1_1.done; list_1_1 = list_1.next()) {
var entity = list_1_1.value;
@@ -4276,6 +4286,29 @@ var es;
}
return returnList;
};
/**
* 返回第一个找到该tag的实体
* @param tag
* @returns
*/
EntityList.prototype.entityWithTag = function (tag) {
var e_13, _a;
var list = this.getTagList(tag);
try {
for (var list_2 = __values(list), list_2_1 = list_2.next(); !list_2_1.done; list_2_1 = list_2.next()) {
var entity = list_2_1.value;
return entity;
}
}
catch (e_13_1) { e_13 = { error: e_13_1 }; }
finally {
try {
if (list_2_1 && !list_2_1.done && (_a = list_2.return)) _a.call(list_2);
}
finally { if (e_13) throw e_13.error; }
}
return null;
};
/**
* 返回一个T类型的所有实体的列表。
* 返回的List可以通过ListPool.free放回池中。
@@ -4345,7 +4378,7 @@ var es;
for (var _i = 0; _i < arguments.length; _i++) {
types[_i] = arguments[_i];
}
var e_13, _a, e_14, _b;
var e_14, _a, e_15, _b;
var entities = [];
for (var i = 0; i < this._entities.length; i++) {
if (this._entities[i].enabled) {
@@ -4360,12 +4393,12 @@ var es;
}
}
}
catch (e_13_1) { e_13 = { error: e_13_1 }; }
catch (e_14_1) { e_14 = { error: e_14_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; }
finally { if (e_14) throw e_14.error; }
}
if (meet) {
entities.push(this._entities[i]);
@@ -4386,12 +4419,12 @@ var es;
}
}
}
catch (e_14_1) { e_14 = { error: e_14_1 }; }
catch (e_15_1) { e_15 = { error: e_15_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; }
finally { if (e_15) throw e_15.error; }
}
if (meet) {
entities.push(entity);
@@ -7309,7 +7342,7 @@ var es;
* @param layerMask
*/
SpatialHash.prototype.overlapRectangle = function (rect, results, layerMask) {
var e_15, _a;
var e_16, _a;
this._overlapTestBox.updateBox(rect.width, rect.height);
this._overlapTestBox.position = rect.location;
var resultCounter = 0;
@@ -7340,12 +7373,12 @@ var es;
return resultCounter;
}
}
catch (e_15_1) { e_15 = { error: e_15_1 }; }
catch (e_16_1) { e_16 = { error: e_16_1 }; }
finally {
try {
if (potentials_1_1 && !potentials_1_1.done && (_a = potentials_1.return)) _a.call(potentials_1);
}
finally { if (e_15) throw e_15.error; }
finally { if (e_16) throw e_16.error; }
}
return resultCounter;
};
@@ -7357,7 +7390,7 @@ var es;
* @param layerMask
*/
SpatialHash.prototype.overlapCircle = function (circleCenter, radius, results, layerMask) {
var e_16, _a;
var e_17, _a;
var bounds = new es.Rectangle(circleCenter.x - radius, circleCenter.y - radius, radius * 2, radius * 2);
this._overlapTestCircle.radius = radius;
this._overlapTestCircle.position = circleCenter;
@@ -7390,12 +7423,12 @@ var es;
return resultCounter;
}
}
catch (e_16_1) { e_16 = { error: e_16_1 }; }
catch (e_17_1) { e_17 = { error: e_17_1 }; }
finally {
try {
if (potentials_2_1 && !potentials_2_1.done && (_a = potentials_2.return)) _a.call(potentials_2);
}
finally { if (e_16) throw e_16.error; }
finally { if (e_17) throw e_17.error; }
}
return resultCounter;
};
@@ -11542,7 +11575,7 @@ var es;
* 创建一个Set从一个Enumerable.List< T>。
*/
List.prototype.toSet = function () {
var e_17, _a;
var e_18, _a;
var result = new Set();
try {
for (var _b = __values(this._elements), _c = _b.next(); !_c.done; _c = _b.next()) {
@@ -11550,12 +11583,12 @@ var es;
result.add(x);
}
}
catch (e_17_1) { e_17 = { error: e_17_1 }; }
catch (e_18_1) { e_18 = { error: e_18_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_17) throw e_17.error; }
finally { if (e_18) throw e_18.error; }
}
return result;
};
@@ -11804,7 +11837,7 @@ var es;
* 计算可见性多边形并返回三角形扇形的顶点减去中心顶点。返回的数组来自ListPool
*/
VisibilityComputer.prototype.end = function () {
var e_18, _a;
var e_19, _a;
var output = es.ListPool.obtain();
this.updateSegments();
this._endPoints.sort(this._radialComparer.compare);
@@ -11843,12 +11876,12 @@ var es;
}
}
}
catch (e_18_1) { e_18 = { error: e_18_1 }; }
catch (e_19_1) { e_19 = { error: e_19_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_18) throw e_18.error; }
finally { if (e_19) throw e_19.error; }
}
}
VisibilityComputer._openSegments.clear();
@@ -11964,7 +11997,7 @@ var es;
* 处理片段,以便我们稍后对它们进行分类
*/
VisibilityComputer.prototype.updateSegments = function () {
var e_19, _a;
var e_20, _a;
try {
for (var _b = __values(this._segments), _c = _b.next(); !_c.done; _c = _b.next()) {
var segment = _c.value;
@@ -11982,12 +12015,12 @@ var es;
segment.p2.begin = !segment.p1.begin;
}
}
catch (e_19_1) { e_19 = { error: e_19_1 }; }
catch (e_20_1) { e_20 = { error: e_20_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_19) throw e_19.error; }
finally { if (e_20) throw e_20.error; }
}
// 如果我们有一个聚光灯,我们需要存储前两个段的角度。
// 这些是光斑的边界,我们将用它们来过滤它们之外的任何顶点。