Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
 private void InvokeCommandModifiedOnScript(Script script, Command oldCommand, Command newCommand)
 {
     CommandModifiedOnScript?.Invoke(script, oldCommand, newCommand);
 }
Exemplo n.º 3
0
 public void ApplyCommandModifications(Command command)
 {
     m_IsDirty = true;
     CommandModifiedOnScript?.Invoke(this, command, command);
 }