{"action":"created","issue":{"url":"https://api.github.com/repos/TeamPorcupine/ProjectPorcupine/issues/1310","repository_url":"https://api.github.com/repos/TeamPorcupine/ProjectPorcupine","labels_url":"https://api.github.com/repos/TeamPorcupine/ProjectPorcupine/issues/1310/labels{/name}","comments_url":"https://api.github.com/repos/TeamPorcupine/ProjectPorcupine/issues/1310/comments","events_url":"https://api.github.com/repos/TeamPorcupine/ProjectPorcupine/issues/1310/events","html_url":"https://github.com/TeamPorcupine/ProjectPorcupine/issues/1310","id":176826382,"number":1310,"title":"Using composition over inheritance for moddability","user":{"login":"pderuiter77","id":19798520,"avatar_url":"https://avatars.githubusercontent.com/u/19798520?v=3","gravatar_id":"","url":"https://api.github.com/users/pderuiter77","html_url":"https://github.com/pderuiter77","followers_url":"https://api.github.com/users/pderuiter77/followers","following_url":"https://api.github.com/users/pderuiter77/following{/other_user}","gists_url":"https://api.github.com/users/pderuiter77/gists{/gist_id}","starred_url":"https://api.github.com/users/pderuiter77/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pderuiter77/subscriptions","organizations_url":"https://api.github.com/users/pderuiter77/orgs","repos_url":"https://api.github.com/users/pderuiter77/repos","events_url":"https://api.github.com/users/pderuiter77/events{/privacy}","received_events_url":"https://api.github.com/users/pderuiter77/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-14T06:33:10Z","updated_at":"2016-09-14T08:27:43Z","closed_at":null,"body":"When we want this game to be moddable, most people think of it in terms of inheritance. I'd like to make a case against that, and for composition.\r\nWhy would we want that? Well, imagine you have the following classes:\r\n- Lamp. Obviously, gives off light. derives from installedobject\r\n- Bush. Something you place for beauty. derives from installedobject\r\n- Enemy. A pirate. Derives from character. can attack.\r\n\r\nBut now i want an enemy robot with builtin light. Or a sentient thorn bush that can attack you.\r\nIf you want to do this using inheritance, things get real messy, real fast.\r\n\r\nIf, however, you go the composition way, you just have 1 class: Entity. Anything in the world is an entity. But the behaviour / characteristics are in components. \r\nA light component. A beauty component. An attack component. An AI component.\r\n\r\nI hope you can see, that this way, we can just bolt on the stuff we want, without making a huge mess.\r\nA robot that can light its own surroundings? That's an entity with AI and light component.\r\nA thorn bush with an attitude? Entity with AI, light, attack and beauty.\r\n\r\nYou can do this for as much or as little as you like. We could make the tiles themselves entities. Or we use it just for characters / inventory / installed objects. \r\n\r\nI'll leave you with some links to articles about Entity Component Systems. There are several ways to implement this, so i hope we can leave any specific implementation details to later after we decide to go this route.\r\n\r\nhttps://en.wikipedia.org/wiki/Entity_component_system\r\nhttp://www.gamedev.net/page/resources/_/technical/game-programming/understanding-component-entity-systems-r3013\r\nhttps://www.raywenderlich.com/24878/introduction-to-component-based-architecture-in-games"},"comment":{"url":"https://api.github.com/repos/TeamPorcupine/ProjectPorcupine/issues/comments/246941872","html_url":"https://github.com/TeamPorcupine/ProjectPorcupine/issues/1310#issuecomment-246941872","issue_url":"https://api.github.com/repos/TeamPorcupine/ProjectPorcupine/issues/1310","id":246941872,"user":{"login":"sboigelot","id":6545998,"avatar_url":"https://avatars.githubusercontent.com/u/6545998?v=3","gravatar_id":"","url":"https://api.github.com/users/sboigelot","html_url":"https://github.com/sboigelot","followers_url":"https://api.github.com/users/sboigelot/followers","following_url":"https://api.github.com/users/sboigelot/following{/other_user}","gists_url":"https://api.github.com/users/sboigelot/gists{/gist_id}","starred_url":"https://api.github.com/users/sboigelot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sboigelot/subscriptions","organizations_url":"https://api.github.com/users/sboigelot/orgs","repos_url":"https://api.github.com/users/sboigelot/repos","events_url":"https://api.github.com/users/sboigelot/events{/privacy}","received_events_url":"https://api.github.com/users/sboigelot/received_events","type":"User","site_admin":false},"created_at":"2016-09-14T08:27:43Z","updated_at":"2016-09-14T08:27:43Z","body":"Entity system are great, a lot of time but also dangerous. I wouldn't make every tile an entity as it would be super costly in cpu cycle and mem usage.\r\n\r\nConsider that for each tile you would have to cycle through each behavior (or component) of the entity on each action/method on the tile. That's a lot of cycle.\r\n\r\nI would agree to change some things to a more entity-like system but not everything. And also, not everything being the same entity. We should have a different entity root for the furniture and the character for instance."}}
{"actor":{"display_login":"sboigelot"}}