コード例 #1
0
    public static void RefreshActions()
    {
        if (AdvGame.GetReferences() == null || AdvGame.GetReferences().actionsManager == null)
        {
            return;
        }

        // Load default Actions
        ActionsManager actionsManager = AdvGame.GetReferences().actionsManager;
        DirectoryInfo  dir            = new DirectoryInfo("Assets/" + actionsManager.folderPath);

        FileInfo[] info = dir.GetFiles("*.cs");

        actionsManager.AllActions.Clear();

        foreach (FileInfo f in info)
        {
            int    extentionPosition = f.Name.IndexOf(".cs");
            string className         = f.Name.Substring(0, extentionPosition);
            Action tempAction        = (Action)CreateInstance(className);
            actionsManager.AllActions.Add(new ActionType(className, tempAction));
        }

        // Load custom Actions
        if (actionsManager.customFolderPath != actionsManager.folderPath)
        {
            dir  = new DirectoryInfo("Assets/" + actionsManager.customFolderPath);
            info = dir.GetFiles("*.cs");

            foreach (FileInfo f in info)
            {
                try
                {
                    int    extentionPosition = f.Name.IndexOf(".cs");
                    string className         = f.Name.Substring(0, extentionPosition);
                    Action tempAction        = (Action)CreateInstance(className);
                    if (tempAction is Action)
                    {
                        actionsManager.AllActions.Add(new ActionType(className, tempAction));
                    }
                }
                catch {}
            }
        }

        actionsManager.AllActions.Sort(delegate(ActionType i1, ActionType i2) { return(i1.GetFullTitle(true).CompareTo(i2.GetFullTitle(true))); });
        actionsManager.SetEnabled();
    }