public static void Init()
 {
     if (_instance == null)
     {
         // Get existing open window or if none, make a new one:
         _instance = (ForgeNetworkingEditor)EditorWindow.GetWindow(typeof(ForgeNetworkingEditor));
         _instance.Initialize();
         _instance.Show();
     }
     else
     {
         _instance.CloseFinal();
     }
 }
        /// <summary>
        /// This will render the main menu
        /// </summary>
        private void RenderMainMenu()
        {
            if (_editorButtons == null)
            {
                Initialize();
                return;                 //Editor is getting refreshed
            }

            EditorGUILayout.HelpBox("Please note when using source control to please ignore the FNWizardData.bin that is generated because of the NCW. This is because the serialization is based on the computer that has done it. The serialization is a process to help make upgrading easier, so this file is not necessary unless upgrading.", MessageType.Info);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Search", GUILayout.Width(50));
            _searchField = GUILayout.TextField(_searchField);
            Rect verticleButton = EditorGUILayout.BeginVertical("Button", GUILayout.Width(100), GUILayout.Height(15));

            if (ProVersion)
            {
                GUI.color = TealBlue;
            }
            if (GUI.Button(verticleButton, GUIContent.none))
            {
                ActiveButton           = new ForgeEditorButton("");
                ActiveButton.IsCreated = true;
                ChangeMenu(ForgeEditorActiveMenu.Create);
            }
            GUI.color = Color.white;
            GUILayout.BeginHorizontal();
            GUILayout.Label(Star);
            GUILayout.Label("Create", EditorStyles.boldLabel);
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            _scrollView = GUILayout.BeginScrollView(_scrollView);

            for (int i = 0; i < _editorButtons.Count; ++i)
            {
                if (_editorButtons[i].IsNetworkBehavior)
                {
                    continue;
                }

                if (string.IsNullOrEmpty(_searchField) || _editorButtons[i].PossiblyMatches(_searchField))
                {
                    _editorButtons[i].Render();
                }

                if (_editorButtons[i].MarkedForDeletion)
                {
                    if (EditorUtility.DisplayDialog("Confirmation", "Are you sure? This will delete the class", "Yes", "No"))
                    {
                        if (_editorButtons[i].TiedObject.IsNetworkObject || _editorButtons[i].TiedObject.IsNetworkBehavior)
                        {
                            //Then we will need to remove this from the factory and destroy the other object as well
                            string searchName           = _editorButtons[i].TiedObject.StrippedSearchName;
                            string folderPath           = _editorButtons[i].TiedObject.FileLocation.Substring(0, _editorButtons[i].TiedObject.FileLocation.Length - _editorButtons[i].TiedObject.Filename.Length);
                            string filePathBehavior     = Path.Combine(folderPath, searchName + "Behavior.cs");
                            string filePathNetworkedObj = Path.Combine(folderPath, searchName + "NetworkObject.cs");

                            if (File.Exists(filePathBehavior))                             //Delete the behavior
                            {
                                File.Delete(filePathBehavior);
                            }
                            if (File.Exists(filePathNetworkedObj))                             //Delete the object
                            {
                                File.Delete(filePathNetworkedObj);
                            }
                            _editorButtons.RemoveAt(i);

                            string factoryData = SourceCodeFactory();
                            using (StreamWriter sw = File.CreateText(Path.Combine(_storingPath, "NetworkObjectFactory.cs")))
                            {
                                sw.Write(factoryData);
                            }

                            string networkManagerData = SourceCodeNetworkManager();
                            using (StreamWriter sw = File.CreateText(Path.Combine(_storingPath, "NetworkManager.cs")))
                            {
                                sw.Write(networkManagerData);
                            }

                            //IFormatter previousSavedState = new BinaryFormatter();
                            //using (Stream s = new FileStream(Path.Combine(Application.persistentDataPath, FN_WIZARD_DATA), FileMode.OpenOrCreate, FileAccess.Write, FileShare.None))
                            //{
                            //	previousSavedState.Serialize(s, _editorButtons);
                            //}
                        }
                        else
                        {
                            //Random object
                            //File.Delete(_editorButtons[i].TiedObject.FileLocation);
                        }
                        AssetDatabase.Refresh();
                        CloseFinal();
                        break;
                    }
                    else
                    {
                        _editorButtons[i].MarkedForDeletion = false;
                    }
                }
            }

            GUILayout.EndScrollView();

            Rect backBtn = EditorGUILayout.BeginVertical("Button", GUILayout.Height(50));

            if (ProVersion)
            {
                GUI.color = ShadedBlue;
            }
            if (GUI.Button(backBtn, GUIContent.none))
            {
                //CloseFinal();
                Close();
                _instance = null;
                return;
            }
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            GUI.color = Color.white;
            GUILayout.FlexibleSpace();
            GUIStyle boldStyle = new GUIStyle(GUI.skin.GetStyle("boldLabel"));

            boldStyle.alignment = TextAnchor.UpperCenter;
            GUILayout.Label("Close", boldStyle);
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
        }
 public void CloseFinal()
 {
     Close();
     _instance = null;
 }
        /// <summary>
        /// Setup all the variables to be used within the editor
        /// </summary>
        public void Initialize()
        {
            titleContent = new GUIContent("Forge Wizard");
            ProVersion   = EditorGUIUtility.isProSkin;

            ForgeClassObject.IDENTITIES = 0;
            _referenceBitWise           = new List <string>();
            _referenceBitWise.Add("0x1");
            _referenceBitWise.Add("0x2");
            _referenceBitWise.Add("0x4");
            _referenceBitWise.Add("0x8");
            _referenceBitWise.Add("0x10");
            _referenceBitWise.Add("0x20");
            _referenceBitWise.Add("0x40");
            _referenceBitWise.Add("0x80");

            _referenceVariables = new Dictionary <object, string>();
            _referenceVariables.Add(typeof(bool).Name, "bool");
            _referenceVariables.Add(typeof(byte).Name, "byte");
            _referenceVariables.Add(typeof(char).Name, "char");
            _referenceVariables.Add(typeof(short).Name, "short");
            _referenceVariables.Add(typeof(ushort).Name, "ushort");
            _referenceVariables.Add(typeof(int).Name, "int");
            _referenceVariables.Add(typeof(uint).Name, "uint");
            _referenceVariables.Add(typeof(float).Name, "float");
            _referenceVariables.Add(typeof(long).Name, "long");
            _referenceVariables.Add(typeof(ulong).Name, "ulong");
            _referenceVariables.Add(typeof(double).Name, "double");
            _referenceVariables.Add(typeof(string).Name, "string");
            _referenceVariables.Add(typeof(Vector2).Name, "Vector2");
            _referenceVariables.Add(typeof(Vector3).Name, "Vector3");
            _referenceVariables.Add(typeof(Vector4).Name, "Vector4");
            _referenceVariables.Add(typeof(Quaternion).Name, "Quaternion");
            _referenceVariables.Add(typeof(Color).Name, "Color");
            _referenceVariables.Add(typeof(object).Name, "object");
            _referenceVariables.Add(typeof(object[]).Name, "object[]");
            _referenceVariables.Add(typeof(byte[]).Name, "byte[]");

            _scrollView    = Vector2.zero;
            _editorButtons = new List <ForgeEditorButton>();
            _instance      = this;

            _storingPath     = Path.Combine(Application.dataPath, GENERATED_FOLDER_PATH);
            _userStoringPath = Path.Combine(Application.dataPath, USER_GENERATED_FOLDER_PATH);

            if (!Directory.Exists(_storingPath))
            {
                Directory.CreateDirectory(_storingPath);
            }

            if (!Directory.Exists(_userStoringPath))
            {
                Directory.CreateDirectory(_userStoringPath);
            }

            string[] files     = Directory.GetFiles(_storingPath, "*.cs", SearchOption.TopDirectoryOnly);
            string[] userFiles = Directory.GetFiles(_userStoringPath, "*.cs", SearchOption.TopDirectoryOnly);

            //if (File.Exists(Path.Combine(Application.persistentDataPath, FN_WIZARD_DATA))) //Check for our temp file, this will make it so that we can load this data from memory regaurdless of errors
            //{
            //	IFormatter bFormatter = new BinaryFormatter();
            //	bool updateColors = false;
            //	using (Stream s = new FileStream(Path.Combine(Application.persistentDataPath, FN_WIZARD_DATA), FileMode.Open, FileAccess.Read, FileShare.Read))
            //	{
            //		try
            //		{
            //			object deserializedObject = bFormatter.Deserialize(s);
            //			if (deserializedObject != null)
            //			{
            //				_editorButtons = (List<ForgeEditorButton>)deserializedObject;
            //				bool cleared = true;
            //				for (int i = 0; i < _editorButtons.Count; ++i)
            //				{
            //					_editorButtons[i].SetupLists();
            //					if (_editorButtons[i].TiedObject == null)
            //					{
            //						cleared = false;
            //						break;
            //					}
            //				}

            //				if (cleared)
            //					updateColors = true;
            //				else
            //				{
            //					_editorButtons = new List<ForgeEditorButton>();
            //					ReloadScripts(files, userFiles);
            //				}
            //			}
            //			else
            //				ReloadScripts(files, userFiles);
            //		}
            //		catch
            //		{
            //			ReloadScripts(files, userFiles);
            //		}
            //	}

            //	if (updateColors)
            //	{
            //		for (int i = 0; i < _editorButtons.Count; ++i)
            //		{
            //			_editorButtons[i].UpdateButtonColor();
            //			if (_editorButtons[i].IsNetworkObject)
            //				ForgeClassObject.IDENTITIES++;
            //		}
            //	}
            //}
            //else
            ReloadScripts(files, userFiles);

            #region Texture Loading
            Arrow             = Resources.Load <Texture2D>("Arrow");
            SideArrow         = Resources.Load <Texture2D>("SideArrow");
            SideArrowInverse  = FlipTexture(SideArrow);
            Star              = Resources.Load <Texture2D>("Star");
            TrashIcon         = Resources.Load <Texture2D>("Trash");
            SubtractIcon      = Resources.Load <Texture2D>("Subtract");
            AddIcon           = Resources.Load <Texture2D>("Add");
            SaveIcon          = Resources.Load <Texture2D>("Save");
            LightbulbIcon     = Resources.Load <Texture2D>("Lightbulb");
            BackgroundTexture = new Texture2D(1, 1);
            BackgroundTexture.SetPixel(0, 0, LightsOffBackgroundColor);
            BackgroundTexture.Apply();
            #endregion

            _createUndo = () =>
            {
                if (ActiveButton.IsDirty)
                {
                    if (EditorUtility.DisplayDialog("Confirmation", "Are you sure? This will trash the current object", "Yes", "No"))
                    {
                        ActiveButton = null;
                        ChangeMenu(ForgeEditorActiveMenu.Main);
                    }
                }
                else
                {
                    //We don't care because they didn't do anything
                    ActiveButton = null;
                    ChangeMenu(ForgeEditorActiveMenu.Main);
                }
            };

            _modifyUndo = () =>
            {
                bool isDirty = ActiveButton.IsDirty;

                if (isDirty)
                {
                    if (EditorUtility.DisplayDialog("Confirmation", "Are you sure? This will undo the current changes", "Yes", "No"))
                    {
                        ActiveButton.ResetToDefaults();
                        ActiveButton = null;
                        ChangeMenu(ForgeEditorActiveMenu.Main);
                    }
                }
                else
                {
                    ActiveButton.ResetToDefaults();
                    ActiveButton = null;
                    ChangeMenu(ForgeEditorActiveMenu.Main);
                }
            };

            AssetDatabase.Refresh();
        }
Exemple #5
0
        public bool IsSetupCorrectly()
        {
            bool returnValue = true;

            List <string> variableNames = new List <string>();

            //Make sure it doesn't match the class name
            if (ForgeNetworkingEditor.IsValidName(ButtonName))
            {
                variableNames.Add(ButtonName);
            }
            else
            {
                returnValue = false;
            }

            string checkedName = string.Empty;

            //Check the fields
            if (returnValue)
            {
                for (int i = 0; i < ClassVariables.Count; ++i)
                {
                    checkedName = ClassVariables[i].FieldName;
                    if (variableNames.Contains(checkedName))
                    {
                        returnValue = false;
                        break;
                    }

                    if (ForgeNetworkingEditor.IsValidName(checkedName))
                    {
                        variableNames.Add(checkedName);
                    }
                    else
                    {
                        Debug.LogError("Invalid Character Found");
                        returnValue = false;
                        break;
                    }
                }
            }

            //Check the rpcs
            if (returnValue)
            {
                for (int i = 0; i < RPCVariables.Count; ++i)
                {
                    checkedName = RPCVariables[i].FieldName;
                    if (variableNames.Contains(checkedName))
                    {
                        returnValue = false;
                        break;
                    }

                    if (ForgeNetworkingEditor.IsValidName(checkedName))
                    {
                        variableNames.Add(checkedName);
                    }
                    else
                    {
                        Debug.LogError("Invalid Character Found");
                        returnValue = false;
                        break;
                    }
                }
            }

            //Check the rewinds
            if (returnValue)
            {
                for (int i = 0; i < RewindVariables.Count; ++i)
                {
                    checkedName = RewindVariables[i].FieldName;
                    if (variableNames.Contains(checkedName))
                    {
                        returnValue = false;
                        break;
                    }

                    if (ForgeNetworkingEditor.IsValidName(checkedName))
                    {
                        variableNames.Add(checkedName);
                    }
                    else
                    {
                        Debug.LogError("Invalid Character Found");
                        returnValue = false;
                        break;
                    }
                }
            }

            return(returnValue);
        }
Exemple #6
0
        /// <summary>
        /// This will render the main menu
        /// </summary>
        private void RenderMainMenu()
        {
            if (_editorButtons == null)
            {
                Initialize();
                return;                 //Editor is getting refreshed
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label("Search", GUILayout.Width(50));
            _searchField = GUILayout.TextField(_searchField);
            Rect verticleButton = EditorGUILayout.BeginVertical("Button", GUILayout.Width(100), GUILayout.Height(15));

            if (ProVersion)
            {
                GUI.color = TealBlue;
            }
            if (GUI.Button(verticleButton, GUIContent.none))
            {
                ActiveButton           = new ForgeEditorButton("");
                ActiveButton.IsCreated = true;
                ChangeMenu(ForgeEditorActiveMenu.Create);
            }
            GUI.color = Color.white;
            GUILayout.BeginHorizontal();
            GUILayout.Label(Star);
            GUILayout.Label("Create", EditorStyles.boldLabel);
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            _scrollView = GUILayout.BeginScrollView(_scrollView);

            for (int i = 0; i < _editorButtons.Count; ++i)
            {
                if (_editorButtons[i].IsNetworkBehavior)
                {
                    continue;
                }

                if (string.IsNullOrEmpty(_searchField) || _editorButtons[i].PossiblyMatches(_searchField))
                {
                    _editorButtons[i].Render();
                }

                if (_editorButtons[i].MarkedForDeletion)
                {
                    if (EditorUtility.DisplayDialog("Confirmation", "Are you sure? This will delete the class", "Yes", "No"))
                    {
                        if (_editorButtons[i].TiedObject.IsNetworkObject || _editorButtons[i].TiedObject.IsNetworkBehavior)
                        {
                            //Then we will need to remove this from the factory and destroy the other object as well
                            string searchName           = _editorButtons[i].TiedObject.StrippedSearchName;
                            string folderPath           = _editorButtons[i].TiedObject.FileLocation.Substring(0, _editorButtons[i].TiedObject.FileLocation.Length - _editorButtons[i].TiedObject.Filename.Length);
                            string filePathBehavior     = Path.Combine(folderPath, searchName + "Behavior.cs");
                            string filePathNetworkedObj = Path.Combine(folderPath, searchName + "NetworkObject.cs");

                            if (File.Exists(filePathBehavior))                             //Delete the behavior
                            {
                                File.Delete(filePathBehavior);
                            }
                            if (File.Exists(filePathNetworkedObj))                             //Delete the object
                            {
                                File.Delete(filePathNetworkedObj);
                            }
                            _editorButtons.RemoveAt(i);

                            string factoryData = SourceCodeFactory();
                            using (StreamWriter sw = File.CreateText(Path.Combine(_storingPath, "NetworkObjectFactory.cs")))
                            {
                                sw.Write(factoryData);
                            }

                            string networkManagerData = SourceCodeNetworkManager();
                            using (StreamWriter sw = File.CreateText(Path.Combine(_storingPath, "NetworkManager.cs")))
                            {
                                sw.Write(networkManagerData);
                            }
                        }
                        else
                        {
                            //Random object
                            //File.Delete(_editorButtons[i].TiedObject.FileLocation);
                        }
                        AssetDatabase.Refresh();
                        CloseFinal();
                        break;
                    }
                    else
                    {
                        _editorButtons[i].MarkedForDeletion = false;
                    }
                }
            }

            GUILayout.EndScrollView();

            Rect backBtn = EditorGUILayout.BeginVertical("Button", GUILayout.Height(50));

            if (ProVersion)
            {
                GUI.color = ShadedBlue;
            }
            if (GUI.Button(backBtn, GUIContent.none))
            {
                //CloseFinal();
                Close();
                _instance = null;
                return;
            }
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            GUI.color = Color.white;
            GUILayout.FlexibleSpace();
            GUIStyle boldStyle = new GUIStyle(GUI.skin.GetStyle("boldLabel"));

            boldStyle.alignment = TextAnchor.UpperCenter;
            GUILayout.Label("Close", boldStyle);
            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
        }
Exemple #7
0
        /// <summary>
        /// Setup all the variables to be used within the editor
        /// </summary>
        public void Initialize()
        {
            titleContent = new GUIContent("Forge Wizard");
            ProVersion   = EditorGUIUtility.isProSkin;

            ForgeClassObject.IDENTITIES = 0;
            _referenceBitWise           = new List <string>();
            _referenceBitWise.Add("0x1");
            _referenceBitWise.Add("0x2");
            _referenceBitWise.Add("0x4");
            _referenceBitWise.Add("0x8");
            _referenceBitWise.Add("0x10");
            _referenceBitWise.Add("0x20");
            _referenceBitWise.Add("0x40");
            _referenceBitWise.Add("0x80");

            _referenceVariables = new Dictionary <object, string>();
            _referenceVariables.Add(typeof(bool).Name, "bool");
            _referenceVariables.Add(typeof(byte).Name, "byte");
            _referenceVariables.Add(typeof(char).Name, "char");
            _referenceVariables.Add(typeof(short).Name, "short");
            _referenceVariables.Add(typeof(ushort).Name, "ushort");
            _referenceVariables.Add(typeof(int).Name, "int");
            _referenceVariables.Add(typeof(uint).Name, "uint");
            _referenceVariables.Add(typeof(float).Name, "float");
            _referenceVariables.Add(typeof(long).Name, "long");
            _referenceVariables.Add(typeof(ulong).Name, "ulong");
            _referenceVariables.Add(typeof(double).Name, "double");
            _referenceVariables.Add(typeof(string).Name, "string");
            _referenceVariables.Add(typeof(Vector2).Name, "Vector2");
            _referenceVariables.Add(typeof(Vector3).Name, "Vector3");
            _referenceVariables.Add(typeof(Vector4).Name, "Vector4");
            _referenceVariables.Add(typeof(Quaternion).Name, "Quaternion");
            _referenceVariables.Add(typeof(Color).Name, "Color");
            _referenceVariables.Add(typeof(object).Name, "object");
            _referenceVariables.Add(typeof(object[]).Name, "object[]");
            _referenceVariables.Add(typeof(byte[]).Name, "byte[]");

            _scrollView    = Vector2.zero;
            _editorButtons = new List <ForgeEditorButton>();
            _instance      = this;

            _storingPath     = Path.Combine(Application.dataPath, GENERATED_FOLDER_PATH);
            _userStoringPath = Path.Combine(Application.dataPath, USER_GENERATED_FOLDER_PATH);

            if (!Directory.Exists(_storingPath))
            {
                Directory.CreateDirectory(_storingPath);
            }

            if (!Directory.Exists(_userStoringPath))
            {
                Directory.CreateDirectory(_userStoringPath);
            }

            string[] files     = Directory.GetFiles(_storingPath, "*", SearchOption.TopDirectoryOnly);
            string[] userFiles = Directory.GetFiles(_userStoringPath, "*", SearchOption.TopDirectoryOnly);
            List <ForgeClassObject> correctFiles = new List <ForgeClassObject>();

            for (int i = 0; i < files.Length; ++i)
            {
                if (!files[i].EndsWith(".meta"))                 //Ignore all meta files
                {
                    correctFiles.Add(new ForgeClassObject(files[i]));
                }
            }

            for (int i = 0; i < userFiles.Length; ++i)
            {
                if (!userFiles[i].EndsWith(".meta"))                 //Ignore all meta files
                {
                    correctFiles.Add(new ForgeClassObject(userFiles[i]));
                }
            }

            if (!ForgeClassObject.HasExactFilename(correctFiles, "NetworkObjectFactory"))
            {
                MakeForgeFactory();                 //We do not have the Forge Factory, we need to make this!
            }
            for (int i = 0; i < correctFiles.Count; ++i)
            {
                var btn = new ForgeEditorButton(correctFiles[i]);

                if (btn.IsNetworkObject || btn.IsNetworkBehavior)
                {
                    _editorButtons.Add(btn);
                }
            }

            #region Texture Loading
            Arrow             = Resources.Load <Texture2D>("Arrow");
            SideArrow         = Resources.Load <Texture2D>("SideArrow");
            SideArrowInverse  = FlipTexture(SideArrow);
            Star              = Resources.Load <Texture2D>("Star");
            TrashIcon         = Resources.Load <Texture2D>("Trash");
            SubtractIcon      = Resources.Load <Texture2D>("Subtract");
            AddIcon           = Resources.Load <Texture2D>("Add");
            SaveIcon          = Resources.Load <Texture2D>("Save");
            LightbulbIcon     = Resources.Load <Texture2D>("Lightbulb");
            BackgroundTexture = new Texture2D(1, 1);
            BackgroundTexture.SetPixel(0, 0, LightsOffBackgroundColor);
            BackgroundTexture.Apply();
            #endregion

            _createUndo = () =>
            {
                if (ActiveButton.IsDirty)
                {
                    if (EditorUtility.DisplayDialog("Confirmation", "Are you sure? This will trash the current object", "Yes", "No"))
                    {
                        ActiveButton = null;
                        ChangeMenu(ForgeEditorActiveMenu.Main);
                    }
                }
                else
                {
                    //We don't care because they didn't do anything
                    ActiveButton = null;
                    ChangeMenu(ForgeEditorActiveMenu.Main);
                }
            };

            _modifyUndo = () =>
            {
                bool isDirty = ActiveButton.IsDirty;

                if (isDirty)
                {
                    if (EditorUtility.DisplayDialog("Confirmation", "Are you sure? This will undo the current changes", "Yes", "No"))
                    {
                        ActiveButton.ResetToDefaults();
                        ActiveButton = null;
                        ChangeMenu(ForgeEditorActiveMenu.Main);
                    }
                }
                else
                {
                    ActiveButton.ResetToDefaults();
                    ActiveButton = null;
                    ChangeMenu(ForgeEditorActiveMenu.Main);
                }
            };

            AssetDatabase.Refresh();
        }
Exemple #8
0
        public ValidationResult ValidateSetup()
        {
            ValidationResult result        = new ValidationResult();
            List <string>    variableNames = new List <string>();

            //Make sure the class name is valid, and that no fields/RPCs/Rewinds match the class name
            if (ForgeNetworkingEditor.IsValidName(ButtonName))
            {
                variableNames.Add(ButtonName);
            }
            else
            {
                result.ReportValidationError(String.Format("Class \"{0}\" has a non-valid name", ButtonName));
            }

            string checkedName = string.Empty;

            //Validate Fields
            for (int i = 0; i < ClassVariables.Count; ++i)
            {
                checkedName = ClassVariables[i].FieldName;
                if (variableNames.Contains(checkedName))
                {
                    result.ReportValidationError(String.Format("Duplicate element \"{0}\" found in \"{1}\"", checkedName, ButtonName));
                }

                switch (ClassVariables[i].FieldName)
                {
                case "IDENTITY":
                case "networkObject":
                case "fieldAltered":
                case "_dirtyFields":
                case "dirtyFields":
                    result.ReportValidationError(String.Format("Field \"{0}\" conflicts with a field name reserved for Forge Networking Remastered", checkedName));
                    break;
                }

                string duplicate = string.Empty;
                if (checkedName.EndsWith("Changed"))
                {
                    duplicate = checkedName.Substring(0, checkedName.LastIndexOf("Changed"));
                    if (variableNames.Contains(duplicate))
                    {
                        result.ReportValidationError(String.Format("Field \"{0}\" conflicts with Changed event of {1}", checkedName, duplicate));
                    }
                }

                if (checkedName.EndsWith("Interpolation"))
                {
                    duplicate = checkedName.Substring(0, checkedName.LastIndexOf("Interpolation"));
                    if (variableNames.Contains(duplicate))
                    {
                        result.ReportValidationError(String.Format("Field \"{0}\" conflicts with Interpolation field of {1}", checkedName, duplicate));
                    }
                }

                //Check if the field name is a valid identifier
                if (ForgeNetworkingEditor.IsValidName(checkedName))
                {
                    variableNames.Add(checkedName);
                }
                else
                {
                    result.ReportValidationError(String.Format("Invalid identifier for Field \"{0}\" in \"{1}\"", checkedName, ButtonName));
                }
            }

            //Validate RPCs
            for (int i = 0; i < RPCVariables.Count; ++i)
            {
                checkedName = RPCVariables[i].FieldName;
                if (variableNames.Contains(checkedName))
                {
                    result.ReportValidationError(String.Format("Duplicate element \"{0}\" found in \"{1}\"", checkedName, ButtonName));
                }

                //Check if RPC name is a valid identifier
                if (ForgeNetworkingEditor.IsValidName(checkedName))
                {
                    variableNames.Add(checkedName);
                }
                else
                {
                    result.ReportValidationError(String.Format("Invalid identifier for RPC \"{0}\" in \"{1}\"", checkedName, ButtonName));
                }

                switch (RPCVariables[i].FieldName.ToLower())
                {
                case "initialize":
                case "networkcreateobject":
                    result.ReportValidationError(String.Format("RPC \"{0}\" conflicts with a method name reserved for Forge Networking Remastered", checkedName));
                    break;
                }

                if (RPCVariables[i].FieldName.StartsWith("get_") ||
                    RPCVariables[i].FieldName.StartsWith("set_"))
                {
                    result.ReportValidationError(String.Format("RPC \"{0}\" cannot start with \"get_\" or \"set_\"", checkedName));
                    break;
                }
            }

            //Validate Rewinds
            for (int i = 0; i < RewindVariables.Count; ++i)
            {
                checkedName = RewindVariables[i].FieldName;
                if (variableNames.Contains(checkedName))
                {
                    result.ReportValidationError(String.Format("Duplicate element \"{0}\" found in \"{1}\"", checkedName, ButtonName));
                }
                //Check if Rewind name is a valid identifier
                if (ForgeNetworkingEditor.IsValidName(checkedName))
                {
                    variableNames.Add(checkedName);
                }
                else
                {
                    result.ReportValidationError(String.Format("Invalid identifier for Rewind \"{0}\" in \"{1}\"", checkedName, ButtonName));
                }
            }

            return(result);
        }