iupdatable无法判断接口 去除改为component支持
This commit is contained in:
13
source/bin/framework.d.ts
vendored
13
source/bin/framework.d.ts
vendored
@@ -205,6 +205,7 @@ declare abstract class Component extends egret.DisplayObjectContainer {
|
||||
onEnabled(): void;
|
||||
onDisabled(): void;
|
||||
debugRender(): void;
|
||||
update(): void;
|
||||
onEntityTransformChanged(comp: TransformComponent): void;
|
||||
registerComponent(): void;
|
||||
deregisterComponent(): void;
|
||||
@@ -258,11 +259,6 @@ declare enum TransformComponent {
|
||||
scale = 1,
|
||||
position = 2
|
||||
}
|
||||
interface IUpdatable {
|
||||
enabled: boolean;
|
||||
updateOrder: number;
|
||||
update(): any;
|
||||
}
|
||||
declare class Scene extends egret.DisplayObjectContainer {
|
||||
camera: Camera;
|
||||
readonly entities: EntityList;
|
||||
@@ -314,7 +310,7 @@ declare class SceneManager {
|
||||
static registerActiveSceneChanged(current: Scene, next: Scene): void;
|
||||
onSceneChanged(): void;
|
||||
}
|
||||
declare class Camera extends Component implements IUpdatable {
|
||||
declare class Camera extends Component {
|
||||
private _zoom;
|
||||
private _origin;
|
||||
private _minimumZoom;
|
||||
@@ -430,7 +426,7 @@ declare class SpriteAnimation {
|
||||
readonly frameRate: number;
|
||||
constructor(sprites: Sprite[], frameRate: number);
|
||||
}
|
||||
declare class SpriteAnimator extends SpriteRenderer implements IUpdatable {
|
||||
declare class SpriteAnimator extends SpriteRenderer {
|
||||
onAnimationCompletedEvent: Function;
|
||||
speed: number;
|
||||
animationState: State;
|
||||
@@ -477,7 +473,7 @@ declare class Mover extends Component {
|
||||
applyMovement(motion: Vector2): void;
|
||||
move(motion: Vector2): CollisionResult;
|
||||
}
|
||||
declare abstract class Collider extends Component implements IUpdatable {
|
||||
declare abstract class Collider extends Component {
|
||||
shape: Shape;
|
||||
physicsLayer: number;
|
||||
isTrigger: boolean;
|
||||
@@ -575,7 +571,6 @@ declare class ComponentList {
|
||||
private _components;
|
||||
private _componentsToAdd;
|
||||
private _componentsToRemove;
|
||||
private _updatableComponents;
|
||||
private _tempBufferList;
|
||||
constructor(entity: Entity);
|
||||
readonly count: number;
|
||||
|
||||
@@ -1011,6 +1011,8 @@ var Component = (function (_super) {
|
||||
};
|
||||
Component.prototype.debugRender = function () {
|
||||
};
|
||||
Component.prototype.update = function () {
|
||||
};
|
||||
Component.prototype.onEntityTransformChanged = function (comp) {
|
||||
};
|
||||
Component.prototype.registerComponent = function () {
|
||||
@@ -2575,7 +2577,6 @@ var ComponentList = (function () {
|
||||
this._components = [];
|
||||
this._componentsToAdd = [];
|
||||
this._componentsToRemove = [];
|
||||
this._updatableComponents = [];
|
||||
this._tempBufferList = [];
|
||||
this._entity = entity;
|
||||
}
|
||||
@@ -2610,7 +2611,6 @@ var ComponentList = (function () {
|
||||
this.handleRemove(this._components[i]);
|
||||
}
|
||||
this._components.length = 0;
|
||||
this._updatableComponents.length = 0;
|
||||
this._componentsToAdd.length = 0;
|
||||
this._componentsToRemove.length = 0;
|
||||
};
|
||||
@@ -2619,8 +2619,6 @@ var ComponentList = (function () {
|
||||
var component = this._components[i];
|
||||
if (component instanceof RenderableComponent)
|
||||
this._entity.scene.renderableComponents.remove(component);
|
||||
if (egret.is(component, "IUpdatable"))
|
||||
this._updatableComponents.remove(component);
|
||||
this._entity.componentBits.set(ComponentTypeManager.getIndexFor(component), false);
|
||||
this._entity.scene.entityProcessors.onComponentRemoved(this._entity);
|
||||
}
|
||||
@@ -2630,8 +2628,6 @@ var ComponentList = (function () {
|
||||
var component = this._components[i];
|
||||
if (component instanceof RenderableComponent)
|
||||
this._entity.scene.renderableComponents.add(component);
|
||||
if (egret.is(component, "IUpdatable"))
|
||||
this._updatableComponents.push(component);
|
||||
this._entity.componentBits.set(ComponentTypeManager.getIndexFor(component));
|
||||
this._entity.scene.entityProcessors.onComponentAdded(this._entity);
|
||||
}
|
||||
@@ -2649,8 +2645,6 @@ var ComponentList = (function () {
|
||||
var component = this._componentsToAdd[i];
|
||||
if (component instanceof RenderableComponent)
|
||||
this._entity.scene.renderableComponents.add(component);
|
||||
if (egret.is(component, "IUpdatable"))
|
||||
this._updatableComponents.push(component);
|
||||
this._entity.componentBits.set(ComponentTypeManager.getIndexFor(component));
|
||||
this._entity.scene.entityProcessors.onComponentAdded(this._entity);
|
||||
this._components.push(component);
|
||||
@@ -2680,8 +2674,6 @@ var ComponentList = (function () {
|
||||
ComponentList.prototype.handleRemove = function (component) {
|
||||
if (component instanceof RenderableComponent)
|
||||
this._entity.scene.renderableComponents.remove(component);
|
||||
if (egret.is(component, "IUpdatable"))
|
||||
this._updatableComponents.remove(component);
|
||||
this._entity.componentBits.set(ComponentTypeManager.getIndexFor(component), false);
|
||||
this._entity.scene.entityProcessors.onComponentRemoved(this._entity);
|
||||
component.onRemovedFromEntity();
|
||||
@@ -2735,8 +2727,8 @@ var ComponentList = (function () {
|
||||
};
|
||||
ComponentList.prototype.update = function () {
|
||||
this.updateLists();
|
||||
for (var i = 0; i < this._updatableComponents.length; i++) {
|
||||
var updatable = this._updatableComponents[i];
|
||||
for (var i = 0; i < this._components.length; i++) {
|
||||
var updatable = this._components[i];
|
||||
var updateableComponent = void 0;
|
||||
if (updatable instanceof Component)
|
||||
updateableComponent = updatable;
|
||||
|
||||
2
source/bin/framework.min.js
vendored
2
source/bin/framework.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -71,6 +71,10 @@ abstract class Component extends egret.DisplayObjectContainer {
|
||||
|
||||
}
|
||||
|
||||
public update(){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 当实体的位置改变时调用。这允许组件知道它们由于父实体的移动而移动了。
|
||||
* @param comp
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
///<reference path="../Component.ts"/>
|
||||
class Camera extends Component implements IUpdatable {
|
||||
class Camera extends Component {
|
||||
private _zoom;
|
||||
private _origin: Vector2 = Vector2.zero;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
abstract class Collider extends Component implements IUpdatable {
|
||||
abstract class Collider extends Component {
|
||||
/** 对撞机的基本形状 */
|
||||
public shape: Shape;
|
||||
/** 在处理冲突时,physicsLayer可以用作过滤器。Flags类有帮助位掩码的方法。 */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
///<reference path="./SpriteRenderer.ts" />
|
||||
class SpriteAnimator extends SpriteRenderer implements IUpdatable {
|
||||
class SpriteAnimator extends SpriteRenderer {
|
||||
/** 在动画完成时触发,包括动画名称; */
|
||||
public onAnimationCompletedEvent: Function;
|
||||
/** 动画播放速度 */
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class SpriteRenderer extends RenderableComponent {
|
||||
class SpriteRenderer extends RenderableComponent{
|
||||
private _sprite: Sprite;
|
||||
protected bitmap: egret.Bitmap;
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
/** 当将该接口添加到组件时,只要启用了组件和实体,它就需要调用每帧的更新方法。 */
|
||||
interface IUpdatable {
|
||||
enabled: boolean;
|
||||
updateOrder: number;
|
||||
update();
|
||||
}
|
||||
@@ -6,8 +6,6 @@ class ComponentList {
|
||||
private _componentsToAdd: Component[] = [];
|
||||
/** 标记要删除此框架的组件列表。用来对组件进行分组,这样我们就可以同时进行加工 */
|
||||
private _componentsToRemove: Component[] = [];
|
||||
/** 需要调用更新的所有组件的列表 */
|
||||
private _updatableComponents: IUpdatable[] = [];
|
||||
private _tempBufferList: Component[] = [];
|
||||
|
||||
constructor(entity: Entity) {
|
||||
@@ -48,7 +46,6 @@ class ComponentList {
|
||||
}
|
||||
|
||||
this._components.length = 0;
|
||||
this._updatableComponents.length = 0;
|
||||
this._componentsToAdd.length = 0;
|
||||
this._componentsToRemove.length = 0;
|
||||
}
|
||||
@@ -61,10 +58,6 @@ class ComponentList {
|
||||
if (component instanceof RenderableComponent)
|
||||
this._entity.scene.renderableComponents.remove(component);
|
||||
|
||||
// 处理IUpdatable
|
||||
if (egret.is(component, "IUpdatable"))
|
||||
this._updatableComponents.remove(component);
|
||||
|
||||
this._entity.componentBits.set(ComponentTypeManager.getIndexFor(component), false);
|
||||
this._entity.scene.entityProcessors.onComponentRemoved(this._entity);
|
||||
}
|
||||
@@ -77,9 +70,6 @@ class ComponentList {
|
||||
if (component instanceof RenderableComponent)
|
||||
this._entity.scene.renderableComponents.add(component);
|
||||
|
||||
if (egret.is(component, "IUpdatable"))
|
||||
this._updatableComponents.push(component as any);
|
||||
|
||||
this._entity.componentBits.set(ComponentTypeManager.getIndexFor(component));
|
||||
this._entity.scene.entityProcessors.onComponentAdded(this._entity);
|
||||
}
|
||||
@@ -104,9 +94,6 @@ class ComponentList {
|
||||
if (component instanceof RenderableComponent)
|
||||
this._entity.scene.renderableComponents.add(component);
|
||||
|
||||
if (egret.is(component, "IUpdatable"))
|
||||
this._updatableComponents.push(component as any);
|
||||
|
||||
this._entity.componentBits.set(ComponentTypeManager.getIndexFor(component));
|
||||
this._entity.scene.entityProcessors.onComponentAdded(this._entity);
|
||||
|
||||
@@ -148,9 +135,6 @@ class ComponentList {
|
||||
if (component instanceof RenderableComponent)
|
||||
this._entity.scene.renderableComponents.remove(component);
|
||||
|
||||
if (egret.is(component, "IUpdatable"))
|
||||
this._updatableComponents.remove(component);
|
||||
|
||||
this._entity.componentBits.set(ComponentTypeManager.getIndexFor(component), false);
|
||||
this._entity.scene.entityProcessors.onComponentRemoved(this._entity);
|
||||
|
||||
@@ -224,8 +208,8 @@ class ComponentList {
|
||||
|
||||
public update() {
|
||||
this.updateLists();
|
||||
for (let i = 0; i < this._updatableComponents.length; i++) {
|
||||
let updatable = this._updatableComponents[i];
|
||||
for (let i = 0; i < this._components.length; i++) {
|
||||
let updatable = this._components[i];
|
||||
let updateableComponent;
|
||||
if (updatable instanceof Component)
|
||||
updateableComponent = updatable as Component;
|
||||
|
||||
Reference in New Issue
Block a user