更改命名空间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

@@ -116,7 +116,7 @@ module es {
* @param manager
*/
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;
}

View File

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

View File

@@ -145,7 +145,7 @@ module es {
* @param component
*/
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列表中!`);
sceneComponentList.remove(component);
component.onRemovedFromScene();
@@ -165,7 +165,7 @@ module es {
* @param 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);
entity.scene = this;

View File

@@ -34,7 +34,7 @@ module es {
}
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);
if (interest && !contains)
@@ -51,7 +51,7 @@ module es {
public onAdded(entity: Entity) { }
public remove(entity: Entity) {
new linq.List(this._entities).remove(entity);
new es.List(this._entities).remove(entity);
this.onRemoved(entity);
}

View File

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

View File

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

View File

@@ -95,7 +95,7 @@ module es {
* @param entity
*/
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) {
@@ -133,7 +133,7 @@ module es {
this.removeFromTagList(entity);
// 处理常规实体列表
new linq.List(this._entities).remove(entity);
new es.List(this._entities).remove(entity);
entity.onRemovedFromScene();
entity.scene = null;

View File

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

View File

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

View File

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

View File

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

View File

@@ -50,7 +50,7 @@ module es {
let messageData = this._messageTable.get(eventType);
let index = messageData.findIndex(data => data.func == handler);
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
*/
public static addIfNotPresent<T>(list: T[], item: T) {
if (new linq.List(list).contains(item))
if (new es.List(list).contains(item))
return false;
list.push(item);

View File

@@ -1,4 +1,4 @@
module linq {
module es {
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
export class List<T> {

View File

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