108 lines
2.4 KiB
Go
108 lines
2.4 KiB
Go
package machine
|
|
|
|
import (
|
|
"mongo.games.com/game/gamesrv/slotspkg/slots/intf"
|
|
"mongo.games.com/game/gamesrv/slotspkg/slots/reg"
|
|
"reflect"
|
|
)
|
|
|
|
// OnInit is called after Init
|
|
func (m *Machine) OnInit() {
|
|
if _, ok := reg.Plugins[m.Theme]; !ok {
|
|
return
|
|
}
|
|
|
|
for _, t := range reg.Plugins[m.Theme] {
|
|
reflect.New(t.Elem()).Interface().(intf.Plugin).OnInit(m)
|
|
}
|
|
}
|
|
|
|
// OnStepBegin is called on step initializing
|
|
func (m *Machine) OnStepBegin() {
|
|
if _, ok := reg.Plugins[m.Theme]; !ok {
|
|
return
|
|
}
|
|
|
|
for _, t := range reg.Plugins[m.Theme] {
|
|
reflect.New(t.Elem()).Interface().(intf.Plugin).OnStepBegin(m)
|
|
}
|
|
}
|
|
|
|
// BeforeSpin is called before Spin
|
|
func (m *Machine) BeforeSpin() {
|
|
if _, ok := reg.Plugins[m.Theme]; !ok {
|
|
return
|
|
}
|
|
|
|
if m.CursorNode().ProgressValue == 0 && !m.CursorNode().Prepared {
|
|
for _, t := range reg.Plugins[m.Theme] {
|
|
reflect.New(t.Elem()).Interface().(intf.Plugin).OnEnterNode(m)
|
|
}
|
|
}
|
|
|
|
for _, t := range reg.Plugins[m.Theme] {
|
|
reflect.New(t.Elem()).Interface().(intf.Plugin).BeforeSpin(m)
|
|
}
|
|
}
|
|
|
|
// BeforeDisplay is call before display
|
|
func (m *Machine) BeforeDisplay() {
|
|
if _, ok := reg.Plugins[m.Theme]; !ok {
|
|
return
|
|
}
|
|
|
|
for _, t := range reg.Plugins[m.Theme] {
|
|
reflect.New(t.Elem()).Interface().(intf.Plugin).BeforeDisplay(m)
|
|
}
|
|
}
|
|
|
|
// AfterDisplay is call after display
|
|
func (m *Machine) AfterDisplay() {
|
|
if _, ok := reg.Plugins[m.Theme]; !ok {
|
|
return
|
|
}
|
|
|
|
for _, t := range reg.Plugins[m.Theme] {
|
|
reflect.New(t.Elem()).Interface().(intf.Plugin).AfterDisplay(m)
|
|
}
|
|
}
|
|
|
|
// AfterSpin is called before Spin
|
|
func (m *Machine) AfterSpin() {
|
|
if _, ok := reg.Plugins[m.Theme]; !ok {
|
|
return
|
|
}
|
|
|
|
for _, t := range reg.Plugins[m.Theme] {
|
|
reflect.New(t.Elem()).Interface().(intf.Plugin).AfterSpin(m)
|
|
}
|
|
|
|
if m.CursorNode().ProgressValue+1 >= m.CursorNode().ProgressMax {
|
|
for _, t := range reg.Plugins[m.Theme] {
|
|
reflect.New(t.Elem()).Interface().(intf.Plugin).OnLeaveNode(m)
|
|
}
|
|
}
|
|
}
|
|
|
|
// OnStepEnd is called on step finalizing
|
|
func (m *Machine) OnStepEnd() {
|
|
if _, ok := reg.Plugins[m.Theme]; !ok {
|
|
return
|
|
}
|
|
|
|
for _, t := range reg.Plugins[m.Theme] {
|
|
reflect.New(t.Elem()).Interface().(intf.Plugin).OnStepEnd(m)
|
|
}
|
|
}
|
|
|
|
// OnStay is called to do something out of normal step
|
|
func (m *Machine) OnStay() {
|
|
if _, ok := reg.Plugins[m.Theme]; !ok {
|
|
return
|
|
}
|
|
|
|
for _, t := range reg.Plugins[m.Theme] {
|
|
reflect.New(t.Elem()).Interface().(intf.Plugin).OnStay(m)
|
|
}
|
|
}
|