Object oriented round system/combining subclasses help

With OOP avoid using subclasses/inheritance

Because of this:

That is the diamond problem, I talked about it here like @JamminRedPandaMan said and why I moved on to use ECS instead (Though it has other problems like too many components and my bad organization because I’m new to ECS and didn’t plan my system).

If you are still going with an OOP approach consider componentizing it instead. Discussion here.

Instead of a IsA relationship you use HasA relationship maybe something like this?.

map.__index = map

function map.new(gamemode, mapSettings)
     local newmap= map.new()
     setmetatable(newmap, map)
     local mode = mode.new(mapSettings)
if mode == "CaptureTheFlag" then
self:AddFlagToMap()
end
     return newmap
end

Each map has a mode which can modify the map object.

Honestly either way, just functionalize everything make it easy to copy and paste when you need to rework the system eventually.

1 Like