Kiwi.PluginManager Class
The plugin manager registers plugins, checks plugin dependencies, and calls designated functions on each registered plugin at boot time, and during the update loop if required. Plugins are registered on the global Kiwi instance. Once a plugin in registered it is allocated a place on the Kiwi.Plugins name space. Eg. FooPlugin will be accessible at Kiwi.Plugins.FooPlugin. When a game instance is created, it can contain a list of required plugins in the configuration object. At this point the plugin manager will validate that the plugins exist, and that dependencies are met (both Kiwi version and versions of other required plugins). If the plugin has a "create" function, the plugin manager instance will call that function as part of the boot process. The create function may do anything, but usually it would create an instance of an object. The plugin manager update function is called every update loop. If an object was created by the "create" function and it has an "update" function, that function will be called in turn.
Constructor
Kiwi.PluginManager
-
game
-
plugins
Parameters:
-
game
Kiwi.GameThe state that this entity belongs to. Used to generate the Unique ID and for garbage collection.
-
plugins
StringThe entities position on the x axis.
Returns:
This PluginManager.
Item Index
Methods
Properties
- _availablePlugins static
- _bootObjects
- _plugins
- getAvailablePlugins static
- objType
- objType
Methods
_createPlugins
()
private
Called after all other core objects and services created by the Kiwi.Game constructor are created. Attempts to find a "create" function on each plugin and calls it if it exists. The create function may return an object on which a boot function exists - to be called during boot process.
boot
()
public
Calls the boot functions on any objects that plugins used by the game instance have designated during creation.
pluginIsRegistered
-
pluginName
Returns true if a plugin identified by the supplied pluginName is registered.
Parameters:
-
pluginName
String
register
-
plugin
Registers a plugin object as available. Any game instance can choose to use the plugin. Plugins need only be registered once per webpage. If registered a second time it will be ignored. Two plugins with the same names cannot be reigstered simultaneously, even if different versions.
Parameters:
-
plugin
Object
update
()
public
Calls the update functions on any objects that plugins used by the game instance have designated during creation.
validatePlugins
()
public
Builds a list of valid plugins used by the game instance. Each plugin name that is supplied in the Kiwi.Game constructor configuration object
is checked against the Kiwi.Plugins namespace to ensure that a property of the same name exists.
This will ignore plugin that are registered but not used by the game instance.
validMinimumPluginVersionExists
-
name
-
version
Returns whether a valid minimum version of a plugin exists.
Parameters:
-
name
StringName of plugin
-
version
StringMinimum version
Returns:
boolean
Properties
_availablePlugins
Array
private
static
An array of plugins which have been included in the webpage and registered successfully.
_bootObjects
Array
private
An array of objects that contain a boot function, each of which will be called when PluginManager.boot is invoked.
_plugins
Array
private
An array of plugin names which the game instance has been configured to use. Each name must match the constructor function for the plugin.
getAvailablePlugins
Array
private
static
An array of objects represetning all available plugins, each containing the name and version number of an available plugin
objType
String "PluginManager"
public
Identifies the object as a PluginManager.