private static void DrawMissionOutpost(ICECreatureControl _control) { if (_control.Display.ShowMissionsHome == false) { return; } ICEEditorStyle.SplitterByIndent(EditorGUI.indentLevel); _control.Display.FoldoutMissionOutpost = ICEEditorLayout.Foldout(_control.Display.FoldoutMissionOutpost, "Outpost Mission", Info.MISSION_OUTPOST); if (!_control.Display.FoldoutMissionOutpost) { return; } _control.Creature.Missions.Outpost.Enabled = ICEEditorLayout.Toggle("Mission Enabled", "", _control.Creature.Missions.Outpost.Enabled, Info.MISSION_ENABLED); EditorGUILayout.Separator(); EditorGUI.BeginDisabledGroup(_control.Creature.Missions.Outpost.Enabled == false); _control.Creature.Missions.Outpost.Target = EditorSharedTools.DrawTarget(_control, _control.Creature.Missions.Outpost.Target, "Target", Info.MISSION_OUTPOST_TARGET); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Behaviour", ICEEditorStyle.LabelBold); EditorGUI.indentLevel++; _control.Creature.Missions.Outpost.BehaviourModeTravel = EditorBehaviour.BehaviourSelect(_control, "Travel", "Move behaviour to reach the Outpost", _control.Creature.Missions.Outpost.BehaviourModeTravel, "TRAVEL"); _control.Creature.Missions.Outpost.BehaviourModeRendezvous = EditorBehaviour.BehaviourSelect(_control, "Rendezvous", "Idle behaviour after reaching the current target move position.", _control.Creature.Missions.Outpost.BehaviourModeRendezvous, "RENDEZVOUS"); EditorGUI.BeginDisabledGroup(_control.Creature.Missions.Outpost.Target.TargetRandomRange == 0); _control.Creature.Missions.Outpost.BehaviourModeLeisure = EditorBehaviour.BehaviourSelect(_control, "Leisure", "Randomized leisure activities around the Outpost", _control.Creature.Missions.Outpost.BehaviourModeLeisure, "STANDBY"); EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel--; EditorGUI.EndDisabledGroup(); EditorGUILayout.Separator(); }
private static InteractorObject DrawInteractorOffset(ICECreatureControl _control, InteractorObject _interactor) { TargetObject _target = new TargetObject(TargetType.INTERACTOR); _target.TargetGameObject = m_creature_register.GetReferenceCreatureByName(_interactor.Name); ICEEditorLayout.BeginHorizontal(); _interactor.Name = EditorSharedTools.RegisterPopup("Target Object", _interactor.Name); if (_target.TargetGameObject != null) { if (GUILayout.Button("SHOW", ICEEditorStyle.ButtonMiddle)) { var view = SceneView.currentDrawingSceneView; if (view != null) { Vector3 _pos = _target.TargetGameObject.transform.position; _pos.y += 20; view.rotation = new Quaternion(1, 0, 0, 1); view.LookAt(_pos); // view.AlignViewToObject(_target.TargetGameObject.transform); } } if (GUILayout.Button("SELECT", ICEEditorStyle.ButtonMiddle)) { Selection.activeGameObject = _target.TargetGameObject; } } ICEEditorLayout.EndHorizontal(Info.INTERACTION_INTERACTOR_TARGET); _target.UpdateOffset(_interactor.DefaultOffset); _target.TargetStopDistance = _interactor.DefaultStopDistance; _target.TargetRandomRange = _interactor.DefaultRandomRange; _target.UseUpdateOffsetOnActivateTarget = _interactor.UpdateOffsetOnActivateTarget; _target.UseUpdateOffsetOnMovePositionReached = _interactor.UpdateOffsetOnMovePositionReached; _target.TargetSmoothingMultiplier = _interactor.DefaultSmoothingMultiplier; _target.TargetIgnoreLevelDifference = _interactor.DefaultIgnoreLevelDifference; _target = EditorSharedTools.DrawTargetOffset(_control, _target); _interactor.DefaultOffset = _target.TargetOffset; _interactor.DefaultStopDistance = _target.TargetStopDistance; _interactor.DefaultRandomRange = _target.TargetRandomRange; _interactor.UpdateOffsetOnActivateTarget = _target.UseUpdateOffsetOnActivateTarget; _interactor.UpdateOffsetOnMovePositionReached = _target.UseUpdateOffsetOnMovePositionReached; _interactor.DefaultIgnoreLevelDifference = _target.TargetIgnoreLevelDifference; _interactor.DefaultSmoothingMultiplier = _target.TargetSmoothingMultiplier; _target.TargetGameObject = null; _target = null; return(_interactor); }
private static void DrawMissionEscort(ICECreatureControl _control) { if (_control.Display.ShowMissionsEscort == false) { return; } ICEEditorStyle.SplitterByIndent(EditorGUI.indentLevel); ICEEditorLayout.BeginHorizontal(); _control.Display.FoldoutMissionEscort = ICEEditorLayout.Foldout(_control.Display.FoldoutMissionEscort, "Escort Mission"); if (GUILayout.Button("SAVE", ICEEditorStyle.ButtonMiddle)) { CreatureIO.SaveMissionEscortToFile(_control.Creature.Missions.Escort, _control.gameObject.name); } if (GUILayout.Button("LOAD", ICEEditorStyle.ButtonMiddle)) { _control.Creature.Missions.Escort = CreatureIO.LoadMissionEscortFromFile(_control.Creature.Missions.Escort); } ICEEditorLayout.EndHorizontal(Info.MISSION_ESCORT); if (!_control.Display.FoldoutMissionEscort) { return; } _control.Creature.Missions.Escort.Enabled = ICEEditorLayout.Toggle("Mission Enabled", "", _control.Creature.Missions.Escort.Enabled, Info.MISSION_ENABLED); EditorGUILayout.Separator(); EditorGUI.BeginDisabledGroup(_control.Creature.Missions.Escort.Enabled == false); _control.Creature.Missions.Escort.Target = EditorSharedTools.DrawTarget(_control, _control.Creature.Missions.Escort.Target, "Target", Info.MISSION_ESCORT_TARGET); EditorGUILayout.Separator(); ICEEditorLayout.Label("Behaviour", true, Info.MISSION_ESCORT_BEHAVIOUR); EditorGUI.indentLevel++; _control.Creature.Missions.Escort.BehaviourModeFollow = EditorBehaviour.BehaviourSelect(_control, "Follow", "Move behaviour to follow and reach the leader", _control.Creature.Missions.Escort.BehaviourModeFollow, "FOLLOW"); _control.Creature.Missions.Escort.BehaviourModeEscort = EditorBehaviour.BehaviourSelect(_control, "Escort", "Move behaviour to escort the leader", _control.Creature.Missions.Escort.BehaviourModeEscort, "ESCORT"); _control.Creature.Missions.Escort.BehaviourModeStandby = EditorBehaviour.BehaviourSelect(_control, "Standby", "Idle behaviour if the leader stops", _control.Creature.Missions.Escort.BehaviourModeStandby, "STANDBY"); EditorGUI.indentLevel++; _control.Creature.Missions.Escort.DurationStandby = ICEEditorLayout.Slider("Duration (until IDLE)", "", _control.Creature.Missions.Escort.DurationStandby, 1, 0, 60); EditorGUI.indentLevel--; _control.Creature.Missions.Escort.BehaviourModeIdle = EditorBehaviour.BehaviourSelect(_control, "Idle", "Idle behaviour if the leader breaks for a longer time-span", _control.Creature.Missions.Escort.BehaviourModeIdle, "IDLE"); EditorGUI.indentLevel--; EditorGUILayout.Separator(); EditorGUI.EndDisabledGroup(); }
/// <summary> /// Handles the essential settings. /// </summary> /// <param name="_creature_control">_creature_control.</param> private static void HandleEssentialSettings(ICECreatureControl _control) { _control.Creature.Essentials.Target = EditorSharedTools.DrawTarget(_control, _control.Creature.Essentials.Target, "Home", Info.ESSENTIALS_HOME); EditorGUILayout.Separator(); ICEEditorLayout.Label("Behaviours", true, Info.ESSENTIALS_BEHAVIOURS); EditorGUI.indentLevel++; _control.Creature.Essentials.BehaviourModeTravel = EditorBehaviour.BehaviourSelect(_control, "Travel", "Move behaviour if your creature is on a journey", _control.Creature.Essentials.BehaviourModeTravel, "TRAVEL"); _control.Creature.Essentials.BehaviourModeRendezvous = EditorBehaviour.BehaviourSelect(_control, "Rendezvous", "Idle behaviour after reaching the current target move position.", _control.Creature.Essentials.BehaviourModeRendezvous, "RENDEZVOUS"); EditorGUI.BeginDisabledGroup(_control.Creature.Essentials.Target.TargetRandomRange == 0); _control.Creature.Essentials.BehaviourModeLeisure = EditorBehaviour.BehaviourSelect(_control, "Leisure", "Randomized leisure activities around the home area", _control.Creature.Essentials.BehaviourModeLeisure, "LEISURE"); EditorGUI.EndDisabledGroup(); _control.Creature.Essentials.BehaviourModeDead = EditorBehaviour.BehaviourSelect(_control, "Dead", "Static behaviour if your creature is dead", _control.Creature.Essentials.BehaviourModeDead, "DEAD"); _control.Creature.Essentials.BehaviourModeRespawn = EditorBehaviour.BehaviourSelect(_control, "Respawn", "Idle behaviour after respawn", _control.Creature.Essentials.BehaviourModeRespawn, "RESPAWN"); EditorGUI.indentLevel--; EditorGUILayout.Separator(); }
private static void DrawMissionPatrolWaypoint(ICECreatureControl _control, int _index) { ICEEditorStyle.SplitterByIndent(EditorGUI.indentLevel + 1); WaypointObject _waypoint = _control.Creature.Missions.Patrol.Waypoints.Waypoints[_index]; if (_waypoint == null) { return; } // HEADER BEGIN ICEEditorLayout.BeginHorizontal(); _waypoint.Enabled = EditorGUILayout.ToggleLeft("Waypoint #" + (int)(_index + 1), _waypoint.Enabled, EditorStyles.boldLabel); GUILayout.FlexibleSpace(); if (ICEEditorLayout.ButtonUp()) { WaypointObject _wp = _control.Creature.Missions.Patrol.Waypoints.Waypoints[_index]; _control.Creature.Missions.Patrol.Waypoints.Waypoints.RemoveAt(_index); if (_index - 1 < 0) { _control.Creature.Missions.Patrol.Waypoints.Waypoints.Add(_wp); } else { _control.Creature.Missions.Patrol.Waypoints.Waypoints.Insert(_index - 1, _wp); } return; } if (ICEEditorLayout.ButtonDown()) { WaypointObject _wp = _control.Creature.Missions.Patrol.Waypoints.Waypoints[_index]; _control.Creature.Missions.Patrol.Waypoints.Waypoints.RemoveAt(_index); if (_index + 1 > _control.Creature.Missions.Patrol.Waypoints.Waypoints.Count) { _control.Creature.Missions.Patrol.Waypoints.Waypoints.Insert(0, _wp); } else { _control.Creature.Missions.Patrol.Waypoints.Waypoints.Insert(_index + 1, _wp); } return; } if (ICEEditorLayout.ButtonCloseDouble()) { _control.Creature.Missions.Patrol.Waypoints.Waypoints.RemoveAt(_index); --_index; } ICEEditorLayout.EndHorizontal(Info.MISSION_PATROL_WAYPOINT); // HEADER END // CONTENT BEGIN EditorGUI.BeginDisabledGroup(_waypoint.Enabled == false); EditorGUI.indentLevel++; _waypoint = (WaypointObject)EditorSharedTools.DrawTarget(_control, (TargetObject)_waypoint, "Target", Info.MISSION_PATROL_TARGET); EditorGUILayout.Separator(); _waypoint.UseCustomBehaviour = ICEEditorLayout.Toggle("Custom Behaviour", "", _waypoint.UseCustomBehaviour, Info.MISSION_PATROL_CUSTOM_BEHAVIOUR); EditorGUILayout.Separator(); if (_waypoint.UseCustomBehaviour) { EditorGUI.indentLevel++; _waypoint.BehaviourModeTravel = EditorBehaviour.BehaviourSelect(_control, "Travel", "Travel behaviour to reach this waypoint and to start this mission", _waypoint.BehaviourModeTravel, "WP_TRAVEL_" + (int)(_index + 1)); _waypoint.BehaviourModePatrol = EditorBehaviour.BehaviourSelect(_control, "Patrol", "Patrol behaviour to reach this waypoint", _waypoint.BehaviourModePatrol, "WP_PATROL_" + (int)(_index + 1)); EditorSharedTools.DrawInRangeBehaviour(_control, ref _waypoint.BehaviourModeLeisure, ref _waypoint.BehaviourModeRendezvous, ref _waypoint.DurationOfStay, ref _waypoint.IsTransitPoint, _waypoint.TargetRandomRange, (int)(_index + 1)); /* * EditorGUI.BeginDisabledGroup( _waypoint.IsTransitPoint == true ); * * _waypoint.BehaviourModeLeisure = EditorBehaviour.BehaviourSelect( m_creature_control, "Leisure", "Leisure activities after reaching this waypoint range", _waypoint.BehaviourModeLeisure, "WP_LEISURE_" + _index ); * _waypoint.BehaviourModeRendezvous = EditorBehaviour.BehaviourSelect( m_creature_control, "Rendezvous", "Action behaviour after reaching this current target move position", _waypoint.BehaviourModeRendezvous, "WP_RENDEZVOUS_" + _index ); * EditorGUI.EndDisabledGroup(); * * _waypoint.DurationOfStay = ICEEditorLayout.DurationSlider( "Duration Of Stay", "Duration of stay", _waypoint.DurationOfStay, Init.DURATION_OF_STAY_STEP, Init.DURATION_OF_STAY_MIN, Init.DURATION_OF_STAY_MAX,Init.DURATION_OF_STAY_DEFAULT, ref _waypoint.IsTransitPoint ); * */ EditorGUI.indentLevel--; EditorGUILayout.Separator(); } EditorGUI.indentLevel--; EditorGUI.EndDisabledGroup(); // CONTENT END }
private static void DrawMissionPatrol(ICECreatureControl _control) { if (_control.Display.ShowMissionsPatrol == false) { return; } ICEEditorStyle.SplitterByIndent(EditorGUI.indentLevel); _control.Display.FoldoutMissionPatrol = ICEEditorLayout.Foldout(_control.Display.FoldoutMissionPatrol, "Patrol Mission", Info.MISSION_PATROL); if (!_control.Display.FoldoutMissionPatrol) { return; } _control.Creature.Missions.Patrol.Enabled = ICEEditorLayout.Toggle("Mission Enabled", "", _control.Creature.Missions.Patrol.Enabled, Info.MISSION_ENABLED); EditorGUILayout.Separator(); EditorGUI.BeginDisabledGroup(_control.Creature.Missions.Patrol.Enabled == false); 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.ButtonCheck("DESC", "descending order", !_control.Creature.Missions.Patrol.Waypoints.Ascending, ICEEditorStyle.CMDButtonDouble); EditorGUI.EndDisabledGroup(); ICEEditorLayout.EndHorizontal(Info.MISSION_PATROL_ORDER_TYPE); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Behaviour", ICEEditorStyle.LabelBold); EditorGUI.indentLevel++; _control.Creature.Missions.Patrol.BehaviourModeTravel = EditorBehaviour.BehaviourSelect(_control, "Travel", "Default travel behaviour to reach the first waypoint", _control.Creature.Missions.Patrol.BehaviourModeTravel, "WP_TRAVEL"); _control.Creature.Missions.Patrol.BehaviourModePatrol = EditorBehaviour.BehaviourSelect(_control, "Patrol", "Default patrol behaviour to reach the next waypoint", _control.Creature.Missions.Patrol.BehaviourModePatrol, "WP_PATROL"); EditorSharedTools.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); /* * EditorGUI.BeginDisabledGroup( m_creature_control.Creature.Missions.Patrol.IsTransitPoint == true ); * m_creature_control.Creature.Missions.Patrol.BehaviourModeLeisure = EditorBehaviour.BehaviourSelect( m_creature_control, "Leisure", "Leisure activities after reaching this waypoint range", m_creature_control.Creature.Missions.Patrol.BehaviourModeLeisure, "WP_LEISURE" ); * m_creature_control.Creature.Missions.Patrol.BehaviourModeRendezvous = EditorBehaviour.BehaviourSelect( m_creature_control, "Rendezvous", "Action behaviour after reaching this current waypoint target position", m_creature_control.Creature.Missions.Patrol.BehaviourModeRendezvous, "WP_RENDEZVOUS" ); * EditorGUI.EndDisabledGroup(); * * m_creature_control.Creature.Missions.Patrol.DurationOfStay = ICEEditorLayout.DurationSlider( "Duration Of Stay", "Duration of stay", m_creature_control.Creature.Missions.Patrol.DurationOfStay, Init.DURATION_OF_STAY_STEP, Init.DURATION_OF_STAY_MIN, Init.DURATION_OF_STAY_MAX,Init.DURATION_OF_STAY_DEFAULT, ref m_creature_control.Creature.Missions.Patrol.IsTransitPoint ); */ EditorGUI.indentLevel--; EditorGUILayout.Separator(); ICEEditorLayout.Label("Waypoints", true, Info.MISSION_PATROL_WAYPOINTS); EditorGUI.indentLevel++; ICEEditorLayout.BeginHorizontal(); _control.Creature.Missions.Patrol.Waypoints.WaypointGroup = (GameObject)EditorGUILayout.ObjectField("Add Waypoint Group", _control.Creature.Missions.Patrol.Waypoints.WaypointGroup, typeof(GameObject), true); if (GUILayout.Button("REFRESH", ICEEditorStyle.ButtonLarge)) { _control.Creature.Missions.Patrol.Waypoints.UpdateWaypointGroup(); } ICEEditorLayout.EndHorizontal(Info.MISSION_PATROL_ADD_WAYPOINT_GROUP); ICEEditorLayout.BeginHorizontal(); ICEEditorLayout.Label("Add Single Waypoint", false); GUILayout.FlexibleSpace(); if (GUILayout.Button("ADD WAYPOINT", ICEEditorStyle.ButtonLarge)) { _control.Creature.Missions.Patrol.Waypoints.Waypoints.Add(new WaypointObject()); } ICEEditorLayout.EndHorizontal(Info.MISSION_PATROL_ADD_WAYPOINT); EditorGUI.indentLevel--; EditorGUILayout.Separator(); for (int i = 0; i < _control.Creature.Missions.Patrol.Waypoints.Waypoints.Count; ++i) { DrawMissionPatrolWaypoint(_control, i); } EditorGUILayout.Separator(); EditorGUI.EndDisabledGroup(); }
/// <summary> /// Handles the system settings. /// </summary> /// <param name="_creature_control">_creature_control.</param> private static void HandleSystemSettings(ICECreatureControl _control) { EditorGUILayout.Separator(); ICEEditorLayout.Label("Motion and Pathfinding", true, Info.ESSENTIALS_SYSTEM); EditorGUI.indentLevel++; ICEEditorLayout.BeginHorizontal(); _control.Creature.Move.GroundCheck = (GroundCheckType)ICEEditorLayout.EnumPopup("Ground Check", "Method to handle ground related checks and movements", _control.Creature.Move.GroundCheck); if (_control.Creature.Move.GroundCheck == GroundCheckType.RAYCAST) { if (GUILayout.Button("Add Layer", ICEEditorStyle.ButtonMiddle)) { _control.Creature.Move.GroundLayers.Add("Default"); } } ICEEditorLayout.EndHorizontal(Info.ESSENTIALS_SYSTEM_GROUND_CHECK); if (_control.Creature.Move.GroundCheck == GroundCheckType.RAYCAST) { EditorGUI.indentLevel++; DrawGroundLayers(_control.Creature.Move.GroundLayers); EditorGUI.indentLevel--; } EditorGUILayout.Separator(); if (_control.Creature.Move.GroundOrientation == GroundOrientationType.NONE || _control.Creature.Move.GroundOrientation == GroundOrientationType.BIPED) { _control.Creature.Move.GroundOrientationPlus = false; } ICEEditorLayout.BeginHorizontal(); _control.Creature.Move.GroundOrientation = (GroundOrientationType)ICEEditorLayout.EnumPopup("Ground Orientation", "Vertical direction relative to the ground", _control.Creature.Move.GroundOrientation); EditorGUI.BeginDisabledGroup(_control.Creature.Move.GroundOrientation == GroundOrientationType.NONE || _control.Creature.Move.GroundOrientation == GroundOrientationType.BIPED); _control.Creature.Move.GroundOrientationPlus = ICEEditorLayout.ButtonCheck("PLUS", "", _control.Creature.Move.GroundOrientationPlus, ICEEditorStyle.CMDButtonDouble); EditorGUI.EndDisabledGroup(); ICEEditorLayout.EndHorizontal(Info.ESSENTIALS_SYSTEM_GROUND_ORIENTATION); EditorGUI.BeginDisabledGroup(_control.Creature.Move.GroundOrientation == GroundOrientationType.NONE); EditorGUI.indentLevel++; if (_control.Creature.Move.GroundOrientationPlus) { _control.Creature.Move.Width = ICEEditorLayout.DefaultSlider("Width", "", _control.Creature.Move.Width, 0.01f, 0, 45, (_control.GetComponentInChildren <Renderer>().bounds.size.x / _control.transform.lossyScale.x)); EditorGUI.indentLevel++; _control.Creature.Move.WidthOffset = ICEEditorLayout.DefaultSlider("x-Offset", "", _control.Creature.Move.WidthOffset, 0.01f, -10, 10, 0); EditorGUI.indentLevel--; _control.Creature.Move.Depth = ICEEditorLayout.DefaultSlider("Depth", "", _control.Creature.Move.Depth, 0.01f, 0, 45, (_control.GetComponentInChildren <Renderer>().bounds.size.z / _control.transform.lossyScale.z)); EditorGUI.indentLevel++; _control.Creature.Move.DepthOffset = ICEEditorLayout.DefaultSlider("z-Offset", "", _control.Creature.Move.DepthOffset, 0.01f, -10, 10, 0); EditorGUI.indentLevel--; } _control.Creature.Move.BaseOffset = ICEEditorLayout.DefaultSlider("Base Offset", "", _control.Creature.Move.BaseOffset, 0.01f, -1, 1, 0, Info.ESSENTIALS_SYSTEM_BASE_OFFSET); _control.Creature.Move.UseLeaningTurn = ICEEditorLayout.Toggle("Use Leaning Turn", "Allows to lean into a turn", _control.Creature.Move.UseLeaningTurn, Info.ESSENTIALS_SYSTEM_LEAN_ANGLE); if (_control.Creature.Move.UseLeaningTurn) { Info.Warning(Info.ESSENTIALS_SYSTEM_LEAN_ANGLE_WARNING); } EditorGUI.indentLevel++; EditorGUI.BeginDisabledGroup(_control.Creature.Move.UseLeaningTurn == false); _control.Creature.Move.LeanAngleMultiplier = ICEEditorLayout.DefaultSlider("Lean Angle Multiplier", "Lean angle multiplier", _control.Creature.Move.LeanAngleMultiplier, 0.05f, 0, 1, 0.5f); _control.Creature.Move.MaxLeanAngle = ICEEditorLayout.DefaultSlider("Max. Lean Angle", "Maximum lean angle", _control.Creature.Move.MaxLeanAngle, 0.25f, 0, 45, 35); EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel--; EditorGUI.indentLevel--; EditorGUI.EndDisabledGroup(); EditorGUILayout.Separator(); _control.Creature.Move.UseInternalGravity = ICEEditorLayout.Toggle("Handle Gravity", "Use internal gravity", _control.Creature.Move.UseInternalGravity, Info.ESSENTIALS_SYSTEM_GRAVITY); EditorGUI.indentLevel++; EditorGUI.BeginDisabledGroup(_control.Creature.Move.UseInternalGravity == false); _control.Creature.Move.Gravity = ICEEditorLayout.AutoSlider("Gravity", "Gravity value (default 9.8)", _control.Creature.Move.Gravity, 0.01f, 0, 100, ref _control.Creature.Move.UseWorldGravity, 9.81f); EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel--; EditorGUILayout.Separator(); _control.Creature.Move.UseDeadlockHandling = ICEEditorLayout.Toggle("Handle Deadlocks", "Use deadlock handling", _control.Creature.Move.UseDeadlockHandling, Info.DEADLOCK); EditorGUI.indentLevel++; EditorGUI.BeginDisabledGroup(_control.Creature.Move.UseDeadlockHandling == false); _control.Creature.Move.DeadlockMinMoveDistance = ICEEditorLayout.DefaultSlider("Test 1 - Move Distance", "Expected distance the creature should have covered until the defined interval", _control.Creature.Move.DeadlockMinMoveDistance, 0.01f, 0, 5, 0.2f, Info.DEADLOCK_MOVE_DISTANCE); EditorGUI.indentLevel++; _control.Creature.Move.DeadlockMoveInterval = ICEEditorLayout.DefaultSlider("Test Interval (sec.)", "Interval until the next test", _control.Creature.Move.DeadlockMoveInterval, 0.25f, 0, 30, 2, Info.DEADLOCK_MOVE_INTERVAL); _control.Creature.Move.DeadlockMoveMaxCriticalPositions = (int)ICEEditorLayout.DefaultSlider("Max. Critical Positions", "Tolerates the defined number of critical positions before deadlocked will flagged as true.", _control.Creature.Move.DeadlockMoveMaxCriticalPositions, 1, 0, 100, 10, Info.DEADLOCK_MOVE_CRITICAL_POSITION); EditorGUI.indentLevel--; _control.Creature.Move.DeadlockLoopRange = ICEEditorLayout.DefaultSlider("Test 2 - Loop Range", "Expected distance the creature should have covered until the defined interval", _control.Creature.Move.DeadlockLoopRange, 0.01f, 0, 25, _control.Creature.Move.MoveStopDistance, Info.DEADLOCK_LOOP_RANGE); EditorGUI.indentLevel++; _control.Creature.Move.DeadlockLoopInterval = ICEEditorLayout.DefaultSlider("Test Interval (sec.)", "Interval until the next test", _control.Creature.Move.DeadlockLoopInterval, 0.25f, 0, 30, 5, Info.DEADLOCK_LOOP_INTERVAL); _control.Creature.Move.DeadlockLoopMaxCriticalPositions = (int)ICEEditorLayout.DefaultSlider("Max. Critical Positions", "Tolerates the defined number of critical positions before deadlocked will flagged as true.", _control.Creature.Move.DeadlockLoopMaxCriticalPositions, 1, 0, 100, 10, Info.DEADLOCK_LOOP_CRITICAL_POSITION); EditorGUI.indentLevel--; _control.Creature.Move.DeadlockAction = (DeadlockActionType)ICEEditorLayout.EnumPopup("Deadlock Action", "", _control.Creature.Move.DeadlockAction, Info.DEADLOCK_ACTION); if (_control.Creature.Move.DeadlockAction == DeadlockActionType.BEHAVIOUR) { EditorGUI.indentLevel++; _control.Creature.Move.DeadlockBehaviour = EditorBehaviour.BehaviourSelect(_control, "Deadlock Behaviour", "", _control.Creature.Move.DeadlockBehaviour, "DEADLOCK", Info.DEADLOCK_ACTION_BEHAVIOUR); EditorGUI.indentLevel--; } EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel--; EditorGUILayout.Separator(); EditorGUILayout.Separator(); _control.Creature.Move.FieldOfView = ICEEditorLayout.DefaultSlider("Field Of View", "Field Of View", _control.Creature.Move.FieldOfView * 2, 0.05f, 0, 360, 60, Info.FOV) / 2; EditorGUI.BeginDisabledGroup(_control.Creature.Move.FieldOfView == 0); EditorGUI.indentLevel++; _control.Creature.Move.VisualRange = ICEEditorLayout.DefaultSlider("Visual Range", "Max. Sighting Distance", _control.Creature.Move.VisualRange, 0.25f, 0, 500, 100, Info.FOV_VISUAL_RANGE); EditorGUI.indentLevel--; EditorGUI.EndDisabledGroup(); /* * Info.Help ( Info.ESSENTIALS_SYSTEM_GRADIENT_ANGLE ); * _creature_control.Creature.Move.MaxGradientAngle = ICEEditorLayout.DefaultSlider("Max. Gradient Angle", "Maximum gradient angle for walkable surfaces", _creature_control.Creature.Move.MaxGradientAngle, 1, 0, 90, 45 ); * */ EditorGUILayout.Separator(); EditorGUILayout.LabelField("Default Move"); EditorGUI.indentLevel++; EditorSharedTools.DrawMove(ref _control.Creature.Move.DefaultMove.MoveSegmentLength, ref _control.Creature.Move.DefaultMove.MoveStopDistance, ref _control.Creature.Move.DefaultMove.MoveSegmentVariance, ref _control.Creature.Move.DefaultMove.MoveLateralVariance, ref _control.Creature.Move.DefaultMove.MoveIgnoreLevelDifference, Info.MOVE_DEFAULT); EditorGUI.indentLevel--; EditorGUI.indentLevel--; EditorGUILayout.Separator(); ICEEditorLayout.Label("Additional Components", true, Info.EXTERNAL_COMPONENTS); EditorGUI.indentLevel++; if (_control.GetComponent <NavMeshAgent>() == null) { _control.Creature.Move.UseNavMesh = false; } _control.Creature.Move.UseNavMesh = ICEEditorLayout.Toggle("Use NavMeshAgent", "", _control.Creature.Move.UseNavMesh, Info.EXTERNAL_COMPONENTS_NAVMESHAGENT); if (_control.Creature.Move.UseNavMesh && _control.GetComponent <NavMeshAgent>() == null) { _control.gameObject.AddComponent <NavMeshAgent>(); } ICEEditorLayout.BeginHorizontal(); if (_control.GetComponent <Rigidbody>() == null) { _control.Creature.Move.UseRigidbody = false; } _control.Creature.Move.UseRigidbody = ICEEditorLayout.Toggle("Use Rigidbody", "", _control.Creature.Move.UseRigidbody); if (_control.Creature.Move.UseRigidbody && _control.GetComponent <Rigidbody>() == null) { _control.gameObject.AddComponent <Rigidbody>(); } GUILayout.FlexibleSpace(); if (_control.GetComponent <Rigidbody>() != null) { if (GUILayout.Button("FULL", ICEEditorStyle.ButtonMiddle)) { Rigidbody _rigidbody = _control.GetComponent <Rigidbody>(); _rigidbody.useGravity = true; _rigidbody.isKinematic = false; _rigidbody.angularDrag = 0; _rigidbody.constraints = RigidbodyConstraints.FreezeRotation; } if (GUILayout.Button("SEMI", ICEEditorStyle.ButtonMiddle)) { Rigidbody _rigidbody = _control.GetComponent <Rigidbody>(); _rigidbody.useGravity = false; _rigidbody.isKinematic = true; _rigidbody.angularDrag = 0.05f; _rigidbody.constraints = RigidbodyConstraints.FreezeRotation; } if (GUILayout.Button("OFF", ICEEditorStyle.ButtonMiddle)) { Rigidbody _rigidbody = _control.GetComponent <Rigidbody>(); _rigidbody.useGravity = false; _rigidbody.isKinematic = true; _rigidbody.angularDrag = 0; _rigidbody.constraints = RigidbodyConstraints.FreezeAll; } } ICEEditorLayout.EndHorizontal(Info.EXTERNAL_COMPONENTS_RIGIDBODY); EditorGUI.BeginDisabledGroup(false == false); if (_control.GetComponent <CharacterController>() == null) { _control.Creature.Move.UseCharacterController = false; } _control.Creature.Move.UseCharacterController = EditorGUILayout.Toggle("Use Character Controller", _control.Creature.Move.UseCharacterController); if (_control.Creature.Move.UseCharacterController && _control.GetComponent <CharacterController>() == null) { _control.gameObject.AddComponent <CharacterController>(); } EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel--; EditorGUILayout.Separator(); EditorGUILayout.LabelField("Runtime Behaviour", ICEEditorStyle.LabelBold); EditorGUI.indentLevel++; _control.Creature.UseCoroutine = ICEEditorLayout.Toggle("Use Coroutine", "", _control.Creature.UseCoroutine, Info.RUNTIME_COROUTINE); _control.Creature.DontDestroyOnLoad = ICEEditorLayout.Toggle("Dont Destroy On Load", "", _control.Creature.DontDestroyOnLoad, Info.RUNTIME_DONTDESTROYONLOAD); EditorGUI.indentLevel--; EditorGUILayout.Separator(); }
private static void DrawEnvironmentSurfaceSettings(ICECreatureControl _control) { ICEEditorLayout.BeginHorizontal(); _control.Creature.Environment.SurfaceHandler.Enabled = ICEEditorLayout.ToggleLeft("Surfaces", "", _control.Creature.Environment.SurfaceHandler.Enabled, true); if (GUILayout.Button(new GUIContent("ADD", "add a new surface rule"), ICEEditorStyle.ButtonMiddle)) { _control.Creature.Environment.SurfaceHandler.Surfaces.Add(new SurfaceDataObject()); } if (GUILayout.Button(new GUIContent("RESET", "removes all surface rules"), ICEEditorStyle.ButtonMiddle)) { _control.Creature.Environment.SurfaceHandler.Surfaces.Clear(); } ICEEditorLayout.EndHorizontal(Info.ENVIROMENT_SURFACE); if (_control.Creature.Environment.SurfaceHandler.Surfaces.Count == 0) { _control.Creature.Environment.SurfaceHandler.Enabled = false; } EditorGUI.BeginDisabledGroup(_control.Creature.Environment.SurfaceHandler.Enabled == false); EditorGUI.indentLevel++; for (int i = 0; i < _control.Creature.Environment.SurfaceHandler.Surfaces.Count; ++i) { // HEADER BEGIN SurfaceDataObject _surface = _control.Creature.Environment.SurfaceHandler.Surfaces[i]; if (_surface.Name == "") { _surface.Name = "Surface Rule #" + (i + 1); } ICEEditorLayout.BeginHorizontal(); _surface.Foldout = ICEEditorLayout.Foldout(_surface.Foldout, _surface.Name); _surface.Enabled = ICEEditorLayout.ButtonCheck("ACTIVE", "activates/deactivates the rule", _surface.Enabled, ICEEditorStyle.ButtonMiddle); if (GUILayout.Button(new GUIContent("REMOVE", "removes the selected surface rule"), ICEEditorStyle.ButtonMiddle)) { _control.Creature.Environment.SurfaceHandler.Surfaces.RemoveAt(i); --i; } ICEEditorLayout.EndHorizontal(Info.ENVIROMENT_SURFACE_RULE); // HEADER END // CONTENT if (_surface.Foldout) { EditorGUI.BeginDisabledGroup(_surface.Enabled == false); ICEEditorLayout.BeginHorizontal(); _surface.Name = ICEEditorLayout.Text("Name", "", _surface.Name); if (GUILayout.Button(new GUIContent("CLR", ""), ICEEditorStyle.CMDButtonDouble)) { _surface.Name = ""; } ICEEditorLayout.EndHorizontal(Info.ENVIROMENT_SURFACE_RULE_NAME); _surface.Interval = ICEEditorLayout.DefaultSlider("Interval", "", _surface.Interval, 0.25f, 0, 30, 1, Info.ENVIROMENT_SURFACE_RULE_INTERVAL); //ICEEditorStyle.SplitterByIndent( EditorGUI.indentLevel + 1 ); DrawEnvironmentTextures(_surface); ICEEditorLayout.Label("Procedures", true, Info.ENVIROMENT_SURFACE_RULE_PROCEDURES); EditorGUI.indentLevel++; EditorGUI.BeginDisabledGroup(_surface.Textures.Count == 0); _surface.Audio = EditorSharedTools.DrawSharedAudio(_surface.Audio, Info.ENVIROMENT_SURFACE_AUDIO); _surface.Effect = EditorSharedTools.DrawSharedEffect(_surface.Effect, Info.ENVIROMENT_SURFACE_EFFECT); _surface.Influences = EditorSharedTools.DrawSharedInfluences(_surface.Influences, Info.ENVIROMENT_SURFACE_INFLUENCES); EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel--; EditorGUILayout.Separator(); EditorGUI.EndDisabledGroup(); ICEEditorStyle.SplitterByIndent(EditorGUI.indentLevel + 1); } } EditorGUI.indentLevel--; EditorGUI.EndDisabledGroup(); }
private static void DrawEnvironmentCollisionSettings(ICECreatureControl _control) { // IMPACT HEADER BEGIN ICEEditorLayout.BeginHorizontal(); _control.Creature.Environment.CollisionHandler.Enabled = ICEEditorLayout.ToggleLeft("Collisions", "", _control.Creature.Environment.CollisionHandler.Enabled, true); if (GUILayout.Button(new GUIContent("ADD", "add a new impact rule"), ICEEditorStyle.ButtonMiddle)) { _control.Creature.Environment.CollisionHandler.Collisions.Add(new CollisionDataObject()); _control.Creature.Environment.CollisionHandler.Enabled = true; } if (GUILayout.Button(new GUIContent("RESET", "removes all impact rules"), ICEEditorStyle.ButtonMiddle)) { _control.Creature.Environment.CollisionHandler.Collisions.Clear(); } ICEEditorLayout.EndHorizontal(Info.ENVIROMENT_COLLISION); // IMPACT HEADER END if (_control.Creature.Environment.CollisionHandler.Collisions.Count == 0) { _control.Creature.Environment.CollisionHandler.Enabled = false; } // IMPACT CONTENT BEGIN EditorGUI.BeginDisabledGroup(_control.Creature.Environment.CollisionHandler.Enabled == false); EditorGUI.indentLevel++; for (int i = 0; i < _control.Creature.Environment.CollisionHandler.Collisions.Count; i++) { CollisionDataObject _collision = _control.Creature.Environment.CollisionHandler.Collisions[i]; if (_collision != null) { string _title = _collision.Name; if (_title == "") { _title = "Collision Rule #" + (i + 1); if (_collision.TagPriority > 0) { if (_title != "") { _title += " "; } _title += "T:" + _collision.Tag; } if (_collision.LayerPriority > 0) { if (_title != "") { _title += " "; } _title += "L:" + LayerMask.LayerToName(_collision.Layer); } _collision.Name = _title; } // IMPACT RULE HEADER BEGIN ICEEditorLayout.BeginHorizontal(); _collision.Foldout = ICEEditorLayout.Foldout(_collision.Foldout, _collision.Name); _collision.Enabled = ICEEditorLayout.ButtonCheck("ACTIVE", "activates/deactivates the selected collision rule", _collision.Enabled, ICEEditorStyle.ButtonMiddle); if (GUILayout.Button(new GUIContent("REMOVE", "removes the selected collision rule"), ICEEditorStyle.ButtonMiddle)) { _control.Creature.Environment.CollisionHandler.Collisions.Remove(_collision); return; } ICEEditorLayout.EndHorizontal(Info.ENVIROMENT_COLLISION_RULE); // IMPACT RULE HEADER END // IMPACT RULE CONTENT BEGIN if (_collision.Foldout) { EditorGUI.BeginDisabledGroup(_collision.Enabled == false); ICEEditorLayout.BeginHorizontal(); _collision.Name = ICEEditorLayout.Text("Name", "", _collision.Name); if (GUILayout.Button(new GUIContent("CLR", ""), ICEEditorStyle.CMDButtonDouble)) { _collision.Name = ""; } ICEEditorLayout.EndHorizontal(Info.ENVIROMENT_COLLISION_RULE_NAME); EditorGUILayout.Separator(); ICEEditorLayout.Label("Conditions", true, Info.ENVIROMENT_COLLISION_RULE_CONDITIONS); EditorGUI.indentLevel++; _collision.Type = (CollisionConditionType)ICEEditorLayout.EnumPopup("Type", "Collision ", _collision.Type, Info.ENVIROMENT_COLLISION_RULE_TYPE); if (_collision.Type == CollisionConditionType.LAYER) { _collision.TagPriority = 0; } else if (_collision.Type == CollisionConditionType.LAYER) { _collision.LayerPriority = 0; } if (_collision.Type == CollisionConditionType.LAYER || _collision.Type == CollisionConditionType.TAG_AND_LAYER) { _collision.Layer = ICEEditorLayout.Layer("Layer", "Desired collision layer", _collision.Layer, Info.ENVIROMENT_COLLISION_RULE_LAYER); EditorGUI.indentLevel++; _collision.LayerPriority = (int)ICEEditorLayout.DefaultSlider("Priority", "", _collision.LayerPriority, 1, 0, 10, 1, Info.ENVIROMENT_COLLISION_RULE_LAYER_PRIORITY); EditorGUI.indentLevel--; } if (_collision.Type == CollisionConditionType.TAG || _collision.Type == CollisionConditionType.TAG_AND_LAYER) { _collision.Tag = ICEEditorLayout.Tag("Tag", "Desired collision tag", _collision.Tag, Info.ENVIROMENT_COLLISION_RULE_TAG); EditorGUI.indentLevel++; _collision.TagPriority = (int)ICEEditorLayout.DefaultSlider("Priority", "", _collision.TagPriority, 1, 0, 10, 1, Info.ENVIROMENT_COLLISION_RULE_TAG_PRIORITY); EditorGUI.indentLevel--; } EditorGUI.indentLevel--; EditorGUILayout.Separator(); ICEEditorLayout.Label("Procedures", true, Info.ENVIROMENT_COLLISION_RULE_PROCEDURES); EditorGUI.indentLevel++; //_impact.ForceInteraction = EditorGUILayout.Toggle("Force Interaction", _impact.ForceInteraction ); _collision.Influences.Enabled = EditorGUILayout.Toggle("Influences", _collision.Influences.Enabled); _collision.Influences = EditorSharedTools.DrawShareInfluencesContent(_collision.Influences, Info.ENVIROMENT_COLLISION_INFLUENCES); _collision.BehaviourModeKey = EditorBehaviour.BehaviourSelect(_control, "Behaviour", "Reaction to this impact", _collision.BehaviourModeKey, "IMPACT_" + _collision.Tag.ToUpper()); EditorGUI.indentLevel--; EditorGUILayout.Separator(); EditorGUI.EndDisabledGroup(); ICEEditorStyle.SplitterByIndent(EditorGUI.indentLevel + 1); } // IMPACT RULE CONTENT END } } EditorGUILayout.Separator(); EditorGUI.indentLevel--; EditorGUI.EndDisabledGroup(); }
private static void DrawInteractor(ICECreatureControl _control, InteractionObject _interaction_object, int _index) { ICEEditorStyle.SplitterByIndent(EditorGUI.indentLevel); InteractorObject _interactor_object = _interaction_object.Interactors[_index]; ICEEditorLayout.BeginHorizontal(); _interactor_object.Foldout = EditorGUILayout.Foldout(_interactor_object.Foldout, "Interactor '" + _interactor_object.Name + "' (" + _interactor_object.Rules.Count + " Rules) ", ICEEditorStyle.Foldout); if (GUILayout.Button(new GUIContent("SAVE", "Saves selected interactor to file"), ICEEditorStyle.ButtonMiddle)) { CreatureIO.SaveInteractorToFile(_interactor_object, _interactor_object.Name); } if (GUILayout.Button(new GUIContent("LOAD", "Replaces selected interactor settings"), ICEEditorStyle.ButtonMiddle)) { _control.Creature.Interaction.Interactors.Insert(_index, CreatureIO.LoadInteractorFromFile(new InteractorObject())); _interaction_object.Interactors.Remove(_interactor_object); return; } if (GUILayout.Button(new GUIContent("REMOVE", "Removes selected interactor"), ICEEditorStyle.ButtonMiddle)) { _interaction_object.Interactors.RemoveAt(_index); --_index; return; } ICEEditorLayout.EndHorizontal(Info.INTERACTION_INTERACTOR); if (!_interactor_object.Foldout) { return; } EditorGUILayout.Separator(); _interactor_object.Enabled = ICEEditorLayout.ToggleLeft("Enabled", "", _interactor_object.Enabled, false, Info.INTERACTION_INTERACTOR_ENABLED); EditorGUI.BeginDisabledGroup(_interactor_object.Enabled == false); EditorGUILayout.Separator(); EditorSharedTools.DrawTargetSelectors(_control, _interactor_object.Selectors, TargetType.INTERACTOR, Init.SELECTION_RANGE_MIN, Init.SELECTION_RANGE_MAX); if (_interactor_object.Selectors.SelectionRange == 0) { EditorGUI.indentLevel++; Info.Note("Selection Range adjusted to zero - no regional selection restriction!"); EditorGUI.indentLevel--; } _interactor_object = DrawInteractorOffset(_control, _interactor_object); _interactor_object.BehaviourModeKey = EditorBehaviour.BehaviourSelect(_control, "Behaviour", "Behaviour while sensing this interactor", _interactor_object.BehaviourModeKey, "SENSE"); EditorGUILayout.Separator(); ICEEditorLayout.Label("Additional Rules for meeting '" + _interactor_object.Name + "' creatures.", true); if (_interactor_object.Rules.Count == 0) { Info.Note(Info.INTERACTION_INTERACTOR_NO_RULES); } else { EditorGUILayout.Separator(); for (int _behaviour_index = 0; _behaviour_index < _interactor_object.Rules.Count; _behaviour_index++) { DrawInteractorRule(_control, _interactor_object, _behaviour_index); } } ICEEditorStyle.SplitterByIndent(EditorGUI.indentLevel + 1); ICEEditorLayout.BeginHorizontal(); EditorGUILayout.LabelField("Add Interaction Rule for '" + _interactor_object.Name + "'", EditorStyles.boldLabel); if (GUILayout.Button("ADD", ICEEditorStyle.ButtonMiddle)) { _interactor_object.Rules.Add(new InteractorRuleObject("")); } ICEEditorLayout.EndHorizontal(); EditorGUILayout.Separator(); EditorGUI.EndDisabledGroup(); }
private static void DrawInteractorRule(ICECreatureControl _control, InteractorObject _interactor, int _index) { InteractorRuleObject _rule = _interactor.Rules[_index]; InteractorRuleObject _prev_rule = null; InteractorRuleObject _next_rule = null; float _rule_max_distance = Init.DEFAULT_MAX_DISTANCE; float _rule_min_distance = 0; if (_interactor.Selectors.SelectionRange >= _rule.Selectors.SelectionRange + Init.SELECTION_RANGE_STEP) { _rule_max_distance = _interactor.Selectors.SelectionRange - Init.SELECTION_RANGE_STEP; } int _prev_index = _index - 1; int _next_index = _index + 1; if (_prev_index >= 0) { _prev_rule = _interactor.Rules[_prev_index]; _rule_max_distance = _prev_rule.Selectors.SelectionRange - Init.SELECTION_RANGE_STEP; } if (_next_index < _interactor.Rules.Count) { _next_rule = _interactor.Rules[_next_index]; _rule_min_distance = _next_rule.Selectors.SelectionRange + Init.SELECTION_RANGE_STEP; } ICEEditorLayout.BeginHorizontal(); _rule.Enabled = ICEEditorLayout.ToggleLeft(" RULE #" + _index + " - " + (_rule.BehaviourModeKey.Trim() != ""?_rule.BehaviourModeKey:"UNDEFINED"), "", _rule.Enabled, true); if (_interactor.Rules.Count > 1) { EditorGUI.BeginDisabledGroup(_index <= 0); if (ICEEditorLayout.ButtonUp()) { InteractorRuleObject _obj = _interactor.Rules[_index]; _interactor.Rules.RemoveAt(_index); float _obj_selection_range = _obj.Selectors.SelectionRange; if (_index - 1 < 0) { _interactor.Rules.Add(_obj); } else { _interactor.Rules.Insert(_index - 1, _obj); } if (_prev_rule != null) { _obj.Selectors.SelectionRange = _prev_rule.Selectors.SelectionRange; _prev_rule.Selectors.SelectionRange = _obj_selection_range; } return; } EditorGUI.EndDisabledGroup(); EditorGUI.BeginDisabledGroup(_index >= _interactor.Rules.Count - 1); if (ICEEditorLayout.ButtonDown()) { InteractorRuleObject _obj = _interactor.Rules[_index]; _interactor.Rules.RemoveAt(_index); float _obj_selection_range = _obj.Selectors.SelectionRange; if (_index + 1 > _interactor.Rules.Count) { _interactor.Rules.Insert(0, _obj); } else { _interactor.Rules.Insert(_index + 1, _obj); } if (_next_rule != null) { _obj.Selectors.SelectionRange = _next_rule.Selectors.SelectionRange; _next_rule.Selectors.SelectionRange = _obj_selection_range; } return; } EditorGUI.EndDisabledGroup(); } if (GUILayout.Button("X", ICEEditorStyle.CMDButtonDouble)) { _interactor.Rules.RemoveAt(_index); --_index; } ICEEditorLayout.EndHorizontal(Info.INTERACTION_INTERACTOR_RULE); EditorGUI.BeginDisabledGroup(_rule.Enabled == false); EditorGUI.indentLevel++; _rule.Selectors.CanUseDefaultPriority = true; _rule.Selectors.DefaultPriority = _interactor.Selectors.Priority; EditorSharedTools.DrawTargetSelectors(_control, _rule.Selectors, TargetType.INTERACTOR, _rule_min_distance, _rule_max_distance); EditorGUILayout.Separator(); // TARGET MOVE POSITION _rule.OverrideTargetMovePosition = ICEEditorLayout.ToggleLeft("Override Target Move Specifications", "Overriding the Target Move Specifications", _rule.OverrideTargetMovePosition, false); if (_rule.OverrideTargetMovePosition) { _rule = DrawInteractorRuleOffset(_control, _interactor, _rule); EditorGUI.indentLevel++; EditorGUILayout.Separator(); _rule.BlockRuleUpdateUntilMovePositionReached = ICEEditorLayout.Toggle("Block Next Rule", "Blocking the next rule until the target move position was reached", _rule.BlockRuleUpdateUntilMovePositionReached, Info.INTERACTION_INTERACTOR_RULE_BLOCK); if (_rule.BlockRuleUpdateUntilMovePositionReached) { string _text = "This rule will be active until your creature reached the given move-position, so please make sure, that all potential positions " + "reachable for your creature, otherwise you will provoke a deadlock!"; if (_rule.Selectors.SelectionRange == 0) { _text += "\n\nThe SelectionRange of this rule is adjusted to zero "; } Info.Note(_text); } EditorGUI.indentLevel--; } EditorGUILayout.Separator(); // BEHAVIOUR string _auto_key = _interactor.Name + "_action_" + _index; _rule.BehaviourModeKey = EditorBehaviour.BehaviourSelect(_control, "Behaviour", "Action behaviour for this interaction rule", _rule.BehaviourModeKey, _auto_key); EditorGUILayout.Separator(); EditorGUI.indentLevel--; EditorGUI.EndDisabledGroup(); }
private static InteractorRuleObject DrawInteractorRuleOffset(ICECreatureControl _control, InteractorObject _interactor, InteractorRuleObject _rule) { EditorGUI.indentLevel++; TargetObject _target = new TargetObject(TargetType.INTERACTOR); _target.TargetGameObject = m_creature_register.GetReferenceCreatureByName(_interactor.Name); ICEEditorLayout.BeginHorizontal(); string _title = "Target Object"; if (PrefabUtility.GetPrefabParent(_target.TargetGameObject) == null && PrefabUtility.GetPrefabObject(_target.TargetGameObject) != null) // Is a prefab { _title += " (prefab)"; } else if (_target.TargetGameObject != null) { _title += " (scene)"; } else { _title += " (null)"; } EditorGUILayout.LabelField(_title, _interactor.Name); if (_target.TargetGameObject != null) { if (GUILayout.Button("SHOW", ICEEditorStyle.ButtonMiddle)) { var view = SceneView.currentDrawingSceneView; if (view != null) { Vector3 _pos = _target.TargetGameObject.transform.position; _pos.y += 20; view.rotation = new Quaternion(1, 0, 0, 1); view.LookAt(_pos); // view.AlignViewToObject(_target.TargetGameObject.transform); } } if (GUILayout.Button("SELECT", ICEEditorStyle.ButtonMiddle)) { Selection.activeGameObject = _target.TargetGameObject; } } ICEEditorLayout.EndHorizontal(); _target.UpdateOffset(_rule.Offset); _target.TargetStopDistance = _rule.StopDistance; _target.TargetRandomRange = _rule.RandomRange; _target.TargetIgnoreLevelDifference = _rule.IgnoreLevelDifference; _target.UseUpdateOffsetOnActivateTarget = _rule.UpdateOffsetOnActivateTarget; _target.UseUpdateOffsetOnMovePositionReached = _rule.UpdateOffsetOnMovePositionReached; _target.TargetSmoothingMultiplier = _rule.SmoothingMultiplier; _target = EditorSharedTools.DrawTargetOffset(_control, _target); _rule.Offset = _target.TargetOffset; _rule.StopDistance = _target.TargetStopDistance; _rule.RandomRange = _target.TargetRandomRange; _rule.UpdateOffsetOnActivateTarget = _target.UseUpdateOffsetOnActivateTarget; _rule.UpdateOffsetOnMovePositionReached = _target.UseUpdateOffsetOnMovePositionReached; _rule.SmoothingMultiplier = _target.TargetSmoothingMultiplier; _rule.IgnoreLevelDifference = _target.TargetIgnoreLevelDifference; _target.TargetGameObject = null; _target = null; EditorGUI.indentLevel--; return(_rule); }