Last active
August 29, 2015 14:06
-
-
Save maxov/3d2c7e740fa3db20f97b to your computer and use it in GitHub Desktop.
Body-Component-System
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
// Represents a thing in the game world | |
interface Body { | |
int getID(); | |
} | |
// Represents a behavior | |
interface Component { | |
} | |
// Manages a single component | |
interface ComponentSystem<C extends Component> { | |
C add(int body, Component c); | |
C get(int body); | |
C remove(int body, C component); | |
boolean has(int body); | |
} | |
// Manages a set of bodies | |
interface ComponentContext { | |
Body spawn(); | |
Body despawn(int id); | |
List<Body> getAllBodies(); | |
} | |
// Finally: Manages a set of ComponentSystems, as well as the ComponentContext they act on | |
// Note: Can totally merge this with ComponentContext. | |
interface ComponentManager { | |
void add(ComponentSystem system); | |
void remove(ComponentSystem system); | |
ComponentContext getContext(); | |
void setContext(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment