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(); }
public static void RefreshActions() { if (AdvGame.GetReferences() == null || AdvGame.GetReferences().actionsManager == null) { return; } ActionsManager actionsManager = AdvGame.GetReferences().actionsManager; // Collect data to transfer List <ActionType> oldActionTypes = new List <ActionType>(); foreach (ActionType actionType in actionsManager.AllActions) { oldActionTypes.Add(actionType); } // Load default Actions DirectoryInfo dir = new DirectoryInfo("Assets/" + actionsManager.folderPath); FileInfo[] info = dir.GetFiles("*.cs"); actionsManager.AllActions.Clear(); foreach (FileInfo f in info) { try { int extentionPosition = f.Name.IndexOf(".cs"); string className = f.Name.Substring(0, extentionPosition); StreamReader streamReader = new StreamReader(f.FullName); string fileContents = streamReader.ReadToEnd(); streamReader.Close(); fileContents = fileContents.Replace(" ", ""); if (fileContents.Contains("class" + className + ":Action") || fileContents.Contains("class" + className + ":AC.Action")) { Action tempAction = (Action)CreateInstance(className); if (tempAction is Action) { ActionType newActionType = new ActionType(className, tempAction); // Transfer back data foreach (ActionType oldActionType in oldActionTypes) { if (newActionType.IsMatch(oldActionType)) { newActionType.color = oldActionType.color; if (newActionType.color == new Color(0f, 0f, 0f, 0f)) { newActionType.color = Color.white; } if (newActionType.color.a < 1f) { newActionType.color = new Color(newActionType.color.r, newActionType.color.g, newActionType.color.b, 1f); } } } actionsManager.AllActions.Add(newActionType); } } else { ACDebug.LogError("The script '" + f.FullName + "' must derive from AC's Action class in order to be available as an Action."); } } catch {} } // Load custom Actions if (!string.IsNullOrEmpty(actionsManager.customFolderPath) && 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); StreamReader streamReader = new StreamReader(f.FullName); string fileContents = streamReader.ReadToEnd(); streamReader.Close(); fileContents = fileContents.Replace(" ", ""); if (fileContents.Contains("class" + className + ":Action") || fileContents.Contains("class" + className + ":AC.Action")) { Action tempAction = (Action)CreateInstance(className); if (tempAction is Action) { actionsManager.AllActions.Add(new ActionType(className, tempAction)); } } else { ACDebug.LogError("The script '" + f.FullName + "' must derive from AC's Action class in order to be available as an Action."); } } catch {} } } actionsManager.AllActions.Sort(delegate(ActionType i1, ActionType i2) { return(i1.GetFullTitle(true).CompareTo(i2.GetFullTitle(true))); }); actionsManager.SetEnabled(); }
public static void RefreshActions() { if (AdvGame.GetReferences() == null || AdvGame.GetReferences().actionsManager == null) { return; } ActionsManager actionsManager = AdvGame.GetReferences().actionsManager; // Collect data to transfer List <ActionType> oldActionTypes = new List <ActionType>(); foreach (ActionType actionType in actionsManager.AllActions) { oldActionTypes.Add(actionType); } // Load default Actions 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); ActionType newActionType = new ActionType(className, tempAction); // Transfer back data foreach (ActionType oldActionType in oldActionTypes) { if (newActionType.IsMatch(oldActionType)) { newActionType.color = oldActionType.color; if (newActionType.color == new Color(0f, 0f, 0f, 0f)) { newActionType.color = Color.white; } if (newActionType.color.a < 1f) { newActionType.color = new Color(newActionType.color.r, newActionType.color.g, newActionType.color.b, 1f); } } } actionsManager.AllActions.Add(newActionType); } // 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(); }