//加载用户模组 private IEnumerator GameInitUserMods() { //加载mod文件夹下所有模组 string modFolderPath = GamePathManager.GetResRealPath("mod", ""); if (Directory.Exists(modFolderPath)) { DirectoryInfo direction = new DirectoryInfo(modFolderPath); FileInfo[] files = direction.GetFiles("*.ballance", SearchOption.TopDirectoryOnly); for (int i = 0, c = files.Length; i < c; i++) { ModManager.LoadGameMod(GamePathManager.GetResRealPath("mod", files[i].Name), false); GameInitSetUIProgressValue(0.6f + i / (float)c * 0.2f); UIProgressText.text = "Loading " + files[i].Name; } } //根据用户设置启用对应模组 string[] enableMods = ModManager.GetModEnableStatusList(); foreach (string packageName in enableMods) { GameMod m = ModManager.FindGameMod(packageName); if (m != null) { ModManager.InitializeLoadGameMod(m); yield return(new WaitUntil(m.IsLoadComplete)); } } UIProgressText.text = "Loading"; GameInitSetUIProgressValue(0.8f); yield break; }
/// <summary> /// 创建预制的天空盒 /// </summary> /// <param name="s">天空盒名字,(必须是 A~K ,对应原版游戏11个天空)</param> /// <returns>返回创建好的天空盒材质</returns> public static Material MakeSkyBox(string s) { if (ModManager == null) { ModManager = (IModManager)GameManager.GetManager("ModManager"); } if (skyAssetPack == null) { skyAssetPack = ModManager.FindGameMod("core.assets.skys"); } if (skyAssetPack == null) { GameLogger.Error(TAG, "MakeSkyBox failed because skybase pack core.assets.skys not load !"); return(null); } Texture SkyLeft = skyAssetPack.GetAsset <Texture>("Sky_" + s + "_Left.BMP"); Texture SkyRight = skyAssetPack.GetAsset <Texture>("Sky_" + s + "_Right.BMP"); Texture SkyFront = skyAssetPack.GetAsset <Texture>("Sky_" + s + "_Front.BMP"); Texture SkyBack = skyAssetPack.GetAsset <Texture>("Sky_" + s + "_Back.BMP"); Texture SkyDown = skyAssetPack.GetAsset <Texture>("Sky_" + s + "_Down.BMP"); return(MakeCustomSkyBox(SkyLeft, SkyRight, SkyFront, SkyBack, SkyDown, null)); }
// Init and get // =========================== private bool LuaInit() { if (GameMod == null) { if (string.IsNullOrEmpty(LuaModName)) { GameLogger.Error(TAG + ":" + Name, "LuaObject {0} load error : LuaModName not provide ", Name); GameErrorManager.LastError = GameError.ParamNotProvide; return(false); } GameMod = ModManager.FindGameMod(LuaModName); if (GameMod == null) { GameLogger.Error(TAG + ":" + Name, "LuaObject {0} load error : LuaModName not found : {1}", Name, LuaModName); GameErrorManager.LastError = GameError.NotRegister; return(false); } GameMod.AddeLuaObject(this); _PackageName = GameMod.PackageName; if (CreateStore) { Store = GameManager.GameMediator.RegisterGlobalDataStore(PackageName + ":" + Name); } if (CreateActionStore) { ActionStore = GameManager.GameMediator.RegisterActionStore(PackageName + ":" + Name); } LuaState = GameMod.ModLuaState; if (LuaState == null) { GameLogger.Error(TAG + ":" + Name, "LuaObject {0} load error : Mod can not run : {1}", Name, LuaModName); GameErrorManager.LastError = GameError.ModCanNotRun; return(false); } } LuaFunction classInit = GameMod.RequireLuaClass(LuaClassName); if (classInit == null) { GameLogger.Error(TAG + ":" + Name, "LuaObject {0} load error : class not found : {1}", Name, LuaClassName); GameErrorManager.LastError = GameError.ClassNotFound; return(false); } object o = classInit.call(); if (o != null && o is LuaTable) { self = o as LuaTable; } else { GameLogger.Error(TAG + ":" + Name, "LuaObject {0} load error : table not return ", Name); GameErrorManager.LastError = GameError.NotReturn; return(false); } InitLuaInternalVars(); InitLuaVars(); //初始化引入参数 //调用其他LUA初始化脚本 SendMessage("OnInitLua", gameObject, SendMessageOptions.DontRequireReceiver); InitLuaEvents(); return(true); }