rendering items, pick up, iventory re-make in progress to aloow item drop/wear/whatever

This commit is contained in:
2019-11-17 02:09:41 +03:00
parent 685dfeeeb1
commit 0a6c642dc2
12 changed files with 349 additions and 207 deletions

View File

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