private static bool DrawMissionPatrolWaypoint(ICECreatureControl _control, int _index)
        {
            ICEEditorStyle.SplitterByIndent(EditorGUI.indentLevel);
            WaypointObject _waypoint = _control.Creature.Missions.Patrol.Waypoints.Waypoints[_index];

            if (_waypoint == null)
            {
                return(false);
            }

            // HEADER BEGIN
            ICEEditorLayout.BeginHorizontal();
            _waypoint.WaypointFoldout = ICEEditorLayout.Foldout(_waypoint.WaypointFoldout, "Waypoint #" + (int)(_index + 1) + (!string.IsNullOrEmpty(_waypoint.TargetName) ? " (" + _waypoint.TargetName + ")": ""), "", true);

            if (ICEEditorLayout.ListDeleteButton <WaypointObject>(_control.Creature.Missions.Patrol.Waypoints.Waypoints, _waypoint))
            {
                return(true);
            }

            GUILayout.Space(5);
            if (ICEEditorLayout.ListUpDownButtons <WaypointObject>(_control.Creature.Missions.Patrol.Waypoints.Waypoints, _control.Creature.Missions.Patrol.Waypoints.Waypoints.IndexOf(_waypoint)))
            {
                return(true);
            }



            _waypoint.Enabled = ICEEditorLayout.EnableButton(_waypoint.Enabled);

            ICEEditorLayout.EndHorizontal(Info.MISSION_PATROL_WAYPOINT);
            // HEADER END

            // CONTENT BEGIN
            if (_waypoint.WaypointFoldout)
            {
                EditorGUI.indentLevel++;
                EditorGUI.BeginDisabledGroup(_waypoint.Enabled == false);
                TargetEditor.DrawMissionTarget(_control, (TargetObject)_waypoint, "Target", Info.MISSION_PATROL_TARGET);

                ICEEditorLayout.BeginHorizontal();
                EditorGUI.BeginDisabledGroup(_waypoint.UseCustomBehaviour == false);
                _waypoint.BehaviourFoldout = ICEEditorLayout.Foldout(_waypoint.BehaviourFoldout, "Behaviour", true);
                EditorGUI.EndDisabledGroup();
                _waypoint.UseCustomBehaviour = ICEEditorLayout.CheckButton("Override", "", _waypoint.UseCustomBehaviour, ICEEditorStyle.ButtonMiddle);
                ICEEditorLayout.EndHorizontal(Info.MISSION_PATROL_CUSTOM_BEHAVIOUR);

                if (!_waypoint.UseCustomBehaviour)
                {
                    _waypoint.BehaviourFoldout = false;
                }

                if (_waypoint.BehaviourFoldout)
                {
                    _waypoint.BehaviourModeTravel = BehaviourEditor.BehaviourSelect(_control, "Travel", "Travel behaviour to reach this waypoint and to start this mission", _waypoint.BehaviourModeTravel, "WP_TRAVEL_" + (int)(_index + 1));
                    _waypoint.BehaviourModePatrol = BehaviourEditor.BehaviourSelect(_control, "Patrol", "Patrol behaviour to reach this waypoint", _waypoint.BehaviourModePatrol, "WP_PATROL_" + (int)(_index + 1));

                    BehaviourEditor.DrawInRangeBehaviour(_control,
                                                         ref _waypoint.BehaviourModeLeisure,
                                                         ref _waypoint.BehaviourModeRendezvous,
                                                         ref _waypoint.DurationOfStay,
                                                         ref _waypoint.IsTransitPoint,
                                                         _waypoint.Move.RandomRange,
                                                         (int)(_index + 1));

                    EditorGUILayout.Separator();
                }

                EditorGUI.EndDisabledGroup();
                EditorGUI.indentLevel--;
            }
            // CONTENT END


            return(false);
        }
        private static void DrawMissionPatrol(ICECreatureControl _control)
        {
            ICEEditorStyle.SplitterByIndent(EditorGUI.indentLevel);

            //HEADER BEGIN
            ICEEditorLayout.BeginHorizontal();
            _control.Creature.Missions.Patrol.Foldout = ICEEditorLayout.Foldout(_control.Creature.Missions.Patrol.Foldout, "Patrol Mission");
            if (ICEEditorLayout.SaveButton())
            {
                CreatureEditorIO.SaveMissionPatrolToFile(_control.Creature.Missions.Patrol, _control.gameObject.name);
            }
            if (ICEEditorLayout.LoadButton())
            {
                _control.Creature.Missions.Patrol = CreatureEditorIO.LoadMissionPatrolFromFile(_control.Creature.Missions.Patrol);
            }
            if (ICEEditorLayout.ResetButton())
            {
                _control.Creature.Missions.Patrol = new PatrolObject();
            }
            _control.Creature.Missions.Patrol.Enabled = ICEEditorLayout.EnableButton(_control.Creature.Missions.Patrol.Enabled);
            ICEEditorLayout.EndHorizontal(Info.MISSION_PATROL);
            //HEADER END

            if (!_control.Creature.Missions.Patrol.Foldout)
            {
                return;
            }

            EditorGUI.BeginDisabledGroup(_control.Creature.Missions.Patrol.Enabled == false);



            EditorGUILayout.Separator();

            EditorGUI.indentLevel++;
            _control.Creature.Missions.Patrol.BehaviourFoldout = ICEEditorLayout.Foldout(_control.Creature.Missions.Patrol.BehaviourFoldout, "Behaviour", Info.MISSION_OUTPOST_BEHAVIOR, true);
            if (_control.Creature.Missions.Patrol.BehaviourFoldout)
            {
                _control.Creature.Missions.Patrol.BehaviourModeTravel = BehaviourEditor.BehaviourSelect(_control, "Travel", "Default travel behaviour to reach the first waypoint", _control.Creature.Missions.Patrol.BehaviourModeTravel, "WP_TRAVEL");
                _control.Creature.Missions.Patrol.BehaviourModePatrol = BehaviourEditor.BehaviourSelect(_control, "Patrol", "Default patrol behaviour to reach the next waypoint", _control.Creature.Missions.Patrol.BehaviourModePatrol, "WP_PATROL");
                BehaviourEditor.DrawInRangeBehaviour(_control,
                                                     ref _control.Creature.Missions.Patrol.BehaviourModeLeisure,
                                                     ref _control.Creature.Missions.Patrol.BehaviourModeRendezvous,
                                                     ref _control.Creature.Missions.Patrol.DurationOfStay,
                                                     ref _control.Creature.Missions.Patrol.IsTransitPoint,
                                                     1);
                EditorGUILayout.Separator();
            }
            EditorGUI.indentLevel--;



            EditorGUI.indentLevel++;
            ICEEditorLayout.BeginHorizontal();

            int    _count_all   = _control.Creature.Missions.Patrol.Waypoints.Waypoints.Count;
            int    _count_valid = _control.Creature.Missions.Patrol.Waypoints.GetValidWaypoints().Count;
            string _title       = "Waypoints" + (_count_all > 0 ? " (" + _count_valid + "/" + _count_all + ")" : "");

            _control.Creature.Missions.Patrol.WaypointsFoldout = ICEEditorLayout.Foldout(_control.Creature.Missions.Patrol.WaypointsFoldout, _title, true);


            _control.Creature.Missions.Patrol.Waypoints.WaypointGroup = (GameObject)EditorGUILayout.ObjectField(_control.Creature.Missions.Patrol.Waypoints.WaypointGroup, typeof(GameObject), true, GUILayout.Width(65));
            _control.Creature.Missions.Patrol.Waypoints.WaypointGroup = null;

            //if( ICEEditorLayout.ButtonMiddle( "RESET", "Removes all waypoints." ) )
            //	_control.Creature.Missions.Patrol.Waypoints.Waypoints.Clear();

            if (ICEEditorLayout.ListClearButton <WaypointObject>(_control.Creature.Missions.Patrol.Waypoints.Waypoints))
            {
                return;
            }

            if (ICEEditorLayout.AddButtonSmall("Adds a new waypoint item."))
            {
                _control.Creature.Missions.Patrol.Waypoints.Waypoints.Add(new WaypointObject());
            }

            GUILayout.Space(5);
            ICEEditorLayout.ListFoldoutButtons <WaypointObject>(_control.Creature.Missions.Patrol.Waypoints.Waypoints);

            ICEEditorLayout.EndHorizontal(Info.MISSION_PATROL_WAYPOINTS);
            if (_control.Creature.Missions.Patrol.WaypointsFoldout)
            {
                ICEEditorLayout.BeginHorizontal();
                _control.Creature.Missions.Patrol.Waypoints.Order = (WaypointOrderType)ICEEditorLayout.EnumPopup("Order Type", "", _control.Creature.Missions.Patrol.Waypoints.Order);
                EditorGUI.BeginDisabledGroup(_control.Creature.Missions.Patrol.Waypoints.Order != WaypointOrderType.CYCLE);
                _control.Creature.Missions.Patrol.Waypoints.Ascending = !ICEEditorLayout.CheckButtonSmall("DESC", "descending order", !_control.Creature.Missions.Patrol.Waypoints.Ascending);
                EditorGUI.EndDisabledGroup();
                ICEEditorLayout.EndHorizontal(Info.MISSION_PATROL_ORDER_TYPE);

                EditorGUILayout.Separator();
                for (int i = 0; i < _control.Creature.Missions.Patrol.Waypoints.Waypoints.Count; ++i)
                {
                    if (DrawMissionPatrolWaypoint(_control, i))
                    {
                        return;
                    }
                }
            }
            EditorGUI.indentLevel--;

            EditorGUI.EndDisabledGroup();
            EditorGUILayout.Separator();
        }