/// <summary> /// Gets the run env. /// </summary> /// <returns>The run env.</returns> /// <param name="tid">Tid.</param> public RunEnv GetRunEnv(TID tid) { RunEnv env = null; tid2EnvDict.TryGetValue(tid, out env); return(env); }
public void Close() { if (isStarted) { List <RunEnv> cached = this.mainloopEnvs; for (int i = 0; i < cached.Count; ++i) { RunEnv env = cached[i]; if (env != null && env.IsStarted) { env.Close(); App.RemoveEnvFromDict(env); App.RemoveEnvFromMainloop(env); } } // unload templates templateMgr = null; isStarted = false; // 清除cache fileCache = null; langFileCache = null; isFileCacheLoaded = false; } }
/// <summary> /// Gets the run env. /// </summary> /// <returns>The run env.</returns> /// <param name="envName">Env name.</param> public RunEnv GetRunEnv(string envName) { RunEnv env = null; name2EnvDict.TryGetValue(envName, out env); return(env); }
public Mod() { ctrlEnv = null; parent = null; isStarted = false; mainloopEnvs = new List <RunEnv>(); isFileCacheLoaded = false; templateMgr = null; }
public void Reset() { if (isStarted) { List <RunEnv> cached = this.mainloopEnvs; for (int i = 0; i < cached.Count; ++i) { RunEnv env = cached[i]; if (env != null && env.IsStarted) { env.Reset(); } } } }
public void Start() { if (!isStarted) { List <RunEnv> cached = this.mainloopEnvs; for (int i = 0; i < cached.Count; ++i) { RunEnv env = cached[i]; if (env != null && env.StartNow) { env.Start(); } } isStarted = true; } }
public bool Open() { bool result = true; //gameapp init已经初始化了parent LoadFileCache(); LoadTemplates(); // init env TID[] envs = template.configs[App.Tid].envs; for (int i = 0; i < envs.Length; ++i) { TID tid = envs[i]; if (tid != TID.None) { // todo: GameApp:templateMgr RunEnv env = App.TemplateMgr.CreateObject(tid) as RunEnv; if (env != null) { env.SetApp(App); env.SetMod(this); env.SetTemplateMgr(templateMgr); env.Init(); App.AddEnvToDict(env); App.AddEnvToMainloop(env); AddMainloopEnv(env); //if (env.modService != null) { // if (env.modService.SetMod(this) <= 0) { // result = false; // } //} } else { Logger.Error("init mod: runenv {0} create failed!", tid); result = false; } } } return(result); }
public void AddMainloopEnv(RunEnv env) { mainloopEnvs.Add(env); }
public virtual void Init(RunEnv env) { this.env = env; }
/// <summary> /// Adds the env to mainloop. /// </summary> /// <param name="env">Env.</param> public void AddEnvToMainloop(RunEnv env) { mainloopEnvs.Add(env); }
/// <summary> /// Removes the env from dict. /// </summary> /// <param name="env">Env.</param> public void RemoveEnvFromDict(RunEnv env) { name2EnvDict.Remove(env.Name); tid2EnvDict.Remove(env.Tid); }
/// <summary> /// Removes the env from mainloop. /// </summary> /// <param name="env">Env.</param> public void RemoveEnvFromMainloop(RunEnv env) { mainloopEnvs.Remove(env); }
/// <summary> /// Adds the env to dict. /// </summary> /// <param name="env">Env.</param> public void AddEnvToDict(RunEnv env) { name2EnvDict[env.Name] = env; tid2EnvDict[env.Tid] = env; }