예제 #1
0
        /// <summary>
        /// Compiles and runs a script.
        /// </summary>
        /// <param name="relativeScriptPath">The relative path of the script from the scripts directory e.g. 'SubDirectory\\Script.cel'</param>
        /// <returns></returns>
        public static CelesteScript CreateScript(string relativeScriptPath)
        {
            CelesteScript script = null;

            if (CompiledScripts.TryGetValue(relativeScriptPath, out script))
            {
                return(script);
            }

            string filePath = Path.Combine(scriptDirectoryPath, relativeScriptPath);

            if (File.Exists(filePath))
            {
                script = new CelesteScript(relativeScriptPath);
            }
            else
            {
                Debug.Fail("Invalid filepath " + filePath + ".  Script does not exist");
            }

            CompiledScripts.Add(relativeScriptPath, script);
            return(script);
        }