I'm using the EntityIDs enum to differentiate between what kinds of objects are colliding during each Collide() function. So my IDs consist of things like Block, Player, Enemy, etc. It's what I'd figure I'd use. Since I don't intend to have any of the types change it's also a constant that is accessible publicly so I don't have to have a GetType function. Just other->ID. That's still fine, right? Though I guess it is kind of a hassle with stuff like this.
Yep, that's still fine.
EntityIDs implies (at least to me) that it's a unique identifier per entity instance. EntityTypeID would perhaps be a better name, since it implies each type of entity (Block, Enemy, etc...) has a unique ID.
I've seen games that have entities that each have unique IDs. Would I come up with some method for generating one and then initialize them with that unique ID in a similar fashion?
Having a unique ID per-entity is useful for other purposes, but isn't what you want here for implementing your collision logic. If you want both (for those other uses), you could do it like:
//__int32 is implementation-specific. int32_t and uint32_t are standardized,
//but you need to #include <cinttypes> for it.
#include <cinttypes>
enum class EntityType { Player, Block, Enemy };
class Entity
{
public:
const uint32_t ID; //Unique per entity.
const EntityType Type; //Unique per type.
public:
Entity(uint32_t id, EntityType entityType) : ID(id), Type(entityType) { }
protected:
static uint32_t generateNextID() { return ++nextEntityID; }
private:
static uint32_t nextEntityID = 0;
};
class Block
{
public:
Block() : Entity(Entity::generateNextID(), EntityType::Block) { }
};
<opinion>
...but personally, I don't think entities should know their own ID. Usually, the ID is only used outside of the entity class to find the right entity, so I just do std::unordered_map<EntityID, Entity>, where the map is allowed to do its job of mapping the IDs to the entities.
And if performance becomes an issue during iteration, due to thousands of entities at once, I'd use a vector of entities with a unordered_map<EntityID, VectorIndex> backing it up.
</opinion>
But the simplest way starting out would be to keep the ID in the entity, and keep the entities in a vector, and search the vector for the correct entity when needed.
Important: Don't forget that when using polymorphism (i.e. treating a Derived as if it's a Base), you must refer to your instances by pointers! You can't do Base myBase = Derived, or it crams the bits of the Derived into a Base variable, parts of it get lost, and bad things result.