更改命名空间linq为es

This commit is contained in:
yhh
2021-03-29 15:28:18 +08:00
parent 8b5bc444f1
commit 6b2c18ad75
21 changed files with 80 additions and 127 deletions

View File

@@ -3391,16 +3391,6 @@ declare module es {
right = 3 right = 3
} }
} }
declare module es {
class Enumerable {
/**
* 生成包含一个重复值的序列
* @param element 要重复的值
* @param count 在生成的序列中重复该值的次数
*/
static repeat<T>(element: T, count: number): any[];
}
}
declare module es { declare module es {
class EqualityComparer<T> implements IEqualityComparer<T> { class EqualityComparer<T> implements IEqualityComparer<T> {
static default<T>(): EqualityComparer<T>; static default<T>(): EqualityComparer<T>;
@@ -4373,7 +4363,7 @@ declare module es {
static round(vec: Vector2): Vector2; static round(vec: Vector2): Vector2;
} }
} }
declare module linq { declare module es {
class Enumerable { class Enumerable {
/** /**
* 在指定范围内生成一个整数序列。 * 在指定范围内生成一个整数序列。
@@ -4385,7 +4375,7 @@ declare module linq {
static repeat<T>(element: T, count: number): List<T>; static repeat<T>(element: T, count: number): List<T>;
} }
} }
declare module linq { declare module es {
/** /**
* 检查传递的参数是否为对象 * 检查传递的参数是否为对象
*/ */
@@ -4400,7 +4390,7 @@ declare module linq {
const composeComparers: <T>(previousComparer: (a: T, b: T) => number, currentComparer: (a: T, b: T) => number) => (a: T, b: T) => number; const composeComparers: <T>(previousComparer: (a: T, b: T) => number, currentComparer: (a: T, b: T) => number) => (a: T, b: T) => number;
const keyComparer: <T>(_keySelector: (key: T) => string, descending?: boolean) => (a: T, b: T) => number; const keyComparer: <T>(_keySelector: (key: T) => string, descending?: boolean) => (a: T, b: T) => number;
} }
declare module linq { declare module es {
type PredicateType<T> = (value?: T, index?: number, list?: T[]) => boolean; type PredicateType<T> = (value?: T, index?: number, list?: T[]) => boolean;
class List<T> { class List<T> {
protected _elements: T[]; protected _elements: T[];

View File

@@ -162,7 +162,7 @@ var es;
* @param manager * @param manager
*/ */
Core.unregisterGlobalManager = function (manager) { Core.unregisterGlobalManager = function (manager) {
new linq.List(this._instance._globalManagers).remove(manager); new es.List(this._instance._globalManagers).remove(manager);
manager.enabled = false; manager.enabled = false;
}; };
/** /**
@@ -1400,7 +1400,7 @@ var es;
* @param component * @param component
*/ */
Scene.prototype.removeSceneComponent = function (component) { Scene.prototype.removeSceneComponent = function (component) {
var sceneComponentList = new linq.List(this._sceneComponents); var sceneComponentList = new es.List(this._sceneComponents);
es.Insist.isTrue(sceneComponentList.contains(component), "SceneComponent" + component + "\u4E0D\u5728SceneComponents\u5217\u8868\u4E2D!"); es.Insist.isTrue(sceneComponentList.contains(component), "SceneComponent" + component + "\u4E0D\u5728SceneComponents\u5217\u8868\u4E2D!");
sceneComponentList.remove(component); sceneComponentList.remove(component);
component.onRemovedFromScene(); component.onRemovedFromScene();
@@ -1418,7 +1418,7 @@ var es;
* @param entity * @param entity
*/ */
Scene.prototype.addEntity = function (entity) { Scene.prototype.addEntity = function (entity) {
es.Insist.isFalse(new linq.List(this.entities.buffer).contains(entity), "\u60A8\u8BD5\u56FE\u5C06\u540C\u4E00\u5B9E\u4F53\u6DFB\u52A0\u5230\u573A\u666F\u4E24\u6B21: " + entity); es.Insist.isFalse(new es.List(this.entities.buffer).contains(entity), "\u60A8\u8BD5\u56FE\u5C06\u540C\u4E00\u5B9E\u4F53\u6DFB\u52A0\u5230\u573A\u666F\u4E24\u6B21: " + entity);
this.entities.add(entity); this.entities.add(entity);
entity.scene = this; entity.scene = this;
for (var i = 0; i < entity.transform.childCount; i++) for (var i = 0; i < entity.transform.childCount; i++)
@@ -1776,7 +1776,7 @@ var es;
if (this._parent == parent) if (this._parent == parent)
return this; return this;
if (!this._parent) { if (!this._parent) {
var children = new linq.List(this._parent._children); var children = new es.List(this._parent._children);
children.remove(this); children.remove(this);
children.add(this); children.add(this);
} }
@@ -2872,7 +2872,7 @@ var es;
var _this = _super.call(this) || this; var _this = _super.call(this) || this;
// 第一点和最后一点决不能相同。我们想要一个开放的多边形 // 第一点和最后一点决不能相同。我们想要一个开放的多边形
var isPolygonClosed = points[0] == points[points.length - 1]; var isPolygonClosed = points[0] == points[points.length - 1];
var linqPoints = new linq.List(points); var linqPoints = new es.List(points);
// 最后一个移除 // 最后一个移除
if (isPolygonClosed) if (isPolygonClosed)
linqPoints.remove(linqPoints.last()); linqPoints.remove(linqPoints.last());
@@ -2920,7 +2920,7 @@ var es;
EntitySystem.prototype.initialize = function () { EntitySystem.prototype.initialize = function () {
}; };
EntitySystem.prototype.onChanged = function (entity) { EntitySystem.prototype.onChanged = function (entity) {
var contains = new linq.List(this._entities).contains(entity); var contains = new es.List(this._entities).contains(entity);
var interest = this._matcher.isInterestedEntity(entity); var interest = this._matcher.isInterestedEntity(entity);
if (interest && !contains) if (interest && !contains)
this.add(entity); this.add(entity);
@@ -2933,7 +2933,7 @@ var es;
}; };
EntitySystem.prototype.onAdded = function (entity) { }; EntitySystem.prototype.onAdded = function (entity) { };
EntitySystem.prototype.remove = function (entity) { EntitySystem.prototype.remove = function (entity) {
new linq.List(this._entities).remove(entity); new es.List(this._entities).remove(entity);
this.onRemoved(entity); this.onRemoved(entity);
}; };
EntitySystem.prototype.onRemoved = function (entity) { }; EntitySystem.prototype.onRemoved = function (entity) { };
@@ -3827,8 +3827,8 @@ var es;
this._componentsToAdd.push(component); this._componentsToAdd.push(component);
}; };
ComponentList.prototype.remove = function (component) { ComponentList.prototype.remove = function (component) {
var componentToRemove = new linq.List(this._componentsToRemove); var componentToRemove = new es.List(this._componentsToRemove);
var componentToAdd = new linq.List(this._componentsToAdd); var componentToAdd = new es.List(this._componentsToAdd);
es.Debug.warnIf(componentToRemove.contains(component), "\u60A8\u6B63\u5728\u5C1D\u8BD5\u5220\u9664\u4E00\u4E2A\u60A8\u5DF2\u7ECF\u5220\u9664\u7684\u7EC4\u4EF6(" + component + ")"); es.Debug.warnIf(componentToRemove.contains(component), "\u60A8\u6B63\u5728\u5C1D\u8BD5\u5220\u9664\u4E00\u4E2A\u60A8\u5DF2\u7ECF\u5220\u9664\u7684\u7EC4\u4EF6(" + component + ")");
// 这可能不是一个活动的组件,所以我们必须注意它是否还没有被处理,它可能正在同一帧中被删除 // 这可能不是一个活动的组件,所以我们必须注意它是否还没有被处理,它可能正在同一帧中被删除
if (componentToAdd.contains(component)) { if (componentToAdd.contains(component)) {
@@ -3858,7 +3858,7 @@ var es;
continue; continue;
// 处理IUpdatable // 处理IUpdatable
if (es.isIUpdatable(component)) if (es.isIUpdatable(component))
new linq.List(this._updatableComponents).remove(component); new es.List(this._updatableComponents).remove(component);
this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(es.TypeUtils.getType(component)), false); this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(es.TypeUtils.getType(component)), false);
this._entity.scene.entityProcessors.onComponentRemoved(this._entity); this._entity.scene.entityProcessors.onComponentRemoved(this._entity);
} }
@@ -3897,7 +3897,7 @@ var es;
if (this._componentsToRemove.length > 0) { if (this._componentsToRemove.length > 0) {
for (var i = 0; i < this._componentsToRemove.length; i++) { for (var i = 0; i < this._componentsToRemove.length; i++) {
this.handleRemove(this._componentsToRemove[i]); this.handleRemove(this._componentsToRemove[i]);
new linq.List(this._components).remove(this._componentsToRemove[i]); new es.List(this._components).remove(this._componentsToRemove[i]);
} }
this._componentsToRemove.length = 0; this._componentsToRemove.length = 0;
} }
@@ -3932,7 +3932,7 @@ var es;
}; };
ComponentList.prototype.handleRemove = function (component) { ComponentList.prototype.handleRemove = function (component) {
if (es.isIUpdatable(component)) if (es.isIUpdatable(component))
new linq.List(this._updatableComponents).remove(component); new es.List(this._updatableComponents).remove(component);
this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(es.TypeUtils.getType(component)), false); this._entity.componentBits.set(es.ComponentTypeManager.getIndexFor(es.TypeUtils.getType(component)), false);
this._entity.scene.entityProcessors.onComponentRemoved(this._entity); this._entity.scene.entityProcessors.onComponentRemoved(this._entity);
component.onRemovedFromEntity(); component.onRemovedFromEntity();
@@ -4167,7 +4167,7 @@ var es;
* @param entity * @param entity
*/ */
EntityList.prototype.contains = function (entity) { EntityList.prototype.contains = function (entity) {
return new linq.List(this._entities).contains(entity) || this._entitiesToAdded.contains(entity); return new es.List(this._entities).contains(entity) || this._entitiesToAdded.contains(entity);
}; };
EntityList.prototype.getTagList = function (tag) { EntityList.prototype.getTagList = function (tag) {
var list = this._entityDict.get(tag); var list = this._entityDict.get(tag);
@@ -4210,7 +4210,7 @@ var es;
// 处理标签列表 // 处理标签列表
_this.removeFromTagList(entity); _this.removeFromTagList(entity);
// 处理常规实体列表 // 处理常规实体列表
new linq.List(_this._entities).remove(entity); new es.List(_this._entities).remove(entity);
entity.onRemovedFromScene(); entity.onRemovedFromScene();
entity.scene = null; entity.scene = null;
_this.scene.entityProcessors.onEntityRemoved(entity); _this.scene.entityProcessors.onEntityRemoved(entity);
@@ -4414,7 +4414,7 @@ var es;
this._processors.push(processor); this._processors.push(processor);
}; };
EntityProcessorList.prototype.remove = function (processor) { EntityProcessorList.prototype.remove = function (processor) {
new linq.List(this._processors).remove(processor); new es.List(this._processors).remove(processor);
}; };
EntityProcessorList.prototype.onComponentAdded = function (entity) { EntityProcessorList.prototype.onComponentAdded = function (entity) {
this.notifyEntityChanged(entity); this.notifyEntityChanged(entity);
@@ -7198,7 +7198,7 @@ var es;
var cell = this.cellAtPosition(x, y); var cell = this.cellAtPosition(x, y);
es.Insist.isNotNull(cell, "\u4ECE\u4E0D\u5B58\u5728\u78B0\u649E\u5668\u7684\u5355\u5143\u683C\u4E2D\u79FB\u9664\u78B0\u649E\u5668: [" + collider + "]"); es.Insist.isNotNull(cell, "\u4ECE\u4E0D\u5B58\u5728\u78B0\u649E\u5668\u7684\u5355\u5143\u683C\u4E2D\u79FB\u9664\u78B0\u649E\u5668: [" + collider + "]");
if (cell != null) if (cell != null)
new linq.List(cell).remove(collider); new es.List(cell).remove(collider);
} }
} }
}; };
@@ -7445,7 +7445,7 @@ var es;
*/ */
NumberDictionary.prototype.remove = function (obj) { NumberDictionary.prototype.remove = function (obj) {
this._store.forEach(function (list) { this._store.forEach(function (list) {
var linqList = new linq.List(list); var linqList = new es.List(list);
if (linqList.contains(obj)) if (linqList.contains(obj))
linqList.remove(obj); linqList.remove(obj);
}); });
@@ -7488,7 +7488,7 @@ var es;
for (var i = 0; i < cell.length; i++) { for (var i = 0; i < cell.length; i++) {
var potential = cell[i]; var potential = cell[i];
// 管理我们已经处理过的碰撞器 // 管理我们已经处理过的碰撞器
if (new linq.List(this._checkedColliders).contains(potential)) if (new es.List(this._checkedColliders).contains(potential))
continue; continue;
this._checkedColliders.push(potential); this._checkedColliders.push(potential);
// 只有当我们被设置为这样做时才会点击触发器 // 只有当我们被设置为这样做时才会点击触发器
@@ -8512,7 +8512,7 @@ var es;
var messageData = this._messageTable.get(eventType); var messageData = this._messageTable.get(eventType);
var index = messageData.findIndex(function (data) { return data.func == handler; }); var index = messageData.findIndex(function (data) { return data.func == handler; });
if (index != -1) if (index != -1)
new linq.List(messageData).removeAt(index); new es.List(messageData).removeAt(index);
}; };
/** /**
* 触发该事件 * 触发该事件
@@ -8546,27 +8546,6 @@ var es;
})(Edge = es.Edge || (es.Edge = {})); })(Edge = es.Edge || (es.Edge = {}));
})(es || (es = {})); })(es || (es = {}));
var es; var es;
(function (es) {
var Enumerable = /** @class */ (function () {
function Enumerable() {
}
/**
* 生成包含一个重复值的序列
* @param element 要重复的值
* @param count 在生成的序列中重复该值的次数
*/
Enumerable.repeat = function (element, count) {
var result = [];
while (count--) {
result.push(element);
}
return result;
};
return Enumerable;
}());
es.Enumerable = Enumerable;
})(es || (es = {}));
var es;
(function (es) { (function (es) {
var EqualityComparer = /** @class */ (function () { var EqualityComparer = /** @class */ (function () {
function EqualityComparer() { function EqualityComparer() {
@@ -9949,7 +9928,7 @@ var es;
if (this.tickCoroutine(coroutine)) if (this.tickCoroutine(coroutine))
this._shouldRunNextFrame.push(coroutine); this._shouldRunNextFrame.push(coroutine);
} }
var linqCoroutines = new linq.List(this._unblockedCoroutines); var linqCoroutines = new es.List(this._unblockedCoroutines);
linqCoroutines.clear(); linqCoroutines.clear();
linqCoroutines.addRange(this._shouldRunNextFrame); linqCoroutines.addRange(this._shouldRunNextFrame);
this._shouldRunNextFrame.length = 0; this._shouldRunNextFrame.length = 0;
@@ -10031,7 +10010,7 @@ var es;
var numRectanglesToProcess = this.freeRectangles.length; var numRectanglesToProcess = this.freeRectangles.length;
for (var i = 0; i < numRectanglesToProcess; ++i) { for (var i = 0; i < numRectanglesToProcess; ++i) {
if (this.splitFreeNode(this.freeRectangles[i], newNode)) { if (this.splitFreeNode(this.freeRectangles[i], newNode)) {
new linq.List(this.freeRectangles).removeAt(i); new es.List(this.freeRectangles).removeAt(i);
--i; --i;
--numRectanglesToProcess; --numRectanglesToProcess;
} }
@@ -10116,12 +10095,12 @@ var es;
for (var i = 0; i < this.freeRectangles.length; ++i) for (var i = 0; i < this.freeRectangles.length; ++i)
for (var j = i + 1; j < this.freeRectangles.length; ++j) { for (var j = i + 1; j < this.freeRectangles.length; ++j) {
if (this.isContainedIn(this.freeRectangles[i], this.freeRectangles[j])) { if (this.isContainedIn(this.freeRectangles[i], this.freeRectangles[j])) {
new linq.List(this.freeRectangles).removeAt(i); new es.List(this.freeRectangles).removeAt(i);
--i; --i;
break; break;
} }
if (this.isContainedIn(this.freeRectangles[j], this.freeRectangles[i])) { if (this.isContainedIn(this.freeRectangles[j], this.freeRectangles[i])) {
new linq.List(this.freeRectangles).removeAt(j); new es.List(this.freeRectangles).removeAt(j);
--j; --j;
} }
} }
@@ -10389,7 +10368,7 @@ var ArrayUtils = /** @class */ (function () {
* @param item * @param item
*/ */
ArrayUtils.addIfNotPresent = function (list, item) { ArrayUtils.addIfNotPresent = function (list, item) {
if (new linq.List(list).contains(item)) if (new es.List(list).contains(item))
return false; return false;
list.push(item); list.push(item);
return true; return true;
@@ -11091,8 +11070,8 @@ var es;
}()); }());
es.Vector2Ext = Vector2Ext; es.Vector2Ext = Vector2Ext;
})(es || (es = {})); })(es || (es = {}));
var linq; var es;
(function (linq) { (function (es) {
var Enumerable = /** @class */ (function () { var Enumerable = /** @class */ (function () {
function Enumerable() { function Enumerable() {
} }
@@ -11100,7 +11079,7 @@ var linq;
* 在指定范围内生成一个整数序列。 * 在指定范围内生成一个整数序列。
*/ */
Enumerable.range = function (start, count) { Enumerable.range = function (start, count) {
var result = new linq.List(); var result = new es.List();
while (count--) { while (count--) {
result.add(start++); result.add(start++);
} }
@@ -11110,7 +11089,7 @@ var linq;
* 生成包含一个重复值的序列。 * 生成包含一个重复值的序列。
*/ */
Enumerable.repeat = function (element, count) { Enumerable.repeat = function (element, count) {
var result = new linq.List(); var result = new es.List();
while (count--) { while (count--) {
result.add(element); result.add(element);
} }
@@ -11118,18 +11097,18 @@ var linq;
}; };
return Enumerable; return Enumerable;
}()); }());
linq.Enumerable = Enumerable; es.Enumerable = Enumerable;
})(linq || (linq = {})); })(es || (es = {}));
var linq; var es;
(function (linq) { (function (es) {
/** /**
* 检查传递的参数是否为对象 * 检查传递的参数是否为对象
*/ */
linq.isObj = function (x) { return !!x && typeof x === 'object'; }; es.isObj = function (x) { return !!x && typeof x === 'object'; };
/** /**
* 创建一个否定谓词结果的函数 * 创建一个否定谓词结果的函数
*/ */
linq.negate = function (pred) { return function () { es.negate = function (pred) { return function () {
var args = []; var args = [];
for (var _i = 0; _i < arguments.length; _i++) { for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i]; args[_i] = arguments[_i];
@@ -11139,10 +11118,10 @@ var linq;
/** /**
* 比较器助手 * 比较器助手
*/ */
linq.composeComparers = function (previousComparer, currentComparer) { return function (a, b) { es.composeComparers = function (previousComparer, currentComparer) { return function (a, b) {
return previousComparer(a, b) || currentComparer(a, b); return previousComparer(a, b) || currentComparer(a, b);
}; }; }; };
linq.keyComparer = function (_keySelector, descending) { return function (a, b) { es.keyComparer = function (_keySelector, descending) { return function (a, b) {
var sortKeyA = _keySelector(a); var sortKeyA = _keySelector(a);
var sortKeyB = _keySelector(b); var sortKeyB = _keySelector(b);
if (sortKeyA > sortKeyB) { if (sortKeyA > sortKeyB) {
@@ -11155,9 +11134,9 @@ var linq;
return 0; return 0;
} }
}; }; }; };
})(linq || (linq = {})); })(es || (es = {}));
var linq; var es;
(function (linq) { (function (es) {
var List = /** @class */ (function () { var List = /** @class */ (function () {
/** /**
* 默认为列表的元素 * 默认为列表的元素
@@ -11400,7 +11379,7 @@ var linq;
* 根据键按升序对序列中的元素进行排序。 * 根据键按升序对序列中的元素进行排序。
*/ */
List.prototype.orderBy = function (keySelector, comparer) { List.prototype.orderBy = function (keySelector, comparer) {
if (comparer === void 0) { comparer = linq.keyComparer(keySelector, false); } if (comparer === void 0) { comparer = es.keyComparer(keySelector, false); }
// tslint:disable-next-line: no-use-before-declare // tslint:disable-next-line: no-use-before-declare
return new OrderedList(this._elements, comparer); return new OrderedList(this._elements, comparer);
}; };
@@ -11408,7 +11387,7 @@ var linq;
* 根据键值降序对序列中的元素进行排序。 * 根据键值降序对序列中的元素进行排序。
*/ */
List.prototype.orderByDescending = function (keySelector, comparer) { List.prototype.orderByDescending = function (keySelector, comparer) {
if (comparer === void 0) { comparer = linq.keyComparer(keySelector, true); } if (comparer === void 0) { comparer = es.keyComparer(keySelector, true); }
// tslint:disable-next-line: no-use-before-declare // tslint:disable-next-line: no-use-before-declare
return new OrderedList(this._elements, comparer); return new OrderedList(this._elements, comparer);
}; };
@@ -11436,7 +11415,7 @@ var linq;
* 删除与指定谓词定义的条件匹配的所有元素。 * 删除与指定谓词定义的条件匹配的所有元素。
*/ */
List.prototype.removeAll = function (predicate) { List.prototype.removeAll = function (predicate) {
return this.where(linq.negate(predicate)); return this.where(es.negate(predicate));
}; };
/** /**
* 删除列表指定索引处的元素。 * 删除列表指定索引处的元素。
@@ -11601,7 +11580,7 @@ var linq;
}; };
return List; return List;
}()); }());
linq.List = List; es.List = List;
/** /**
* 表示已排序的序列。该类的方法是通过使用延迟执行来实现的。 * 表示已排序的序列。该类的方法是通过使用延迟执行来实现的。
* 即时返回值是一个存储执行操作所需的所有信息的对象。 * 即时返回值是一个存储执行操作所需的所有信息的对象。
@@ -11620,19 +11599,19 @@ var linq;
* @override * @override
*/ */
OrderedList.prototype.thenBy = function (keySelector) { OrderedList.prototype.thenBy = function (keySelector) {
return new OrderedList(this._elements, linq.composeComparers(this._comparer, linq.keyComparer(keySelector, false))); return new OrderedList(this._elements, es.composeComparers(this._comparer, es.keyComparer(keySelector, false)));
}; };
/** /**
* 根据键值按降序对序列中的元素执行后续排序。 * 根据键值按降序对序列中的元素执行后续排序。
* @override * @override
*/ */
OrderedList.prototype.thenByDescending = function (keySelector) { OrderedList.prototype.thenByDescending = function (keySelector) {
return new OrderedList(this._elements, linq.composeComparers(this._comparer, linq.keyComparer(keySelector, true))); return new OrderedList(this._elements, es.composeComparers(this._comparer, es.keyComparer(keySelector, true)));
}; };
return OrderedList; return OrderedList;
}(List)); }(List));
linq.OrderedList = OrderedList; es.OrderedList = OrderedList;
})(linq || (linq = {})); })(es || (es = {}));
var es; var es;
(function (es) { (function (es) {
/** /**
@@ -12080,7 +12059,7 @@ var es;
for (var i = this._timers.length - 1; i >= 0; i--) { for (var i = this._timers.length - 1; i >= 0; i--) {
if (this._timers[i].tick()) { if (this._timers[i].tick()) {
this._timers[i].unload(); this._timers[i].unload();
new linq.List(this._timers).removeAt(i); new es.List(this._timers).removeAt(i);
} }
} }
}; };

File diff suppressed because one or more lines are too long

View File

@@ -116,7 +116,7 @@ module es {
* @param manager * @param manager
*/ */
public static unregisterGlobalManager(manager: es.GlobalManager) { public static unregisterGlobalManager(manager: es.GlobalManager) {
new linq.List(this._instance._globalManagers).remove(manager); new es.List(this._instance._globalManagers).remove(manager);
manager.enabled = false; manager.enabled = false;
} }

View File

@@ -13,7 +13,7 @@ module es {
// 第一点和最后一点决不能相同。我们想要一个开放的多边形 // 第一点和最后一点决不能相同。我们想要一个开放的多边形
let isPolygonClosed = points[0] == points[points.length - 1]; let isPolygonClosed = points[0] == points[points.length - 1];
let linqPoints = new linq.List(points); let linqPoints = new es.List(points);
// 最后一个移除 // 最后一个移除
if (isPolygonClosed) if (isPolygonClosed)
linqPoints.remove(linqPoints.last()); linqPoints.remove(linqPoints.last());

View File

@@ -145,7 +145,7 @@ module es {
* @param component * @param component
*/ */
public removeSceneComponent(component: SceneComponent) { public removeSceneComponent(component: SceneComponent) {
const sceneComponentList = new linq.List(this._sceneComponents); const sceneComponentList = new es.List(this._sceneComponents);
Insist.isTrue(sceneComponentList.contains(component), `SceneComponent${component}不在SceneComponents列表中!`); Insist.isTrue(sceneComponentList.contains(component), `SceneComponent${component}不在SceneComponents列表中!`);
sceneComponentList.remove(component); sceneComponentList.remove(component);
component.onRemovedFromScene(); component.onRemovedFromScene();
@@ -165,7 +165,7 @@ module es {
* @param entity * @param entity
*/ */
public addEntity(entity: Entity) { public addEntity(entity: Entity) {
Insist.isFalse(new linq.List(this.entities.buffer).contains(entity), `您试图将同一实体添加到场景两次: ${entity}`); Insist.isFalse(new es.List(this.entities.buffer).contains(entity), `您试图将同一实体添加到场景两次: ${entity}`);
this.entities.add(entity); this.entities.add(entity);
entity.scene = this; entity.scene = this;

View File

@@ -34,7 +34,7 @@ module es {
} }
public onChanged(entity: Entity) { public onChanged(entity: Entity) {
let contains = new linq.List(this._entities).contains(entity); let contains = new es.List(this._entities).contains(entity);
let interest = this._matcher.isInterestedEntity(entity); let interest = this._matcher.isInterestedEntity(entity);
if (interest && !contains) if (interest && !contains)
@@ -51,7 +51,7 @@ module es {
public onAdded(entity: Entity) { } public onAdded(entity: Entity) { }
public remove(entity: Entity) { public remove(entity: Entity) {
new linq.List(this._entities).remove(entity); new es.List(this._entities).remove(entity);
this.onRemoved(entity); this.onRemoved(entity);
} }

View File

@@ -267,7 +267,7 @@ module es {
return this; return this;
if (!this._parent) { if (!this._parent) {
let children = new linq.List(this._parent._children); let children = new es.List(this._parent._children);
children.remove(this); children.remove(this);
children.add(this); children.add(this);
} }

View File

@@ -50,8 +50,8 @@ module es {
} }
public remove(component: Component) { public remove(component: Component) {
let componentToRemove = new linq.List(this._componentsToRemove); let componentToRemove = new es.List(this._componentsToRemove);
let componentToAdd = new linq.List(this._componentsToAdd); let componentToAdd = new es.List(this._componentsToAdd);
Debug.warnIf(componentToRemove.contains(component), `您正在尝试删除一个您已经删除的组件(${component})`); Debug.warnIf(componentToRemove.contains(component), `您正在尝试删除一个您已经删除的组件(${component})`);
// 这可能不是一个活动的组件,所以我们必须注意它是否还没有被处理,它可能正在同一帧中被删除 // 这可能不是一个活动的组件,所以我们必须注意它是否还没有被处理,它可能正在同一帧中被删除
@@ -83,7 +83,7 @@ module es {
// 处理IUpdatable // 处理IUpdatable
if (isIUpdatable(component)) if (isIUpdatable(component))
new linq.List(this._updatableComponents).remove(component); new es.List(this._updatableComponents).remove(component);
this._entity.componentBits.set(ComponentTypeManager.getIndexFor(TypeUtils.getType(component)), false); this._entity.componentBits.set(ComponentTypeManager.getIndexFor(TypeUtils.getType(component)), false);
this._entity.scene.entityProcessors.onComponentRemoved(this._entity); this._entity.scene.entityProcessors.onComponentRemoved(this._entity);
@@ -107,7 +107,7 @@ module es {
if (this._componentsToRemove.length > 0) { if (this._componentsToRemove.length > 0) {
for (let i = 0; i < this._componentsToRemove.length; i++) { for (let i = 0; i < this._componentsToRemove.length; i++) {
this.handleRemove(this._componentsToRemove[i]); this.handleRemove(this._componentsToRemove[i]);
new linq.List(this._components).remove(this._componentsToRemove[i]); new es.List(this._components).remove(this._componentsToRemove[i]);
} }
this._componentsToRemove.length = 0; this._componentsToRemove.length = 0;
@@ -153,7 +153,7 @@ module es {
public handleRemove(component: Component) { public handleRemove(component: Component) {
if (isIUpdatable(component)) if (isIUpdatable(component))
new linq.List(this._updatableComponents).remove(component); new es.List(this._updatableComponents).remove(component);
this._entity.componentBits.set(ComponentTypeManager.getIndexFor(TypeUtils.getType(component)), false); this._entity.componentBits.set(ComponentTypeManager.getIndexFor(TypeUtils.getType(component)), false);
this._entity.scene.entityProcessors.onComponentRemoved(this._entity); this._entity.scene.entityProcessors.onComponentRemoved(this._entity);

View File

@@ -95,7 +95,7 @@ module es {
* @param entity * @param entity
*/ */
public contains(entity: Entity): boolean { public contains(entity: Entity): boolean {
return new linq.List(this._entities).contains(entity) || this._entitiesToAdded.contains(entity); return new es.List(this._entities).contains(entity) || this._entitiesToAdded.contains(entity);
} }
public getTagList(tag: number) { public getTagList(tag: number) {
@@ -133,7 +133,7 @@ module es {
this.removeFromTagList(entity); this.removeFromTagList(entity);
// 处理常规实体列表 // 处理常规实体列表
new linq.List(this._entities).remove(entity); new es.List(this._entities).remove(entity);
entity.onRemovedFromScene(); entity.onRemovedFromScene();
entity.scene = null; entity.scene = null;

View File

@@ -7,7 +7,7 @@ module es {
} }
public remove(processor: EntitySystem) { public remove(processor: EntitySystem) {
new linq.List(this._processors).remove(processor); new es.List(this._processors).remove(processor);
} }
public onComponentAdded(entity: Entity) { public onComponentAdded(entity: Entity) {

View File

@@ -77,7 +77,7 @@ module es {
let cell = this.cellAtPosition(x, y); let cell = this.cellAtPosition(x, y);
Insist.isNotNull(cell, `从不存在碰撞器的单元格中移除碰撞器: [${collider}]`); Insist.isNotNull(cell, `从不存在碰撞器的单元格中移除碰撞器: [${collider}]`);
if (cell != null) if (cell != null)
new linq.List(cell).remove(collider); new es.List(cell).remove(collider);
} }
} }
} }
@@ -325,7 +325,7 @@ module es {
*/ */
public remove(obj: Collider) { public remove(obj: Collider) {
this._store.forEach(list => { this._store.forEach(list => {
let linqList = new linq.List(list); let linqList = new es.List(list);
if (linqList.contains(obj)) if (linqList.contains(obj))
linqList.remove(obj); linqList.remove(obj);
}) })
@@ -379,7 +379,7 @@ module es {
let potential = cell[i]; let potential = cell[i];
// 管理我们已经处理过的碰撞器 // 管理我们已经处理过的碰撞器
if (new linq.List(this._checkedColliders).contains(potential)) if (new es.List(this._checkedColliders).contains(potential))
continue; continue;
this._checkedColliders.push(potential); this._checkedColliders.push(potential);

View File

@@ -101,7 +101,7 @@ module es {
this._shouldRunNextFrame.push(coroutine); this._shouldRunNextFrame.push(coroutine);
} }
let linqCoroutines = new linq.List(this._unblockedCoroutines); let linqCoroutines = new es.List(this._unblockedCoroutines);
linqCoroutines.clear(); linqCoroutines.clear();
linqCoroutines.addRange(this._shouldRunNextFrame); linqCoroutines.addRange(this._shouldRunNextFrame);
this._shouldRunNextFrame.length = 0; this._shouldRunNextFrame.length = 0;

View File

@@ -40,7 +40,7 @@ module es {
let numRectanglesToProcess = this.freeRectangles.length; let numRectanglesToProcess = this.freeRectangles.length;
for (let i = 0; i < numRectanglesToProcess; ++i) { for (let i = 0; i < numRectanglesToProcess; ++i) {
if (this.splitFreeNode(this.freeRectangles[i], newNode)) { if (this.splitFreeNode(this.freeRectangles[i], newNode)) {
new linq.List(this.freeRectangles).removeAt(i); new es.List(this.freeRectangles).removeAt(i);
--i; --i;
--numRectanglesToProcess; --numRectanglesToProcess;
} }
@@ -142,12 +142,12 @@ module es {
for (let i = 0; i < this.freeRectangles.length; ++i) for (let i = 0; i < this.freeRectangles.length; ++i)
for (let j = i + 1; j < this.freeRectangles.length; ++j) { for (let j = i + 1; j < this.freeRectangles.length; ++j) {
if (this.isContainedIn(this.freeRectangles[i], this.freeRectangles[j])) { if (this.isContainedIn(this.freeRectangles[i], this.freeRectangles[j])) {
new linq.List(this.freeRectangles).removeAt(i); new es.List(this.freeRectangles).removeAt(i);
--i; --i;
break; break;
} }
if (this.isContainedIn(this.freeRectangles[j], this.freeRectangles[i])) { if (this.isContainedIn(this.freeRectangles[j], this.freeRectangles[i])) {
new linq.List(this.freeRectangles).removeAt(j); new es.List(this.freeRectangles).removeAt(j);
--j; --j;
} }
} }

View File

@@ -50,7 +50,7 @@ module es {
let messageData = this._messageTable.get(eventType); let messageData = this._messageTable.get(eventType);
let index = messageData.findIndex(data => data.func == handler); let index = messageData.findIndex(data => data.func == handler);
if (index != -1) if (index != -1)
new linq.List(messageData).removeAt(index); new es.List(messageData).removeAt(index);
} }
/** /**

View File

@@ -1,16 +0,0 @@
module es {
export class Enumerable {
/**
* 生成包含一个重复值的序列
* @param element 要重复的值
* @param count 在生成的序列中重复该值的次数
*/
public static repeat<T>(element: T, count: number){
let result = [];
while (count--) {
result.push(element)
}
return result;
}
}
}

View File

@@ -254,7 +254,7 @@ class ArrayUtils {
* @param item * @param item
*/ */
public static addIfNotPresent<T>(list: T[], item: T) { public static addIfNotPresent<T>(list: T[], item: T) {
if (new linq.List(list).contains(item)) if (new es.List(list).contains(item))
return false; return false;
list.push(item); list.push(item);

View File

@@ -1,4 +1,4 @@
module linq { module es {
export class Enumerable { export class Enumerable {
/** /**
* 在指定范围内生成一个整数序列。 * 在指定范围内生成一个整数序列。

View File

@@ -1,4 +1,4 @@
module linq { module es {
/** /**
* 检查传递的参数是否为对象 * 检查传递的参数是否为对象
*/ */

View File

@@ -1,4 +1,4 @@
module linq { module es {
type PredicateType<T> = (value?: T, index?: number, list?: T[]) => boolean type PredicateType<T> = (value?: T, index?: number, list?: T[]) => boolean
export class List<T> { export class List<T> {

View File

@@ -9,7 +9,7 @@ module es {
for (let i = this._timers.length - 1; i >= 0; i --){ for (let i = this._timers.length - 1; i >= 0; i --){
if (this._timers[i].tick()){ if (this._timers[i].tick()){
this._timers[i].unload(); this._timers[i].unload();
new linq.List(this._timers).removeAt(i); new es.List(this._timers).removeAt(i);
} }
} }
} }