1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2025-07-26 11:24:38 -04:00
OpenDiablo2/d2core/d2systems/game_client_bootstrap.go
gravestench e6d418fdb2 Adding input system, mouse cursor scene, interactive component
* added `d2common/d2input`, copied input vector logic from hellspawner
* added an `InteractiveComponent` which contains input vector, enable
flag, and callback function
* Added an InputSystem which handles input logic and iterates over
entities with interactive components
* added a mouse cursor scene for rendering the mouse cursor
* made the trademark sprite disappear when left mouse is clicked
* various other small bugfixes in scene systems
2020-12-07 12:44:11 -08:00

70 lines
1.7 KiB
Go

package d2systems
import (
"github.com/gravestench/akara"
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2util"
)
const (
logPrefixGameClientBootstrap = "Game Client Bootstrap"
)
// static check that the game config system implements the system interface
var _ akara.System = &GameClientBootstrapSystem{}
// GameClientBootstrapSystem is responsible for setting up other
// systems that are common to both the game client and the headless game server
type GameClientBootstrapSystem struct {
akara.BaseSubscriberSystem
*d2util.Logger
}
// Init injects the common systems required by both the game client and headless server
func (m *GameClientBootstrapSystem) Init(world *akara.World) {
m.World = world
m.setupLogger()
m.Info("initializing ...")
m.injectSystems()
m.Info("initialization complete")
if err := m.World.Update(0); err != nil {
m.Error(err.Error())
}
}
func (m *GameClientBootstrapSystem) setupLogger() {
m.Logger = d2util.NewLogger()
m.SetPrefix(logPrefixGameClientBootstrap)
}
func (m *GameClientBootstrapSystem) injectSystems() {
m.Info("injecting render system")
m.AddSystem(&RenderSystem{})
m.Info("injecting input system")
m.AddSystem(&InputSystem{})
m.Info("injecting update counter system")
m.AddSystem(&UpdateCounter{})
m.Info("injecting loading scene")
m.AddSystem(NewLoadingScene())
m.Info("injecting main menu scene")
m.AddSystem(NewMainMenuScene())
m.Info("injecting mouse cursor scene")
m.AddSystem(NewMouseCursorScene())
}
// Update does nothing, but exists to satisfy the `akara.System` interface
func (m *GameClientBootstrapSystem) Update() {
m.Info("game client bootstrap complete, deactivating")
m.RemoveSystem(m)
}