public void TryCombined(Item sourceItem, Item targetItem) { if (sourceItem.dropSequence == null) { return; } ActionState combinedState = sourceItem.dropSequence.actionStates[0]; combinedState.targetActorName = controlledActor.name; if (combinedState.Get <Item>("Source Item") != sourceItem || combinedState.Get <Item>("Target Item") != targetItem) { return; } GameInstance.Singleton.SequenceManager.ActivateSequence(sourceItem.dropSequence); }
public override void OnInspectorGUI() { targetSequence = (Sequence)target; if (actionClasses == null) { CollectActionClasses(); } if (targetSequence != null) { GUILayout.Label(targetSequence.name); } else { GUILayout.Label("None"); return; } GUILayout.BeginVertical(GUILayout.MaxWidth(500)); { if (targetSequence.actionStates.Count == 0) { insertState.Push(0); } for (int i = 0; i < targetSequence.actionStates.Count; i++) { GUILayout.BeginVertical(GUI.skin.box); { GUILayout.BeginHorizontal(); { if (GUILayout.Button("Remove")) { removedStates.Push(targetSequence.actionStates[i]); } if (GUILayout.Button("Insert")) { insertState.Push(i); } if (GUILayout.Button("Clone")) { cloneState.Push(targetSequence.actionStates[i]); } } GUILayout.EndHorizontal(); ActionState state = targetSequence.actionStates[i]; state.ActionClass = GetActionName(EditorGUILayout.Popup("Action", GetActionIndex(state.ActionClass), actionClassNames)); state.targetActorName = EditorGUILayout.TextField("Target Actor Name", state.targetActorName); GUILayout.BeginVertical(GUI.skin.box); { ActionVariable[] variables = null; if (variablesByType.TryGetValue(state.ActionClass, out variables)) { for (int v = 0; v < variables.Length; v++) { ActionVariable variable = variables[v]; switch (variable.type) { case VariableType.Item: state.Set(variable, EditorGUILayout.ObjectField(variable.name, state.Get <Item>(variable), typeof(Item), false)); break; case VariableType.Sequence: state.Set(variable, EditorGUILayout.ObjectField(variable.name, state.Get <Sequence>(variable), typeof(Sequence), false)); break; case VariableType.Float: state.Set(variable, EditorGUILayout.FloatField(variable.name, state.Get <float>(variable))); break; case VariableType.String: state.Set(variable, EditorGUILayout.TextField(variable.name, state.Get <string>(variable))); break; case VariableType.Vector2: state.Set(variable, EditorGUILayout.Vector2Field(variable.name, state.Get <Vector2>(variable))); break; } } } } GUILayout.EndVertical(); } GUILayout.EndVertical(); } while (removedStates.Count != 0) { targetSequence.actionStates.Remove(removedStates.Pop()); } while (insertState.Count != 0) { targetSequence.actionStates.Insert(insertState.Pop(), new ActionState()); } if (GUI.changed) { EditorUtility.SetDirty(targetSequence); } } GUILayout.EndVertical(); DrawDefaultInspector(); }