In an ECS architecture imagine a very simple component representing the position of an entity on a game board. It only requires two integers: X and Y.
Possible approaches:
1) Plain component
class Position
{
public int X;
public int Y;
}
Very immediate. What bothers me is that I end up having multiple components like this (X and Y only) to represent other positions on the board, say a target location.
2) Component using a custom type
class Position
{
public Point Coords;
}
Same as above but it has the advantage of being able to reuse the features of the Point type (math operators come to mind). Actually the component IS the position so having to store its coords in a separate object/value seems awkard. Nonetheless I can't see any real drawbacks here, I think this is often better than #1.
3) Using a Point value as the component itself
Makes more sense imho. The serious drawback is that components cannot be referenced by their type anymore, they would need to be named (of course, that would be the same if we reused the Position class).
var entity = /* ... */
var myPosition = entity.GetComponent<Point>("Position");
var targetPosition = entity.GetComponent<Point>("Target");
var homePosition = entity.GetComponent<Point>("Home");
Naming is necessary because multiple Point components exist.
***
Actually I'm using solution #2. What's the best (usable in most cases) way of handling such situatuons in your opinion?