随机类移动至es命名空间

This commit is contained in:
yhh
2021-03-29 17:45:36 +08:00
parent e6096b644f
commit 0b8d752773
6 changed files with 1013 additions and 997 deletions

View File

@@ -649,12 +649,12 @@ declare module es {
* 返回第一个启用加载的类型为T的组件 * 返回第一个启用加载的类型为T的组件
* @param type * @param type
*/ */
findComponentOfType<T extends Component>(type: any): T; findComponentOfType<T extends Component>(type: new (...args: any[]) => T): T;
/** /**
* 返回类型为T的所有已启用已加载组件的列表 * 返回类型为T的所有已启用已加载组件的列表
* @param type * @param type
*/ */
findComponentsOfType<T extends Component>(type: any): T[]; findComponentsOfType<T extends Component>(type: new (...args: any[]) => T): T[];
/** /**
* 返回场景中包含特定组件的实体列表 * 返回场景中包含特定组件的实体列表
* @param type * @param type
@@ -3974,7 +3974,8 @@ declare module es {
isContainedIn(a: Rectangle, b: Rectangle): boolean; isContainedIn(a: Rectangle, b: Rectangle): boolean;
} }
} }
declare class ArrayUtils { declare module es {
class ArrayUtils {
/** /**
* 执行冒泡排序 * 执行冒泡排序
* @param ary * @param ary
@@ -4087,6 +4088,7 @@ declare class ArrayUtils {
* @param itemCount 从列表中返回的随机项目的数量 * @param itemCount 从列表中返回的随机项目的数量
*/ */
static randomItems<T>(list: T[], itemCount: number): T[]; static randomItems<T>(list: T[], itemCount: number): T[];
}
} }
declare module es { declare module es {
class Base64Utils { class Base64Utils {
@@ -4146,7 +4148,8 @@ declare module es {
static toNumber(value: any): number; static toNumber(value: any): number;
} }
} }
declare class RandomUtils { declare module es {
class RandomUtils {
/** /**
* 在 start 与 stop之间取一个随机整数可以用step指定间隔 但不包括较大的端点start与stop较大的一个 * 在 start 与 stop之间取一个随机整数可以用step指定间隔 但不包括较大的端点start与stop较大的一个
* 如 * 如
@@ -4214,6 +4217,7 @@ declare class RandomUtils {
*/ */
static boolean(chance?: number): boolean; static boolean(chance?: number): boolean;
private static _randomCompare; private static _randomCompare;
}
} }
declare module es { declare module es {
class RectangleExt { class RectangleExt {

View File

@@ -10114,7 +10114,9 @@ var es;
}()); }());
es.MaxRectsBinPack = MaxRectsBinPack; es.MaxRectsBinPack = MaxRectsBinPack;
})(es || (es = {})); })(es || (es = {}));
var ArrayUtils = /** @class */ (function () { var es;
(function (es) {
var ArrayUtils = /** @class */ (function () {
function ArrayUtils() { function ArrayUtils() {
} }
/** /**
@@ -10356,7 +10358,7 @@ var ArrayUtils = /** @class */ (function () {
var n = list.length; var n = list.length;
while (n > 1) { while (n > 1) {
n--; n--;
var k = RandomUtils.randint(0, n + 1); var k = es.RandomUtils.randint(0, n + 1);
var value = list[k]; var value = list[k];
list[k] = list[n]; list[k] = list[n];
list[n] = value; list[n] = value;
@@ -10385,7 +10387,7 @@ var ArrayUtils = /** @class */ (function () {
* @param list * @param list
*/ */
ArrayUtils.randomItem = function (list) { ArrayUtils.randomItem = function (list) {
return list[RandomUtils.randint(0, list.length - 1)]; return list[es.RandomUtils.randint(0, list.length - 1)];
}; };
/** /**
* 从列表中随机获取物品。不清空检查列表也不验证列表数是否大于项目数。返回的List可以通过ListPool.free放回池中 * 从列表中随机获取物品。不清空检查列表也不验证列表数是否大于项目数。返回的List可以通过ListPool.free放回池中
@@ -10404,7 +10406,9 @@ var ArrayUtils = /** @class */ (function () {
return items; return items;
}; };
return ArrayUtils; return ArrayUtils;
}()); }());
es.ArrayUtils = ArrayUtils;
})(es || (es = {}));
var es; var es;
(function (es) { (function (es) {
var Base64Utils = /** @class */ (function () { var Base64Utils = /** @class */ (function () {
@@ -10578,7 +10582,9 @@ var es;
}()); }());
es.NumberExtension = NumberExtension; es.NumberExtension = NumberExtension;
})(es || (es = {})); })(es || (es = {}));
var RandomUtils = /** @class */ (function () { var es;
(function (es) {
var RandomUtils = /** @class */ (function () {
function RandomUtils() { function RandomUtils() {
} }
/** /**
@@ -10702,7 +10708,9 @@ var RandomUtils = /** @class */ (function () {
return (this.random() > .5) ? 1 : -1; return (this.random() > .5) ? 1 : -1;
}; };
return RandomUtils; return RandomUtils;
}()); }());
es.RandomUtils = RandomUtils;
})(es || (es = {}));
var es; var es;
(function (es) { (function (es) {
var RectangleExt = /** @class */ (function () { var RectangleExt = /** @class */ (function () {

File diff suppressed because one or more lines are too long

View File

@@ -212,7 +212,7 @@ module es {
* 返回第一个启用加载的类型为T的组件 * 返回第一个启用加载的类型为T的组件
* @param type * @param type
*/ */
public findComponentOfType<T extends Component>(type): T { public findComponentOfType<T extends Component>(type: new (...args) => T): T {
return this.entities.findComponentOfType<T>(type); return this.entities.findComponentOfType<T>(type);
} }
@@ -220,7 +220,7 @@ module es {
* 返回类型为T的所有已启用已加载组件的列表 * 返回类型为T的所有已启用已加载组件的列表
* @param type * @param type
*/ */
public findComponentsOfType<T extends Component>(type): T[] { public findComponentsOfType<T extends Component>(type: new (...args) => T): T[] {
return this.entities.findComponentsOfType<T>(type); return this.entities.findComponentsOfType<T>(type);
} }

View File

@@ -1,4 +1,5 @@
class ArrayUtils { module es {
export class ArrayUtils {
/** /**
* 执行冒泡排序 * 执行冒泡排序
* @param ary * @param ary
@@ -294,4 +295,5 @@ class ArrayUtils {
set.forEach(value => items.push(value)); set.forEach(value => items.push(value));
return items; return items;
} }
}
} }

View File

@@ -1,4 +1,5 @@
class RandomUtils { module es {
export class RandomUtils {
/** /**
* 在 start 与 stop之间取一个随机整数可以用step指定间隔 但不包括较大的端点start与stop较大的一个 * 在 start 与 stop之间取一个随机整数可以用step指定间隔 但不包括较大的端点start与stop较大的一个
* 如 * 如
@@ -130,4 +131,5 @@ class RandomUtils {
private static _randomCompare(a: Object, b: Object): number { private static _randomCompare(a: Object, b: Object): number {
return (this.random() > .5) ? 1 : -1; return (this.random() > .5) ? 1 : -1;
} }
}
} }