package reg import ( "mongo.games.com/game/gamesrv/slotspkg/slots/intf" "reflect" ) // Plugins stores plugins mapped by theme name var Plugins = make(map[string][]reflect.Type) // RegisterPlugin registers plugins in machine func RegisterPlugin(plugin intf.Plugin) { theme := plugin.Theme() if _, ok := Plugins[theme]; !ok { Plugins[theme] = make([]reflect.Type, 0) } Plugins[theme] = append(Plugins[theme], reflect.TypeOf(plugin)) } // DeregisterPlugin deregisters plugins in machine func DeregisterPlugin(plugin intf.Plugin) { theme := plugin.Theme() if _, ok := Plugins[theme]; !ok { return } for index := 0; index < len(Plugins[theme]); index++ { if Plugins[theme][index] == reflect.TypeOf(plugin) { Plugins[theme] = append(Plugins[theme][:index], Plugins[theme][index+1:]...) index-- } } }