private void OnTrigger(int levelIndex) { if (FsmUtility.CompareFloat(levelIndex, level.Value, comparer)) { isTrigger = true; } }
private void InitFsmVars() { GameObject ownerDefaultTarget = base.Fsm.GetOwnerDefaultTarget(this.gameObject); if (ownerDefaultTarget == null) { return; } if (ownerDefaultTarget != this.cachedGO) { this.sourceVariables = new INamedVariable[this.getVariables.Length]; this.targetVariables = new NamedVariable[this.getVariables.Length]; for (int i = 0; i < this.getVariables.Length; i++) { string variableName = this.getVariables[i].variableName; this.sourceFsm = ActionHelpers.GetGameObjectFsm(ownerDefaultTarget, this.fsmName.Value); this.sourceVariables[i] = this.sourceFsm.FsmVariables.GetVariable(variableName); this.targetVariables[i] = base.Fsm.Variables.GetVariable(variableName); this.getVariables[i].Type = FsmUtility.GetVariableType(this.targetVariables[i]); if (!string.IsNullOrEmpty(variableName) && this.sourceVariables[i] == null) { base.LogWarning("Missing Variable: " + variableName); } this.cachedGO = ownerDefaultTarget; } } }
private void DoRaycast() { RaycastHit hit; Vector3 position = FsmUtility.GetPosition(target, origin); Vector3 dir = GetDirection(); if (Physics.Raycast(position, dir, out hit, distance.Value, layerMask)) { if (!hitDistance.IsNone) { hitDistance.Value = hit.distance; } if (!hitNormal.IsNone) { hitNormal.Value = hit.normal; } if (!hitPoint.IsNone) { hitPoint.Value = hit.point; } if (!hitGameObject.IsNone) { hitGameObject.Value = hit.transform.gameObject; } if (!hitEvent.IsNone) { this.Root.Owner.SendEvent(hitEvent.Value, null); } } }
void InitFsmVars() { var go = Fsm.GetOwnerDefaultTarget(gameObject); if (go == null) { return; } if (go != cachedGO) { sourceVariables = new INamedVariable[getVariables.Length]; targetVariables = new NamedVariable[getVariables.Length]; for (var i = 0; i < getVariables.Length; i++) { var variableName = getVariables[i].variableName; sourceFsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); sourceVariables[i] = sourceFsm.FsmVariables.GetVariable(variableName); targetVariables[i] = Fsm.Variables.GetVariable(variableName); getVariables[i].Type = FsmUtility.GetVariableType(targetVariables[i]); if (!string.IsNullOrEmpty(variableName) && sourceVariables[i] == null) { LogWarning("Missing Variable: " + variableName); } cachedGO = go; } } }
void InitFsmVar() { var go = Fsm.GetOwnerDefaultTarget(gameObject); if (go == null) { return; } if (go != cachedGO) { sourceFsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); sourceVariable = sourceFsm.FsmVariables.GetVariable(setValue.variableName); targetVariable = Fsm.Variables.GetVariable(setValue.variableName); setValue.Type = FsmUtility.GetVariableType(targetVariable); if (!string.IsNullOrEmpty(setValue.variableName) && sourceVariable == null) { LogWarning("Missing Variable: " + setValue.variableName); } cachedGO = go; } }
public override void OnUpdate() { if (Time.time > repathTime) { seeker.StartPath(seeker.transform.position, FsmUtility.GetPosition(target, destination), OnPathComplete); repathTime = Time.time + repathRate.Value; } if (path == null || path.vectorPath.Count <= currentWaypoint) { //We have no path to move after yet return; } Vector3 dir = (path.vectorPath [currentWaypoint] - seeker.transform.position); if (dir != Vector3.zero) { dir.y = 0; Quaternion wantedRotation = Quaternion.LookRotation(dir); seeker.transform.rotation = Quaternion.Slerp(seeker.transform.rotation, wantedRotation, Time.deltaTime * rotation.Value); } dir = dir.normalized; dir *= speed.Value; characterController.SimpleMove(dir); characterController.Move(Vector3.down * 15 * Time.deltaTime); if (Vector3.Distance(seeker.transform.position, path.vectorPath [currentWaypoint]) < threshold.Value) { currentWaypoint++; } }
public override bool Validate() { // float distance= Vector3.Distance (FsmUtility.GetPosition(first, a),FsmUtility.GetPosition(second, b)); float distance = Mathf.Abs(FsmUtility.GetPosition(first, a).y - FsmUtility.GetPosition(second, b).y); return(FsmUtility.CompareFloat(distance, value.Value, comparer)); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); SerializedProperty property = serializedObject.FindProperty("stateMachine"); if (property.objectReferenceValue != null) { StateMachine fsm = property.objectReferenceValue as StateMachine; showInfo = EditorGUILayout.Foldout(showInfo, "Info"); if (showInfo) { int indent = EditorGUI.indentLevel; EditorGUI.indentLevel++; GUILayout.Label("StateMachines (" + (fsm.StateMachinesRecursive.Length + 1) + ")"); GUILayout.Label("States (" + fsm.StatesRecursive.Length + ")"); GUILayout.Label("Actions (" + fsm.ActionsRecursive.Length + ")"); GUILayout.Label("Variables (" + fsm.VisibleVariables.Length + ")"); EditorGUI.indentLevel = indent; } showVariables = EditorGUILayout.Foldout(showVariables, "Variables"); if (showVariables) { FsmVariable[] variables = fsm.VisibleVariables; for (int i = 0; i < variables.Length; i++) { SerializedObject obj = new SerializedObject(variables[i]); obj.Update(); EditorGUILayout.PropertyField(obj.FindProperty("value"), new GUIContent(obj.FindProperty("name").stringValue)); obj.ApplyModifiedProperties(); } } } bool flag = GUI.enabled; GUI.enabled = !(property.objectReferenceValue == null || !EditorUtility.IsPersistent(property.objectReferenceValue)); if (GUILayout.Button("Bind to GameObject")) { serializedObject.Update(); StateMachine stateMachine = (StateMachine)FsmUtility.Copy((StateMachine)property.objectReferenceValue); property.objectReferenceValue = stateMachine; serializedObject.ApplyModifiedProperties(); if (FsmEditor.instance != null) { FsmEditor.SelectStateMachine(stateMachine); } } GUI.enabled = flag; if (GUILayout.Button("Open in Editor")) { FsmEditor.ShowWindow(); if (FsmEditor.instance != null) { FsmEditor.SelectStateMachine((StateMachine)property.objectReferenceValue); } } }
private void Do() { if (!weight.IsNone) { animator.SetIKPositionWeight(goal, weight.Value); } animator.SetIKPosition(goal, FsmUtility.GetPosition(target, position)); }
public override void OnEnter() { base.OnEnter(); store.Value = Vector3.Distance(FsmUtility.GetPosition(first, a), FsmUtility.GetPosition(second, b)); if (!everyFrame) { Finish(); } }
private void DoGetInRange() { Vector3 position = FsmUtility.GetPosition(target, initialPosition); Vector3 inRange = new Vector3(position.x + Random.Range(-range.Value, range.Value), position.y + (setY.Value?Random.Range(-range.Value, range.Value):0), position.z + Random.Range(-range.Value, range.Value) ); store.Value = inRange; }
private void DoLookAt() { Vector3 targetPosition = FsmUtility.GetPosition(target, position); Vector3 lookAt = new Vector3(targetPosition.x, (inY.Value ? transform.position.y : targetPosition.y), targetPosition.z ); transform.LookAt(lookAt, worldUp.Value); }
public static string GenerateUniqueNodeName(Type type, StateMachine stateMachine) { int cnt = 0; string uniqueName = (type == typeof(State)?"State":"FSM"); while (FsmUtility.NodeExists(stateMachine.Root, uniqueName + " " + cnt.ToString())) { cnt++; } return(uniqueName + " " + cnt.ToString()); }
public override void OnEnter() { GameObject createdObject = new GameObject(_name.IsNone?string.Empty:_name.Value); createdObject.transform.position = FsmUtility.GetPosition(spawnPoint, position); createdObject.transform.rotation = Quaternion.Euler(rotation.Value); if (!storeObject.IsNone) { storeObject.Value = createdObject; } Finish(); }
public override void OnGUI(SerializedProperty property, GUIContent label) { SerializedProperty componentProperty = property.serializedObject.FindProperty("component"); SerializedProperty propProperty = property.serializedObject.FindProperty("property"); SerializedProperty parameterProperty = property.serializedObject.FindProperty("parameter"); GUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(componentProperty); ComponentHint(componentProperty, propProperty); GUILayout.EndHorizontal(); if (!string.IsNullOrEmpty(componentProperty.stringValue)) { Type componentType = TypeUtility.GetType(componentProperty.stringValue); if (componentType != null) { GUILayout.BeginHorizontal(); EditorGUILayout.PropertyField(propProperty); PropertyHint(propProperty, componentType); GUILayout.EndHorizontal(); if (!string.IsNullOrEmpty(propProperty.stringValue)) { Type variableType = FsmUtility.GetVariableType(TypeUtility.GetMemberType(componentType, propProperty.stringValue)); Debug.Log(variableType); if (variableType != null) { fieldInfo = property.serializedObject.targetObject.GetType().GetField("parameter"); if (parameterProperty.objectReferenceValue == null || parameterProperty.objectReferenceValue.GetType() != variableType) { FsmEditorUtility.DestroyImmediate(parameterProperty.objectReferenceValue as FsmVariable); FsmVariable variable = ScriptableObject.CreateInstance(variableType) as FsmVariable; variable.hideFlags = HideFlags.HideInHierarchy; if (EditorUtility.IsPersistent(parameterProperty.serializedObject.targetObject)) { AssetDatabase.AddObjectToAsset(variable, property.serializedObject.targetObject); AssetDatabase.SaveAssets(); } variable.IsShared = fieldInfo.HasAttribute(typeof(SharedAttribute)) || EditorUtility.IsPersistent(variable) && fieldInfo.HasAttribute(typeof(SharedPersistentAttribute)) || variable is FsmArray; parameterProperty.serializedObject.Update(); parameterProperty.objectReferenceValue = variable; parameterProperty.serializedObject.ApplyModifiedProperties(); } base.OnGUI(parameterProperty, new GUIContent("Parameter")); } } } } }
private GameObject DoFind() { GameObject go = GameObject.Find(_name.Value); if (includeInactive.Value && go == null) { Transform[] gos = FsmUtility.FindAll <Transform>(true); foreach (Transform tr in gos) { if (tr.name == _name.Value) { return(tr.gameObject); } } } return(go); }
public override void OnUpdate() { Vector3 targetPosition = FsmUtility.GetPosition(target, position); Vector3 gameObjectPosition = transform.position; targetPosition.y = (inY.Value ? gameObjectPosition.y : targetPosition.y); Vector3 diff = targetPosition - gameObjectPosition; if (diff != Vector3.zero && diff.sqrMagnitude > 0) { desiredRotation = Quaternion.LookRotation(diff); } lastRotation = Quaternion.Slerp(lastRotation, desiredRotation, speed.Value * Time.deltaTime); transform.rotation = lastRotation; }
private void DoOverlapSphere() { Collider[] hits = Physics.OverlapSphere(FsmUtility.GetPosition(target, origin), radius.Value, layerMask); if (!hitGameObjects.IsNone) { List <object> gos = new List <object> (); foreach (Collider hit in hits) { gos.Add(hit.gameObject); } hitGameObjects.Value = gos.ToArray(); } if (!randomGameObject.IsNone) { Collider randomCollider = hits.GetRandom <Collider>(); if (randomCollider != null) { randomGameObject.Value = randomCollider.gameObject; } } }
private void InitFsmVar() { GameObject ownerDefaultTarget = base.Fsm.GetOwnerDefaultTarget(this.gameObject); if (ownerDefaultTarget == null) { return; } if (ownerDefaultTarget != this.cachedGO) { this.sourceFsm = ActionHelpers.GetGameObjectFsm(ownerDefaultTarget, this.fsmName.Value); this.sourceVariable = this.sourceFsm.FsmVariables.GetVariable(this.storeValue.variableName); this.targetVariable = base.Fsm.Variables.GetVariable(this.storeValue.variableName); this.storeValue.Type = FsmUtility.GetVariableType(this.targetVariable); if (!string.IsNullOrEmpty(this.storeValue.variableName) && this.sourceVariable == null) { base.LogWarning("Missing Variable: " + this.storeValue.variableName); } this.cachedGO = ownerDefaultTarget; } }
public override void OnEnter() { base.OnEnter(); agents = new List <UnityEngine.AI.NavMeshAgent> (); foreach (object obj in gameObjects.Value) { if (obj is GameObject) { UnityEngine.AI.NavMeshAgent mAgent = (obj as GameObject).GetComponent <UnityEngine.AI.NavMeshAgent>(); if (mAgent != null) { agents.Add(mAgent); } } } maxInRow = Mathf.CeilToInt(Mathf.Sqrt(agents.Count)); master = agents [0]; SetDestination(FsmUtility.GetPosition(target, destination)); if (!everyFrame) { Finish(); } }
protected override void CanvasContextMenu () { if (currentEvent.type != EventType.MouseDown || currentEvent.button != 1 || currentEvent.clickCount != 1 || FsmEditor.Active == null){ return; } GenericMenu canvasMenu = new GenericMenu (); canvasMenu.AddItem (FsmContent.createState, false, delegate() { State state= FsmEditorUtility.AddNode<State>(mousePosition,FsmEditor.Active); state.IsStartNode=FsmEditor.Active.GetStartNode() == null; FsmEditorUtility.UpdateNodeColor(state); }); canvasMenu.AddItem (FsmContent.createSubFsm, false, delegate() { StateMachine stateMachine=FsmEditorUtility.AddNode<StateMachine>(mousePosition,FsmEditor.Active); stateMachine.IsStartNode=FsmEditor.Active.GetStartNode() == null; FsmEditorUtility.UpdateNodeColor(stateMachine); }); canvasMenu.AddItem (FsmContent.copy, false, delegate() { Pasteboard.Copy(new List<Node>(){FsmEditor.Active}); }); if (Pasteboard.CanPaste ()) { canvasMenu.AddItem (FsmContent.paste, false, delegate() { Pasteboard.Paste(mousePosition,FsmEditor.Active); }); } canvasMenu.AddSeparator (""); if (Selection.activeGameObject != null) { canvasMenu.AddItem (FsmContent.addToSelection, false, delegate() { foreach(GameObject go in Selection.gameObjects){ ICodeBehaviour behaviour = go.AddComponent<ICodeBehaviour>(); behaviour.stateMachine = FsmEditor.Active.Root; EditorUtility.SetDirty(behaviour); } SelectGameObject(Selection.activeGameObject); }); canvasMenu.AddItem (FsmContent.bindToGameObject, false, delegate() { foreach(GameObject go in Selection.gameObjects){ ICodeBehaviour behaviour = go.AddComponent<ICodeBehaviour>(); behaviour.stateMachine = (StateMachine)FsmUtility.Copy(FsmEditor.Active.Root);//FsmEditor.Active.Root; EditorUtility.SetDirty(behaviour); } SelectGameObject(Selection.activeGameObject); }); } else { canvasMenu.AddDisabledItem(FsmContent.addToSelection); canvasMenu.AddDisabledItem(FsmContent.bindToGameObject); } if (FsmEditor.Active.Root != null && !EditorUtility.IsPersistent(FsmEditor.Active.Root)) { canvasMenu.AddItem (FsmContent.saveAsAsset, false, delegate() { string mPath = EditorUtility.SaveFilePanelInProject ( "Save StateMachine as Asset", "New StateMachine.asset", "asset", ""); if(mPath != null){ StateMachine stateMachine=(StateMachine)FsmUtility.Copy(FsmEditor.Active.Root); AssetDatabase.CreateAsset(stateMachine,mPath); AssetDatabase.SaveAssets(); FsmEditorUtility.ParentChilds(stateMachine); } }); } else { canvasMenu.AddDisabledItem(FsmContent.saveAsAsset); } canvasMenu.ShowAsContext (); }
public static void Paste(Vector2 position, StateMachine stateMachine) { List <Node> copiedNodes = new List <Node> (); Vector2 center = GetCenter(nodes); for (int i = 0; i < nodes.Count; i++) { Node origNode = nodes[i]; List <FsmVariable> sharedVariables = new List <FsmVariable>(); GetSharedVariables(origNode, ref sharedVariables); if (sharedVariables.Count > 0) { string variableNames = string.Empty; sharedVariables.Select(x => x.Name).ToList().ForEach(y => variableNames = (variableNames + (string.IsNullOrEmpty(variableNames)?"":",") + y)); if (EditorUtility.DisplayDialog("Paste Variables", "Copied states have reference to shared variables, do you want to paste those variables? (" + variableNames + ")", "Yes", "No")) { for (int j = 0; j < sharedVariables.Count; j++) { FsmVariable variable = sharedVariables[j]; stateMachine.SetVariable(variable.Name, variable.GetValue()); } } } Node mNode = (Node)FsmUtility.Copy(origNode); mNode.Parent = stateMachine; mNode.hideFlags = HideFlags.HideInHierarchy; if (mNode.IsStartNode && stateMachine.GetStartNode() != null) { mNode.IsStartNode = false; } //mNode.Name = FsmEditorUtility.GenerateUniqueNodeName(mNode.GetType(),stateMachine); stateMachine.Nodes = ArrayUtility.Add <Node> (stateMachine.Nodes, mNode); mNode.position = new Rect(-(center.x - origNode.position.x) + position.x, -(center.y - origNode.position.y) + position.y, FsmEditorStyles.StateWidth, FsmEditorStyles.StateHeight); if (mNode.GetType() == typeof(StateMachine)) { mNode.position.width = FsmEditorStyles.StateMachineWidth; mNode.position.height = FsmEditorStyles.StateMachineHeight; } FsmEditorUtility.UpdateNodeColor(mNode); copiedNodes.Add(mNode); } for (int i = 0; i < copiedNodes.Count; i++) { Node mNode = copiedNodes [i]; if (mNode is AnyState) { bool mOverride = EditorUtility.DisplayDialog("Override AnyState", "AnyState can only exist once per state machine. Do you want to override it?", "Yes", "No"); AnyState anyState = stateMachine.Nodes.ToList().Find(x => x.GetType() == typeof(AnyState) && (mOverride && x != mNode || !mOverride && x == mNode)) as AnyState; stateMachine.Nodes = ArrayUtility.Remove(stateMachine.Nodes, anyState); FsmEditorUtility.DestroyImmediate(anyState); FsmEditor.SelectedNodes.Clear(); } } for (int i = 0; i < copiedNodes.Count; i++) { Node mNode = copiedNodes[i]; foreach (Transition transition in mNode.Transitions) { Node toNode = copiedNodes.Find(x => x.Name == transition.ToNode.Name) ?? stateMachine.Nodes.ToList().Find(x => x.Name == transition.ToNode.Name); if (toNode != null) { transition.ToNode = toNode; } else { FsmEditorUtility.DestroyImmediate(transition); mNode.Transitions = ArrayUtility.Remove(mNode.Transitions, transition); } } } for (int i = 0; i < copiedNodes.Count; i++) { Node mNode = stateMachine.Nodes.ToList().Find(x => x.Name == copiedNodes[i].Name && x != copiedNodes[i]); if (mNode != null) { copiedNodes[i].Name = FsmEditorUtility.GenerateUniqueNodeName(copiedNodes[i].GetType(), stateMachine); } } FsmEditorUtility.ParentChilds(stateMachine); nodes.Clear(); EditorUtility.SetDirty(stateMachine); ErrorChecker.CheckForErrors(); }
private void ResetConditionList() { if (transition == null) { return; } this.conditions = this.transition.Conditions; this.conditionList = new ReorderableList(this.conditions, "Condition", true, true) { drawElementCallback = new ReorderableList.ElementCallbackDelegate(this.OnConditionElement), onReorderCallback = new ReorderableList.ReorderCallbackDelegate(this.OnReorderConditionList), onAddCallback = new ReorderableList.AddCallbackDelegate(delegate(){ FsmGUIUtility.SubclassMenu <Condition> (CreateCondition); }), onContextClick = new ReorderableList.ContextCallbackDelegate(delegate(int index){ FsmGUIUtility.ExecutableContextMenu(conditions[index], node).ShowAsContext(); }), onHeaderClick = new ReorderableList.OnHeaderClick(delegate(){ GenericMenu menu = new GenericMenu(); if (conditions.Length > 0) { menu.AddItem(new GUIContent("Copy"), false, delegate { copy = transition; }); } else { menu.AddDisabledItem(new GUIContent("Copy")); } if (copy != null && copy.Conditions.Length > 0) { menu.AddItem(new GUIContent("Paste After"), false, delegate() { for (int i = 0; i < copy.Conditions.Length; i++) { ExecutableNode dest = FsmUtility.Copy(copy.Conditions[i]); transition.Conditions = ArrayUtility.Add <Condition>(transition.Conditions, (Condition)dest); FsmEditorUtility.ParentChilds(transition); NodeInspector.Dirty(); } }); menu.AddItem(new GUIContent("Paste Before"), false, delegate() { for (int i = 0; i < copy.Conditions.Length; i++) { ExecutableNode dest = FsmUtility.Copy(copy.Conditions[i]); transition.Conditions = ArrayUtility.Insert <Condition>(transition.Conditions, (Condition)dest, 0); FsmEditorUtility.ParentChilds(transition); NodeInspector.Dirty(); } }); if (copy != transition) { menu.AddItem(new GUIContent("Replace"), false, delegate() { for (int i = 0; i < transition.Conditions.Length; i++) { FsmEditorUtility.DestroyImmediate(transition.Conditions[i]); } transition.Conditions = new Condition[0]; ResetConditionList(); for (int i = 0; i < copy.Conditions.Length; i++) { ExecutableNode dest = FsmUtility.Copy(copy.Conditions[i]); transition.Conditions = ArrayUtility.Add <Condition>(transition.Conditions, (Condition)dest); FsmEditorUtility.ParentChilds(transition); NodeInspector.Dirty(); } }); } else { menu.AddDisabledItem(new GUIContent("Replace")); } } else { menu.AddDisabledItem(new GUIContent("Paste After")); menu.AddDisabledItem(new GUIContent("Paste Before")); menu.AddDisabledItem(new GUIContent("Replace")); } menu.ShowAsContext(); }), }; this.host.Repaint(); if (FsmEditor.instance != null) { FsmEditor.instance.Repaint(); } }
public void AddEventHandlerComponents() { if (!PlayMakerGlobals.IsEditor) { Debug.Log("FSM not Preprocessed: " + FsmUtility.GetFullFsmLabel(fsm)); } if (fsm.MouseEvents) { AddEventHandlerComponent <PlayMakerMouseEvents>(); } if (fsm.HandleCollisionEnter) { AddEventHandlerComponent <PlayMakerCollisionEnter>(); } if (fsm.HandleCollisionExit) { AddEventHandlerComponent <PlayMakerCollisionExit>(); } if (fsm.HandleCollisionStay) { AddEventHandlerComponent <PlayMakerCollisionStay>(); } if (fsm.HandleTriggerEnter) { AddEventHandlerComponent <PlayMakerTriggerEnter>(); } if (fsm.HandleTriggerExit) { AddEventHandlerComponent <PlayMakerTriggerExit>(); } if (fsm.HandleTriggerStay) { AddEventHandlerComponent <PlayMakerTriggerStay>(); } if (fsm.HandleCollisionEnter2D) { AddEventHandlerComponent <PlayMakerCollisionEnter2D>(); } if (fsm.HandleCollisionExit2D) { AddEventHandlerComponent <PlayMakerCollisionExit2D>(); } if (fsm.HandleCollisionStay2D) { AddEventHandlerComponent <PlayMakerCollisionStay2D>(); } if (fsm.HandleTriggerEnter2D) { AddEventHandlerComponent <PlayMakerTriggerEnter2D>(); } if (fsm.HandleTriggerExit2D) { AddEventHandlerComponent <PlayMakerTriggerExit2D>(); } if (fsm.HandleTriggerStay2D) { AddEventHandlerComponent <PlayMakerTriggerStay2D>(); } if (fsm.HandleParticleCollision) { AddEventHandlerComponent <PlayMakerParticleCollision>(); } if (fsm.HandleControllerColliderHit) { AddEventHandlerComponent <PlayMakerControllerColliderHit>(); } if (fsm.HandleJointBreak) { AddEventHandlerComponent <PlayMakerJointBreak>(); } if (fsm.HandleJointBreak2D) { AddEventHandlerComponent <PlayMakerJointBreak>(); } if (fsm.HandleFixedUpdate) { AddEventHandlerComponent <PlayMakerFixedUpdate>(); } if (fsm.HandleOnGUI && GetComponent <PlayMakerOnGUI>() == null) { PlayMakerOnGUI playMakerOnGUI = base.gameObject.AddComponent <PlayMakerOnGUI>(); playMakerOnGUI.playMakerFSM = this; } if (fsm.HandleApplicationEvents) { AddEventHandlerComponent <PlayMakerApplicationEvents>(); } if (fsm.HandleAnimatorMove) { AddEventHandlerComponent <PlayMakerAnimatorMove>(); } if (fsm.HandleAnimatorIK) { AddEventHandlerComponent <PlayMakerAnimatorIK>(); } eventHandlerComponentsAdded = true; }
public override void OnEnter() { base.OnEnter(); AudioSource.PlayClipAtPoint((AudioClip)clip.Value, FsmUtility.GetPosition(target, position), volume.Value); Finish(); }
private void DoInstantiate() { store.Value = PhotonNetwork.InstantiateSceneObject(prefabName.Value, FsmUtility.GetPosition(target, position), target.Value != null && euler.IsNone?target.Value.transform.rotation:Quaternion.Euler(euler.Value), group.Value, null); }
private void DoInstantiate() { store.Value = BoltNetwork.Instantiate(original.Value, FsmUtility.GetPosition(target, position), target.Value != null && rotation.IsNone?target.Value.transform.rotation:Quaternion.Euler(rotation.Value)).gameObject; }
public static GenericMenu ExecutableContextMenu(ExecutableNode executable, Node node) { GenericMenu menu = new GenericMenu(); if (executable == null) { return(menu); } menu.AddItem(new GUIContent("Enable"), executable.IsEnabled, delegate() { executable.IsEnabled = !executable.IsEnabled; }); menu.AddSeparator(""); menu.AddItem(new GUIContent("Find Script"), false, delegate() { MonoScript[] monoScriptArray = (MonoScript[])Resources.FindObjectsOfTypeAll(typeof(MonoScript)); Selection.activeObject = monoScriptArray.ToList().Find(x => x.GetClass() == executable.GetType()); }); menu.AddItem(new GUIContent("Edit Script"), false, delegate() { MonoScript[] monoScriptArray = (MonoScript[])Resources.FindObjectsOfTypeAll(typeof(MonoScript)); Selection.activeObject = monoScriptArray.ToList().Find(x => x.GetClass() == executable.GetType()); AssetDatabase.OpenAsset(Selection.activeObject); }); menu.AddSeparator(""); bool moveDown = false; int currentIndex = -1; if (executable.GetType().IsSubclassOf(typeof(StateAction))) { State state = node as State; currentIndex = Array.IndexOf(state.Actions, executable); moveDown = currentIndex + 1 < state.Actions.Length; } else { currentIndex = Array.IndexOf(FsmEditor.SelectedTransition.Conditions, executable); moveDown = currentIndex + 1 < FsmEditor.SelectedTransition.Conditions.Length; } if (currentIndex - 1 >= 0) { menu.AddItem(new GUIContent("Move Up"), false, delegate() { if (executable.GetType().IsSubclassOf(typeof(StateAction))) { State state = node as State; state.Actions = ArrayUtility.MoveItem(state.Actions, currentIndex, currentIndex - 1); } else { FsmEditor.SelectedTransition.Conditions = ArrayUtility.MoveItem(FsmEditor.SelectedTransition.Conditions, currentIndex, currentIndex - 1); } NodeInspector.Dirty(); }); } else { menu.AddDisabledItem(new GUIContent("Move Up")); } if (moveDown) { menu.AddItem(new GUIContent("Move Down"), false, delegate() { if (executable.GetType().IsSubclassOf(typeof(StateAction))) { State state = node as State; state.Actions = ArrayUtility.MoveItem(state.Actions, currentIndex, currentIndex + 1); } else { FsmEditor.SelectedTransition.Conditions = ArrayUtility.MoveItem(FsmEditor.SelectedTransition.Conditions, currentIndex, currentIndex + 1); } NodeInspector.Dirty(); }); } else { menu.AddDisabledItem(new GUIContent("Move Down")); } menu.AddSeparator(""); menu.AddItem(new GUIContent("Copy"), false, delegate() { executableCopy = executable; }); if (executableCopy != null) { menu.AddItem(new GUIContent("Paste After"), false, delegate() { ExecutableNode dest = FsmUtility.Copy(executableCopy); if (dest.GetType().IsSubclassOf(typeof(StateAction))) { State state = node as State; state.Actions = ArrayUtility.Insert <StateAction>(state.Actions, (StateAction)dest, currentIndex + 1); } else { FsmEditor.SelectedTransition.Conditions = ArrayUtility.Insert <Condition>(FsmEditor.SelectedTransition.Conditions, (Condition)dest, currentIndex + 1); } FsmEditorUtility.ParentChilds(node); NodeInspector.Dirty(); }); menu.AddItem(new GUIContent("Paste Before"), false, delegate() { ExecutableNode dest = FsmUtility.Copy(executableCopy); if (dest.GetType().IsSubclassOf(typeof(StateAction))) { State state = node as State; state.Actions = ArrayUtility.Insert <StateAction>(state.Actions, (StateAction)dest, currentIndex); } else { FsmEditor.SelectedTransition.Conditions = ArrayUtility.Insert <Condition>(FsmEditor.SelectedTransition.Conditions, (Condition)dest, currentIndex); } FsmEditorUtility.ParentChilds(node); NodeInspector.Dirty(); }); menu.AddItem(new GUIContent("Replace"), false, delegate() { ExecutableNode dest = FsmUtility.Copy(executableCopy); if (dest.GetType().IsSubclassOf(typeof(StateAction))) { State state = node as State; FsmEditorUtility.DestroyImmediate(state.Actions[currentIndex]); state.Actions = ArrayUtility.RemoveAt <StateAction>(state.Actions, currentIndex); state.Actions = ArrayUtility.Insert <StateAction>(state.Actions, (StateAction)dest, currentIndex); } else { FsmEditorUtility.DestroyImmediate(FsmEditor.SelectedTransition.Conditions[currentIndex]); FsmEditor.SelectedTransition.Conditions = ArrayUtility.RemoveAt <Condition>(FsmEditor.SelectedTransition.Conditions, currentIndex); FsmEditor.SelectedTransition.Conditions = ArrayUtility.Insert <Condition>(FsmEditor.SelectedTransition.Conditions, (Condition)dest, currentIndex); } FsmEditorUtility.ParentChilds(node); NodeInspector.Dirty(); }); } else { menu.AddDisabledItem(new GUIContent("Paste After")); menu.AddDisabledItem(new GUIContent("Paste Before")); menu.AddDisabledItem(new GUIContent("Replace")); } menu.AddSeparator(""); menu.AddItem(new GUIContent("Remove"), false, delegate() { if (executable.GetType().IsSubclassOf(typeof(StateAction))) { State state = node as State; state.Actions = ArrayUtility.Remove <StateAction> (state.Actions, (StateAction)executable); } else { FsmEditor.SelectedTransition.Conditions = ArrayUtility.Remove <Condition>(FsmEditor.SelectedTransition.Conditions, (Condition)executable); } FsmEditorUtility.DestroyImmediate(executable); NodeInspector.Dirty(); }); return(menu); }
private void DoSetDestination() { agent.SetDestination(FsmUtility.GetPosition(target, destination)); }
private void DoInstantiate() { store.Value = (GameObject)Instantiate(originals.GetRandom <Object>(), FsmUtility.GetPosition(target, position), Quaternion.Euler(rotation.Value)); }