/// <summary> /// Replace existing command value on its node. Will keep nested commands intact. /// Calls CommandModified event. /// </summary> public Command ReplaceCommand(Command originalCommand, Command newCommand) { Debug.Assert(Commands.GetAllNodes().Select(n => n.value).Contains(originalCommand), "Original Command should exist on script"); Debug.Assert(!Commands.GetAllNodes().Select(n => n.value).Contains(newCommand), "New Command should not exist on script"); m_IsDirty = true; var node = Commands.GetNodeFromValue(originalCommand); m_CommandGuidMap.RemoveGuidFromMap(node.value); m_CommandGuidMap.AddGuidToMapAndGenerateUniqueIfNeeded(newCommand); node.value = newCommand; CommandModifiedOnScript?.Invoke(this, originalCommand, newCommand); CheckCommandGuidConsistency(); return(newCommand); }
private void InvokeCommandModifiedOnScript(Script script, Command oldCommand, Command newCommand) { CommandModifiedOnScript?.Invoke(script, oldCommand, newCommand); }
public void ApplyCommandModifications(Command command) { m_IsDirty = true; CommandModifiedOnScript?.Invoke(this, command, command); }