void Load(string path, bool needsInit) { try { Assembly lib = Assembly.LoadFile(path); Type[] types = lib.GetTypes(); for (int i = 0; i < types.Length; i++) { if (!IsPlugin(types[i])) { continue; } IGameComponent plugin = (IGameComponent)Activator.CreateInstance(types[i]); if (needsInit) { plugin.Init(game); plugin.Ready(game); } if (plugin == null) { throw new InvalidOperationException("Type " + types[i].Name + " returned null instance"); } game.AddComponent(plugin); } } catch (Exception ex) { path = Path.GetFileNameWithoutExtension(path); ErrorHandler.LogError("PluginLoader.Load() - " + path, ex); } }
public GuiInterface(Game game) { fpsScreen = game.AddComponent(new FpsScreen(game)); hudScreen = game.AddComponent(new HudScreen(game)); }