register updates
parent
70ebe7a5ec
commit
8068dcf3ef
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
||||||
// COMPILE TIME DEFINITIONS (Generated via gulp)
|
// COMPILE TIME DEFINITIONS (Generated via gulp)
|
||||||
var __DATE__ = "Mon Dec 04 2017 13:21:42 GMT+0100 (CET)";
|
var __DATE__ = "Mon Dec 04 2017 14:10:07 GMT+0100 (CET)";
|
||||||
// END COMPILE TIME DEFINITIONS
|
// END COMPILE TIME DEFINITIONS
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1581,6 +1581,7 @@ GameLib.Component.PARTICLE = 0x54;
|
||||||
GameLib.Component.AUDIO = 0x55;
|
GameLib.Component.AUDIO = 0x55;
|
||||||
GameLib.Component.SYSTEM_AUDIO = 0x56;
|
GameLib.Component.SYSTEM_AUDIO = 0x56;
|
||||||
GameLib.Component.CAST = 0x57;
|
GameLib.Component.CAST = 0x57;
|
||||||
|
GameLib.Component.MAX_COMPONENTS = 0x58;
|
||||||
|
|
||||||
GameLib.Component.GRAPHICS_RUNTIME = 0x1;
|
GameLib.Component.GRAPHICS_RUNTIME = 0x1;
|
||||||
GameLib.Component.PHYSICS_RUNTIME = 0x2;
|
GameLib.Component.PHYSICS_RUNTIME = 0x2;
|
||||||
|
@ -1590,8 +1591,11 @@ GameLib.Component.DEFAULT_RUNTIME = 0x5;
|
||||||
GameLib.Component.GUI_RUNTIME = 0x6;
|
GameLib.Component.GUI_RUNTIME = 0x6;
|
||||||
GameLib.Component.CODER_RUNTIME = 0x7;
|
GameLib.Component.CODER_RUNTIME = 0x7;
|
||||||
|
|
||||||
GameLib.Component.GetCompentType = function(constructor) {
|
GameLib.Component.GetCompentTypes = function(constructor) {
|
||||||
console.log('todo: implement?');
|
|
||||||
|
if (constructor === GameLib.Component) {
|
||||||
|
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23320,7 +23324,8 @@ GameLib.EntityManager.prototype.findEntities = function(components) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all actual components of all entities that contain this component
|
* Returns all actual components of all entities that contain this component
|
||||||
* @param componentTypes (array of constructor or just a single constructor)
|
* More efficient
|
||||||
|
* @param componentTypes (array of component types or a single component type)
|
||||||
*/
|
*/
|
||||||
GameLib.EntityManager.prototype.queryComponents = function(componentTypes) {
|
GameLib.EntityManager.prototype.queryComponents = function(componentTypes) {
|
||||||
|
|
||||||
|
@ -23347,6 +23352,37 @@ GameLib.EntityManager.prototype.queryComponents = function(componentTypes) {
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Slower way of retrieving objects
|
||||||
|
* @param constructors (array of constructors, or a constructor)
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
GameLib.EntityManager.prototype.queryComponentsByConstructor = function(constructors) {
|
||||||
|
return Object.keys(this.idRegister).reduce(
|
||||||
|
function(result, componentId) {
|
||||||
|
if (constructors instanceof Array) {
|
||||||
|
|
||||||
|
constructors.map(
|
||||||
|
function(constructor) {
|
||||||
|
if (this.idRegister[componentId] instanceof constructor) {
|
||||||
|
result.push(this.idRegister[componentId]);
|
||||||
|
}
|
||||||
|
}.bind(this)
|
||||||
|
)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (this.idRegister[componentId] instanceof constructors) {
|
||||||
|
result.push(this.idRegister[componentId]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}.bind(this),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a GameLib.Entity to GameLib.API.Entity
|
* Converts a GameLib.Entity to GameLib.API.Entity
|
||||||
* @returns {GameLib.API.EntityManager}
|
* @returns {GameLib.API.EntityManager}
|
||||||
|
@ -26888,7 +26924,9 @@ GameLib.System.GUI.prototype.buildParentSelectionControl = function(folder, comp
|
||||||
|
|
||||||
var componentType = GameLib.Component[type];
|
var componentType = GameLib.Component[type];
|
||||||
|
|
||||||
var options = GameLib.EntityManager.Instance.queryComponents(componentType).reduce(
|
var constructor = GameLib.Component.GetComponentConstructor(componentType);
|
||||||
|
|
||||||
|
var options = GameLib.EntityManager.Instance.queryComponentsByConstructor(constructor).reduce(
|
||||||
function(result, object) {
|
function(result, object) {
|
||||||
result[object.name] = object;
|
result[object.name] = object;
|
||||||
return result;
|
return result;
|
||||||
|
@ -27111,19 +27149,19 @@ GameLib.System.GUI.prototype.buildSelectControl = function(folder, componentTemp
|
||||||
/**
|
/**
|
||||||
* We need to discover the constructor for this component
|
* We need to discover the constructor for this component
|
||||||
*/
|
*/
|
||||||
var constructor = null;
|
var constructors = null;
|
||||||
|
|
||||||
if (componentTemplate.template[property]) {
|
if (componentTemplate.template[property]) {
|
||||||
constructor = componentTemplate.template[property].constructor;
|
constructors = componentTemplate.template[property].constructor;
|
||||||
} else {
|
} else {
|
||||||
if (componentTemplate.template.linkedObjects[property]) {
|
if (componentTemplate.template.linkedObjects[property]) {
|
||||||
constructor = componentTemplate.template.linkedObjects[property];
|
constructors = componentTemplate.template.linkedObjects[property];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var object = componentTemplate.template;
|
var object = componentTemplate.template;
|
||||||
|
|
||||||
var objects = GameLib.EntityManager.Instance.queryComponents(constructor);
|
var objects = GameLib.EntityManager.Instance.queryComponentsByConstructor(constructors);
|
||||||
|
|
||||||
var idObject = {};
|
var idObject = {};
|
||||||
|
|
||||||
|
@ -29113,7 +29151,7 @@ GameLib.System.Input.prototype.onKeyDown = function(event) {
|
||||||
|
|
||||||
if (event.code === 'Delete') {
|
if (event.code === 'Delete') {
|
||||||
|
|
||||||
meshes = GameLib.EntityManager.Instance.queryComponents([GameLib.Component.MESH]);
|
meshes = GameLib.EntityManager.Instance.queryComponentsByConstructor(GameLib.D3.Mesh);
|
||||||
|
|
||||||
var deletedMeshes = [];
|
var deletedMeshes = [];
|
||||||
|
|
||||||
|
@ -29149,7 +29187,7 @@ GameLib.System.Input.prototype.onKeyDown = function(event) {
|
||||||
|
|
||||||
this.selectAll = !this.selectAll;
|
this.selectAll = !this.selectAll;
|
||||||
|
|
||||||
meshes = GameLib.EntityManager.Instance.queryComponents([GameLib.Component.MESH]);
|
meshes = GameLib.EntityManager.Instance.queryComponentsByConstructor(GameLib.D3.Mesh);
|
||||||
|
|
||||||
meshes.map(function(mesh){
|
meshes.map(function(mesh){
|
||||||
if (this.selectAll) {
|
if (this.selectAll) {
|
||||||
|
@ -30220,10 +30258,11 @@ GameLib.System.Linking.prototype.instanceCreated = function(data) {
|
||||||
/**
|
/**
|
||||||
* Check ALL components for 'parentScenes' - this is expensive so it checks the register directly
|
* Check ALL components for 'parentScenes' - this is expensive so it checks the register directly
|
||||||
*/
|
*/
|
||||||
GameLib.EntityManager.Instance.register.map(
|
|
||||||
function(component) {
|
Object.keys(GameLib.EntityManager.Instance.idRegister).map(
|
||||||
if (component.parentScene === data.component.id) {
|
function(componentId) {
|
||||||
component.parentScene = data.component;
|
if (GameLib.EntityManager.Instance.idRegister[componentId].parentScene === data.component.id) {
|
||||||
|
GameLib.EntityManager.Instance.idRegister[componentId].parentScene = data.component;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -30266,22 +30305,21 @@ GameLib.System.Linking.prototype.instanceCreated = function(data) {
|
||||||
* Also - it inspects the register directly instead of querying it twice (since it checks ALL components)
|
* Also - it inspects the register directly instead of querying it twice (since it checks ALL components)
|
||||||
*/
|
*/
|
||||||
if (!data.preventParentMeshCheck) {
|
if (!data.preventParentMeshCheck) {
|
||||||
GameLib.EntityManager.Instance.register.map(
|
|
||||||
function (component) {
|
|
||||||
if (component.parentMesh &&
|
|
||||||
component.parentMesh === data.component.id ) {
|
|
||||||
|
|
||||||
component.parentMesh = data.component;
|
|
||||||
|
|
||||||
|
Object.keys(GameLib.EntityManager.Instance.idRegister).map(
|
||||||
|
function(componentId) {
|
||||||
|
if (GameLib.EntityManager.Instance.idRegister[componentId].parentMesh === data.component.id) {
|
||||||
|
GameLib.EntityManager.Instance.idRegister[componentId].parentMesh = data.component;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Check if a component has this mesh as a parent
|
* Check if a component has this mesh as a parent
|
||||||
*/
|
*/
|
||||||
if (component instanceof GameLib.D3.Mesh) {
|
if (GameLib.EntityManager.Instance.idRegister[componentId] instanceof GameLib.D3.Mesh) {
|
||||||
component.setParentMesh(data.component);
|
GameLib.EntityManager.Instance.idRegister[componentId].setParentMesh(data.component);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -285,6 +285,7 @@ GameLib.Component.PARTICLE = 0x54;
|
||||||
GameLib.Component.AUDIO = 0x55;
|
GameLib.Component.AUDIO = 0x55;
|
||||||
GameLib.Component.SYSTEM_AUDIO = 0x56;
|
GameLib.Component.SYSTEM_AUDIO = 0x56;
|
||||||
GameLib.Component.CAST = 0x57;
|
GameLib.Component.CAST = 0x57;
|
||||||
|
GameLib.Component.MAX_COMPONENTS = 0x58;
|
||||||
|
|
||||||
GameLib.Component.GRAPHICS_RUNTIME = 0x1;
|
GameLib.Component.GRAPHICS_RUNTIME = 0x1;
|
||||||
GameLib.Component.PHYSICS_RUNTIME = 0x2;
|
GameLib.Component.PHYSICS_RUNTIME = 0x2;
|
||||||
|
@ -294,8 +295,11 @@ GameLib.Component.DEFAULT_RUNTIME = 0x5;
|
||||||
GameLib.Component.GUI_RUNTIME = 0x6;
|
GameLib.Component.GUI_RUNTIME = 0x6;
|
||||||
GameLib.Component.CODER_RUNTIME = 0x7;
|
GameLib.Component.CODER_RUNTIME = 0x7;
|
||||||
|
|
||||||
GameLib.Component.GetCompentType = function(constructor) {
|
GameLib.Component.GetCompentTypes = function(constructor) {
|
||||||
console.log('todo: implement?');
|
|
||||||
|
if (constructor === GameLib.Component) {
|
||||||
|
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -285,7 +285,8 @@ GameLib.EntityManager.prototype.findEntities = function(components) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all actual components of all entities that contain this component
|
* Returns all actual components of all entities that contain this component
|
||||||
* @param componentTypes (array of constructor or just a single constructor)
|
* More efficient
|
||||||
|
* @param componentTypes (array of component types or a single component type)
|
||||||
*/
|
*/
|
||||||
GameLib.EntityManager.prototype.queryComponents = function(componentTypes) {
|
GameLib.EntityManager.prototype.queryComponents = function(componentTypes) {
|
||||||
|
|
||||||
|
@ -312,6 +313,37 @@ GameLib.EntityManager.prototype.queryComponents = function(componentTypes) {
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Slower way of retrieving objects
|
||||||
|
* @param constructors (array of constructors, or a constructor)
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
GameLib.EntityManager.prototype.queryComponentsByConstructor = function(constructors) {
|
||||||
|
return Object.keys(this.idRegister).reduce(
|
||||||
|
function(result, componentId) {
|
||||||
|
if (constructors instanceof Array) {
|
||||||
|
|
||||||
|
constructors.map(
|
||||||
|
function(constructor) {
|
||||||
|
if (this.idRegister[componentId] instanceof constructor) {
|
||||||
|
result.push(this.idRegister[componentId]);
|
||||||
|
}
|
||||||
|
}.bind(this)
|
||||||
|
)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if (this.idRegister[componentId] instanceof constructors) {
|
||||||
|
result.push(this.idRegister[componentId]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}.bind(this),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a GameLib.Entity to GameLib.API.Entity
|
* Converts a GameLib.Entity to GameLib.API.Entity
|
||||||
* @returns {GameLib.API.EntityManager}
|
* @returns {GameLib.API.EntityManager}
|
||||||
|
|
|
@ -384,7 +384,9 @@ GameLib.System.GUI.prototype.buildParentSelectionControl = function(folder, comp
|
||||||
|
|
||||||
var componentType = GameLib.Component[type];
|
var componentType = GameLib.Component[type];
|
||||||
|
|
||||||
var options = GameLib.EntityManager.Instance.queryComponents(componentType).reduce(
|
var constructor = GameLib.Component.GetComponentConstructor(componentType);
|
||||||
|
|
||||||
|
var options = GameLib.EntityManager.Instance.queryComponentsByConstructor(constructor).reduce(
|
||||||
function(result, object) {
|
function(result, object) {
|
||||||
result[object.name] = object;
|
result[object.name] = object;
|
||||||
return result;
|
return result;
|
||||||
|
@ -607,19 +609,19 @@ GameLib.System.GUI.prototype.buildSelectControl = function(folder, componentTemp
|
||||||
/**
|
/**
|
||||||
* We need to discover the constructor for this component
|
* We need to discover the constructor for this component
|
||||||
*/
|
*/
|
||||||
var constructor = null;
|
var constructors = null;
|
||||||
|
|
||||||
if (componentTemplate.template[property]) {
|
if (componentTemplate.template[property]) {
|
||||||
constructor = componentTemplate.template[property].constructor;
|
constructors = componentTemplate.template[property].constructor;
|
||||||
} else {
|
} else {
|
||||||
if (componentTemplate.template.linkedObjects[property]) {
|
if (componentTemplate.template.linkedObjects[property]) {
|
||||||
constructor = componentTemplate.template.linkedObjects[property];
|
constructors = componentTemplate.template.linkedObjects[property];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var object = componentTemplate.template;
|
var object = componentTemplate.template;
|
||||||
|
|
||||||
var objects = GameLib.EntityManager.Instance.queryComponents(constructor);
|
var objects = GameLib.EntityManager.Instance.queryComponentsByConstructor(constructors);
|
||||||
|
|
||||||
var idObject = {};
|
var idObject = {};
|
||||||
|
|
||||||
|
|
|
@ -756,7 +756,7 @@ GameLib.System.Input.prototype.onKeyDown = function(event) {
|
||||||
|
|
||||||
if (event.code === 'Delete') {
|
if (event.code === 'Delete') {
|
||||||
|
|
||||||
meshes = GameLib.EntityManager.Instance.queryComponents([GameLib.Component.MESH]);
|
meshes = GameLib.EntityManager.Instance.queryComponentsByConstructor(GameLib.D3.Mesh);
|
||||||
|
|
||||||
var deletedMeshes = [];
|
var deletedMeshes = [];
|
||||||
|
|
||||||
|
@ -792,7 +792,7 @@ GameLib.System.Input.prototype.onKeyDown = function(event) {
|
||||||
|
|
||||||
this.selectAll = !this.selectAll;
|
this.selectAll = !this.selectAll;
|
||||||
|
|
||||||
meshes = GameLib.EntityManager.Instance.queryComponents([GameLib.Component.MESH]);
|
meshes = GameLib.EntityManager.Instance.queryComponentsByConstructor(GameLib.D3.Mesh);
|
||||||
|
|
||||||
meshes.map(function(mesh){
|
meshes.map(function(mesh){
|
||||||
if (this.selectAll) {
|
if (this.selectAll) {
|
||||||
|
|
|
@ -606,10 +606,11 @@ GameLib.System.Linking.prototype.instanceCreated = function(data) {
|
||||||
/**
|
/**
|
||||||
* Check ALL components for 'parentScenes' - this is expensive so it checks the register directly
|
* Check ALL components for 'parentScenes' - this is expensive so it checks the register directly
|
||||||
*/
|
*/
|
||||||
GameLib.EntityManager.Instance.register.map(
|
|
||||||
function(component) {
|
Object.keys(GameLib.EntityManager.Instance.idRegister).map(
|
||||||
if (component.parentScene === data.component.id) {
|
function(componentId) {
|
||||||
component.parentScene = data.component;
|
if (GameLib.EntityManager.Instance.idRegister[componentId].parentScene === data.component.id) {
|
||||||
|
GameLib.EntityManager.Instance.idRegister[componentId].parentScene = data.component;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -652,22 +653,21 @@ GameLib.System.Linking.prototype.instanceCreated = function(data) {
|
||||||
* Also - it inspects the register directly instead of querying it twice (since it checks ALL components)
|
* Also - it inspects the register directly instead of querying it twice (since it checks ALL components)
|
||||||
*/
|
*/
|
||||||
if (!data.preventParentMeshCheck) {
|
if (!data.preventParentMeshCheck) {
|
||||||
GameLib.EntityManager.Instance.register.map(
|
|
||||||
function (component) {
|
|
||||||
if (component.parentMesh &&
|
|
||||||
component.parentMesh === data.component.id ) {
|
|
||||||
|
|
||||||
component.parentMesh = data.component;
|
|
||||||
|
|
||||||
|
Object.keys(GameLib.EntityManager.Instance.idRegister).map(
|
||||||
|
function(componentId) {
|
||||||
|
if (GameLib.EntityManager.Instance.idRegister[componentId].parentMesh === data.component.id) {
|
||||||
|
GameLib.EntityManager.Instance.idRegister[componentId].parentMesh = data.component;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Check if a component has this mesh as a parent
|
* Check if a component has this mesh as a parent
|
||||||
*/
|
*/
|
||||||
if (component instanceof GameLib.D3.Mesh) {
|
if (GameLib.EntityManager.Instance.idRegister[componentId] instanceof GameLib.D3.Mesh) {
|
||||||
component.setParentMesh(data.component);
|
GameLib.EntityManager.Instance.idRegister[componentId].setParentMesh(data.component);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue