Timeline for Implementing Entity and Component in a game engine
Current License: CC BY-SA 3.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Mar 18, 2016 at 21:03 | comment | added | CXO2 |
Thanks for your help, I need one more thing to clarify: how about the Components? the main purpose of Component is to add, remove as well as modify an Entity behavior. for example: I need to add IUpdatable and IRenderable Component to an Entity while the Entity itself doesn't implement those interfaces. In such case, the Component need to be updated (and rendered) on each frame while the Entity itself is not (It's sounds make sense for me). What should I do in such case? is Component should apply same rule as the Child? or let the Scene handle the Component stuffs?
|
|
| Mar 18, 2016 at 14:18 | comment | added | somebody |
If you want to prevent the IRenderable from being added, the easiest way is probably to have a method that takes an Entity parent, and Entity child, then in the function do something like: if (!parent is <interface> && child is <interface>) {throw new <yourexception>("<interface>")}, where <yourexception> prints something like "Parent does not support {0}", interface
|
|
| Mar 18, 2016 at 14:12 | comment | added | CXO2 | Thanks for your clarification, and I saw your edited answer everything seems to be clear now! | |
| Mar 18, 2016 at 14:02 | history | edited | somebody | CC BY-SA 3.0 |
added 456 characters in body
|
| Mar 18, 2016 at 13:52 | comment | added | somebody |
The method in the Entity should render its children, especially especially since it may be nested. The Render method should do everything the Entity needs to render fully, but it should always be called by the renderer.
|
|
| Mar 18, 2016 at 13:50 | comment | added | CXO2 |
Thanks for your reply, I changed type casting code and use Dictionary to store the components. About the braces, I stripped the braces from original codes for simplicity sake, I'll edit the question. Anyway, so the Scene is the one that should calling the Render method of an Entity and it's children?
|
|
| Mar 18, 2016 at 13:26 | history | answered | somebody | CC BY-SA 3.0 |