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
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1500,87 +1500,88 @@ GameLib.Component.prototype.toString = function() {
|
||||||
return this.id;
|
return this.id;
|
||||||
};
|
};
|
||||||
|
|
||||||
//GameLib.Component.PATH_FOLLOWING = 0x1;
|
//GameLib.Component.PATH_FOLLOWING = 0x1;
|
||||||
GameLib.Component.MATERIAL = 0x2;
|
GameLib.Component.MATERIAL = 0x2;
|
||||||
GameLib.Component.RENDERER = 0x3;
|
GameLib.Component.RENDERER = 0x3;
|
||||||
//GameLib.Component.LOOK_AT = 0x4;
|
//GameLib.Component.LOOK_AT = 0x4;
|
||||||
GameLib.Component.CAMERA = 0x5;
|
GameLib.Component.CAMERA = 0x5;
|
||||||
//GameLib.Component.FOLLOW = 0x6;
|
//GameLib.Component.FOLLOW = 0x6;
|
||||||
GameLib.Component.MESH = 0x7;
|
GameLib.Component.MESH = 0x7;
|
||||||
GameLib.Component.SPLINE = 0x8;
|
GameLib.Component.SPLINE = 0x8;
|
||||||
GameLib.Component.LIGHT = 0x9;
|
GameLib.Component.LIGHT = 0x9;
|
||||||
//GameLib.Component.INPUT_DRIVE = 0xa;
|
//GameLib.Component.INPUT_DRIVE = 0xa;
|
||||||
GameLib.Component.COMPOSER = 0xb;
|
GameLib.Component.COMPOSER = 0xb;
|
||||||
GameLib.Component.RENDER_TARGET = 0xc;
|
GameLib.Component.RENDER_TARGET = 0xc;
|
||||||
GameLib.Component.PASS = 0xd;
|
GameLib.Component.PASS = 0xd;
|
||||||
GameLib.Component.SCENE = 0xe;
|
GameLib.Component.SCENE = 0xe;
|
||||||
GameLib.Component.RAYCASTER = 0xf;
|
GameLib.Component.RAYCASTER = 0xf;
|
||||||
//GameLib.Component.INPUT_EDITOR = 0x10;
|
//GameLib.Component.INPUT_EDITOR = 0x10;
|
||||||
//GameLib.Component.EDITOR = 0x11;
|
//GameLib.Component.EDITOR = 0x11;
|
||||||
GameLib.Component.VIEWPORT = 0x12;
|
GameLib.Component.VIEWPORT = 0x12;
|
||||||
GameLib.Component.SYSTEM = 0x13;
|
GameLib.Component.SYSTEM = 0x13;
|
||||||
GameLib.Component.GRAPHICS = 0x14;
|
GameLib.Component.GRAPHICS = 0x14;
|
||||||
GameLib.Component.HELPER = 0x15;
|
GameLib.Component.HELPER = 0x15;
|
||||||
GameLib.Component.CUSTOM_CODE = 0x16;
|
GameLib.Component.CUSTOM_CODE = 0x16;
|
||||||
GameLib.Component.MOUSE = 0x17;
|
GameLib.Component.MOUSE = 0x17;
|
||||||
GameLib.Component.SKELETON = 0x18;
|
GameLib.Component.SKELETON = 0x18;
|
||||||
GameLib.Component.TEXTURE = 0x19;
|
GameLib.Component.TEXTURE = 0x19;
|
||||||
GameLib.Component.ENTITY_MANAGER = 0x1a;
|
GameLib.Component.ENTITY_MANAGER = 0x1a;
|
||||||
GameLib.Component.DOM_ELEMENT = 0x1b;
|
GameLib.Component.DOM_ELEMENT = 0x1b;
|
||||||
//GameLib.Component.IMAGE_FACTORY = 0x1c;
|
//GameLib.Component.IMAGE_FACTORY = 0x1c;
|
||||||
GameLib.Component.STATS = 0x1d;
|
GameLib.Component.STATS = 0x1d;
|
||||||
GameLib.Component.GUI = 0x1e;
|
GameLib.Component.GUI = 0x1e;
|
||||||
GameLib.Component.IMAGE = 0x1f;
|
GameLib.Component.IMAGE = 0x1f;
|
||||||
GameLib.Component.ENTITY = 0x20;
|
GameLib.Component.ENTITY = 0x20;
|
||||||
GameLib.Component.MESH_SPHERE = 0x21;
|
GameLib.Component.MESH_SPHERE = 0x21;
|
||||||
GameLib.Component.MESH_PLANE = 0x22;
|
GameLib.Component.MESH_PLANE = 0x22;
|
||||||
GameLib.Component.MESH_CURVE = 0x23;
|
GameLib.Component.MESH_CURVE = 0x23;
|
||||||
GameLib.Component.PHYSICS_WORLD = 0x24;
|
GameLib.Component.PHYSICS_WORLD = 0x24;
|
||||||
GameLib.Component.BROADPHASE = 0x25;
|
GameLib.Component.BROADPHASE = 0x25;
|
||||||
GameLib.Component.SOLVER = 0x26;
|
GameLib.Component.SOLVER = 0x26;
|
||||||
GameLib.Component.RIGID_BODY = 0x27;
|
GameLib.Component.RIGID_BODY = 0x27;
|
||||||
GameLib.Component.SHAPE = 0x28;
|
GameLib.Component.SHAPE = 0x28;
|
||||||
GameLib.Component.SHAPE_BOX = 0x29;
|
GameLib.Component.SHAPE_BOX = 0x29;
|
||||||
GameLib.Component.SHAPE_SPHERE = 0x2a;
|
GameLib.Component.SHAPE_SPHERE = 0x2a;
|
||||||
GameLib.Component.SHAPE_TRI_MESH = 0x2b;
|
GameLib.Component.SHAPE_TRI_MESH = 0x2b;
|
||||||
GameLib.Component.SHAPE_CONVEX_HULL = 0x2c;
|
GameLib.Component.SHAPE_CONVEX_HULL = 0x2c;
|
||||||
GameLib.Component.SHAPE_CONVEX_HULL_CYLINDER = 0x2d;
|
GameLib.Component.SHAPE_CONVEX_HULL_CYLINDER = 0x2d;
|
||||||
GameLib.Component.SHAPE_HEIGHT_MAP = 0x2e;
|
GameLib.Component.SHAPE_HEIGHT_MAP = 0x2e;
|
||||||
GameLib.Component.SHAPE_PLANE = 0x2f;
|
GameLib.Component.SHAPE_PLANE = 0x2f;
|
||||||
GameLib.Component.CONTROLS = 0x30;
|
GameLib.Component.CONTROLS = 0x30;
|
||||||
GameLib.Component.CONTROLS_EDITOR = 0x31;
|
GameLib.Component.CONTROLS_EDITOR = 0x31;
|
||||||
GameLib.Component.CONTROLS_TOUCH = 0x32;
|
GameLib.Component.CONTROLS_TOUCH = 0x32;
|
||||||
GameLib.Component.FRICTION_MATERIAL = 0x33;
|
GameLib.Component.FRICTION_MATERIAL = 0x33;
|
||||||
GameLib.Component.FRICTION_CONTACT_MATERIAL = 0x34;
|
GameLib.Component.FRICTION_CONTACT_MATERIAL = 0x34;
|
||||||
GameLib.Component.RAYCAST_VEHICLE = 0x35;
|
GameLib.Component.RAYCAST_VEHICLE = 0x35;
|
||||||
GameLib.Component.RAYCAST_WHEEL = 0x36;
|
GameLib.Component.RAYCAST_WHEEL = 0x36;
|
||||||
GameLib.Component.CLOCK = 0x37;
|
GameLib.Component.CLOCK = 0x37;
|
||||||
GameLib.Component.ANIMATION = 0x38;
|
GameLib.Component.ANIMATION = 0x38;
|
||||||
GameLib.Component.CONTROLS_KEYBOARD = 0x39;
|
GameLib.Component.CONTROLS_KEYBOARD = 0x39;
|
||||||
GameLib.Component.CONTROLS_MOUSE = 0x3a;
|
GameLib.Component.CONTROLS_MOUSE = 0x3a;
|
||||||
GameLib.Component.MESH_TEXT = 0x3b;
|
GameLib.Component.MESH_TEXT = 0x3b;
|
||||||
GameLib.Component.FONT = 0x3c;
|
GameLib.Component.FONT = 0x3c;
|
||||||
GameLib.Component.CANVAS = 0x3d;
|
GameLib.Component.CANVAS = 0x3d;
|
||||||
GameLib.Component.BONE = 0x3e;
|
GameLib.Component.BONE = 0x3e;
|
||||||
GameLib.Component.MESH_BOX = 0x3f;
|
GameLib.Component.MESH_BOX = 0x3f;
|
||||||
GameLib.Component.MESH_CYLINDER = 0x40;
|
GameLib.Component.MESH_CYLINDER = 0x40;
|
||||||
GameLib.Component.SYSTEM_ANIMATION = 0x41;
|
GameLib.Component.SYSTEM_ANIMATION = 0x41;
|
||||||
GameLib.Component.SYSTEM_CUSTOM_CODE = 0x42;
|
GameLib.Component.SYSTEM_CUSTOM_CODE = 0x42;
|
||||||
GameLib.Component.SYSTEM_GUI = 0x43;
|
GameLib.Component.SYSTEM_GUI = 0x43;
|
||||||
GameLib.Component.SYSTEM_INPUT = 0x44;
|
GameLib.Component.SYSTEM_INPUT = 0x44;
|
||||||
GameLib.Component.SYSTEM_LINKING = 0x45;
|
GameLib.Component.SYSTEM_LINKING = 0x45;
|
||||||
GameLib.Component.SYSTEM_PHYSICS = 0x46;
|
GameLib.Component.SYSTEM_PHYSICS = 0x46;
|
||||||
GameLib.Component.SYSTEM_RENDER = 0x47;
|
GameLib.Component.SYSTEM_RENDER = 0x47;
|
||||||
GameLib.Component.SYSTEM_STORAGE = 0x48;
|
GameLib.Component.SYSTEM_STORAGE = 0x48;
|
||||||
GameLib.Component.SYSTEM_VISUALIZATION = 0x49;
|
GameLib.Component.SYSTEM_VISUALIZATION = 0x49;
|
||||||
GameLib.Component.FOG = 0x50;
|
GameLib.Component.FOG = 0x50;
|
||||||
GameLib.Component.MESH_LINE = 0x51;
|
GameLib.Component.MESH_LINE = 0x51;
|
||||||
GameLib.Component.PARTICLE_ENGINE = 0x52;
|
GameLib.Component.PARTICLE_ENGINE = 0x52;
|
||||||
GameLib.Component.SYSTEM_PARTICLE = 0x53;
|
GameLib.Component.SYSTEM_PARTICLE = 0x53;
|
||||||
GameLib.Component.PARTICLE = 0x54;
|
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,23 +30305,22 @@ 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) {
|
||||||
* Check if a component has this mesh as a parent
|
GameLib.EntityManager.Instance.idRegister[componentId].parentMesh = data.component;
|
||||||
*/
|
}
|
||||||
if (component instanceof GameLib.D3.Mesh) {
|
/**
|
||||||
component.setParentMesh(data.component);
|
* Check if a component has this mesh as a parent
|
||||||
}
|
*/
|
||||||
|
if (GameLib.EntityManager.Instance.idRegister[componentId] instanceof GameLib.D3.Mesh) {
|
||||||
|
GameLib.EntityManager.Instance.idRegister[componentId].setParentMesh(data.component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -204,87 +204,88 @@ GameLib.Component.prototype.toString = function() {
|
||||||
return this.id;
|
return this.id;
|
||||||
};
|
};
|
||||||
|
|
||||||
//GameLib.Component.PATH_FOLLOWING = 0x1;
|
//GameLib.Component.PATH_FOLLOWING = 0x1;
|
||||||
GameLib.Component.MATERIAL = 0x2;
|
GameLib.Component.MATERIAL = 0x2;
|
||||||
GameLib.Component.RENDERER = 0x3;
|
GameLib.Component.RENDERER = 0x3;
|
||||||
//GameLib.Component.LOOK_AT = 0x4;
|
//GameLib.Component.LOOK_AT = 0x4;
|
||||||
GameLib.Component.CAMERA = 0x5;
|
GameLib.Component.CAMERA = 0x5;
|
||||||
//GameLib.Component.FOLLOW = 0x6;
|
//GameLib.Component.FOLLOW = 0x6;
|
||||||
GameLib.Component.MESH = 0x7;
|
GameLib.Component.MESH = 0x7;
|
||||||
GameLib.Component.SPLINE = 0x8;
|
GameLib.Component.SPLINE = 0x8;
|
||||||
GameLib.Component.LIGHT = 0x9;
|
GameLib.Component.LIGHT = 0x9;
|
||||||
//GameLib.Component.INPUT_DRIVE = 0xa;
|
//GameLib.Component.INPUT_DRIVE = 0xa;
|
||||||
GameLib.Component.COMPOSER = 0xb;
|
GameLib.Component.COMPOSER = 0xb;
|
||||||
GameLib.Component.RENDER_TARGET = 0xc;
|
GameLib.Component.RENDER_TARGET = 0xc;
|
||||||
GameLib.Component.PASS = 0xd;
|
GameLib.Component.PASS = 0xd;
|
||||||
GameLib.Component.SCENE = 0xe;
|
GameLib.Component.SCENE = 0xe;
|
||||||
GameLib.Component.RAYCASTER = 0xf;
|
GameLib.Component.RAYCASTER = 0xf;
|
||||||
//GameLib.Component.INPUT_EDITOR = 0x10;
|
//GameLib.Component.INPUT_EDITOR = 0x10;
|
||||||
//GameLib.Component.EDITOR = 0x11;
|
//GameLib.Component.EDITOR = 0x11;
|
||||||
GameLib.Component.VIEWPORT = 0x12;
|
GameLib.Component.VIEWPORT = 0x12;
|
||||||
GameLib.Component.SYSTEM = 0x13;
|
GameLib.Component.SYSTEM = 0x13;
|
||||||
GameLib.Component.GRAPHICS = 0x14;
|
GameLib.Component.GRAPHICS = 0x14;
|
||||||
GameLib.Component.HELPER = 0x15;
|
GameLib.Component.HELPER = 0x15;
|
||||||
GameLib.Component.CUSTOM_CODE = 0x16;
|
GameLib.Component.CUSTOM_CODE = 0x16;
|
||||||
GameLib.Component.MOUSE = 0x17;
|
GameLib.Component.MOUSE = 0x17;
|
||||||
GameLib.Component.SKELETON = 0x18;
|
GameLib.Component.SKELETON = 0x18;
|
||||||
GameLib.Component.TEXTURE = 0x19;
|
GameLib.Component.TEXTURE = 0x19;
|
||||||
GameLib.Component.ENTITY_MANAGER = 0x1a;
|
GameLib.Component.ENTITY_MANAGER = 0x1a;
|
||||||
GameLib.Component.DOM_ELEMENT = 0x1b;
|
GameLib.Component.DOM_ELEMENT = 0x1b;
|
||||||
//GameLib.Component.IMAGE_FACTORY = 0x1c;
|
//GameLib.Component.IMAGE_FACTORY = 0x1c;
|
||||||
GameLib.Component.STATS = 0x1d;
|
GameLib.Component.STATS = 0x1d;
|
||||||
GameLib.Component.GUI = 0x1e;
|
GameLib.Component.GUI = 0x1e;
|
||||||
GameLib.Component.IMAGE = 0x1f;
|
GameLib.Component.IMAGE = 0x1f;
|
||||||
GameLib.Component.ENTITY = 0x20;
|
GameLib.Component.ENTITY = 0x20;
|
||||||
GameLib.Component.MESH_SPHERE = 0x21;
|
GameLib.Component.MESH_SPHERE = 0x21;
|
||||||
GameLib.Component.MESH_PLANE = 0x22;
|
GameLib.Component.MESH_PLANE = 0x22;
|
||||||
GameLib.Component.MESH_CURVE = 0x23;
|
GameLib.Component.MESH_CURVE = 0x23;
|
||||||
GameLib.Component.PHYSICS_WORLD = 0x24;
|
GameLib.Component.PHYSICS_WORLD = 0x24;
|
||||||
GameLib.Component.BROADPHASE = 0x25;
|
GameLib.Component.BROADPHASE = 0x25;
|
||||||
GameLib.Component.SOLVER = 0x26;
|
GameLib.Component.SOLVER = 0x26;
|
||||||
GameLib.Component.RIGID_BODY = 0x27;
|
GameLib.Component.RIGID_BODY = 0x27;
|
||||||
GameLib.Component.SHAPE = 0x28;
|
GameLib.Component.SHAPE = 0x28;
|
||||||
GameLib.Component.SHAPE_BOX = 0x29;
|
GameLib.Component.SHAPE_BOX = 0x29;
|
||||||
GameLib.Component.SHAPE_SPHERE = 0x2a;
|
GameLib.Component.SHAPE_SPHERE = 0x2a;
|
||||||
GameLib.Component.SHAPE_TRI_MESH = 0x2b;
|
GameLib.Component.SHAPE_TRI_MESH = 0x2b;
|
||||||
GameLib.Component.SHAPE_CONVEX_HULL = 0x2c;
|
GameLib.Component.SHAPE_CONVEX_HULL = 0x2c;
|
||||||
GameLib.Component.SHAPE_CONVEX_HULL_CYLINDER = 0x2d;
|
GameLib.Component.SHAPE_CONVEX_HULL_CYLINDER = 0x2d;
|
||||||
GameLib.Component.SHAPE_HEIGHT_MAP = 0x2e;
|
GameLib.Component.SHAPE_HEIGHT_MAP = 0x2e;
|
||||||
GameLib.Component.SHAPE_PLANE = 0x2f;
|
GameLib.Component.SHAPE_PLANE = 0x2f;
|
||||||
GameLib.Component.CONTROLS = 0x30;
|
GameLib.Component.CONTROLS = 0x30;
|
||||||
GameLib.Component.CONTROLS_EDITOR = 0x31;
|
GameLib.Component.CONTROLS_EDITOR = 0x31;
|
||||||
GameLib.Component.CONTROLS_TOUCH = 0x32;
|
GameLib.Component.CONTROLS_TOUCH = 0x32;
|
||||||
GameLib.Component.FRICTION_MATERIAL = 0x33;
|
GameLib.Component.FRICTION_MATERIAL = 0x33;
|
||||||
GameLib.Component.FRICTION_CONTACT_MATERIAL = 0x34;
|
GameLib.Component.FRICTION_CONTACT_MATERIAL = 0x34;
|
||||||
GameLib.Component.RAYCAST_VEHICLE = 0x35;
|
GameLib.Component.RAYCAST_VEHICLE = 0x35;
|
||||||
GameLib.Component.RAYCAST_WHEEL = 0x36;
|
GameLib.Component.RAYCAST_WHEEL = 0x36;
|
||||||
GameLib.Component.CLOCK = 0x37;
|
GameLib.Component.CLOCK = 0x37;
|
||||||
GameLib.Component.ANIMATION = 0x38;
|
GameLib.Component.ANIMATION = 0x38;
|
||||||
GameLib.Component.CONTROLS_KEYBOARD = 0x39;
|
GameLib.Component.CONTROLS_KEYBOARD = 0x39;
|
||||||
GameLib.Component.CONTROLS_MOUSE = 0x3a;
|
GameLib.Component.CONTROLS_MOUSE = 0x3a;
|
||||||
GameLib.Component.MESH_TEXT = 0x3b;
|
GameLib.Component.MESH_TEXT = 0x3b;
|
||||||
GameLib.Component.FONT = 0x3c;
|
GameLib.Component.FONT = 0x3c;
|
||||||
GameLib.Component.CANVAS = 0x3d;
|
GameLib.Component.CANVAS = 0x3d;
|
||||||
GameLib.Component.BONE = 0x3e;
|
GameLib.Component.BONE = 0x3e;
|
||||||
GameLib.Component.MESH_BOX = 0x3f;
|
GameLib.Component.MESH_BOX = 0x3f;
|
||||||
GameLib.Component.MESH_CYLINDER = 0x40;
|
GameLib.Component.MESH_CYLINDER = 0x40;
|
||||||
GameLib.Component.SYSTEM_ANIMATION = 0x41;
|
GameLib.Component.SYSTEM_ANIMATION = 0x41;
|
||||||
GameLib.Component.SYSTEM_CUSTOM_CODE = 0x42;
|
GameLib.Component.SYSTEM_CUSTOM_CODE = 0x42;
|
||||||
GameLib.Component.SYSTEM_GUI = 0x43;
|
GameLib.Component.SYSTEM_GUI = 0x43;
|
||||||
GameLib.Component.SYSTEM_INPUT = 0x44;
|
GameLib.Component.SYSTEM_INPUT = 0x44;
|
||||||
GameLib.Component.SYSTEM_LINKING = 0x45;
|
GameLib.Component.SYSTEM_LINKING = 0x45;
|
||||||
GameLib.Component.SYSTEM_PHYSICS = 0x46;
|
GameLib.Component.SYSTEM_PHYSICS = 0x46;
|
||||||
GameLib.Component.SYSTEM_RENDER = 0x47;
|
GameLib.Component.SYSTEM_RENDER = 0x47;
|
||||||
GameLib.Component.SYSTEM_STORAGE = 0x48;
|
GameLib.Component.SYSTEM_STORAGE = 0x48;
|
||||||
GameLib.Component.SYSTEM_VISUALIZATION = 0x49;
|
GameLib.Component.SYSTEM_VISUALIZATION = 0x49;
|
||||||
GameLib.Component.FOG = 0x50;
|
GameLib.Component.FOG = 0x50;
|
||||||
GameLib.Component.MESH_LINE = 0x51;
|
GameLib.Component.MESH_LINE = 0x51;
|
||||||
GameLib.Component.PARTICLE_ENGINE = 0x52;
|
GameLib.Component.PARTICLE_ENGINE = 0x52;
|
||||||
GameLib.Component.SYSTEM_PARTICLE = 0x53;
|
GameLib.Component.SYSTEM_PARTICLE = 0x53;
|
||||||
GameLib.Component.PARTICLE = 0x54;
|
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,23 +653,22 @@ 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) {
|
||||||
* Check if a component has this mesh as a parent
|
GameLib.EntityManager.Instance.idRegister[componentId].parentMesh = data.component;
|
||||||
*/
|
}
|
||||||
if (component instanceof GameLib.D3.Mesh) {
|
/**
|
||||||
component.setParentMesh(data.component);
|
* Check if a component has this mesh as a parent
|
||||||
}
|
*/
|
||||||
|
if (GameLib.EntityManager.Instance.idRegister[componentId] instanceof GameLib.D3.Mesh) {
|
||||||
|
GameLib.EntityManager.Instance.idRegister[componentId].setParentMesh(data.component);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue