There's something that's always puzzled me about category bit masks, and I'm reaching a point where I'm going to need a greater understanding of them. I understand how they work on a fundamental level. Say I was making a dungeon crawler basic hack and slash capabilities. I might use a collection of categories like these:
enum PhysicsCategory{
static let none: UInt32 = 0
static let playerCategory: UInt32 = 0b1
static let enemyCategory: UInt32 = 0b10
static let weaponCategory: UInt32 = 0b100
static let collectibleCategory: UInt32 = 0b1000
static let enemyProjectileCategory: UInt32 = 0b10000
}
This would probably suffice, I could test if I'm attacking the enemy, they're attacking me, etc. That said, if I wanted to make a dungeon crawler with different enemy classes, different weapon types, and different enemy weaknesses and strengths, I feel like I'd run out of categories really fast:
enum PhysicsCategory{
static let none: UInt32 = 0
static let playerCategory: UInt32 = 0b1
static let toxicWeaponCategory: UInt32 = 0b10
static let iceWeaponCategory: UInt32 = 0b100
static let explosiveWeaponCategory: UInt32 = 0b1000
static let bluntWeaponCategory: UInt32 = 0b10000
static let toxicEnemyCategory: UInt32 = 0b100000
static let iceEnemyCategory: UInt32 = 0b1000000
static let explosiveEnemyCategory: UInt32 = 0b10000000
}
I run out of options for enemies and haven't even gotten to things like collectibles, environmental objects, or bosses whose weaknesses and/or strengths make entirely new combinations. How are these things typically accounted for? What I'm trying to make demands more than what you see above and the books / guides I've read only explain this on a very basic level.