clone numbers for components
parent
b042b797d0
commit
aa574574a6
|
@ -32,6 +32,8 @@ GameLib.Component = function(
|
||||||
|
|
||||||
this.linked = false;
|
this.linked = false;
|
||||||
|
|
||||||
|
this.cloneNumber = 0;
|
||||||
|
|
||||||
if (GameLib.Utils.UndefinedOrNull(delayed)) {
|
if (GameLib.Utils.UndefinedOrNull(delayed)) {
|
||||||
delayed = false;
|
delayed = false;
|
||||||
}
|
}
|
||||||
|
@ -403,20 +405,13 @@ GameLib.Component.prototype.clone = function() {
|
||||||
|
|
||||||
var apiObject = this.toApiObject();
|
var apiObject = this.toApiObject();
|
||||||
|
|
||||||
|
this.cloneNumber += 1;
|
||||||
|
|
||||||
apiObject.id = GameLib.Utils.RandomId();
|
apiObject.id = GameLib.Utils.RandomId();
|
||||||
|
|
||||||
var matches = apiObject.name.match(/Clone \((\d+)\)/);
|
apiObject.name = this.name + ' Clone (' + this.cloneNumber + ')';
|
||||||
|
|
||||||
if (matches && matches.length > 1) {
|
var runtimeObject = null;
|
||||||
if (matches.length === 2) {
|
|
||||||
var number = Number(matches[1]);
|
|
||||||
apiObject.name = apiObject.name.replace(/Clone \(\d*\)/, 'Clone (' + (number+1) + ')');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
apiObject.name = apiObject.name + ' Clone (1)'
|
|
||||||
}
|
|
||||||
|
|
||||||
var runtimeObject = null;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
runtimeObject = new this.constructor(this.graphics, apiObject);
|
runtimeObject = new this.constructor(this.graphics, apiObject);
|
||||||
|
@ -436,6 +431,9 @@ GameLib.Component.prototype.clone = function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO check below event emit
|
||||||
|
*/
|
||||||
GameLib.Event.Emit(
|
GameLib.Event.Emit(
|
||||||
GameLib.Event.COMPONENT_CREATED,
|
GameLib.Event.COMPONENT_CREATED,
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue