1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2025-02-10 02:26:29 -05:00
OpenDiablo2/d2core/d2systems/game_object_factory.go
gravestench 2e814f29b0 transform component, scene testing
* removed position,scale,rotation components
* added Transform component that contains position, rotation, and scale
* scene graph update now regenerates the local mat4 using the transform
component
* akara bugfix: adding new subscriptions will process existing entities
* added `--testscene` arg for testing individual scenes in isolation
* added rotation support to d2interface.Surface
2020-12-07 12:44:11 -08:00

52 lines
1.2 KiB
Go

package d2systems
import (
"github.com/gravestench/akara"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
)
const (
logPrefixGameObjectFactory = "Object Factory"
)
// static check that GameObjectFactory implements the System interface
var _ akara.System = &GameObjectFactory{}
// GameObjectFactory is a wrapper system for subordinate sceneSystems that
// do the actual object creation work.
type GameObjectFactory struct {
akara.BaseSystem
*d2util.Logger
*SpriteFactory
*ShapeSystem
}
// Init will initialize the Game Object Factory by injecting all of the factory subsystems into the world
func (t *GameObjectFactory) Init(world *akara.World) {
t.World = world
t.setupLogger()
t.Info("initializing ...")
t.injectSubSystems()
}
func (t *GameObjectFactory) setupLogger() {
t.Logger = d2util.NewLogger()
t.SetPrefix(logPrefixGameObjectFactory)
}
func (t *GameObjectFactory) injectSubSystems() {
t.Info("creating sprite factory")
t.SpriteFactory = NewSpriteFactorySubsystem(t.BaseSystem, t.Logger)
t.ShapeSystem = NewShapeSystem(t.BaseSystem, t.Logger)
}
// Update updates all the sub-sceneSystems
func (t *GameObjectFactory) Update() {
t.SpriteFactory.Update()
t.ShapeSystem.Update()
}