rename custom code component
parent
ececa4428a
commit
503ed91bed
|
@ -377,7 +377,7 @@ GameLib.Component.GetComponentInfo = function(number) {
|
||||||
runtime : GameLib.Component.GRAPHICS_RUNTIME
|
runtime : GameLib.Component.GRAPHICS_RUNTIME
|
||||||
};
|
};
|
||||||
case 0x16 : return {
|
case 0x16 : return {
|
||||||
name : 'GameLib.D3.CustomCode',
|
name : 'GameLib.CustomCode',
|
||||||
runtime : GameLib.Component.DEFAULT_RUNTIME
|
runtime : GameLib.Component.DEFAULT_RUNTIME
|
||||||
};
|
};
|
||||||
case 0x17 : return {
|
case 0x17 : return {
|
||||||
|
@ -764,7 +764,7 @@ GameLib.Component.prototype.generateNewIds = function() {
|
||||||
|
|
||||||
this.buildIdToObject();
|
this.buildIdToObject();
|
||||||
|
|
||||||
var codeComponents = GameLib.EntityManager.Instance.queryComponents(GameLib.D3.CustomCode);
|
var codeComponents = GameLib.EntityManager.Instance.queryComponents(GameLib.CustomCode);
|
||||||
|
|
||||||
for (var property in this.idToObject) {
|
for (var property in this.idToObject) {
|
||||||
if (this.idToObject.hasOwnProperty(property)) {
|
if (this.idToObject.hasOwnProperty(property)) {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
* @param parentEntity
|
* @param parentEntity
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.CustomCode = function (
|
GameLib.API.CustomCode = function (
|
||||||
id,
|
id,
|
||||||
name,
|
name,
|
||||||
eventId,
|
eventId,
|
||||||
|
@ -41,17 +41,17 @@ GameLib.D3.API.CustomCode = function (
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.API.CustomCode.prototype = Object.create(GameLib.Component.prototype);
|
GameLib.API.CustomCode.prototype = Object.create(GameLib.Component.prototype);
|
||||||
GameLib.D3.API.CustomCode.prototype.constructor = GameLib.D3.API.CustomCode;
|
GameLib.API.CustomCode.prototype.constructor = GameLib.API.CustomCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object to GameLib.D3.API.CustomCode
|
* Object to GameLib.API.CustomCode
|
||||||
* @param objectComponent
|
* @param objectComponent
|
||||||
* @returns {GameLib.D3.API.CustomCode}
|
* @returns {GameLib.API.CustomCode}
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.API.CustomCode.FromObject = function(objectComponent) {
|
GameLib.API.CustomCode.FromObject = function(objectComponent) {
|
||||||
return new GameLib.D3.API.CustomCode(
|
return new GameLib.API.CustomCode(
|
||||||
objectComponent.id,
|
objectComponent.id,
|
||||||
objectComponent.name,
|
objectComponent.name,
|
||||||
objectComponent.eventId,
|
objectComponent.eventId,
|
|
@ -1,9 +1,9 @@
|
||||||
/**
|
/**
|
||||||
* Creates a CustomCode object
|
* Creates a CustomCode object
|
||||||
* @param apiCustomCode GameLib.D3.API.CustomCode
|
* @param apiCustomCode GameLib.API.CustomCode
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.CustomCode = function(
|
GameLib.CustomCode = function(
|
||||||
apiCustomCode
|
apiCustomCode
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
@ -11,11 +11,11 @@ GameLib.D3.CustomCode = function(
|
||||||
apiCustomCode = {};
|
apiCustomCode = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (apiCustomCode instanceof GameLib.D3.CustomCode) {
|
if (apiCustomCode instanceof GameLib.CustomCode) {
|
||||||
return apiCustomCode;
|
return apiCustomCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLib.D3.API.CustomCode.call(
|
GameLib.API.CustomCode.call(
|
||||||
this,
|
this,
|
||||||
apiCustomCode.id,
|
apiCustomCode.id,
|
||||||
apiCustomCode.name,
|
apiCustomCode.name,
|
||||||
|
@ -32,10 +32,10 @@ GameLib.D3.CustomCode = function(
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.CustomCode.prototype = Object.create(GameLib.D3.API.CustomCode.prototype);
|
GameLib.CustomCode.prototype = Object.create(GameLib.API.CustomCode.prototype);
|
||||||
GameLib.D3.CustomCode.prototype.constructor = GameLib.D3.CustomCode;
|
GameLib.CustomCode.prototype.constructor = GameLib.CustomCode;
|
||||||
|
|
||||||
GameLib.D3.CustomCode.prototype.createInstance = function() {
|
GameLib.CustomCode.prototype.createInstance = function() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.instance = new Function('data', this.code).bind(this);
|
this.instance = new Function('data', this.code).bind(this);
|
||||||
|
@ -53,7 +53,7 @@ GameLib.D3.CustomCode.prototype.createInstance = function() {
|
||||||
/**
|
/**
|
||||||
* Updates the instance with the current state
|
* Updates the instance with the current state
|
||||||
*/
|
*/
|
||||||
GameLib.D3.CustomCode.prototype.updateInstance = function() {
|
GameLib.CustomCode.prototype.updateInstance = function() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.instance = new Function('data', this.code).bind(this);
|
this.instance = new Function('data', this.code).bind(this);
|
||||||
|
@ -76,12 +76,12 @@ GameLib.D3.CustomCode.prototype.updateInstance = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a GameLib.D3.CustomCode to a new GameLib.D3.API.CustomCode
|
* Converts a GameLib.CustomCode to a new GameLib.API.CustomCode
|
||||||
* @returns {GameLib.D3.API.CustomCode}
|
* @returns {GameLib.API.CustomCode}
|
||||||
*/
|
*/
|
||||||
GameLib.D3.CustomCode.prototype.toApiObject = function() {
|
GameLib.CustomCode.prototype.toApiObject = function() {
|
||||||
|
|
||||||
return new GameLib.D3.API.CustomCode(
|
return new GameLib.API.CustomCode(
|
||||||
this.id,
|
this.id,
|
||||||
this.name,
|
this.name,
|
||||||
this.eventId,
|
this.eventId,
|
||||||
|
@ -92,19 +92,19 @@ GameLib.D3.CustomCode.prototype.toApiObject = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts from an Object CustomCode to a GameLib.D3.CustomCode
|
* Converts from an Object CustomCode to a GameLib.CustomCode
|
||||||
* @param objectCustomCode Object
|
* @param objectCustomCode Object
|
||||||
* @returns {GameLib.D3.CustomCode}
|
* @returns {GameLib.CustomCode}
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
GameLib.D3.CustomCode.FromObject = function(objectCustomCode) {
|
GameLib.CustomCode.FromObject = function(objectCustomCode) {
|
||||||
var apiCustomCode = GameLib.D3.API.CustomCode.FromObject(objectCustomCode);
|
var apiCustomCode = GameLib.API.CustomCode.FromObject(objectCustomCode);
|
||||||
return new GameLib.D3.CustomCode(
|
return new GameLib.CustomCode(
|
||||||
apiCustomCode
|
apiCustomCode
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.CustomCode.prototype.launchEditor = function(){
|
GameLib.CustomCode.prototype.launchEditor = function(){
|
||||||
|
|
||||||
GameLib.Event.Emit(
|
GameLib.Event.Emit(
|
||||||
GameLib.Event.GET_RUNTIME,
|
GameLib.Event.GET_RUNTIME,
|
||||||
|
@ -136,7 +136,7 @@ GameLib.D3.CustomCode.prototype.launchEditor = function(){
|
||||||
}.bind(this))
|
}.bind(this))
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.D3.CustomCode.prototype.closeEditor = function(){
|
GameLib.CustomCode.prototype.closeEditor = function(){
|
||||||
var dom = this.editor.getWrapperElement();
|
var dom = this.editor.getWrapperElement();
|
||||||
dom.parentElement.removeChild(dom);
|
dom.parentElement.removeChild(dom);
|
||||||
};
|
};
|
|
@ -31,7 +31,7 @@ GameLib.System.CustomCode.prototype.start = function() {
|
||||||
|
|
||||||
GameLib.System.prototype.start.call(this);
|
GameLib.System.prototype.start.call(this);
|
||||||
|
|
||||||
GameLib.EntityManager.Instance.queryComponents(GameLib.D3.CustomCode).map(
|
GameLib.EntityManager.Instance.queryComponents(GameLib.CustomCode).map(
|
||||||
function(component) {
|
function(component) {
|
||||||
this.subscriptions[component.id] = GameLib.Event.Subscribe(
|
this.subscriptions[component.id] = GameLib.Event.Subscribe(
|
||||||
component.eventId,
|
component.eventId,
|
||||||
|
@ -64,7 +64,7 @@ GameLib.System.CustomCode.prototype.start = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.System.CustomCode.prototype.instanceCreated = function(data) {
|
GameLib.System.CustomCode.prototype.instanceCreated = function(data) {
|
||||||
if (data.component instanceof GameLib.D3.CustomCode) {
|
if (data.component instanceof GameLib.CustomCode) {
|
||||||
|
|
||||||
if (this.subscriptions[data.component.id]) {
|
if (this.subscriptions[data.component.id]) {
|
||||||
console.warn('a component already existed');
|
console.warn('a component already existed');
|
||||||
|
@ -79,7 +79,7 @@ GameLib.System.CustomCode.prototype.instanceCreated = function(data) {
|
||||||
};
|
};
|
||||||
|
|
||||||
GameLib.System.CustomCode.prototype.removeComponent = function(data) {
|
GameLib.System.CustomCode.prototype.removeComponent = function(data) {
|
||||||
if (data.component instanceof GameLib.D3.CustomCode) {
|
if (data.component instanceof GameLib.CustomCode) {
|
||||||
if (this.subscriptions[data.component.id]) {
|
if (this.subscriptions[data.component.id]) {
|
||||||
this.subscriptions[data.component.id].remove();
|
this.subscriptions[data.component.id].remove();
|
||||||
delete this.subscriptions[data.component.id];
|
delete this.subscriptions[data.component.id];
|
||||||
|
|
Loading…
Reference in New Issue