Hello every one, here’s my issue. I am trying to make a serverside authoritative server and for that, I need my ECS. The logic is like this
The manager has a slice of components, a slice of actions, and handlers for those actions. So movement action is handled by the movementHandler and so on. The movement handler gets the corresponding index and uses it to fetch the entity’s components and does its magic. Now handler as well needs a reference to the Manager to get the slices from him. So naturally, I wanted to split them up into a new package but this isn’t the Go way of working. So I keep them all in the ECS package, but this poses another problem, cluttering. I cannot move the handler implementations into their own folder as they have to all be in the same folder. With more and more handlers it would become a disaster probably.
package ecs
type MovementHandler struct {
manager *EntityManager
}
func (h *MovementHandler) HandleAction(indx uint16) {
}
package ecs
type EntityManager struct {
maxEntities uint8
indexPool []uint8
lastActiveEntity uint8
Actions []action.Action
AttackComponents []AttackComponent
MovementComponents []MovementComponent
PositionComponents []PositionComponent
AIComponents []AIComponent
movementHandler MovementHandler
}
I am newish to the Golang and the whole ecosystem, still getting used to everything. I’d like to find a way to somehow keep them as decoupled as possible while still maintaining the way my system works at the moment.
A code is worth 1000 words so here’s the code to the project. It probably has some other issues as well regarding the structure of the ECS
Thank you very much!