Esempio n. 1
0
        public static string[] GetNpcs()
        {
            int           count = 0;
            List <string> list  = new List <string>();

            ScriptEntry[] entrys = ScriptDatabase.GetType(EScriptContent.Npc);

            for (int i = 0; i < entrys.Length; i++)
            {
                if (entrys[i].Type != EScriptType.Path)
                {
                    continue;
                }
                if (File.Exists(entrys[i].Path) == false)
                {
                    ServerConsole.ErrorLine("Cant find File/Path: \"" + entrys[i].Path + "\"! Skipping...");
                    continue;
                }

                list.Add(Path.Combine(Environment.CurrentDirectory, entrys[i].Path));
                ServerConsole.InfoLine("\t#{0}: \"{1}\"", (++count), entrys[i].Path);
            }

            return(list.ToArray());
        }
Esempio n. 2
0
        /// <summary>Loads all script files in this directory + sub dirs.</summary>
        /// <param name="ScriptListPath">Full pathname of the directory o search in.</param>
        public static void Initialize(string ScriptListPath)
        {
            ScriptList ScriptEntrys = new ScriptList();

            if (File.Exists(ScriptListPath) == false)
            {
                ServerConsole.ErrorLine("Can't load File from \"" + ScriptListPath + "\"!");
                return;
            }

            using (FileStream s = File.OpenRead(ScriptListPath)) {
                ScriptEntrys = mXmlSerializer.Deserialize(s) as ScriptList;
            }

            // Build absolute paths and load includes
            string basePath = Path.GetDirectoryName(ScriptListPath);

            for (int i = 0; i < ScriptEntrys.Count; i++)
            {
                for (int j = 0; j < ScriptEntrys[i].Entrys.Count; j++)
                {
                    // Include or path?
                    if (ScriptEntrys[i].Entrys[j].Type == EScriptType.Include)
                    {
                        string includePath = Path.Combine(Path.GetDirectoryName(ScriptListPath), ScriptEntrys[i].Entrys[j].Path);
                        ScriptDatabase.Initialize(includePath);
                    }
                    else
                    {
                        // Build an absolute path
                        ScriptEntrys[i].Entrys[j].Path = Path.Combine(basePath, Path.GetDirectoryName(ScriptEntrys[i].Entrys[j].Path)) + @"\" + Path.GetFileName(ScriptEntrys[i].Entrys[j].Path);
                    }
                }
            }

            // Push to static list
            if (ScriptEntrys.Count > 0)
            {
                Scripts.AddRange(ScriptEntrys);
            }
        }