Users browsing this thread: 6 Guest(s)
Enribeaver
#16
my set up is an entitiy / component,
IGameObject (Position, isActive, isOnScreen, isSavable, Update, Draw, GUIdraw, onCreate, onDestroy, Save, Load, CreateInstance, CreateInstance(Position))
IGameObjectComponent (Owner, isActive, canUpdate, canDraw, canGUI, Update, Draw, GUI, Save, Load)
with 2 helper classes which flesh out stuff like isActive to have an event onActiveChange and to fill in CreateInstance (which is used in the level editor),
GameObject<T> : IGameObject where T : GameObject<T>, new()
GameObjectComponent<T> : IGameObjectComponent where T : GameObjectComponent<T>, new()
Objects are kept in a dictionary of lists of game objects, organised by type (this is for the sake of making the saving and loading flexible and efficient)
On saving the dictionary is passed through a foreach loop,
foreach type in dictionary, if type count > 0 save fully qualified name, foreach gameobject of type if isSavable, Save.
and in the loading the typename is loaded, the type is retrieved from Type.GetType, an object creator is created using DynamicMethod and MethodInvoker which pumps out empty instances to load.
My physics is run by PhysicsManager which keeps a list of all active PhysicsComponenet's, it handles the collision detection and response as well as applying air resistence and gravity, per the norm.
and for the sake of efficiency I also have a SpatialHashTable handling what gets updated / drawn and what doesn't.

I would have everything be component based but I didn't like the idea of saving components where in a lot of cases they'll start up the same every time (without need to load anything)
Thanked by:


Messages In This Thread
Enribeaver - by recme - 08-17-2012, 09:03 PM
RE: [IN DEVELOPMENT] Enribeaver - by Virt - 08-17-2012, 09:10 PM
RE: Enribeaver - by Zadaben - 08-27-2012, 01:17 PM
RE: Enribeaver - by recme - 01-18-2013, 10:29 PM
RE: Enribeaver - by TheShyGuy - 01-18-2013, 10:41 PM
RE: Enribeaver - by Phaze - 01-19-2013, 11:11 AM
RE: Enribeaver - by recme - 01-19-2013, 11:15 AM
RE: Enribeaver - by TheShyGuy - 02-04-2013, 06:31 PM
RE: Enribeaver - by TheShyGuy - 02-10-2013, 09:42 PM
RE: Enribeaver - by Bombshell93 - 02-11-2013, 02:40 AM
RE: Enribeaver - by TheShyGuy - 02-11-2013, 08:34 AM
RE: Enribeaver - by Bombshell93 - 02-11-2013, 09:23 AM
RE: Enribeaver - by TheShyGuy - 02-11-2013, 06:23 PM
RE: Enribeaver - by Bombshell93 - 02-12-2013, 04:31 AM
RE: Enribeaver - by TheShyGuy - 02-12-2013, 08:20 AM
RE: Enribeaver - by Phaze - 02-12-2013, 01:03 PM
RE: Enribeaver - by TheShyGuy - 02-14-2013, 09:01 PM
RE: Enribeaver - by Bombshell93 - 02-15-2013, 06:44 PM
RE: Enribeaver - by TheShyGuy - 02-15-2013, 09:41 PM
RE: Enribeaver - by Bombshell93 - 02-16-2013, 05:29 AM
RE: Enribeaver - by TheShyGuy - 02-16-2013, 01:06 PM
RE: Enribeaver - by Bombshell93 - 02-16-2013, 02:52 PM
RE: Enribeaver - by TheShyGuy - 02-16-2013, 04:53 PM
EnriBeaver Game - by Zadaben - 08-27-2012, 02:03 AM
RE: EnriBeaver Game - by Kopaka - 08-27-2012, 04:33 AM
RE: EnriBeaver Game - by Goemar - 08-27-2012, 07:11 AM
RE: EnriBeaver Game - by Virt - 08-27-2012, 07:20 AM

Forum Jump: