Last active
August 29, 2015 14:02
-
-
Save kirbysayshi/b9389b5055530bafacea to your computer and use it in GitHub Desktop.
naming is hard.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Having trouble recitfying descriptive yet short names, since | |
// there is a Component (data structure initializer), the instance | |
// of a component (component data) for an entity id, and an entity, | |
// which is simply an object with an `id` property (for now). | |
// Other constrains include trying to keep return types consistent | |
// (always receive an array, or always an object), and providing | |
// query interfaces so the underlying system can be optimized (as | |
// opposed to raw Objects where you just insert a string key). | |
// There are three types of queries that need to be possible. | |
// A: a list of component names => array of entities (that have those component datas) | |
// B: a component name => map of entity_id -> component data | |
// C: a component name => first component data (not entity id) | |
// Currently A and B are provided via: | |
Pocket.prototype.entitiesForComponentNames = function([name1, name2]) { | |
return [entity_1, entity2, ... ] | |
} | |
Pocket.prototype.datasForComponentName = function(name1) { | |
return { entity_id1: data, entity_id2: data, ... } | |
} | |
// C can be accomplished (very hackily) via: | |
var data = datasForComponentName(name); | |
data = data[Object.keys(data)[0]]; | |
// Perhaps: | |
Pocket.prototype.taggedAsArray([name1, name2]) => entities[] | |
Pocket.prototype.taggedAsMap(name1) => { entity_id1: data, ... } | |
Pocket.prototype.taggedAsData(name1) => data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment