For my latest (small) project I thought I'd try out a slightly different way of doing things, namely I've decided to try using MVC for a game.
I've got a reasonable handle on it in terms of observers and events in the model and communicating these to the view (and controller), however I'm having a bit of difficultly in figuring out how to completely eliminate data about the graphical representation from the model.
Take this (massively simple) example of a fairly basic RPG. Since my model is data-driven, I have a single "Unit" class which contains information about the units (no need for Troll, Goblin, etc subclasses).
string name; //Friendly name, e.g. Dave
Unit(string name, int hp, int damage);
Then in my model I keep a list of these Units as well as a method to retrieve them so the view can access them.
class Model // LevelState or similar would be a better name for this
The problem occurs when I come to drawing the units, as far as my model is concerned it doesn't care about if the unit is a goblin, an archer or a giant salamader, all it cares about is the unit's stats which define it's behavior.
However, the view very much cares about if the unit is a goblin, an archer or a giant salamader as it will have to draw different sprites for each of them.
What is the best way to solve this? I could add an enumerated "type" field to the Unit class, but this feels wrong as it's polluting the model with data that it doesn't care about, but I really can't see any other way of doing this.
Am I just overthinking and getting too concerned with what is "right" and "clean"?
I'm currently using the NDK with SDL2 (ex. 1.3) and it's been a piece of cake. Sure, the debuging options are limited, but so long as you setup some defines for logging (so you can use the logcat) and learn how to use gdb it's not too bad. It helps if you can help your project for a different platform (e.g. Linux or Windows) and debug on there, but this may not be possible depending on what you are doing.
I'm sharing code between Windows, OSX, Linux and Android (all non-NEON devices, as SDL doesn't build correctly for them) at the moment, using CMake to build all of the projects except the Android one - where I use the NDK tools on Linux, but I've tested Cygwin and that works too. Eventually I'll add iOS in the mix, but I thought I'd leave that for a while (this is probably a massive mistake) as I wanted to get on and actually start developing.
At some point I'll clear out all the project specific code and upload a blank project template to bitbucket or github, since it's taken a little bit of work to get it all working, but now it is all setup it's a doddle.
I believe Marshal.SizeOf and the typeof() operator should do what you need, it's been a while since I've used it though and I'm not sat in front of a computer I can test this on, but hopefully the following should work.
I've personally only just started on a Component system over the weekend, with a few iterations, and I'm very much of the opinion (so far) that the "best" way to go is that a component is small, focused, data-only object, with the Subsystem for the component managing any behaviors and dependancies on other components/subsystems.
I could be wrong in this, and only time will tell, but even setting up the components and subsystems has been a far more rapid process than any OO approach I've tried in the past since I don't need to plan out my inheritance tree and interactions in advance, I only have to worry about these when I add a new component type/subsystem.
The problem I'm having at the moment though is how best to make the subsystems communicate. Currently I have a Game class that contains all the subsystems, which every subsystem holds a reference to so they can all find each other, but it doesn't seem clean to me. Then again, I could just be fussing too much over it since, well, it works and at the end of the day I guess that is what matters.