private void EndAction(Action action) { action.isRunning = false; ActionEnd actionEnd = action.End(this.actions); if (isSkipping && action.lastResult.skipAction != -10 && (action is ActionCheck || action is ActionCheckMultiple)) { // When skipping an ActionCheck that has already run, revert to previous result actionEnd = new ActionEnd(action.lastResult); } else { action.SetLastResult(new ActionEnd(actionEnd)); ReturnLastResultToSource(actionEnd, actions.IndexOf(action)); } if (action is ActionCheck || action is ActionCheckMultiple) { if (actionEnd.resultAction == ResultAction.Skip && actionEnd.skipAction == actions.IndexOf(action)) { // Looping on itself will cause a StackOverflowException, so delay slightly ProcessActionEnd(actionEnd, actions.IndexOf(action), true); return; } } ProcessActionEnd(actionEnd, actions.IndexOf(action)); }
protected ActionEnd GenerateActionEnd(ResultAction _resultAction, ActionListAsset _linkedAsset, Cutscene _linkedCutscene, int _skipAction, Action _skipActionActual, List <Action> _actions) { ActionEnd actionEnd = new ActionEnd(); actionEnd.resultAction = _resultAction; actionEnd.linkedAsset = _linkedAsset; actionEnd.linkedCutscene = _linkedCutscene; if (_resultAction == ResultAction.RunCutscene) { if (isAssetFile && _linkedAsset != null) { actionEnd.linkedAsset = _linkedAsset; } else if (!isAssetFile && _linkedCutscene != null) { actionEnd.linkedCutscene = _linkedCutscene; } } else if (_resultAction == ResultAction.Skip) { int skip = _skipAction; if (_skipActionActual && _actions.Contains(_skipActionActual)) { skip = _actions.IndexOf(_skipActionActual); } else if (skip == -1) { skip = 0; } actionEnd.skipAction = skip; } return(actionEnd); }
protected ActionEnd GenerateStopActionEnd() { ActionEnd actionEnd = new ActionEnd(); actionEnd.resultAction = ResultAction.Stop; return(actionEnd); }
override public void SkipActionGUI(List <Action> actions, bool showGUI) { if (numSockets < 0) { numSockets = 0; } if (numSockets < endings.Count) { endings.RemoveRange(numSockets, endings.Count - numSockets); } else if (numSockets > endings.Count) { if (numSockets > endings.Capacity) { endings.Capacity = numSockets; } for (int i = endings.Count; i < numSockets; i++) { ActionEnd newEnd = new ActionEnd(); endings.Add(newEnd); } } foreach (ActionEnd ending in endings) { if (showGUI) { EditorGUILayout.Space(); int i = endings.IndexOf(ending); GVar _var = GetVariable(); if (_var != null) { ending.resultAction = (ResultAction)EditorGUILayout.EnumPopup("If result is " + _var.popUps[i] + ":", (ResultAction)ending.resultAction); } else { ending.resultAction = (ResultAction)EditorGUILayout.EnumPopup("If result is " + (i + 1).ToString() + ":", (ResultAction)ending.resultAction); } } if (ending.resultAction == ResultAction.RunCutscene && showGUI) { if (isAssetFile) { ending.linkedAsset = (ActionListAsset)EditorGUILayout.ObjectField("ActionList to run:", ending.linkedAsset, typeof(ActionListAsset), false); } else { ending.linkedCutscene = (Cutscene)EditorGUILayout.ObjectField("Cutscene to run:", ending.linkedCutscene, typeof(Cutscene), true); } } else if (ending.resultAction == ResultAction.Skip) { SkipActionGUI(ending, actions, showGUI); } } }
/** * <summary>A Constructor that copies the values of another ActionEnd.</summary> * <param name = "_actionEnd">The ActionEnd to copy from</param> */ public ActionEnd(ActionEnd _actionEnd) { resultAction = _actionEnd.resultAction; skipAction = _actionEnd.skipAction; skipActionActual = _actionEnd.skipActionActual; linkedCutscene = _actionEnd.linkedCutscene; linkedAsset = _actionEnd.linkedAsset; }
public override void SetLastResult(ActionEnd _actionEnd) { if (!IsTargetSkippable()) { // When skipping, don't want to rely on last result if target can be skipped as well base.SetLastResult(_actionEnd); } }
override public void DrawOutWires(List <Action> actions, int i, int offset) { int totalHeight = 7; for (int j = endings.Count - 1; j >= 0; j--) { ActionEnd ending = endings [j]; float fac = (float)(endings.Count - endings.IndexOf(ending)) / endings.Count; Color wireColor = new Color(1f - fac, fac * 0.7f, 0.1f); if (ending.resultAction == ResultAction.Continue) { if (actions.Count > i + 1) { AdvGame.DrawNodeCurve(nodeRect, actions[i + 1].nodeRect, wireColor, totalHeight, true, isDisplayed); } } else if (ending.resultAction == ResultAction.Skip && showOutputSockets) { if (actions.Contains(ending.skipActionActual)) { AdvGame.DrawNodeCurve(nodeRect, ending.skipActionActual.nodeRect, wireColor, totalHeight, true, isDisplayed); } } if (ending.resultAction == ResultAction.Skip) { totalHeight += 44; } else { totalHeight += 26; } } /*foreach (ActionEnd ending in endings) * { * int k = endings.Count - endings.IndexOf (ending); * float j = ((float) k) / endings.Count; * Color wireColor = new Color (1f-j, j*0.7f, 0.1f); * * if (ending.resultAction == ResultAction.Continue) * { * if (actions.Count > i+1) * { * AdvGame.DrawNodeCurve (nodeRect, actions[i+1].nodeRect, wireColor, k * 43 -13, true, isDisplayed); * } * } * else if (ending.resultAction == ResultAction.Skip && showOutputSockets) * { * if (actions.Contains (ending.skipActionActual)) * { * AdvGame.DrawNodeCurve (nodeRect, ending.skipActionActual.nodeRect, wireColor, k * 43 - 13, true, isDisplayed); * } * } * }*/ }
override public void SkipActionGUI(List <Action> actions, bool showGUI) { if (numSockets < 0) { numSockets = 0; } if (numSockets < endings.Count) { endings.RemoveRange(numSockets, endings.Count - numSockets); } else if (numSockets > endings.Count) { if (numSockets > endings.Capacity) { endings.Capacity = numSockets; } for (int i = endings.Count; i < numSockets; i++) { ActionEnd newEnd = new ActionEnd(); newEnd.resultAction = ResultAction.Stop; endings.Add(newEnd); } } foreach (ActionEnd ending in endings) { if (showGUI) { EditorGUILayout.Space(); int i = endings.IndexOf(ending) + 1; ending.resultAction = (ResultAction)EditorGUILayout.EnumPopup(GetSocketLabel(i), (ResultAction)ending.resultAction); } if (ending.resultAction == ResultAction.RunCutscene && showGUI) { if (isAssetFile) { ending.linkedAsset = ActionListAssetMenu.AssetGUI("ActionList to run:", ending.linkedAsset); } else { ending.linkedCutscene = ActionListAssetMenu.CutsceneGUI("Cutscene to run:", ending.linkedCutscene); } } else if (ending.resultAction == ResultAction.Skip) { SkipActionGUI(ending, actions, showGUI); } /*else * { * EditorGUILayout.Space (); * EditorGUILayout.Space (); * EditorGUILayout.Space (); * }*/ } }
private void ProcessActionEnd(ActionEnd actionEnd, int i) { if (actionEnd.resultAction == ResultAction.RunCutscene) { if (actionEnd.linkedAsset != null) { if (isSkipping) { AdvGame.SkipActionListAsset(actionEnd.linkedAsset); } else { AdvGame.RunActionListAsset(actionEnd.linkedAsset, 0, !IsSkippable()); } CheckEndCutscene(); } else if (actionEnd.linkedCutscene != null) { if (actionEnd.linkedCutscene != this) { if (isSkipping) { actionEnd.linkedCutscene.Skip(); } else { actionEnd.linkedCutscene.Interact(0, !IsSkippable()); } CheckEndCutscene(); } else { if (triggerTime > 0f) { Kill(); StartCoroutine("PauseUntilStart", !IsSkippable()); } else { ProcessAction(0); } } } } else if (actionEnd.resultAction == ResultAction.Stop) { CheckEndCutscene(); } else if (actionEnd.resultAction == ResultAction.Skip) { ProcessAction(actionEnd.skipAction); } else if (actionEnd.resultAction == ResultAction.Continue) { ProcessAction(i + 1); } }
public override void SetLastResult(ActionEnd _actionEnd) { if (!IsTargetSkippable() && !checkSelfSkipping) { // When skipping, don't want to rely on last result if target can be skipped as well base.SetLastResult(_actionEnd); return; } lastResult = new ActionEnd(-10); }
/** * <summary>Downloads and runs the settings and Actions stored within an ActionListAsset.</summary> * <param name = "actionListAsset">The ActionListAsset to copy Actions from and run</param> * <param name = "endConversation">If set, the supplied Conversation will be run when the AcionList ends</param> * <param name = "i">The index number of the first Action to run</param> * <param name = "doSkip">If True, then the Actions will be skipped, instead of run normally</param> * <param name = "addToSkipQueue">If True, the ActionList will be skippable when the user presses 'EndCutscene'</param> * <param name = "dontRun">If True, the Actions will not be run once transferred from the ActionListAsset</param> */ public void DownloadActions(ActionListAsset actionListAsset, Conversation endConversation, int i, bool doSkip, bool addToSkipQueue, bool dontRun = false) { this.name = actionListAsset.name; assetSource = actionListAsset; useParameters = actionListAsset.useParameters; parameters = actionListAsset.parameters; unfreezePauseMenus = actionListAsset.unfreezePauseMenus; actionListType = actionListAsset.actionListType; if (actionListAsset.actionListType == ActionListType.PauseGameplay) { isSkippable = actionListAsset.isSkippable; } else { isSkippable = false; } conversation = endConversation; actions.Clear(); foreach (AC.Action action in actionListAsset.actions) { ActionEnd _lastResult = action.lastResult; actions.Add(action); if (doSkip && action != null) { actions[actions.Count - 1].lastResult = _lastResult; } } if (!useParameters) { foreach (Action action in actions) { action.AssignValues(null); } } if (!dontRun) { if (doSkip) { Skip(i); } else { Interact(i, addToSkipQueue); } } }
/** * <summary>Update the Action's output sockets</summary> * <param name = "actionEndOnPass">A data container for the 'Condition is met' output socket</param> * <param name = "actionEndOnFail">A data container for the 'Condition is not met' output socket</param> */ public void SetOutputs(ActionEnd actionEndOnPass, ActionEnd actionEndOnFail) { resultActionTrue = actionEndOnPass.resultAction; skipActionTrue = actionEndOnPass.skipAction; skipActionTrueActual = actionEndOnPass.skipActionActual; linkedCutsceneTrue = actionEndOnPass.linkedCutscene; linkedAssetTrue = actionEndOnPass.linkedAsset; resultActionFail = actionEndOnFail.resultAction; skipActionFail = actionEndOnFail.skipAction; skipActionFailActual = actionEndOnFail.skipActionActual; linkedCutsceneFail = actionEndOnFail.linkedCutscene; linkedAssetFail = actionEndOnFail.linkedAsset; }
public override ActionEnd End(List <AC.Action> actions) { // If the linkedObject is an immediately-starting ActionList, don't end the cutscene if (runtimeLinkedObject && messageToSend == MessageToSend.Interact) { Cutscene tempAction = runtimeLinkedObject.GetComponent <Cutscene>(); if (tempAction != null && tempAction.triggerTime <= 0f) { ActionEnd actionEnd = new ActionEnd(); actionEnd.resultAction = ResultAction.RunCutscene; return(actionEnd); } } return(base.End(actions)); }
public override ActionEnd End(List<AC.Action> actions) { // If the linkedObject is an immediately-starting ActionList, don't end the cutscene if (linkedObject && messageToSend == MessageToSend.Interact && linkedObject.GetComponent <Cutscene>()) { Cutscene tempAction = linkedObject.GetComponent<Cutscene>(); if (tempAction.triggerTime == 0f) { ActionEnd actionEnd = new ActionEnd (); actionEnd.resultAction = ResultAction.RunCutscene; return actionEnd; } } return (base.End (actions)); }
private void EndAction(Action action) { action.isRunning = false; ActionEnd actionEnd = action.End(this.actions); if (isSkipping && action.lastResult.skipAction != -10 && (action is ActionCheck || action is ActionCheckMultiple)) { // When skipping an ActionCheck that has already run, revert to previous result actionEnd = new ActionEnd(action.lastResult); } else { action.SetLastResult(new ActionEnd(actionEnd)); ReturnLastResultToSource(actionEnd, actions.IndexOf(action)); } ProcessActionEnd(actionEnd, actions.IndexOf(action)); }
public override void DrawOutWires(List <Action> actions, int i, int offset, Vector2 scrollPosition) { int totalHeight = 7; for (int j = endings.Count - 1; j >= 0; j--) { ActionEnd ending = endings [j]; float fac = (float)(endings.Count - endings.IndexOf(ending)) / endings.Count; Color wireColor = new Color(1f - fac, fac * 0.7f, 0.1f); if (ending.resultAction == ResultAction.Continue) { if (actions.Count > i + 1) { AdvGame.DrawNodeCurve(new Rect(NodeRect.position - scrollPosition, NodeRect.size), new Rect(actions[i + 1].NodeRect.position - scrollPosition, actions[i + 1].NodeRect.size), wireColor, totalHeight, true, isDisplayed); } } else if (ending.resultAction == ResultAction.Skip && showOutputSockets) { if (ending.skipActionActual != null && actions.Contains(ending.skipActionActual)) { AdvGame.DrawNodeCurve(new Rect(NodeRect.position - scrollPosition, NodeRect.size), new Rect(ending.skipActionActual.NodeRect.position - scrollPosition, ending.skipActionActual.NodeRect.size), wireColor, totalHeight, true, isDisplayed); } } if (ending.resultAction == ResultAction.Skip) { totalHeight += 44; } else { totalHeight += 28; } } }
override public void DrawOutWires(List <Action> actions, int i, int offset) { int totalHeight = 7; for (int j = endings.Count - 1; j >= 0; j--) { ActionEnd ending = endings [j]; float fac = (float)(endings.Count - endings.IndexOf(ending)) / endings.Count; Color wireColor = new Color(1f - fac, fac * 0.7f, 0.1f); if (ending.resultAction == ResultAction.Continue) { if (actions.Count > i + 1) { AdvGame.DrawNodeCurve(nodeRect, actions[i + 1].nodeRect, wireColor, j + totalHeight, true, isDisplayed); } } else if (ending.resultAction == ResultAction.Skip) { if (actions.Contains(ending.skipActionActual)) { AdvGame.DrawNodeCurve(nodeRect, ending.skipActionActual.nodeRect, wireColor, j + totalHeight, true, isDisplayed); } } if (ending.resultAction == ResultAction.Skip) { totalHeight += 44; } else { totalHeight += 26; } } }
public override void SkipActionGUI(List <Action> actions, bool showGUI) { if (KickStarter.inventoryManager == null) { return; } numSockets = 4; if (numSockets < endings.Count) { endings.RemoveRange(numSockets, endings.Count - numSockets); } else if (numSockets > endings.Count) { if (numSockets > endings.Capacity) { endings.Capacity = numSockets; } for (int i = endings.Count; i < numSockets; i++) { ActionEnd newEnd = new ActionEnd(); if (i > 0) { newEnd.resultAction = ResultAction.Stop; } endings.Add(newEnd); } } foreach (ActionEnd ending in endings) { if (showGUI) { EditorGUILayout.Space(); int i = endings.IndexOf(ending); switch (i) { case 0: ending.resultAction = (ResultAction)EditorGUILayout.EnumPopup("If Inactive:", (ResultAction)ending.resultAction); break; case 1: ending.resultAction = (ResultAction)EditorGUILayout.EnumPopup("If Active:", (ResultAction)ending.resultAction); break; case 2: ending.resultAction = (ResultAction)EditorGUILayout.EnumPopup("If Complete:", (ResultAction)ending.resultAction); break; case 3: ending.resultAction = (ResultAction)EditorGUILayout.EnumPopup("If Failed:", (ResultAction)ending.resultAction); break; } } if (ending.resultAction == ResultAction.RunCutscene && showGUI) { if (isAssetFile) { ending.linkedAsset = (ActionListAsset)EditorGUILayout.ObjectField("ActionList to run:", ending.linkedAsset, typeof(ActionListAsset), false); } else { ending.linkedCutscene = (Cutscene)EditorGUILayout.ObjectField("Cutscene to run:", ending.linkedCutscene, typeof(Cutscene), true); } } else if (ending.resultAction == ResultAction.Skip) { SkipActionGUI(ending, actions, showGUI); } } }
private void ProcessActionEnd(ActionEnd actionEnd, int i, bool doStackOverflowDelay = false) { if (actionEnd.resultAction == ResultAction.RunCutscene) { if (actionEnd.linkedAsset != null) { if (isSkipping) { AdvGame.SkipActionListAsset (actionEnd.linkedAsset); } else { AdvGame.RunActionListAsset (actionEnd.linkedAsset, 0, !IsSkippable ()); } CheckEndCutscene (); } else if (actionEnd.linkedCutscene != null) { if (actionEnd.linkedCutscene != this) { if (isSkipping) { actionEnd.linkedCutscene.Skip (); } else { actionEnd.linkedCutscene.Interact (0, !IsSkippable ()); } CheckEndCutscene (); } else { if (triggerTime > 0f) { Kill (); StartCoroutine ("PauseUntilStart", !IsSkippable ()); } else { ProcessAction (0); } } } else { CheckEndCutscene (); } } else if (actionEnd.resultAction == ResultAction.Stop) { CheckEndCutscene (); } else if (actionEnd.resultAction == ResultAction.Skip) { if (doStackOverflowDelay) { StartCoroutine (DelayProcessAction (actionEnd.skipAction)); } else { ProcessAction (actionEnd.skipAction); } } else if (actionEnd.resultAction == ResultAction.Continue) { ProcessAction (i+1); } }
public override void OnInspectorGUI() { ActionListAsset _target = (ActionListAsset)target; ActionListAssetEditor.ShowPropertiesGUI(_target); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Expand all", EditorStyles.miniButtonLeft)) { Undo.RecordObject(_target, "Expand actions"); foreach (AC.Action action in _target.actions) { action.isDisplayed = true; } } if (GUILayout.Button("Collapse all", EditorStyles.miniButtonMid)) { Undo.RecordObject(_target, "Collapse actions"); foreach (AC.Action action in _target.actions) { action.isDisplayed = false; } } if (GUILayout.Button("Action List Editor", EditorStyles.miniButtonMid)) { ActionListEditorWindow.Init(_target); } if (!Application.isPlaying) { GUI.enabled = false; } if (GUILayout.Button("Run now", EditorStyles.miniButtonRight)) { if (KickStarter.actionListAssetManager != null) { if (!_target.canRunMultipleInstances) { int numRemoved = KickStarter.actionListAssetManager.EndAssetList(_target); if (numRemoved > 0) { ACDebug.Log("Removed 1 instance of ActionList asset '" + _target.name + "' because it is set to only run one at a time.", _target); } } AdvGame.RunActionListAsset(_target); } else { ACDebug.LogWarning("An AC PersistentEngine object must be present in the scene for ActionList assets to run.", _target); } } GUI.enabled = true; EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); if (actionsManager == null) { EditorGUILayout.HelpBox("An Actions Manager asset file must be assigned in the Game Editor Window", MessageType.Warning); OnEnable(); return; } if (!actionsManager.displayActionsInInspector) { EditorGUILayout.HelpBox("As set by the Actions Manager, Actions are only displayed in the ActionList Editor window.", MessageType.Info); return; } for (int i = 0; i < _target.actions.Count; i++) { int typeIndex = KickStarter.actionsManager.GetActionTypeIndex(_target.actions[i]); if (_target.actions[i] == null) { _target.actions.Insert(i, ActionListAssetEditor.RebuildAction(_target.actions[i], typeIndex, _target)); } _target.actions[i].isAssetFile = true; EditorGUILayout.BeginVertical("Button"); string actionLabel = " " + (i).ToString() + ": " + actionsManager.EnabledActions[typeIndex].GetFullTitle() + _target.actions[i].SetLabel(); actionLabel = actionLabel.Replace("\r\n", ""); actionLabel = actionLabel.Replace("\n", ""); actionLabel = actionLabel.Replace("\r", ""); if (actionLabel.Length > 40) { actionLabel = actionLabel.Substring(0, 40) + "..)"; } EditorGUILayout.BeginHorizontal(); _target.actions[i].isDisplayed = EditorGUILayout.Foldout(_target.actions[i].isDisplayed, actionLabel); if (!_target.actions[i].isEnabled) { EditorGUILayout.LabelField("DISABLED", EditorStyles.boldLabel, GUILayout.Width(100f)); } if (GUILayout.Button(Resource.CogIcon, GUILayout.Width(20f), GUILayout.Height(15f))) { ActionSideMenu(_target.actions[i]); } EditorGUILayout.EndHorizontal(); if (_target.actions[i].isDisplayed) { if (!actionsManager.DoesActionExist(_target.actions[i].GetType().ToString())) { EditorGUILayout.HelpBox("This Action type has been disabled in the Actions Manager", MessageType.Warning); } else { int newTypeIndex = ActionListEditor.ShowTypePopup(_target.actions[i], typeIndex); if (newTypeIndex >= 0) { // Rebuild constructor if Subclass and type string do not match ActionEnd _end = new ActionEnd(); _end.resultAction = _target.actions[i].endAction; _end.skipAction = _target.actions[i].skipAction; _end.linkedAsset = _target.actions[i].linkedAsset; _end.linkedCutscene = _target.actions[i].linkedCutscene; Undo.RecordObject(_target, "Change Action type"); _target.actions.Insert(i, ActionListAssetEditor.RebuildAction(_target.actions[i], newTypeIndex, _target, _end.resultAction, _end.skipAction, _end.linkedAsset, _end.linkedCutscene)); } EditorGUILayout.Space(); GUI.enabled = _target.actions[i].isEnabled; if (_target.useParameters) { if (Application.isPlaying) { _target.actions[i].AssignValues(_target.parameters); } _target.actions[i].ShowGUI(_target.parameters); } else { if (Application.isPlaying) { _target.actions[i].AssignValues(null); } _target.actions[i].ShowGUI(null); } } GUI.enabled = true; } if (_target.actions[i].endAction == AC.ResultAction.Skip || _target.actions[i] is ActionCheck || _target.actions[i] is ActionCheckMultiple || _target.actions[i] is ActionParallel) { _target.actions[i].SkipActionGUI(_target.actions, _target.actions[i].isDisplayed); } EditorGUILayout.EndVertical(); EditorGUILayout.Space(); } if (GUILayout.Button("Add new Action")) { Undo.RecordObject(_target, "Create action"); AddAction(actionsManager.GetDefaultAction(), _target.actions.Count, _target); } if (GUI.changed) { EditorUtility.SetDirty(_target); } }
protected void SkipActionGUI(ActionEnd ending, List<Action> actions, bool showGUI) { if (ending.skipAction == -1) { // Set default int i = actions.IndexOf (this); if (actions.Count > i+1) { ending.skipAction = i+1; } else { ending.skipAction = i; } } int tempSkipAction = ending.skipAction; List<string> labelList = new List<string>(); if (ending.skipActionActual) { bool found = false; for (int i = 0; i < actions.Count; i++) { labelList.Add (i.ToString () + ": " + actions [i].title); if (ending.skipActionActual == actions [i]) { ending.skipAction = i; found = true; } } if (!found) { ending.skipAction = tempSkipAction; } } if (ending.skipAction >= actions.Count) { ending.skipAction = actions.Count - 1; } if (showGUI) { if (actions.Count > 1) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField (" Action to skip to:"); tempSkipAction = EditorGUILayout.Popup (ending.skipAction, labelList.ToArray()); ending.skipAction = tempSkipAction; EditorGUILayout.EndHorizontal(); } else { EditorGUILayout.HelpBox ("Cannot skip action - no further Actions available", MessageType.Warning); return; } } ending.skipActionActual = actions [ending.skipAction]; }
/** * <summary>Shows the Conversation's dialogue options.</summary> * <param name = "actionList">The ActionList that contains the Action that calls this function</param> * <param name = "actionConversation">The "Dialogue: Start conversation" Action that calls this function. This is necessary when that Action overrides the Converstion's options.</param> */ public void Interact(ActionList actionList, ActionConversation actionConversation) { overrideActiveList = null; if (actionList) { onFinishActiveList = null; int actionIndex = actionList.actions.IndexOf(actionConversation); if (actionList && actionIndex >= 0 && actionIndex < actionList.actions.Count) { if (actionConversation.overrideOptions) { overrideActiveList = new ActiveList(actionList, true, actionIndex); actionList.ResetList(); } else if (actionConversation.willWait && !KickStarter.settingsManager.allowGameplayDuringConversations && actionConversation.endings.Count > 0) { ActionEnd ending = actionConversation.endings[0]; if (ending.resultAction != ResultAction.Stop) { switch (ending.resultAction) { case ResultAction.Continue: if (actionIndex < actionList.actions.Count - 1) { onFinishActiveList = new ActiveList(actionList, true, actionIndex + 1); } break; case ResultAction.Skip: onFinishActiveList = new ActiveList(actionList, true, ending.skipAction); break; case ResultAction.RunCutscene: if (actionList is RuntimeActionList) { if (ending.linkedAsset) { onFinishActiveList = new ActiveList(null, true, 0); onFinishActiveList.actionListAsset = ending.linkedAsset; } } else if (ending.linkedCutscene) { onFinishActiveList = new ActiveList(ending.linkedCutscene, true, 0); } break; default: break; } } } } } KickStarter.eventManager.Call_OnStartConversation(this); CancelInvoke("RunDefault"); int numPresent = 0; foreach (ButtonDialog _option in options) { if (_option.CanShow()) { numPresent++; } } if (numPresent == 1 && autoPlay) { foreach (ButtonDialog _option in options) { if (_option.CanShow()) { RunOption(_option); return; } } } else if (numPresent > 0) { KickStarter.playerInput.activeConversation = this; } else { KickStarter.playerInput.EndConversation(); return; } if (isTimed) { startTime = Time.time; Invoke("RunDefault", timer); } }
override public void SkipActionGUI(List <Action> actions, bool showGUI) { if (numSockets < 0) { numSockets = 0; } if (numSockets < endings.Count) { endings.RemoveRange(numSockets, endings.Count - numSockets); } else if (numSockets > endings.Count) { if (numSockets > endings.Capacity) { endings.Capacity = numSockets; } for (int i = endings.Count; i < numSockets; i++) { ActionEnd newEnd = new ActionEnd(); endings.Add(newEnd); } } foreach (ActionEnd ending in endings) { if (showGUI) { EditorGUILayout.Space(); int i = endings.IndexOf(ending) + 1; ending.resultAction = (ResultAction)EditorGUILayout.EnumPopup("Output " + i.ToString() + ":", (ResultAction)ending.resultAction); } if (ending.resultAction == ResultAction.RunCutscene && showGUI) { if (isAssetFile) { ending.linkedAsset = ActionListAssetMenu.AssetGUI("ActionList to run:", ending.linkedAsset); } else { ending.linkedCutscene = ActionListAssetMenu.CutsceneGUI("Cutscene to run:", ending.linkedCutscene); } } else if (ending.resultAction == ResultAction.Skip) { SkipActionGUI(ending, actions, showGUI); } } bool shownError = false; List <int> outputIndices = new List <int>(); foreach (ActionEnd ending in endings) { if (ending.resultAction == ResultAction.Skip) { if (outputIndices.Contains(ending.skipAction)) { if (!shownError) { EditorGUILayout.HelpBox("Two or more output sockets connect to the same subsequent Action - this may cause unexpected behaviour and should be changed.", MessageType.Warning); } shownError = true; } else { outputIndices.Add(ending.skipAction); } } } }
/** * <summary>Downloads and runs the settings and Actions stored within an ActionListAsset.</summary> * <param name = "actionListAsset">The ActionListAsset to copy Actions from and run</param> * <param name = "endConversation">If set, the supplied Conversation will be run when the AcionList ends</param> * <param name = "i">The index number of the first Action to run</param> * <param name = "doSkip">If True, then the Actions will be skipped, instead of run normally</param> * <param name = "addToSkipQueue">If True, the ActionList will be skippable when the user presses 'EndCutscene'</param> * <param name = "dontRun">If True, the Actions will not be run once transferred from the ActionListAsset</param> */ public void DownloadActions(ActionListAsset actionListAsset, Conversation endConversation, int i, bool doSkip, bool addToSkipQueue, bool dontRun = false) { assetSource = actionListAsset; useParameters = actionListAsset.useParameters; parameters = new List <ActionParameter>(); List <ActionParameter> assetParameters = actionListAsset.GetParameters(); if (assetParameters != null) { foreach (ActionParameter assetParameter in assetParameters) { parameters.Add(new ActionParameter(assetParameter, true)); } } unfreezePauseMenus = actionListAsset.unfreezePauseMenus; actionListType = actionListAsset.actionListType; if (actionListAsset.actionListType == ActionListType.PauseGameplay) { isSkippable = actionListAsset.isSkippable; } else { isSkippable = false; } conversation = endConversation; actions.Clear(); foreach (AC.Action action in actionListAsset.actions) { if (action != null) { ActionEnd _lastResult = action.lastResult; // Really we should re-instantiate all Actions, but this is 'safer' Action newAction = (actionListAsset.canRunMultipleInstances) ? (Object.Instantiate(action) as Action) : action; if (doSkip) { newAction.lastResult = _lastResult; } actions.Add(newAction); } else { actions.Add(null); } } /*if (!useParameters) * { * foreach (Action action in actions) * { * action.AssignValues (null); * } * }*/ actionListAsset.AfterDownloading(); if (!dontRun) { if (doSkip) { Skip(i); } else { Interact(i, addToSkipQueue); } } if (actionListAsset.canSurviveSceneChanges && !actionListAsset.IsSkippable()) { DontDestroyOnLoad(gameObject); } }
protected void DrawSharedElements() { ActionList _target = (ActionList) target; if (!_target.gameObject.activeInHierarchy) { EditorGUILayout.HelpBox ("Scene-based Actions can not live in prefabs - use ActionList assets instead.", MessageType.Info); return; } if (_target.source == ActionListSource.AssetFile) { return; } int numActions = _target.actions.Count; if (numActions < 1) { numActions = 1; AC.Action newAction = ActionList.GetDefaultAction (); _target.actions.Add (newAction); } if (_target.useParameters) { ShowParametersGUI (_target); } EditorGUILayout.Space (); EditorGUILayout.BeginHorizontal (); if (GUILayout.Button ("Expand all", EditorStyles.miniButtonLeft)) { Undo.RecordObject (_target, "Expand actions"); foreach (AC.Action action in _target.actions) { action.isDisplayed = true; } } if (GUILayout.Button ("Collapse all", EditorStyles.miniButtonMid)) { Undo.RecordObject (_target, "Collapse actions"); foreach (AC.Action action in _target.actions) { action.isDisplayed = false; } } if (GUILayout.Button ("Action List Editor", EditorStyles.miniButtonMid)) { ActionListEditorWindow.Init (_target); } if (!Application.isPlaying) { GUI.enabled = false; } if (GUILayout.Button ("Run now", EditorStyles.miniButtonRight)) { _target.Interact (); } GUI.enabled = true; EditorGUILayout.EndHorizontal (); EditorGUILayout.Space (); ActionListEditor.ResetList (_target); if (actionsManager == null) { EditorGUILayout.HelpBox ("An Actions Manager asset file must be assigned in the Game Editor Window", MessageType.Warning); OnEnable (); return; } if (!actionsManager.displayActionsInInspector) { EditorGUILayout.HelpBox ("As set by the Actions Manager, Actions are only displayed in the ActionList Editor window.", MessageType.Info); return; } for (int i=0; i<_target.actions.Count; i++) { if (_target.actions[i] == null) { Debug.LogWarning ("An empty Action was found, and was deleted"); _target.actions.RemoveAt (i); continue; } EditorGUILayout.BeginVertical ("Button"); EditorGUILayout.BeginHorizontal (); int typeIndex = KickStarter.actionsManager.GetActionTypeIndex (_target.actions[i]); string actionLabel = " (" + (i).ToString() + ") " + actionsManager.EnabledActions[typeIndex].GetFullTitle () + _target.actions[i].SetLabel (); _target.actions[i].isDisplayed = EditorGUILayout.Foldout (_target.actions[i].isDisplayed, actionLabel); if (!_target.actions[i].isEnabled) { EditorGUILayout.LabelField ("DISABLED", EditorStyles.boldLabel, GUILayout.MaxWidth (100f)); } Texture2D icon = (Texture2D) AssetDatabase.LoadAssetAtPath ("Assets/AdventureCreator/Graphics/Textures/inspector-use.png", typeof (Texture2D)); if (GUILayout.Button (icon, GUILayout.Width (20f), GUILayout.Height (15f))) { ActionSideMenu (i); } _target.actions[i].isAssetFile = false; EditorGUILayout.EndHorizontal (); if (_target.actions[i].isBreakPoint) { EditorGUILayout.HelpBox ("Break point", MessageType.None); } if (_target.actions[i].isDisplayed) { GUI.enabled = _target.actions[i].isEnabled; if (!actionsManager.DoesActionExist (_target.actions[i].GetType ().ToString ())) { EditorGUILayout.HelpBox ("This Action type has been disabled in the Actions Manager", MessageType.Warning); } else { int newTypeIndex = ActionListEditor.ShowTypePopup (_target.actions[i], typeIndex); if (newTypeIndex >= 0) { // Rebuild constructor if Subclass and type string do not match ActionEnd _end = new ActionEnd (); _end.resultAction = _target.actions[i].endAction; _end.skipAction = _target.actions[i].skipAction; _end.linkedAsset = _target.actions[i].linkedAsset; _end.linkedCutscene = _target.actions[i].linkedCutscene; Undo.RecordObject (_target, "Change Action type"); _target.actions[i] = ActionListEditor.RebuildAction (_target.actions[i], newTypeIndex, _end.resultAction, _end.skipAction, _end.linkedAsset, _end.linkedCutscene); } if (_target.useParameters && _target.parameters != null && _target.parameters.Count > 0) { _target.actions[i].ShowGUI (_target.parameters); } else { _target.actions[i].ShowGUI (null); } } } if (_target.actions[i].endAction == AC.ResultAction.Skip || _target.actions[i].numSockets == 2 || _target.actions[i] is ActionCheckMultiple || _target.actions[i] is ActionParallel) { _target.actions[i].SkipActionGUI (_target.actions, _target.actions[i].isDisplayed); } GUI.enabled = true; EditorGUILayout.EndVertical (); EditorGUILayout.Space (); } if (GUILayout.Button("Add new action")) { Undo.RecordObject (_target, "Create action"); numActions += 1; } _target.actions = ActionListEditor.ResizeList (_target.actions, numActions); }
public override void OnInspectorGUI() { ActionListAsset _target = (ActionListAsset) target; ActionListAssetEditor.ShowPropertiesGUI (_target); EditorGUILayout.Space (); EditorGUILayout.BeginHorizontal (); if (GUILayout.Button ("Expand all", EditorStyles.miniButtonLeft)) { Undo.RecordObject (_target, "Expand actions"); foreach (AC.Action action in _target.actions) { action.isDisplayed = true; } } if (GUILayout.Button ("Collapse all", EditorStyles.miniButtonMid)) { Undo.RecordObject (_target, "Collapse actions"); foreach (AC.Action action in _target.actions) { action.isDisplayed = false; } } if (GUILayout.Button ("Action List Editor", EditorStyles.miniButtonMid)) { ActionListEditorWindow.Init (_target); } if (!Application.isPlaying) { GUI.enabled = false; } if (GUILayout.Button ("Run now", EditorStyles.miniButtonRight)) { AdvGame.RunActionListAsset (_target); } GUI.enabled = true; EditorGUILayout.EndHorizontal (); EditorGUILayout.Space (); if (actionsManager == null) { EditorGUILayout.HelpBox ("An Actions Manager asset file must be assigned in the Game Editor Window", MessageType.Warning); OnEnable (); return; } if (!actionsManager.displayActionsInInspector) { EditorGUILayout.HelpBox ("As set by the Actions Manager, Actions are only displayed in the ActionList Editor window.", MessageType.Info); return; } for (int i=0; i<_target.actions.Count; i++) { int typeIndex = KickStarter.actionsManager.GetActionTypeIndex (_target.actions[i]); if (_target.actions[i] == null) { _target.actions.Insert (i, ActionListAssetEditor.RebuildAction (_target.actions[i], typeIndex, _target)); } _target.actions[i].isAssetFile = true; EditorGUILayout.BeginVertical("Button"); string actionLabel = " " + (i).ToString() + ": " + actionsManager.EnabledActions[typeIndex].GetFullTitle () + _target.actions[i].SetLabel (); EditorGUILayout.BeginHorizontal (); _target.actions[i].isDisplayed = EditorGUILayout.Foldout (_target.actions[i].isDisplayed, actionLabel); if (!_target.actions[i].isEnabled) { EditorGUILayout.LabelField ("DISABLED", EditorStyles.boldLabel, GUILayout.Width (100f)); } Texture2D icon = (Texture2D) AssetDatabase.LoadAssetAtPath ("Assets/AdventureCreator/Graphics/Textures/inspector-use.png", typeof (Texture2D)); if (GUILayout.Button (icon, GUILayout.Width (20f), GUILayout.Height (15f))) { ActionSideMenu (_target.actions[i]); } EditorGUILayout.EndHorizontal (); if (_target.actions[i].isDisplayed) { if (!actionsManager.DoesActionExist (_target.actions[i].GetType ().ToString ())) { EditorGUILayout.HelpBox ("This Action type has been disabled in the Actions Manager", MessageType.Warning); } else { int newTypeIndex = ActionListEditor.ShowTypePopup (_target.actions[i], typeIndex); if (newTypeIndex >= 0) { // Rebuild constructor if Subclass and type string do not match ActionEnd _end = new ActionEnd (); _end.resultAction = _target.actions[i].endAction; _end.skipAction = _target.actions[i].skipAction; _end.linkedAsset = _target.actions[i].linkedAsset; _end.linkedCutscene = _target.actions[i].linkedCutscene; Undo.RecordObject (_target, "Change Action type"); _target.actions.Insert (i, ActionListAssetEditor.RebuildAction (_target.actions[i], newTypeIndex, _target, _end.resultAction, _end.skipAction, _end.linkedAsset, _end.linkedCutscene)); } EditorGUILayout.Space (); GUI.enabled = _target.actions[i].isEnabled; if (_target.useParameters) { if (Application.isPlaying) { _target.actions[i].AssignValues (_target.parameters); } _target.actions[i].ShowGUI (_target.parameters); } else { if (Application.isPlaying) { _target.actions[i].AssignValues (null); } _target.actions[i].ShowGUI (null); } } GUI.enabled = true; } if (_target.actions[i].endAction == AC.ResultAction.Skip || _target.actions[i] is ActionCheck || _target.actions[i] is ActionCheckMultiple || _target.actions[i] is ActionParallel) { _target.actions[i].SkipActionGUI (_target.actions, _target.actions[i].isDisplayed); } EditorGUILayout.EndVertical(); EditorGUILayout.Space (); } if (GUILayout.Button("Add new Action")) { Undo.RecordObject (_target, "Create action"); AddAction (actionsManager.GetActionName (actionsManager.defaultClass), _target.actions.Count, _target); } if (GUI.changed) { EditorUtility.SetDirty (_target); } }
public override void OnInspectorGUI () { ActionListAsset _target = (ActionListAsset) target; actionsManager = AdvGame.GetReferences ().actionsManager; EditorGUILayout.BeginVertical ("Button"); EditorGUILayout.LabelField ("Asset properties", EditorStyles.boldLabel); _target.actionListType = (ActionListType) EditorGUILayout.EnumPopup ("When running:", _target.actionListType); if (_target.actionListType == ActionListType.PauseGameplay) { _target.isSkippable = EditorGUILayout.Toggle ("Is skippable?", _target.isSkippable); _target.unfreezePauseMenus = EditorGUILayout.Toggle ("Unfreeze 'pause' Menus?", _target.unfreezePauseMenus); } _target.useParameters = EditorGUILayout.Toggle ("Use parameters?", _target.useParameters); EditorGUILayout.EndVertical (); if (_target.useParameters) { ShowParametersGUI (_target); } EditorGUILayout.Space (); EditorGUILayout.BeginHorizontal (); if (GUILayout.Button ("Expand all", EditorStyles.miniButtonLeft)) { Undo.RecordObject (_target, "Expand actions"); foreach (AC.Action action in _target.actions) { action.isDisplayed = true; } } if (GUILayout.Button ("Collapse all", EditorStyles.miniButtonMid)) { Undo.RecordObject (_target, "Collapse actions"); foreach (AC.Action action in _target.actions) { action.isDisplayed = false; } } if (GUILayout.Button ("Action List Editor", EditorStyles.miniButtonMid)) { ActionListEditorWindow window = (ActionListEditorWindow) EditorWindow.GetWindow (typeof (ActionListEditorWindow)); window.Repaint (); } if (!Application.isPlaying) { GUI.enabled = false; } if (GUILayout.Button ("Run now", EditorStyles.miniButtonRight)) { AdvGame.RunActionListAsset (_target); } GUI.enabled = true; EditorGUILayout.EndHorizontal (); EditorGUILayout.Space (); for (int i=0; i<_target.actions.Count; i++) { typeNumber = ActionListEditor.GetTypeNumber (_target.actions[i]); if (_target.actions[i] == null) { _target.actions.Insert (i, ActionListAssetEditor.RebuildAction (_target.actions[i], typeNumber, _target)); } categoryNumber = ActionListEditor.GetCategoryNumber (typeNumber); subCategoryNumber = ActionListEditor.GetSubCategoryNumber (_target.actions[i].title, categoryNumber); _target.actions[i].isAssetFile = true; EditorGUILayout.BeginVertical("Button"); string actionLabel = " " + (i).ToString() + ": " + _target.actions[i].title + _target.actions[i].SetLabel (); EditorGUILayout.BeginHorizontal (); _target.actions[i].isDisplayed = EditorGUILayout.Foldout (_target.actions[i].isDisplayed, actionLabel); if (!_target.actions[i].isEnabled) { EditorGUILayout.LabelField ("DISABLED", EditorStyles.boldLabel, GUILayout.Width (100f)); } Texture2D icon = (Texture2D) AssetDatabase.LoadAssetAtPath ("Assets/AdventureCreator/Graphics/Textures/inspector-use.png", typeof (Texture2D)); if (GUILayout.Button (icon, GUILayout.Width (20f), GUILayout.Height (15f))) { ActionSideMenu (_target.actions[i]); } EditorGUILayout.EndHorizontal (); if (_target.actions[i].isDisplayed) { if (!actionsManager.DoesActionExist (_target.actions[i].GetType ().ToString ())) { EditorGUILayout.HelpBox ("This Action type has been disabled in the Actions Manager", MessageType.Warning); } else { EditorGUILayout.BeginHorizontal (); EditorGUILayout.LabelField ("Action type:", GUILayout.Width (150)); categoryNumber = EditorGUILayout.Popup(categoryNumber, actionsManager.GetActionCategories ()); subCategoryNumber = EditorGUILayout.Popup(subCategoryNumber, actionsManager.GetActionSubCategories (categoryNumber)); EditorGUILayout.EndVertical (); typeNumber = actionsManager.GetTypeNumber (categoryNumber, subCategoryNumber); // Rebuild constructor if Subclass and type string do not match if (_target.actions[i].GetType ().ToString () != actionsManager.GetActionName (typeNumber) && _target.actions[i].GetType ().ToString () != ("AC." + actionsManager.GetActionName (typeNumber))) { ActionEnd _end = new ActionEnd (); _end.resultAction = _target.actions[i].endAction; _end.skipAction = _target.actions[i].skipAction; _end.linkedAsset = _target.actions[i].linkedAsset; _end.linkedCutscene = _target.actions[i].linkedCutscene; Undo.RecordObject (_target, "Change Action type"); _target.actions.Insert (i, ActionListAssetEditor.RebuildAction (_target.actions[i], typeNumber, _target, _end.resultAction, _end.skipAction, _end.linkedAsset, _end.linkedCutscene)); } EditorGUILayout.Space (); GUI.enabled = _target.actions[i].isEnabled; if (_target.useParameters) { _target.actions[i].ShowGUI (_target.parameters); } else { _target.actions[i].ShowGUI (null); } } GUI.enabled = true; } if (_target.actions[i].endAction == AC.ResultAction.Skip || _target.actions[i] is ActionCheck || _target.actions[i] is ActionCheckMultiple) { _target.actions[i].SkipActionGUI (_target.actions, _target.actions[i].isDisplayed); } EditorGUILayout.EndVertical(); EditorGUILayout.Space (); } if (GUILayout.Button("Add new Action")) { AddAction (actionsManager.GetActionName (actionsManager.defaultClass), _target.actions.Count, _target); } if (GUI.changed) { EditorUtility.SetDirty (_target); } }
protected void ReturnLastResultToSource(ActionEnd _lastResult, int i) { }
override public void SkipActionGUI(List <Action> actions, bool showGUI) { if (numSockets < 0) { numSockets = 0; } if (numSockets < endings.Count) { endings.RemoveRange(numSockets, endings.Count - numSockets); } else if (numSockets > endings.Count) { if (numSockets > endings.Capacity) { endings.Capacity = numSockets; } for (int i = endings.Count; i < numSockets; i++) { ActionEnd newEnd = new ActionEnd(); if (i > 0) { newEnd.resultAction = ResultAction.Stop; } endings.Add(newEnd); } } foreach (ActionEnd ending in endings) { if (showGUI) { EditorGUILayout.Space(); int i = endings.IndexOf(ending); GVar _var = (parameterID < 0) ? GetVariable() : null; if (_var != null) { string[] popUpLabels = _var.GenerateEditorPopUpLabels(); ending.resultAction = (ResultAction)EditorGUILayout.EnumPopup("If = '" + popUpLabels[i] + "':", (ResultAction)ending.resultAction); } else if (AdvGame.GetReferences().variablesManager == null) { ending.resultAction = (ResultAction)EditorGUILayout.EnumPopup("If = '" + i.ToString() + "':", (ResultAction)ending.resultAction); } else { PopUpLabelData popUpLabelData = AdvGame.GetReferences().variablesManager.GetPopUpLabelData(placeholderPopUpLabelDataID); if (parameterID >= 0 && popUpLabelData != null) { ending.resultAction = (ResultAction)EditorGUILayout.EnumPopup("If = '" + popUpLabelData.GetValue(i) + "':", (ResultAction)ending.resultAction); } else { ending.resultAction = (ResultAction)EditorGUILayout.EnumPopup("If = '" + i.ToString() + "':", (ResultAction)ending.resultAction); } } } if (ending.resultAction == ResultAction.RunCutscene && showGUI) { if (isAssetFile) { ending.linkedAsset = (ActionListAsset)EditorGUILayout.ObjectField("ActionList to run:", ending.linkedAsset, typeof(ActionListAsset), false); } else { ending.linkedCutscene = (Cutscene)EditorGUILayout.ObjectField("Cutscene to run:", ending.linkedCutscene, typeof(Cutscene), true); } } else if (ending.resultAction == ResultAction.Skip) { SkipActionGUI(ending, actions, showGUI); } } }
public virtual void SetLastResult(ActionEnd _actionEnd) { lastResult = _actionEnd; }
private void EndAction(Action action) { action.isRunning = false; ActionEnd actionEnd = action.End (this.actions); if (isSkipping && action.lastResult.skipAction != -10 && (action is ActionCheck || action is ActionCheckMultiple)) { // When skipping an ActionCheck that has already run, revert to previous result actionEnd = new ActionEnd (action.lastResult); } else { action.SetLastResult (new ActionEnd (actionEnd)); ReturnLastResultToSource (actionEnd, actions.IndexOf (action)); } if (action is ActionCheck || action is ActionCheckMultiple) { if (actionEnd.resultAction == ResultAction.Skip && actionEnd.skipAction == actions.IndexOf (action)) { // Looping on itself will cause a StackOverflowException, so delay slightly ProcessActionEnd (actionEnd, actions.IndexOf (action), true); return; } } ProcessActionEnd (actionEnd, actions.IndexOf (action)); }
protected void DrawSharedElements(ActionList _target) { if (PrefabUtility.GetPrefabType(_target) == PrefabType.Prefab) { EditorGUILayout.HelpBox("Scene-based Actions can not live in prefabs - use ActionList assets instead.", MessageType.Info); return; } int numActions = 0; if (_target.source != ActionListSource.AssetFile) { numActions = _target.actions.Count; if (numActions < 1) { numActions = 1; AC.Action newAction = ActionList.GetDefaultAction(); _target.actions.Add(newAction); } } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); if (_target.source == ActionListSource.AssetFile) { GUI.enabled = false; } if (GUILayout.Button("Expand all", EditorStyles.miniButtonLeft)) { Undo.RecordObject(_target, "Expand actions"); foreach (AC.Action action in _target.actions) { action.isDisplayed = true; } } if (GUILayout.Button("Collapse all", EditorStyles.miniButtonMid)) { Undo.RecordObject(_target, "Collapse actions"); foreach (AC.Action action in _target.actions) { action.isDisplayed = false; } } GUI.enabled = true; if (GUILayout.Button("Action List Editor", EditorStyles.miniButtonMid)) { if (_target.source == ActionListSource.AssetFile) { if (_target.assetFile != null) { ActionListEditorWindow.Init(_target.assetFile); } } else { ActionListEditorWindow.Init(_target); } } if (!Application.isPlaying) { GUI.enabled = false; } if (GUILayout.Button("Run now", EditorStyles.miniButtonRight)) { _target.Interact(); } GUI.enabled = true; EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); if (_target.source == ActionListSource.AssetFile) { return; } ActionListEditor.ResetList(_target); if (actionsManager == null) { EditorGUILayout.HelpBox("An Actions Manager asset file must be assigned in the Game Editor Window", MessageType.Warning); OnEnable(); return; } if (!actionsManager.displayActionsInInspector) { EditorGUILayout.HelpBox("As set by the Actions Manager, Actions are only displayed in the ActionList Editor window.", MessageType.Info); return; } for (int i = 0; i < _target.actions.Count; i++) { if (_target.actions[i] == null) { ACDebug.LogWarning("An empty Action was found, and was deleted"); _target.actions.RemoveAt(i); continue; } EditorGUILayout.BeginVertical("Button"); EditorGUILayout.BeginHorizontal(); int typeIndex = KickStarter.actionsManager.GetActionTypeIndex(_target.actions[i]); string actionLabel = " (" + (i).ToString() + ") " + actionsManager.EnabledActions[typeIndex].GetFullTitle() + _target.actions[i].SetLabel(); _target.actions[i].isDisplayed = EditorGUILayout.Foldout(_target.actions[i].isDisplayed, actionLabel); if (!_target.actions[i].isEnabled) { EditorGUILayout.LabelField("DISABLED", EditorStyles.boldLabel, GUILayout.MaxWidth(100f)); } if (GUILayout.Button(Resource.CogIcon, GUILayout.Width(20f), GUILayout.Height(15f))) { ActionSideMenu(i); } _target.actions[i].isAssetFile = false; EditorGUILayout.EndHorizontal(); if (_target.actions[i].isBreakPoint) { EditorGUILayout.HelpBox("Break point", MessageType.None); } if (_target.actions[i].isDisplayed) { GUI.enabled = _target.actions[i].isEnabled; if (!actionsManager.DoesActionExist(_target.actions[i].GetType().ToString())) { EditorGUILayout.HelpBox("This Action type has been disabled in the Actions Manager", MessageType.Warning); } else { int newTypeIndex = ActionListEditor.ShowTypePopup(_target.actions[i], typeIndex); if (newTypeIndex >= 0) { // Rebuild constructor if Subclass and type string do not match ActionEnd _end = new ActionEnd(); _end.resultAction = _target.actions[i].endAction; _end.skipAction = _target.actions[i].skipAction; _end.linkedAsset = _target.actions[i].linkedAsset; _end.linkedCutscene = _target.actions[i].linkedCutscene; Undo.RecordObject(_target, "Change Action type"); _target.actions[i] = ActionListEditor.RebuildAction(_target.actions[i], newTypeIndex, _end.resultAction, _end.skipAction, _end.linkedAsset, _end.linkedCutscene); } if (_target.useParameters && _target.parameters != null && _target.parameters.Count > 0) { _target.actions[i].ShowGUI(_target.parameters); } else { _target.actions[i].ShowGUI(null); } } } if (_target.actions[i].endAction == AC.ResultAction.Skip || _target.actions[i].numSockets == 2 || _target.actions[i] is ActionCheckMultiple || _target.actions[i] is ActionParallel) { _target.actions[i].SkipActionGUI(_target.actions, _target.actions[i].isDisplayed); } GUI.enabled = true; EditorGUILayout.EndVertical(); EditorGUILayout.Space(); } if (GUILayout.Button("Add new action")) { Undo.RecordObject(_target, "Create action"); numActions += 1; } _target.actions = ActionListEditor.ResizeList(_target.actions, numActions); }
private void ProcessActionEnd(ActionEnd actionEnd, int i, bool doStackOverflowDelay = false) { if (isSkipping && skipIteractions > (actions.Count * 3)) { // StackOverFlow ACDebug.LogWarning("Looping ActionList '" + gameObject.name + "' detected while skipping - ending prematurely to avoid a StackOverflow exception."); CheckEndCutscene(); return; } if (pauseWhenActionFinishes) { resumeIndices.Add(i); if (!AreActionsRunning()) { FinishPause(); } return; } if (actionEnd.resultAction == ResultAction.RunCutscene) { if (actionEnd.linkedAsset != null) { if (isSkipping) { AdvGame.SkipActionListAsset(actionEnd.linkedAsset); } else { AdvGame.RunActionListAsset(actionEnd.linkedAsset, 0, !IsSkippable()); } CheckEndCutscene(); } else if (actionEnd.linkedCutscene != null) { if (actionEnd.linkedCutscene != this) { if (isSkipping) { actionEnd.linkedCutscene.Skip(); } else { actionEnd.linkedCutscene.Interact(0, !IsSkippable()); } CheckEndCutscene(); } else { if (triggerTime > 0f) { Kill(); StartCoroutine("PauseUntilStart", !IsSkippable()); } else { ProcessAction(0); } } } else { CheckEndCutscene(); } } else if (actionEnd.resultAction == ResultAction.Stop) { CheckEndCutscene(); } else if (actionEnd.resultAction == ResultAction.Skip) { if (doStackOverflowDelay) { StartCoroutine(DelayProcessAction(actionEnd.skipAction)); } else { ProcessAction(actionEnd.skipAction); } } else if (actionEnd.resultAction == ResultAction.Continue) { ProcessAction(i + 1); } pauseWhenActionFinishes = false; }
protected void DrawSharedElements () { ActionList _target = (ActionList) target; if (_target.source == ActionListSource.AssetFile) { return; } if (AdvGame.GetReferences () == null) { Debug.LogError ("A References file is required - please use the Adventure Creator window to create one."); EditorGUILayout.LabelField ("No References file found!"); } else { actionsManager = AdvGame.GetReferences ().actionsManager; if (actionsManager) { int numActions = _target.actions.Count; if (numActions < 1) { numActions = 1; AC.Action newAction = GetDefaultAction (); _target.actions.Add (newAction); } if (_target.useParameters) { ShowParametersGUI (_target); } EditorGUILayout.Space (); EditorGUILayout.BeginHorizontal (); if (GUILayout.Button ("Expand all", EditorStyles.miniButtonLeft)) { Undo.RecordObject (_target, "Expand actions"); foreach (AC.Action action in _target.actions) { action.isDisplayed = true; } } if (GUILayout.Button ("Collapse all", EditorStyles.miniButtonMid)) { Undo.RecordObject (_target, "Collapse actions"); foreach (AC.Action action in _target.actions) { action.isDisplayed = false; } } if (GUILayout.Button ("Action List Editor", EditorStyles.miniButtonMid)) { ActionListEditorWindow window = (ActionListEditorWindow) EditorWindow.GetWindow (typeof (ActionListEditorWindow)); window.Repaint (); } if (!Application.isPlaying) { GUI.enabled = false; } if (GUILayout.Button ("Run now", EditorStyles.miniButtonRight)) { _target.Interact (); } GUI.enabled = true; EditorGUILayout.EndHorizontal (); EditorGUILayout.Space (); ActionListEditor.ResetList (_target); for (int i=0; i<_target.actions.Count; i++) { if (_target.actions[i] == null) { Debug.LogWarning ("An empty Action was found, and was deleted"); _target.actions.RemoveAt (i); } EditorGUILayout.BeginVertical ("Button"); typeNumber = ActionListEditor.GetTypeNumber (_target.actions[i]); categoryNumber = ActionListEditor.GetCategoryNumber (typeNumber); subCategoryNumber = ActionListEditor.GetSubCategoryNumber (_target.actions[i].title, categoryNumber); EditorGUILayout.BeginHorizontal (); string actionLabel = " " + (i).ToString() + ": " + _target.actions[i].title + _target.actions[i].SetLabel (); _target.actions[i].isDisplayed = EditorGUILayout.Foldout (_target.actions[i].isDisplayed, actionLabel); if (!_target.actions[i].isEnabled) { EditorGUILayout.LabelField ("DISABLED", EditorStyles.boldLabel, GUILayout.MaxWidth (100f)); } Texture2D icon = (Texture2D) AssetDatabase.LoadAssetAtPath ("Assets/AdventureCreator/Graphics/Textures/inspector-use.png", typeof (Texture2D)); if (GUILayout.Button (icon, GUILayout.Width (20f), GUILayout.Height (15f))) { ActionSideMenu (i); } _target.actions[i].isAssetFile = false; EditorGUILayout.EndHorizontal (); if (_target.actions[i].isDisplayed) { GUI.enabled = _target.actions[i].isEnabled; if (!actionsManager.DoesActionExist (_target.actions[i].GetType ().ToString ())) { EditorGUILayout.HelpBox ("This Action type has been disabled in the Actions Manager", MessageType.Warning); } else { EditorGUILayout.BeginHorizontal (); EditorGUILayout.LabelField ("Action type:", GUILayout.Width (150)); categoryNumber = EditorGUILayout.Popup(categoryNumber, actionsManager.GetActionCategories ()); subCategoryNumber = EditorGUILayout.Popup(subCategoryNumber, actionsManager.GetActionSubCategories (categoryNumber)); EditorGUILayout.EndVertical (); typeNumber = actionsManager.GetTypeNumber (categoryNumber, subCategoryNumber); EditorGUILayout.Space (); // Rebuild constructor if Subclass and type string do not match if (_target.actions[i].GetType ().ToString () != actionsManager.GetActionName (typeNumber) && _target.actions[i].GetType ().ToString () != ("AC." + actionsManager.GetActionName (typeNumber))) { ActionEnd _end = new ActionEnd (); _end.resultAction = _target.actions[i].endAction; _end.skipAction = _target.actions[i].skipAction; _end.linkedAsset = _target.actions[i].linkedAsset; _end.linkedCutscene = _target.actions[i].linkedCutscene; Undo.RecordObject (_target, "Change Action type"); _target.actions[i] = ActionListEditor.RebuildAction (_target.actions[i], typeNumber, _end.resultAction, _end.skipAction, _end.linkedAsset, _end.linkedCutscene); } if (_target.useParameters && _target.parameters != null && _target.parameters.Count > 0) { _target.actions[i].ShowGUI (_target.parameters); } else { _target.actions[i].ShowGUI (null); } } } if (_target.actions[i].endAction == AC.ResultAction.Skip || _target.actions[i].numSockets == 2 || _target.actions[i] is ActionCheckMultiple) { _target.actions[i].SkipActionGUI (_target.actions, _target.actions[i].isDisplayed); } GUI.enabled = true; EditorGUILayout.EndVertical(); EditorGUILayout.Space (); } if (GUILayout.Button("Add new action")) { Undo.RecordObject (_target, "Create action"); numActions += 1; } _target.actions = ActionListEditor.ResizeList (_target.actions, numActions); } } }
protected new void ReturnLastResultToSource(ActionEnd _lastResult, int i) { assetSource.actions[i].lastResult = _lastResult; }
private void NodeWindow (int i) { if (actionsManager == null) { OnEnable (); } if (actionsManager == null) { return; } bool isAsset; Action _action; List<ActionParameter> parameters = null; if (_targetAsset != null) { _action = _targetAsset.actions[i]; isAsset = _action.isAssetFile = true; if (_targetAsset.useParameters) { parameters = _targetAsset.parameters; } } else { _action = _target.actions[i]; isAsset = _action.isAssetFile = false; if (_target.useParameters) { parameters = _target.parameters; } } GUI.enabled = _action.isEnabled; if (!actionsManager.DoesActionExist (_action.GetType ().ToString ())) { EditorGUILayout.HelpBox ("This Action type has been disabled in the Actions Manager", MessageType.Warning); } else { int typeNumber = GetTypeNumber (i, isAsset); int categoryNumber = GetCategoryNumber (typeNumber); int subCategoryNumber = GetSubCategoryNumber (i, categoryNumber, isAsset); EditorGUILayout.BeginHorizontal (); EditorGUILayout.LabelField ("Action type:", GUILayout.Width (100)); categoryNumber = EditorGUILayout.Popup (categoryNumber, actionsManager.GetActionCategories ()); subCategoryNumber = EditorGUILayout.Popup (subCategoryNumber, actionsManager.GetActionSubCategories (categoryNumber)); EditorGUILayout.EndVertical (); typeNumber = actionsManager.GetTypeNumber (categoryNumber, subCategoryNumber); EditorGUILayout.Space (); // Rebuild constructor if Subclass and type string do not match if (_action.GetType ().ToString () != actionsManager.GetActionName (typeNumber) && _action.GetType ().ToString () != ("AC." + actionsManager.GetActionName (typeNumber))) { Vector2 currentPosition = new Vector2 (_action.nodeRect.x, _action.nodeRect.y); // Store "After running data" to transfer over ActionEnd _end = new ActionEnd (); _end.resultAction = _action.endAction; _end.skipAction = _action.skipAction; _end.linkedAsset = _action.linkedAsset; _end.linkedCutscene = _action.linkedCutscene; if (isAsset) { Undo.RecordObject (_targetAsset, "Change Action type"); Action newAction = ActionListAssetEditor.RebuildAction (_action, typeNumber, _targetAsset, _end.resultAction, _end.skipAction, _end.linkedAsset, _end.linkedCutscene); newAction.nodeRect.x = currentPosition.x; newAction.nodeRect.y = currentPosition.y; _targetAsset.actions.Remove (_action); _targetAsset.actions.Insert (i, newAction); } else { Undo.RecordObject (_target, "Change Action type"); Action newAction = ActionListEditor.RebuildAction (_action, typeNumber, _end.resultAction, _end.skipAction, _end.linkedAsset, _end.linkedCutscene); newAction.nodeRect.x = currentPosition.x; newAction.nodeRect.y = currentPosition.y; _target.actions.Remove (_action); _target.actions.Insert (i, newAction); } } _action.ShowGUI (parameters); } GUI.enabled = true; if (_action.endAction == ResultAction.Skip || _action.numSockets == 2 || _action is ActionCheckMultiple) { if (isAsset) { _action.SkipActionGUI (_targetAsset.actions, true); } else { _action.SkipActionGUI (_target.actions, true); } } if (i == 0) { _action.nodeRect.x = 50; _action.nodeRect.y = 50; } else if (deleteSkips == 0) { if (Event.current.button == 0) { GUI.DragWindow (); } } }
public override void SkipActionGUI(List<Action> actions, bool showGUI) { if (numSockets < 0) { numSockets = 0; } if (numSockets < endings.Count) { endings.RemoveRange (numSockets, endings.Count - numSockets); } else if (numSockets > endings.Count) { if (numSockets > endings.Capacity) { endings.Capacity = numSockets; } for (int i=endings.Count; i<numSockets; i++) { ActionEnd newEnd = new ActionEnd (); newEnd.resultAction = ResultAction.Stop; endings.Add (newEnd); } } foreach (ActionEnd ending in endings) { if (showGUI) { EditorGUILayout.Space (); int i = endings.IndexOf (ending) +1; ending.resultAction = (ResultAction) EditorGUILayout.EnumPopup (GetSocketLabel (i), (ResultAction) ending.resultAction); } if (ending.resultAction == ResultAction.RunCutscene && showGUI) { if (isAssetFile) { ending.linkedAsset = ActionListAssetMenu.AssetGUI ("ActionList to run:", ending.linkedAsset); } else { ending.linkedCutscene = ActionListAssetMenu.CutsceneGUI ("Cutscene to run:", ending.linkedCutscene); } } else if (ending.resultAction == ResultAction.Skip) { SkipActionGUI (ending, actions, showGUI); } /*else { EditorGUILayout.Space (); EditorGUILayout.Space (); EditorGUILayout.Space (); }*/ } }
public override void SetLastResult(ActionEnd _actionEnd) { if (!IsTargetSkippable ()) { // When skipping, don't want to rely on last result if target can be skipped as well base.SetLastResult (_actionEnd); } }
protected void SkipActionGUI(ActionEnd ending, List <Action> actions, bool showGUI) { if (ending.skipAction == -1) { // Set default int i = actions.IndexOf(this); if (actions.Count > i + 1) { ending.skipAction = i + 1; } else { ending.skipAction = i; } } int tempSkipAction = ending.skipAction; List <string> labelList = new List <string>(); if (ending.skipActionActual) { bool found = false; for (int i = 0; i < actions.Count; i++) { labelList.Add(i.ToString() + ": " + actions [i].title); if (ending.skipActionActual == actions [i]) { ending.skipAction = i; found = true; } } if (!found) { ending.skipAction = tempSkipAction; } } if (ending.skipAction >= actions.Count) { ending.skipAction = actions.Count - 1; } if (showGUI) { if (actions.Count > 1) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(" Action to skip to:"); tempSkipAction = EditorGUILayout.Popup(ending.skipAction, labelList.ToArray()); ending.skipAction = tempSkipAction; EditorGUILayout.EndHorizontal(); } else { EditorGUILayout.HelpBox("Cannot skip action - no further Actions available", MessageType.Warning); return; } } ending.skipActionActual = actions [ending.skipAction]; }
public override void SkipActionGUI(List<Action> actions, bool showGUI) { if (numSockets < 0) { numSockets = 0; } if (numSockets < endings.Count) { endings.RemoveRange (numSockets, endings.Count - numSockets); } else if (numSockets > endings.Count) { if (numSockets > endings.Capacity) { endings.Capacity = numSockets; } for (int i=endings.Count; i<numSockets; i++) { ActionEnd newEnd = new ActionEnd (); endings.Add (newEnd); } } foreach (ActionEnd ending in endings) { if (showGUI) { EditorGUILayout.Space (); int i = endings.IndexOf (ending); GVar _var = GetVariable (); if (_var != null) { ending.resultAction = (ResultAction) EditorGUILayout.EnumPopup ("If result is " + _var.popUps[i] + ":", (ResultAction) ending.resultAction); } else { ending.resultAction = (ResultAction) EditorGUILayout.EnumPopup ("If result is " + (i+1).ToString () + ":", (ResultAction) ending.resultAction); } } if (ending.resultAction == ResultAction.RunCutscene && showGUI) { if (isAssetFile) { ending.linkedAsset = (ActionListAsset) EditorGUILayout.ObjectField ("ActionList to run:", ending.linkedAsset, typeof (ActionListAsset), false); } else { ending.linkedCutscene = (Cutscene) EditorGUILayout.ObjectField ("Cutscene to run:", ending.linkedCutscene, typeof (Cutscene), true); } } else if (ending.resultAction == ResultAction.Skip) { SkipActionGUI (ending, actions, showGUI); } /*else { EditorGUILayout.Space (); EditorGUILayout.Space (); EditorGUILayout.Space (); }*/ } }
public override void SkipActionGUI(List <Action> actions, bool showGUI) { if (KickStarter.inventoryManager == null) { return; } if (numSockets < 1) { numSockets = 1; } if (numSockets < endings.Count) { endings.RemoveRange(numSockets, endings.Count - numSockets); } else if (numSockets > endings.Count) { if (numSockets > endings.Capacity) { endings.Capacity = numSockets; } for (int i = endings.Count; i < numSockets; i++) { ActionEnd newEnd = new ActionEnd(); if (i > 0) { newEnd.resultAction = ResultAction.Stop; } endings.Add(newEnd); } } foreach (ActionEnd ending in endings) { if (showGUI) { EditorGUILayout.Space(); int i = endings.IndexOf(ending); if (i == 0) { ending.resultAction = (ResultAction)EditorGUILayout.EnumPopup("If inactive:", (ResultAction)ending.resultAction); } else { Objective objective = KickStarter.inventoryManager.GetObjective(objectiveID); if (objective != null) { string[] popUpLabels = objective.GenerateEditorStateLabels(); ending.resultAction = (ResultAction)EditorGUILayout.EnumPopup("If = '" + popUpLabels[i - 1] + "':", (ResultAction)ending.resultAction); } else { ending.resultAction = (ResultAction)EditorGUILayout.EnumPopup("If ID = '" + objectiveID.ToString() + "':", (ResultAction)ending.resultAction); } } } if (ending.resultAction == ResultAction.RunCutscene && showGUI) { if (isAssetFile) { ending.linkedAsset = (ActionListAsset)EditorGUILayout.ObjectField("ActionList to run:", ending.linkedAsset, typeof(ActionListAsset), false); } else { ending.linkedCutscene = (Cutscene)EditorGUILayout.ObjectField("Cutscene to run:", ending.linkedCutscene, typeof(Cutscene), true); } } else if (ending.resultAction == ResultAction.Skip) { SkipActionGUI(ending, actions, showGUI); } } }
private void NodeWindow(int i) { GUI.skin = null; if (actionsManager == null) { OnEnable (); } if (actionsManager == null) { return; } bool isAsset; Action _action; List<ActionParameter> parameters = null; if (windowData.targetAsset != null) { _action = windowData.targetAsset.actions[i]; isAsset = _action.isAssetFile = true; if (windowData.targetAsset.useParameters) { parameters = windowData.targetAsset.parameters; } } else { _action = windowData.target.actions[i]; isAsset = _action.isAssetFile = false; if (windowData.target.useParameters) { parameters = windowData.target.parameters; } } if (!actionsManager.DoesActionExist (_action.GetType ().ToString ())) { EditorGUILayout.HelpBox ("This Action type has been disabled in the Actions Manager", MessageType.Warning); } else { int typeIndex = KickStarter.actionsManager.GetActionTypeIndex (_action); int newTypeIndex = ActionListEditor.ShowTypePopup (_action, typeIndex); if (newTypeIndex >= 0) { // Rebuild constructor if Subclass and type string do not match Vector2 currentPosition = new Vector2 (_action.nodeRect.x, _action.nodeRect.y); // Store "After running data" to transfer over ActionEnd _end = new ActionEnd (); _end.resultAction = _action.endAction; _end.skipAction = _action.skipAction; _end.linkedAsset = _action.linkedAsset; _end.linkedCutscene = _action.linkedCutscene; if (isAsset) { Undo.RecordObject (windowData.targetAsset, "Change Action type"); Action newAction = ActionListAssetEditor.RebuildAction (_action, newTypeIndex, windowData.targetAsset, _end.resultAction, _end.skipAction, _end.linkedAsset, _end.linkedCutscene); newAction.nodeRect.x = currentPosition.x; newAction.nodeRect.y = currentPosition.y; windowData.targetAsset.actions.Remove (_action); windowData.targetAsset.actions.Insert (i, newAction); } else { Undo.RecordObject (windowData.target, "Change Action type"); Action newAction = ActionListEditor.RebuildAction (_action, newTypeIndex, _end.resultAction, _end.skipAction, _end.linkedAsset, _end.linkedCutscene); newAction.nodeRect.x = currentPosition.x; newAction.nodeRect.y = currentPosition.y; windowData.target.actions.Remove (_action); windowData.target.actions.Insert (i, newAction); } } _action.ShowGUI (parameters); } if (_action.endAction == ResultAction.Skip || _action.numSockets == 2 || _action is ActionCheckMultiple || _action is ActionParallel) { if (isAsset) { _action.SkipActionGUI (windowData.targetAsset.actions, true); } else { _action.SkipActionGUI (windowData.target.actions, true); } } _action.isDisplayed = EditorGUI.Foldout (new Rect (10,1,20,16), _action.isDisplayed, ""); if (GUI.Button (new Rect(273,3,16,16), " ", nodeSkin.customStyles[0])) { CreateNodeMenu (isAsset, i, _action); } if (i == 0) { _action.nodeRect.x = 14; _action.nodeRect.y = 14; } else { if (Event.current.button == 0) { GUI.DragWindow (); } } }
public static Action RebuildAction(AC.Action action, int typeIndex, ActionListAsset _target, int insertIndex = -1, ActionEnd _end = null) { ActionsManager actionsManager = AdvGame.GetReferences().actionsManager; if (actionsManager) { bool _showComment = action.showComment; bool _showOutputSockets = action.showOutputSockets; string _comment = action.comment; ActionListAssetEditor.DeleteAction(action, _target); string className = actionsManager.AllActions [typeIndex].fileName; AC.Action newAction = (AC.Action)CreateInstance(className); newAction.name = className; if (_end != null) { newAction.endAction = _end.resultAction; newAction.skipAction = _end.skipAction; newAction.linkedAsset = _end.linkedAsset; newAction.linkedCutscene = _end.linkedCutscene; } newAction.showComment = _showComment; newAction.comment = _comment; newAction.showOutputSockets = _showOutputSockets; if (insertIndex >= 0) { _target.actions.Insert(insertIndex, newAction); } SyncAssetObjects(_target); return(newAction); } return(action); }