Manta-X Code (Part 7)

Entity System

One thing that has bugged me on this whole project is that crappy entity messaging system. Now that things are simpler, leaner, I feel happy enough to get rid of it.

Removing it was fairly simple; the only 4 messages used now are Update and PreRender, Render and PostRender. Realistically, the way they’re used right now is that I have Update and Render. So I decided to collapse these down.

cloc 2120

Having dug through the entity system and fix a couple of bugs that fell out of removing the messaging system, I’ve realised that the game is simple enough to not even use the Entity class at all. I don’t have this deep object graph and if I needed it, I’d likely do it in a different way.

So, controverisally, I deleted it.

If you remember one of the earlier posts, the object graph looked like this:

   FSM
    ^
    |
  Entity        <--- IMMO
    ^
    |
GameObject      <--- ICollidable
    ^
    |
ModelEntity
    ^
    |
GameShip

Now it looks like this:

GameObject
    ^
    |
ModelEntity     <--- ICollidable
    ^
    |
GameShip

GameObject is basically the Entity class now.

I could probably collapse GameShip into ModelEntity, but I’m ok with how it is.

I moved ICollidable to the model - the only reason it’s even around is because the bounding box is being rendered and I didn’t want to remove that ‘feature’. If anything, it show how broken the hierarchy was in the first place. It’s still broken, but if I were to fix it, I’d write a basic component system instead.

Some final cleaning up of more junk, I’m left staring at the cloc.

cloc 1998

Less than 2000. From a starting point of almost 6000.

Journey’s End

I’m pretty much done with the cleanup of this old code. There’s nothing really I can do to it to strip it back and keep the same features.

And with that, we’re at the end of our old code journey. There’s a bunch of stuff I could do to this, but it’d be new code from there on, written in response of a new feature or requirement.

I’m going to sit back and consider what to do next. Do I use this as a test bed to reboot the project? Do I put it back in the box and leave it for another 12 years? I just don’t know at this point.

I have really enjoyed the ride - the insight into one’s own past and constrasting it with the current version of me.

I’ve enjoyed writing about this experience as much as the exploration itself. I hope you’ve enjoyed reading.

Old code is dead. Long live old code.