public void LoadMod(string folder) { try { scripts.StartScriptEnvironment(); state = State.Loading; TOCLoadResult tocLoadResult = GameLink.Game.Components.Get <Query <TOCLoadResult, string> >((int)ComponentKeys.TableOfContentsLoadRequest).Send(folder); if (tocLoadResult.error != TOCLoadError.None) { throw new ModLoaderException("Cannot load table of contents, error: " + tocLoadResult.error); } toc = tocLoadResult.toc; Debug.Log("Start loading " + toc.name); if (toc.extraLuaFiles != null) { for (int i = 0; i < toc.extraLuaFiles.Length; i++) { StartLoadLua(folder, toc.extraLuaFiles[i], string.Format("Extra lua file {0}", i)); } } StartLoadAsset(folder, toc.boardModel, "boardModel"); StartLoadLua(folder, toc.boardSetupFunction, "boardSetupFunction"); StartLoadLua(folder, toc.winLossFunction, "winLossFunction"); if (toc.pieces == null || toc.pieces.Length == 0) { throw new ModLoaderException("Mod requires at least one piece."); } for (int p = 0; p < toc.pieces.Length; p++) { Piece piece = toc.pieces[p]; if (piece == null) { throw new ModLoaderException("Null piece given at position " + p); } else if (string.IsNullOrEmpty(piece.name)) { throw new ModLoaderException("Piece not given a name at position " + p); } string baseExcName = string.Format("piece {0} ", piece.name); StartLoadAsset(folder, piece.player1Model, baseExcName + "player1Model"); StartLoadAsset(folder, piece.player2Model, baseExcName + "player2Model"); if (!string.IsNullOrEmpty(piece.promoteIndicatorModel)) { StartLoadAsset(folder, piece.promoteIndicatorModel, baseExcName + "player2Model"); } StartLoadLua(folder, piece.actionOptionFunction, baseExcName + "actionOptionFunction"); } if (toc.actionIndicators == null || toc.actionIndicators.Length == 0) { throw new ModLoaderException("Mod requires action indicator models."); } for (int i = 0; i < toc.actionIndicators.Length; i++) { ActionIndicator indicator = toc.actionIndicators[i]; if (indicator == null) { throw new ModLoaderException("Null indicator given at position " + i); } else if (string.IsNullOrEmpty(indicator.type)) { throw new ModLoaderException("Indicator not given a type at position " + i); } string testName; if (string.IsNullOrEmpty(indicator.strength)) { testName = string.Format("indicator {0}", indicator.type); } else { testName = string.Format("indicator {0}-{1}", indicator.type, indicator.strength); } StartLoadAsset(folder, indicator.model, testName); } } catch (ModLoaderException mlx) { GameLink.Game.SceneComponents.Get <Message <string> >((int)ComponentKeys.ModLoadError).Send(mlx.Message); } }