private byte[] LoadLogicResource(ref string resource) { byte[] content = FileReaderProxy.ReadFileAsArray(resource); string text = Encoding.UTF8.GetString(content); if (text.StartsWith(BOMMarkUtf8)) { text = text.Remove(0, BOMMarkUtf8.Length); } resource = ScriptManager.Instance.GetLuaScriptPathForDebugger(resource, false); return(System.Text.Encoding.UTF8.GetBytes(text)); }
public bool Load(string file) { // temp, for test if (file.ToLower().EndsWith(".dsl")) { byte[] content = FileReaderProxy.ReadFileAsArray(file); string text = Encoding.UTF8.GetString(content); // remove BOM if used if (text.StartsWith(BOMMarkUtf8)) { text = text.Remove(0, BOMMarkUtf8.Length); } //DashFire.LogSystem.Debug("ScriptableDataFile.Load {0}:\n{1}", file, content); return(LoadFromString(text, file)); } else { Env = ScriptManager.Instance.SetupNewEnv(file, false); ScriptManager.Instance.ExecuteFile(file, false, Env, file); OnStart = ScriptManager.Instance.QueryAction_1("start", Env, false); OnNpcStore = ScriptManager.Instance.QueryAction_1("npcstore", Env, false); OnCityUserMove = ScriptManager.Instance.QueryAction_1("cityusermove", Env, false); OnObjArrived = ScriptManager.Instance.QueryAction_1("objarrived", Env, false); OnCityPlayerMove = ScriptManager.Instance.QueryAction_1("cityplayermove", Env, false); OnPlayerMoveToPos = ScriptManager.Instance.QueryAction_1("playermovetopos", Env, false); OnAiMoveStop = ScriptManager.Instance.QueryAction_1("aimovestopped", Env, false); } return(true); #if false //string content = File.ReadAllText(file); byte[] content = FileReaderProxy.ReadFileAsArray(file); string text = Encoding.UTF8.GetString(content); // remove BOM if used if (text.StartsWith(BOMMarkUtf8)) { text = text.Remove(0, BOMMarkUtf8.Length); } //DashFire.LogSystem.Debug("ScriptableDataFile.Load {0}:\n{1}", file, content); return(LoadFromString(text, file)); #else /* * byte[] content = FileReaderProxy.ReadFileAsArray(file); * string text = Encoding.UTF8.GetString(content); * if ( text.StartsWith(BOMMarkUtf8) ) * { * text = text.Remove(0, BOMMarkUtf8.Length); * } */ Env = ScriptManager.Instance.SetupNewEnv(file, false); ScriptManager.Instance.ExecuteFile(file, false, Env, file); OnStart = ScriptManager.Instance.QueryAction_1("start", Env, false); OnNpcStore = ScriptManager.Instance.QueryAction_1("npcstore", Env, false); OnCityUserMove = ScriptManager.Instance.QueryAction_1("cityusermove", Env, false); OnObjArrived = ScriptManager.Instance.QueryAction_1("objarrived", Env, false); OnCityPlayerMove = ScriptManager.Instance.QueryAction_1("cityplayermove", Env, false); OnPlayerMoveToPos = ScriptManager.Instance.QueryAction_1("playermovetopos", Env, false); OnAiMoveStop = ScriptManager.Instance.QueryAction_1("aimovestopped", Env, false); return(true); #endif }