Lobby + Rooms with different game modes

I’m currently stuck on ideas of how to make multiple rooms with different modes like tdm and dm. I currently have 1 Room/World where I loop through entities and update them, I handle collisions inside the entity’s class so for example Bullet. The bullet would need to hit all players in a DM but when playing TDM it shouldn’t hit teammates. I don’t like the idea of putting if statements in Bullet in this case to check what mode I’m playing and what it should hit.

Don’t check mode, have attributes.

A set of options like you’ve seen in any major game server config:

  • friendly fire
  • available weapon classes
  • perhaps even stuff like gravity, etc.

Then game modes are mostly combinations of these options, with maybe also different win conditions/ui things that have to be specialized.

(this is all server-side) But the thing is I have for example a Bullet class where I check for collisions with entities. How would I make it only hit certain things without if statements. So I have a World class where I loop through entities which all handle collision in their own class.
Maybe I don’t fully understand ur idea :frowning:

Usually bullets and such have a flag or id for the entity who shot it, so you can track who hit who, etc. This also allows you to filter out collision bodies whose owners are on the same team as the bullet’s owner’s team, or at least negate damage towards. (i.e. you don’t want pass-through)

So there’s no escape to checking which gamemode i’m playing in the Bullet so I know when to apply damage.
I could make a flag for which gamemode the player is doing. and then put a Player/Who shot into projectile/bullet and when applying collisions see which mode it is doing?
That’s what I was trying to avoid, but I see no other solution

Well no since if the gamemode determines bullet behavior, then the bullets’s behavior is dependent on the gamemode :stuck_out_tongue:
How it’s implemented is another matter though. Straight if statements, inheritance driven, entity-component composition driven, etc.

Or I’d have to override collision code of the bullet in the Room class

for (every bullet) {
move
check collision and apply effects like damage
}

instead of
for (every bullet) {
bullet.update();
}