fix logger

This commit is contained in:
2020-09-25 00:45:45 +03:00
parent d2b22f4760
commit 9f3eaafa3f
21 changed files with 115 additions and 79 deletions

View File

@ -3,13 +3,11 @@ package ecs
// ECS system by jcerise, github.com/jcerise/gogue
import (
"context"
"lab.zaar.be/thefish/alchemyst-go/util/appctx"
"sort"
)
type Controller struct {
ctx context.Context
systems map[string]System
sortedSystems map[int][]System
priorityKeys []int
@ -23,8 +21,8 @@ type Controller struct {
}
// NewController is a convenience/constructor method to properly initialize a new processor
func NewController(ctx context.Context) *Controller {
controller := Controller{ctx: ctx}
func NewController() *Controller {
controller := Controller{}
controller.systems = make(map[string]System)
controller.sortedSystems = make(map[int][]System)
controller.priorityKeys = []int{}
@ -80,7 +78,7 @@ func (c *Controller) GetMappedComponentClass(componentName string) Component {
return c.componentMap[componentName]
} else {
// TODO: Add better (read: actual) error handling here
appctx.Logger(c.ctx).Warn().Msgf("Component[%s] not registered on Controller.\n", componentName)
appctx.Logger().Warn().Msgf("Component[%s] not registered on Controller.\n", componentName)
return nil
}
}
@ -208,7 +206,7 @@ func (c *Controller) AddSystem(system System, priority int) {
c.sortedSystems[priority] = append(c.sortedSystems[priority], system)
sort.Ints(c.priorityKeys)
} else {
appctx.Logger(c.ctx).Warn().Msgf("A system of type %v was already added to the controller %v!", systemType, c)
appctx.Logger().Warn().Msgf("A system of type %v was already added to the controller %v!", systemType, c)
}
}