public bool ComparePrecursorTarget(TargetObject _precursor)
        {
            if (_precursor == null || _precursor.TargetGameObject == null)
            {
                return(false);
            }

            bool _result = false;

            // using EQUAL to get true if one of the conditions are correct
            if (PrecursorType == TargetPrecursorType.TYPE && PrecursorTargetType == _precursor.Type)
            {
                _result = true;
            }
            else if (PrecursorType == TargetPrecursorType.NAME && PrecursorTargetName == _precursor.TargetGameObject.name)
            {
                _result = true;
            }
            else if (PrecursorType == TargetPrecursorType.TAG && _precursor.TargetGameObject.CompareTag(PrecursorTargetTag))
            {
                _result = true;
            }

            // if the desired operator is NOT we have to invert the result of the EQUAL check
            if (Operator == LogicalOperatorType.NOT)
            {
                _result = !_result;
            }

            return(_result);
        }
Esempio n. 2
0
        private void DrawTargetGizmos(TargetObject _target)
        {
            Color _target_color    = (_target.Active?ActiveTargetColor:TargetColor);
            Color _selection_color = (_target.Active?ActiveTargetColor:InteractionColor);

            DrawTargetGizmos(_target, _target_color, _selection_color);
        }
Esempio n. 3
0
        public TargetObject FindTargetByName(string _name)
        {
            if (_name == "")
            {
                return(null);
            }

            TargetObject _target = null;

            if (_target == null && Essentials.TargetReady() && Essentials.Target.TargetGameObject.name == _name)
            {
                _target = Essentials.Target;
            }
            if (_target == null && Missions.Outpost.Enabled && Missions.Outpost.TargetReady() && Missions.Outpost.Target.TargetGameObject.name == _name)
            {
                _target = Missions.Outpost.Target;
            }
            if (_target == null && Missions.Escort.Enabled && Missions.Escort.TargetReady() && Missions.Escort.Target.TargetGameObject.name == _name)
            {
                _target = Missions.Escort.Target;
            }
            if (_target == null && Missions.Patrol.Enabled)
            {
                _target = Missions.Patrol.Waypoints.GetWaypointByName(_name);
            }

            /*if( _target == null )
             *      _target = Interaction.GetInteractorByName( _name );*/

            return(_target);
        }
Esempio n. 4
0
        /// <summary>
        /// Draws the escort.
        /// </summary>
        public void DrawEscort()
        {
            if (!CreatureControl.Creature.Missions.Escort.TargetReady() || ShowEscort == false)
            {
                return;
            }

            TargetObject _target = CreatureControl.Creature.Missions.Escort.Target;

            DrawTargetGizmos(_target);

            if (!Application.isPlaying)
            {
                BehaviourModeObject _mode = null;
                _mode = CreatureControl.Creature.Behaviour.GetBehaviourModeByKey(CreatureControl.Creature.Missions.Escort.BehaviourModeFollow);
                DrawBehaviourModeGizmos(_target, _mode);

                _mode = CreatureControl.Creature.Behaviour.GetBehaviourModeByKey(CreatureControl.Creature.Missions.Escort.BehaviourModeEscort);
                DrawBehaviourModeGizmos(_target, _mode);

                _mode = CreatureControl.Creature.Behaviour.GetBehaviourModeByKey(CreatureControl.Creature.Missions.Escort.BehaviourModeIdle);
                DrawBehaviourModeGizmos(_target, _mode);

                _mode = CreatureControl.Creature.Behaviour.GetBehaviourModeByKey(CreatureControl.Creature.Missions.Escort.BehaviourModeStandby);
                DrawBehaviourModeGizmos(_target, _mode);
            }
        }
Esempio n. 5
0
        public void AddAvailableTarget(TargetObject _target)
        {
            if (_target == null || !_target.IsValidAndReady)
            {
                return;
            }

            _target.Selectors.ResetStatus();
            AvailableTargets.Add(_target);
        }
Esempio n. 6
0
        private bool IsTargetUpdatePermitted(TargetObject _target)
        {
            if (_target == null)
            {
                return(false);
            }

            if (m_ActiveTarget == null || Behaviour.BehaviourMode == null || Behaviour.BehaviourMode.Favoured.Enabled == false)
            {
                return(true);
            }

            bool _permitted = true;

            if ((Behaviour.BehaviourMode.Favoured.Enabled == true) && (
                    (Behaviour.BehaviourMode.Favoured.FavouredMinimumPeriod > 0 && Behaviour.BehaviourTimer < Behaviour.BehaviourMode.Favoured.FavouredMinimumPeriod) ||
                    (Behaviour.BehaviourMode.Favoured.FavouredUntilNextMovePositionReached && !Move.MovePositionReached()) ||
                    (Behaviour.BehaviourMode.Favoured.FavouredUntilTargetMovePositionReached && !m_ActiveTarget.TargetMoveComplete) ||
                    (Behaviour.BehaviourMode.Favoured.FavouredUntilNewTargetInRange(_target, Vector3.Distance(_target.TargetGameObject.transform.position, m_Owner.transform.position))) ||
                    (Behaviour.BehaviourMode.HasActiveDetourRule && Behaviour.BehaviourMode.Favoured.FavouredUntilDetourPositionReached && !Move.DetourComplete)))
            {
                _permitted = false;
            }
            else
            {
                _permitted = true;
            }

            //mode check - the new mode could be also forced, so we have to check this here
            if (_permitted == false)
            {
                BehaviourModeObject _mode = Behaviour.GetBehaviourModeByKey(_target.BehaviourModeKey);

                if (_mode != null && _mode.Favoured.Enabled == true)
                {
                    if (Behaviour.BehaviourMode.Favoured.FavouredPriority > _mode.Favoured.FavouredPriority)
                    {
                        _permitted = false;
                    }
                    else if (Behaviour.BehaviourMode.Favoured.FavouredPriority < _mode.Favoured.FavouredPriority)
                    {
                        _permitted = true;
                    }
                    else
                    {
                        _permitted = (Random.Range(0, 1) == 0?false:true);
                    }
                }
            }


            return(_permitted);
        }
Esempio n. 7
0
        private Vector3 DrawBehaviourModeGizmos(TargetObject _target, BehaviourModeObject _mode)
        {
            if (_target == null || _target.IsValid == false || _mode == null)
            {
                return(Vector3.zero);
            }

            foreach (BehaviourModeRuleObject _rule in _mode.Rules)
            {
                DrawBehaviourModeRuleGizmos(_target, _rule);
            }

            return(Vector3.zero);
        }
Esempio n. 8
0
        public SpawnPointObject(TargetObject _target)
        {
            Enabled = true;
            Foldout = true;

            AccessType           = _target.AccessType;
            SpawnPointGameObject = _target.TargetGameObject;

            if (_target.Move.HasRandomRange)
            {
                SpawningRangeMin     = _target.Move.StoppingDistance;
                SpawningRangeMax     = _target.Move.RandomRange;
                SpawningRangeMaximum = _target.Move.RandomRangeMaximum;
            }
        }
Esempio n. 9
0
        public bool FavouredUntilNewTargetInRange(TargetObject _target, float _distance)
        {
            if (_target == null || _target.TargetGameObject == null || FavouredTarget == false || FavouredTargetRange <= 0)
            {
                return(false);
            }

            if (_distance <= FavouredTargetRange && (string.IsNullOrEmpty(FavouredTargetName) || _target.TargetGameObject.name == FavouredTargetName))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
 public float CompareSuccessorTargets(TargetObject _target, Vector3 _position)
 {
     /*
      * if( _target == null || _target.TargetGameObject == null || UseAdvanced == false )
      *      return 0;
      *
      * float _relevance_multiplier = 0;
      *
      * foreach( TargetSelectorObject _group in m_SelectorGroups )
      * {
      *      foreach( TargetSelectorConditionObject _selector in _group.Conditions )
      *      {
      *              if( _selector.Enabled == true && _selector.ExpressionType == TargetSelectorExpressionType.SUCCESSOR )
      *              {
      *                      bool _valid = false;
      *
      *                      if( ( _selector.SuccessorType == TargetSuccessorType.NAME && _target.TargetGameObject.name == _selector.SuccessorTargetName ) ||
      *                              ( _selector.SuccessorType == TargetSuccessorType.TAG && _target.TargetGameObject.CompareTag( _selector.SuccessorTargetName ) ) ||
      *                              ( _selector.SuccessorType == TargetSuccessorType.TYPE && _target.Type == _selector.SuccessorTargetType ) )
      *                      {
      *                              if(  _selector.UseRange )
      *                                      _valid = _target.TargetInSelectionRange( _position, _selector.Distance );
      *                              else
      *                                      _valid = true;
      *                      }
      *
      *                      if( _valid == _selector.Included )
      *                              _valid = true;
      *                      else
      *                              _valid = false;
      *
      *                      if( _valid )
      *                      {
      *                              if( _selector.UseMultiplier )
      *                                      _relevance_multiplier += _selector.RelevanceMultiplier;
      *                              else
      *                                      _relevance_multiplier += 1;
      *                      }
      *              }
      *      }
      * }
      * _target.Selectors.UpdateRelevance( _relevance_multiplier );
      *
      * return _relevance_multiplier;*/
     return(0);
 }
        public bool PrepareRuleTarget(ICEWorldBehaviour _component, TargetObject _target)
        {
            if (!Enabled || !OwnerIsReady(_component))
            {
                return(false);
            }

            // By default an additional interactor rule have the same TargetGameObject as the initial rule but while
            // Selectors.Preselection.Enabled is true the rule will select its own best target of the same type according
            // to the specifier pre-selection criteria
            if (Selectors.Preselection.Enabled)
            {
                if (PrepareTargetGameObject(_component) == null || !IsValidAndReady)
                {
                    return(false);
                }
            }
            else
            {
                if (_target == null || _target.IsValidAndReady == false)
                {
                    return(false);
                }

                OverrideTargetGameObject(_target.TargetGameObject);
            }

            if (OverrideInfluences == false)
            {
                Influences.Copy(_target.Influences);
            }

            //if( Selectors.UseDefaultPriority )
            //	Selectors.Priority = _target.Selectors.Priority;

            if (OverrideTargetMovePosition == false)
            {
                Move.Copy(_target.Move);
            }

            Behaviour.CurrentBehaviourModeKey = GetBestBehaviourModeKey(Owner);

            return(true);
        }
Esempio n. 12
0
        public void ResetActiveTarget()
        {
            // handle previous target
            m_PreviousTarget           = m_ActiveTarget;
            m_PreviousTargetGameObject = m_ActiveTargetGameObject;
            m_PreviousTargetID         = m_ActiveTargetID;
            m_PreviousTargetName       = m_ActiveTargetName;
            m_PreviousTargetKey        = m_ActiveTargetName + m_ActiveTargetID.ToString();

            if (m_PreviousTarget != null)
            {
                m_PreviousTarget.SetActive(false);

                if (m_PreviousTarget.EntityComponent != null)
                {
                    m_PreviousTarget.EntityComponent.RemoveActiveCounterpart(OwnerComponent as ICECreatureEntity);
                }

                if (m_PreviousTarget.GroupMessage.Type != BroadcastMessageType.NONE)
                {
                    BroadcastMessageDataObject _data = new BroadcastMessageDataObject();
                    _data.Type             = m_PreviousTarget.GroupMessage.Type;
                    _data.TargetGameObject = m_PreviousTargetGameObject;
                    _data.Command          = "";

                    ICECreatureEntity _entity = OwnerComponent as ICECreatureEntity;
                    if (_entity != null)
                    {
                        _entity.Message.SendGroupMessage(_data);
                    }
                }
            }

            m_ActiveTarget           = null;
            m_ActiveTargetGameObject = null;
            m_ActiveTargetID         = 0;
            m_ActiveTargetName       = "";
            m_ActiveTargetKey        = "";
        }
        public void Copy(TargetObject _target)
        {
            if (_target == null)
            {
                return;
            }

            BehaviourModeKey            = _target.BehaviourModeKey;
            TargetIgnoreLevelDifference = _target.TargetIgnoreLevelDifference;
            IsPrefab     = _target.IsPrefab;
            TargetOffset = _target.TargetOffset;
            TargetSmoothingMultiplier = _target.TargetSmoothingMultiplier;

            TargetGameObject   = _target.TargetGameObject;
            TargetRandomRange  = _target.TargetRandomRange;
            TargetStopDistance = _target.TargetStopDistance;

            UseUpdateOffsetOnActivateTarget      = _target.UseUpdateOffsetOnActivateTarget;
            UseUpdateOffsetOnMovePositionReached = _target.UseUpdateOffsetOnMovePositionReached;

            Selectors.Copy(_target.Selectors);
        }
Esempio n. 14
0
        public void DrawMoveGizmos()
        {
                        #if UNITY_EDITOR
            if (m_Owner == null || m_creature_control.Creature.Move.CurrentTarget == null)
            {
                return;
            }

            TargetObject _target = m_creature_control.Creature.Move.CurrentTarget;

            Vector3 _move_position         = m_creature_control.Creature.Move.MovePosition;
            Vector3 _target_move_position  = _target.TargetMovePosition;
            float   _move_stop_distance    = m_creature_control.Creature.Move.CurrentMove.MoveStopDistance;
            float   _move_lateral_variance = m_creature_control.Creature.Move.CurrentMove.MoveLateralVariance;

            Vector3 _owner_pos = m_Owner.transform.position;
            _owner_pos.y            = GetLevel();
            _move_position.y        = GetLevel();
            _target_move_position.y = GetLevel();



            CustomGizmos.OffsetPath(_owner_pos, 2, _move_position, _move_stop_distance);      // PATH FROM CREATURE TO NEXT MOVE POSITION
            CustomGizmos.Circle(_move_position, _move_stop_distance, 5, false);               // STOP DISTANCE RANGE

            if (m_creature_control.Creature.Move.CurrentMove.Type != MoveType.ESCAPE)
            {
                CustomGizmos.OffsetPath(_move_position, _move_stop_distance, _target_move_position, _target.TargetStopDistance);                      // PATH NEXT MOVE POSITION TO TARGET MOVE POSITION
            }
            if (_move_lateral_variance > 0)
            {
                float _max_range = _move_stop_distance + _move_lateral_variance;

                CustomGizmos.ZickZackCircle(_move_position, _move_lateral_variance, "", false); // RANDOM RANGE
                CustomGizmos.Circle(_move_position, _max_range, 5, true);                       // MAX MOVE RANGE
            }
                        #endif
        }
Esempio n. 15
0
        /// <summary>
        /// Draws the home.
        /// </summary>
        public void DrawHome()
        {
            if (!CreatureControl.Creature.Essentials.TargetReady() || ShowHome == false)
            {
                return;
            }

            TargetObject _target = CreatureControl.Creature.Essentials.Target;

            DrawTargetGizmos(_target);

            if (!Application.isPlaying)
            {
                BehaviourModeObject _mode = null;
                _mode = CreatureControl.Creature.Behaviour.GetBehaviourModeByKey(CreatureControl.Creature.Essentials.BehaviourModeTravel);
                DrawBehaviourModeGizmos(_target, _mode);

                _mode = CreatureControl.Creature.Behaviour.GetBehaviourModeByKey(CreatureControl.Creature.Essentials.BehaviourModeLeisure);
                DrawBehaviourModeGizmos(_target, _mode);

                _mode = CreatureControl.Creature.Behaviour.GetBehaviourModeByKey(CreatureControl.Creature.Essentials.BehaviourModeRendezvous);
                DrawBehaviourModeGizmos(_target, _mode);
            }
        }
 public MissionObject(TargetType _type)
 {
     m_Target = new TargetObject(_type);
 }
 public TargetObject(TargetObject _target)
 {
     Copy(_target);
 }
Esempio n. 18
0
        /// <summary>
        /// Draws the interaction.
        /// </summary>
        public void DrawInteraction()
        {
            if (CreatureControl.Creature.Interaction.Interactors.Count == 0 || ShowInteractor == false)
            {
                return;
            }

            for (int i = 0; i < CreatureControl.Creature.Interaction.Interactors.Count; i++)
            {
                InteractorObject _interactor = CreatureControl.Creature.Interaction.Interactors[i];

                if (!_interactor.Enabled)
                {
                    continue;
                }

                List <GameObject> _target_game_objects = GetCreaturesByName(_interactor.Name);

                if (_target_game_objects != null && _target_game_objects.Count > 0)
                {
                    foreach (GameObject _target_game_object in _target_game_objects)
                    {
                        Vector3 _interactor_pos = _target_game_object.transform.position;

                        TargetObject _target = new TargetObject(TargetType.INTERACTOR);

                        _target.TargetGameObject = _target_game_object;
                        _target.BehaviourModeKey = _interactor.BehaviourModeKey;
                        _target.Selectors.Copy(_interactor.Selectors);
                        _target.UpdateOffset(_interactor.DefaultOffset);
                        _target.TargetStopDistance          = _interactor.DefaultStopDistance;
                        _target.TargetRandomRange           = _interactor.DefaultRandomRange;
                        _target.TargetSmoothingMultiplier   = 0;                      //_interactor.DefaultSmoothingMultiplier; // TODO:REWORK TargetSmoothingMultiplier
                        _target.TargetIgnoreLevelDifference = _interactor.DefaultIgnoreLevelDifference;

                        DrawTargetGizmos(_target);

                        // DIRECTION
                        CustomGizmos.Arrow(_target.TargetPosition, _target.TargetDirection * _target.TargetStopDistance, 0.5f, 20);

                        Vector3 _last_move_position = _target.TargetMovePosition;
                        float   _last_stop_distance = _target.TargetStopDistance;

                        _last_move_position.y = GetLevel();

                        Color _default_color = Gizmos.color;
                        Color _target_color  = (_target.Active?ActiveTargetColor:TargetColor);

                        foreach (InteractorRuleObject _rule in _interactor.Rules)
                        {
                            if (!_rule.Enabled)
                            {
                                continue;
                            }

                            _target = new TargetObject(TargetType.INTERACTOR);

                            _target.TargetGameObject = _target_game_object;
                            _target.BehaviourModeKey = _rule.BehaviourModeKey;
                            _target.Selectors.Copy(_rule.Selectors);

                            _target.UpdateOffset(_interactor.DefaultOffset);
                            _target.TargetStopDistance          = _interactor.DefaultStopDistance;
                            _target.TargetRandomRange           = _interactor.DefaultRandomRange;
                            _target.TargetSmoothingMultiplier   = 0;                          //_interactor.DefaultSmoothingMultiplier; // TODO:REWORK TargetSmoothingMultiplier
                            _target.TargetIgnoreLevelDifference = _interactor.DefaultIgnoreLevelDifference;

                            if (_rule.OverrideTargetMovePosition)
                            {
                                _target.UpdateOffset(_rule.Offset);
                                _target.TargetStopDistance          = _rule.StopDistance;
                                _target.TargetRandomRange           = _rule.RandomRange;
                                _target.TargetSmoothingMultiplier   = 0;
                                _target.TargetIgnoreLevelDifference = _rule.IgnoreLevelDifference;
                            }

                            DrawTargetGizmos(_target);

                            Vector3 _move_position = _target.TargetMovePosition;
                            _move_position.y = GetLevel();

                            Gizmos.color = _target_color;
                            if (_last_move_position != Vector3.zero)
                            {
                                CustomGizmos.OffsetPath(_last_move_position, _last_stop_distance, _move_position, _target.TargetStopDistance, true);
                            }

                            _last_stop_distance = _target.TargetStopDistance;
                            _last_move_position = _move_position;
                        }

                        Gizmos.color = _target_color;
                        if (_last_move_position != Vector3.zero)
                        {
                            CustomGizmos.OffsetPath(_last_move_position, _last_stop_distance, _interactor_pos, 0, false);
                        }

                        Gizmos.color = _default_color;
                        //CustomGizmos.OffsetPath( _default_data.OffsetPosition, _default_data.StopDistance, _interactor_pos, 0 );
                    }
                }
            }
        }
Esempio n. 19
0
        private void DrawBehaviourModeRuleGizmos(TargetObject _target, BehaviourModeRuleObject _rule)
        {
                        #if UNITY_EDITOR
            if (_target == null || _target.IsValid == false || _rule == null)
            {
                return;
            }

            Vector3 _owner_position         = m_Owner.transform.position;
            Vector3 _target_pos             = _target.TargetPosition;
            Vector3 _target_move_position   = _target.TargetMovePosition;
            float   _target_stop_distance   = _target.TargetStopDistance;
            float   _target_selection_range = _target.Selectors.SelectionRange;
            //float _target_selection_angle = _target.Selectors.SelectionAngle;

            DrawOwnerGizmos();

            if (Application.isPlaying)
            {
                DrawPathGizmos();
                DrawMoveGizmos();
            }

            float _level = GetLevel();

            _owner_position.y       = _level;
            _target_pos.y           = _level;
            _target_move_position.y = _level;

            if (_rule.Move.Type == MoveType.DEFAULT)
            {
            }
            else if (_rule.Move.Type == MoveType.AVOID)
            {
                MoveContainer _move = _rule.Move;
                //float _radius = _target_selection_range  + 0.25f;// _move.Avoid.MaxAvoidDistance;//( _target_selection_range / 2 ) + 0.25f;
                //float _angle = _move.Avoid.MaxDirectionAngle;

                Gizmos.color = MoveAvoidColor;
                UnityEditor.Handles.color = Gizmos.color;

                //DrawDirectionAngle( m_Owner.transform, _radius, _angle );
                //DrawDirectionAngle( _target.TargetGameObject.transform, _radius, _angle );

                Vector3 _right           = Vector3.Cross(_target.TargetGameObject.transform.up, _target.TargetGameObject.transform.forward);
                Vector3 _avoid_pos_right = _target_pos + (_right * _move.Avoid.AvoidDistance);
                Vector3 _avoid_pos_left  = _target_pos + (_right * -_move.Avoid.AvoidDistance);

                CustomGizmos.OffsetPath(_target_pos, 0, _avoid_pos_right, _move.MoveStopDistance);
                CustomGizmos.DottedCircle(_avoid_pos_right, _move.MoveStopDistance, 5, 2);
                CustomGizmos.OffsetPath(_target_pos, 0, _avoid_pos_left, _move.MoveStopDistance);
                CustomGizmos.DottedCircle(_avoid_pos_left, _move.MoveStopDistance, 5, 2);

                if (Application.isPlaying)
                {
                    /*
                     * Gizmos.color = Color.blue;
                     * Gizmos.DrawLine( _target_pos, CreatureControl.Creature.Move.AvoidMovePosition );
                     * Gizmos.color = Color.red;
                     * Gizmos.DrawLine( _target_pos, CreatureControl.Creature.Move.MovePosition );
                     */
                }
            }
            else if (_rule.Move.Type == MoveType.ESCAPE)
            {
                MoveContainer _move             = _rule.Move;
                float         _inner_radius     = (_target_selection_range / 2) + 0.25f;
                float         _outer_radius     = _inner_radius + _rule.Move.MoveSegmentLength;
                float         _outer_radius_max = _inner_radius + _rule.Move.MoveSegmentLengthMax;
                float         _outer_radius_min = _inner_radius + _rule.Move.MoveSegmentLengthMin;

                float _inner_angle = 0;
                float _outer_angle = _inner_angle + _move.Escape.RandomEscapeAngle;

                Gizmos.color = MoveEscapeColor;

                Vector3 _left_inner_pos  = Tools.GetDirectionPosition(_target.TargetGameObject.transform, -_inner_angle, _inner_radius);
                Vector3 _right_inner_pos = Tools.GetDirectionPosition(_target.TargetGameObject.transform, _inner_angle, _inner_radius);
                Vector3 _left_outer_pos  = Tools.GetDirectionPosition(_target.TargetGameObject.transform, -_outer_angle, _outer_radius);
                Vector3 _right_outer_pos = Tools.GetDirectionPosition(_target.TargetGameObject.transform, _outer_angle, _outer_radius);

                _target_pos.y      = _level;
                _left_inner_pos.y  = _level;
                _right_inner_pos.y = _level;
                _left_outer_pos.y  = _level;
                _right_outer_pos.y = _level;

                Gizmos.DrawLine(_target_pos, _left_inner_pos);
                Gizmos.DrawLine(_target_pos, _right_inner_pos);

                Gizmos.DrawLine(_left_inner_pos, _left_outer_pos);
                Gizmos.DrawLine(_right_inner_pos, _right_outer_pos);

                CustomGizmos.Arc(_target.TargetGameObject.transform, _inner_radius, 1, -_inner_angle, _inner_angle, _level, false);
                CustomGizmos.Arc(_target.TargetGameObject.transform, _outer_radius, 1, -_outer_angle, _outer_angle, _level, false);

                CustomGizmos.Arc(_target.TargetGameObject.transform, _outer_radius_min, 1, -_outer_angle, _outer_angle, _level, true);
                CustomGizmos.Arc(_target.TargetGameObject.transform, _outer_radius_max, 1, -_outer_angle, _outer_angle, _level, true);

                // DENGER ZONE BEGIN
                _inner_radius += 0.25f;
                float _degree = CustomGizmos.GetBestDegrees(_inner_radius, _inner_angle);
                CustomGizmos.ArrowArc(_target.TargetGameObject.transform, _inner_radius, _degree, -_inner_angle, _inner_angle, _level);

                Transform _target_transform = _target.TargetGameObject.transform;
                Vector3   _center           = _target_transform.position;
                Vector3   _center_pos       = Tools.GetDirectionPosition(_target_transform, 0, _inner_radius + (_inner_radius / 10));
                Vector3   _left_pos         = Tools.GetDirectionPosition(_target_transform, -_inner_angle, _inner_radius);
                Vector3   _right_pos        = Tools.GetDirectionPosition(_target_transform, _inner_angle, _inner_radius);

                _center.y     = _level;
                _center_pos.y = _level;
                _left_pos.y   = _level;
                _right_pos.y  = _level;

                Gizmos.DrawLine(_center, _center_pos);
                Gizmos.DrawLine(_center, _left_pos);
                Gizmos.DrawLine(_center, _right_pos);
            }
            else if (_rule.Move.Type == MoveType.ORBIT)
            {
                MoveContainer _move    = _rule.Move;
                float         _degrees = CreatureControl.Creature.Move.OrbitDegrees;
                float         _radius  = _move.Orbit.Radius;

                if (Application.isPlaying)
                {
                    _move   = CreatureControl.Creature.Move.CurrentMove;
                    _radius = CreatureControl.Creature.Move.OrbitRadius;
                }

                Gizmos.color = MoveOrbitColor;
                CustomGizmos.Orbit(m_Owner.transform.position, _target_move_position, _radius, _degrees, _move.Orbit.RadiusShift, _move.Orbit.MinDistance, _move.Orbit.MaxDistance, _level);
            }
            else if (_rule.Move.Type == MoveType.DETOUR)
            {
                Vector3 _detour_pos = _rule.Move.Detour.Position;

                _detour_pos.y = _level;

                Gizmos.color = MoveDetourColor;
                CustomGizmos.OffsetPath(_detour_pos, _rule.Move.MoveStopDistance, _target_move_position, _target_stop_distance);
                CustomGizmos.Circle(_detour_pos, _rule.Move.MoveStopDistance, 5, false);                   // STOP DISTANCE RANGE
                //DrawMoveGizmos( Vector3 _initial_position, Vector3 _move_position, float _stop_distance, float _random_range, Vector3 _target_position, float _target_stop_distance )
            }
                        #endif
        }
Esempio n. 20
0
        /// <summary>
        /// Draws the target gizmos.
        /// </summary>
        /// <param name="_target">_target.</param>
        private void DrawTargetGizmos(TargetObject _target, Color _target_color, Color _selection_color)
        {
                        #if UNITY_EDITOR
            if (_target == null || _target.IsValid == false)
            {
                return;
            }

            Vector3 _target_pos                = _target.TargetPosition;
            Vector3 _target_direction          = _target.TargetDirection;
            Vector3 _target_pos_offset         = _target.TargetOffsetPosition;
            Vector3 _target_pos_move           = _target.TargetMovePosition;
            float   _target_selection_distance = _target.Selectors.SelectionRange;
            float   _target_selection_angle    = _target.Selectors.SelectionAngle;

            Vector3 _target_pos_top    = _target_pos;
            Vector3 _target_pos_bottom = _target_pos;

            float _level = GetLevel();
            _target_pos.y        = GetLevel();
            _target_pos_offset.y = GetLevel();
            _target_pos_move.y   = GetLevel();
            _target_pos_top.y    = GetLevel() + 3;
            _target_pos_bottom.y = 0;

            Color _previous_color = Gizmos.color;
            Gizmos.color = _target_color;
            UnityEditor.Handles.color = _target_color;

            // SELECTION RANGE BEGIN

            /*if( ShowSolidInteractionRange && SolidInteractionAlpha > 0 )
             * {
             *      UnityEditor.Handles.color = _selection_color;
             *      UnityEditor.Handles.DrawWireDisc( _target_pos , Vector3.up, _target_selection_distance );
             *
             *      Color _selection_color_transparent = _selection_color;
             *      _selection_color_transparent.a = SolidInteractionAlpha;
             *      UnityEditor.Handles.color = _selection_color_transparent;
             *      UnityEditor.Handles.DrawSolidDisc( _target_pos , Vector3.up, _target_selection_distance );
             * }
             * else
             * {
             *      UnityEditor.Handles.color = _selection_color;
             *      UnityEditor.Handles.DrawWireDisc( _target_pos , Vector3.up, _target_selection_distance );
             * }*/


            //if( _target_selection_angle > 0 && _target_selection_angle <= 180 )
            {
                if (_target_selection_angle == 0)
                {
                    _target_selection_angle = 180;
                }


                CustomGizmos.ArrowArc(_target.TargetGameObject.transform, _target_selection_distance, CustomGizmos.GetBestDegrees(_target_selection_distance, _target_selection_angle), -_target_selection_angle, _target_selection_angle, _level, true);


                if (_target_selection_angle < 180)
                {
                    Transform _target_transform = _target.TargetGameObject.transform;
                    Vector3   _center           = _target_transform.position;
                    Vector3   _center_pos       = Tools.GetDirectionPosition(_target_transform, 0, _target_selection_distance + (_target_selection_distance / 10));
                    Vector3   _left_pos         = Tools.GetDirectionPosition(_target_transform, -_target_selection_angle, _target_selection_distance - 0.25f);
                    Vector3   _right_pos        = Tools.GetDirectionPosition(_target_transform, _target_selection_angle, _target_selection_distance - 0.25f);

                    _center.y     = _level;
                    _center_pos.y = _level;
                    _left_pos.y   = _level;
                    _right_pos.y  = _level;

                    //Gizmos.DrawLine( _center, _center_pos );
                    Gizmos.DrawLine(_center, _left_pos);
                    Gizmos.DrawLine(_center, _right_pos);                       /**/
                }
            }
            // SELECTION RANGE END



            // TARGET ICON BEGIN
            Gizmos.DrawLine(_target_pos_bottom, _target_pos_top);
            Gizmos.DrawIcon(_target_pos_top, "ice_waypoint.png");
            // TARGET ICON END


            // TARGET STOP DISTANCE BEGIN
            if (_target.TargetIgnoreLevelDifference)
            {
                CustomGizmos.Circle(_target_pos_move, _target.TargetStopDistance, 5, false);                   // IGNORES LEVEL DIFFERNCE SO WE DRAW JUST A CIRCLE
            }
            else
            {
                Gizmos.DrawWireSphere(_target_pos_move, _target.TargetStopDistance);                  // IF THE LEVEL IS IMPORTANT FOR THE STOP DISTANCE WE DRAW A SPHERE
            }
            // TARGET STOP DISTANCE END

            // MAX AND RANDOM RANGE BEGIN
            CustomGizmos.Circle(_target_pos_offset, _target.TargetRandomRange, 5, false);                             // RANDOM RANGE
            CustomGizmos.Circle(_target_pos_offset, _target.TargetRandomRange + _target.TargetStopDistance, 5, true); // MAX RANGE
            // MAX AND RANDOM RANGE END

            // SPECIAL CASES FOR INTERACTOR WHICH COULD HAVE SEVERAL SELECTION RANGES
            if (_target.Type != TargetType.INTERACTOR)
            {
                if (Vector3.Distance(_target_pos_move, _target_pos_offset) <= _target.TargetStopDistance)
                {
                    CustomGizmos.OffsetPath(_target_pos, 0.0f, _target_pos_offset, _target.TargetStopDistance);
                }
                else
                {
                    Gizmos.DrawLine(_target_pos, _target_pos_offset);
                }

                CustomGizmos.OffsetPath(_target_pos_offset, 0.0f, _target_pos_move, _target.TargetStopDistance);

                // DIRECTION
                CustomGizmos.Arrow(_target_pos, _target_direction * _target.TargetStopDistance, 0.5f, 20);
            }

            BehaviourModeObject _mode = CreatureControl.Creature.Behaviour.GetBehaviourModeByKey(_target.BehaviourModeKey);
            DrawBehaviourModeGizmos(_target, _mode);

            // PRIVIOUS COLOR
            Gizmos.color = _previous_color;
            UnityEditor.Handles.color = _previous_color;
                        #endif
        }
    }

    /// <summary>
    /// Pointer object.
    /// </summary>
    [System.Serializable]
    public class PathObject : System.Object
    {
        public void NavMeshPath(NavMeshAgent _agent)
        {        /*
                  * GameObject _object = new GameObject();
                  * _object.transform.parent = _agent.gameObject.transform;
                  * LineRenderer _line = _object.AddComponent<LineRenderer>();
                  * _line.SetColors(Color.white,Color.white);
                  * _line.SetWidth(0.1f,0.1f);
                  * //Get def material
                  *
                  * _line.gameObject.renderer.material.color = Color.white;
                  * _line.gameObject.renderer.material.shader = Shader.Find("Sprites/Default");
                  * _line.gameObject.AddComponent<LineScript>();
                  * _line.SetVertexCount(_agent.path.corners.Length+1);
                  * int i = 0;
                  * foreach(Vector3 v in p.corners)
                  * {
                  *     _line.SetPosition(i,v);
                  *     //Debug.Log("position agent"+g.transform.position);
                  *     //Debug.Log("position corner = "+v);
                  *     i++;
                  * }
                  * _line.SetPosition(p.corners.Length,_agent.destination);
                  * _line.gameObject.tag = "ligne";*/
        }
    }
 public InteractorObject()
 {
     m_Target = new TargetObject(TargetType.INTERACTOR);
 }
Esempio n. 22
0
        /// <summary>
        /// Sets the active target.
        /// </summary>
        /// <param name="_target">_target.</param>
        public void SetActiveTarget(TargetObject _target)
        {
            if (Status.IsDead)
            {
                return;
            }

            if (Move.Deadlocked)
            {
                Move.ResetDeadlock();
                if (Move.DeadlockAction == DeadlockActionType.BEHAVIOUR)
                {
                    Behaviour.SetBehaviourModeByKey(Move.DeadlockBehaviour);
                    return;
                }
                else if (Move.DeadlockAction == DeadlockActionType.UPDATE && m_ActiveTarget != null)
                {
                    m_ActiveTarget.UpdateOffset();
                }
                else
                {
                    Status.Kill();
                    return;
                }
            }


            if (_target == null || Status.RecreationRequired)
            {
                _target = Essentials.Target;
            }

            if (_target == null || !_target.IsValid)
            {
                Debug.LogError(m_Owner.name + " have no target!");
                return;
            }

            if (IsTargetUpdatePermitted(_target))
            {
                if (m_ActiveTarget != _target)
                {
                    m_PreviousTarget = m_ActiveTarget;

                    if (m_PreviousTarget != null)
                    {
                        m_PreviousTarget.SetActive(false);
                    }

                    m_ActiveTarget = _target;

                    if (m_ActiveTarget != null)
                    {
                        m_ActiveTarget.SetActive(true);
                    }

                    m_TargetChanged = true;
                }

                if (m_ActiveTarget != null)
                {
                    Behaviour.SetBehaviourModeByKey(ActiveTarget.BehaviourModeKey);
                }
            }
        }
Esempio n. 23
0
        public void SelectBestTarget()
        {
            TargetObject _favourite_target = null;

            foreach (TargetObject _target in m_AvailableTargets)
            {
                if (_target == null || _target.IsValid == false)
                {
                    continue;
                }

                _target.Selectors.ResetRelevanceMultiplier();

                /*
                 * if( m_ActiveTarget != null && m_ActiveTarget != _target )
                 *      m_ActiveTarget.Selectors.CompareSuccessorTargets( _target, m_Owner.transform.position );
                 */
                bool _final_result = false;

                if (_target.TargetInSelectionRange(m_Owner.transform, Move.FieldOfView, Move.VisualRange))
                {
                    _final_result = true;
                }

                if (_target.Selectors.UseAdvanced)
                {
                    foreach (TargetSelectorObject _selector in _target.Selectors.Selectors)
                    {
                        bool _selector_result = false;

                        foreach (TargetSelectorConditionObject _condition in _selector.Conditions)
                        {
                            if (_condition.Enabled == false)
                            {
                                continue;
                            }

                            bool _condition_result = false;

                            if (_condition.ExpressionType == TargetSelectorExpressionType.DISTANCE)
                            {
                                _condition_result = false;                                //_target.TargetInSelectionRange( m_Owner.transform.position, _condition.Distance );

                                //TODO - HANDLE DISTANCE
                            }
                            else if (_condition.ExpressionType == TargetSelectorExpressionType.BEHAVIOR)
                            {
                                if (Behaviour.BehaviourModeKey == _condition.BehaviourModeKey)
                                {
                                    _condition_result = true;
                                }

                                if (_condition.Operator == LogicalOperatorType.NOT)
                                {
                                    _condition_result = !_condition_result;
                                }
                            }
                            else if (_condition.ExpressionType == TargetSelectorExpressionType.POSITION)
                            {
                                switch (_condition.PositionType)
                                {
                                case TargetSelectorPositionType.TARGETMOVEPOSITION:
                                    _condition_result = _target.TargetMoveComplete;
                                    break;

                                case TargetSelectorPositionType.TARGETMAXRANGE:
                                    _condition_result = _target.TargetInMaxRange(m_Owner.transform.position);
                                    break;
                                }

                                if (_condition.Operator == LogicalOperatorType.NOT)
                                {
                                    _condition_result = !_condition_result;
                                }
                            }
                            else if (_condition.ExpressionType == TargetSelectorExpressionType.PRECURSOR)
                            {
                                TargetObject _precursor = null;
                                if (_target == m_ActiveTarget)
                                {
                                    _precursor = m_PreviousTarget;
                                }
                                else
                                {
                                    _precursor = m_ActiveTarget;
                                }

                                _condition_result = _condition.ComparePrecursorTarget(_precursor);
                            }

                            if (_condition.ConditionType == ConditionalOperatorType.AND || _condition_result == true)
                            {
                                _selector_result = _condition_result;
                            }
                        }

                        if (_selector_result)
                        {
                            foreach (TargetSelectorStatementObject _statement in _selector.Statements)
                            {
                                if (_statement.StatementType == TargetSelectorStatementType.PRIORITY)
                                {
                                    _target.Selectors.Priority = _statement.Priority;
                                }
                                else if (_statement.StatementType == TargetSelectorStatementType.SUCCESSOR)
                                {
                                    if (_statement.SuccessorType == TargetSuccessorType.NAME)
                                    {
                                        TargetObject _successor = FindTargetByName(_statement.SuccessorTargetName);

                                        if (_successor != null && _successor.IsValid)
                                        {
                                            _favourite_target = _successor;
                                        }
                                    }
                                }
                            }
                        }

                        if (_selector.ConditionType == ConditionalOperatorType.AND || _selector_result == true)
                        {
                            _final_result = _selector_result;
                        }
                    }
                }

                if (_final_result)
                {
                    bool _handled = false;

                    if (_target.Selectors.UseAdvanced && _target.Selectors.Statements.Count > 0)
                    {
                        foreach (TargetSelectorStatementObject _statement in _target.Selectors.Statements)
                        {
                            if (_statement.StatementType == TargetSelectorStatementType.SUCCESSOR)
                            {
                                if (_statement.SuccessorType == TargetSuccessorType.NAME)
                                {
                                    TargetObject _successor = FindTargetByName(_statement.SuccessorTargetName);

                                    if (_successor != null && _successor.IsValid)
                                    {
                                        _favourite_target = _successor;
                                        _handled          = true;
                                    }
                                }
                            }
                        }
                    }

                    if (_handled == false)
                    {
                        if (_favourite_target == null)
                        {
                            _favourite_target = _target;
                        }
                        else if (_target.SelectionPriority > _favourite_target.SelectionPriority)
                        {
                            _favourite_target = _target;
                        }
                        else if (_target.SelectionPriority == _favourite_target.SelectionPriority && Random.Range(0, 1) == 1)
                        {
                            _favourite_target = _target;
                        }
                    }
                }
            }

            SetActiveTarget(_favourite_target);
        }
Esempio n. 24
0
        public void Action(InventoryActionDataObject _action)
        {
            if (_action == null || !_action.Enabled)
            {
                return;
            }

            if (_action.DropItemRequired())
            {
                InventorySlotObject _slot = GetSlotByItemName(_action.ItemName);
                if (_slot != null && _slot.Amount > 0)
                {
                    Transform _transform = ICE.World.Utilities.SystemTools.FindChildByName(_action.ParentName, Owner.transform);
                    _transform = (_transform != null ? _transform : Owner.transform);

                    Quaternion _rotation = Quaternion.Euler(0, UnityEngine.Random.Range(0, 360), 0);
                    Vector3    _position = PositionTools.FixTransformPoint(_transform, _action.Offset);

                    GameObject _item = _slot.GiveItem(_position, _rotation);
                    if (_item == null)
                    {
                        _item = CreatureRegister.Spawn(_slot.ItemReferenceObject, _position, _rotation);
                        _slot.Amount--;
                    }
                }
            }
            else if (_action.ParentUpdateRequired())
            {
                InventorySlotObject _slot = GetSlotByItemName(_action.ItemName);
                if (_slot != null && _slot.Amount > 0)
                {
                    if (_slot.ItemObject != null)
                    {
                        _slot.MountPointName = _action.ParentName;
                    }
                }
            }
            else if (_action.CollectActiveItemRequired())
            {
                ICECreatureControl _control = OwnerComponent as ICECreatureControl;
                TargetObject       _target  = _control.Creature.ActiveTarget;

                if (_control != null && _target != null && _target.Selectors.TotalCheckIsValid)                  //&& LastCollectedObjectID != _target.TargetID  )
                {
                    GameObject _item = _target.TargetGameObject;

                    //LastCollectedObjectID = _target.TargetID;

                    if (_target.EntityComponent != null && _target.EntityComponent.IsChildEntity)
                    {
                        ICEWorldEntity _parent = _target.EntityComponent.RootEntity;
                        if (_parent != null)
                        {
                            if (DebugLogIsEnabled)
                            {
                                PrintDebugLog(this, "CollectActiveItem : take '" + _target.Name + "' from " + _parent.name + " (" + _parent.ObjectInstanceID + ")");
                            }

                            InventorySlotObject _slot = GetInventorySlot(_parent.gameObject, _target.TargetName);
                            if (_slot != null)
                            {
                                _item = _slot.GiveItem();
                            }
                        }
                    }

                    if (Insert(_item))
                    {
                        //Debug.Log( _control.Creature.ActiveTarget.TargetGameObject.name + " - " +  _control.Creature.ActiveTarget.TargetGameObject.GetInstanceID() );
                        //_target.ResetTargetGameObject();
                        _control.Creature.ResetActiveTarget();

                        //
                    }
                }
            }
        }
Esempio n. 25
0
        /// <summary>
        /// Draws the patrol.
        /// </summary>
        public void DrawPatrol()
        {
            if (!CreatureControl.Creature.Missions.Patrol.TargetReady() || ShowPatrol == false)
            {
                return;
            }

            TargetObject _target = null;
            Vector3      _target_move_position = Vector3.zero;
            float        _target_stop_distance = 0;

            WaypointObject _last_waypoint_target = CreatureControl.Creature.Missions.Patrol.Waypoints.GetLastValidWaypoint();

            Vector3 _last_target_move_position = Vector3.zero;
            float   _last_target_stop_distance = 0;

            if (_last_waypoint_target != null)
            {
                _last_target_move_position   = _last_waypoint_target.TargetMovePosition;
                _last_target_move_position.y = GetLevel();
                _last_target_stop_distance   = _last_waypoint_target.TargetStopDistance;
            }

            for (int i = 0; i < CreatureControl.Creature.Missions.Patrol.Waypoints.Waypoints.Count; i++)
            {
                _target = (TargetObject)CreatureControl.Creature.Missions.Patrol.Waypoints.Waypoints[i];

                if (_target.IsValid == false)
                {
                    continue;
                }

                _target_move_position   = _target.TargetMovePosition;
                _target_move_position.y = GetLevel();
                _target_stop_distance   = _target.TargetStopDistance;

                if (CreatureControl.Creature.Missions.Patrol.Waypoints.Waypoints[i].Enabled)
                {
                    DrawTargetGizmos(_target);

                    Color _default_color = Gizmos.color;
                    Gizmos.color = MoveProjectedPathColor;
                    CustomGizmos.OffsetPath(_last_target_move_position, _last_target_stop_distance, _target_move_position, _target_stop_distance);
                    Gizmos.color = _default_color;

                    _last_target_move_position = _target_move_position;
                    _last_target_stop_distance = _target_stop_distance;
                }
                else
                {
                    Color _color = TargetColor;
                    _color.a = 0.25f;
                    DrawTargetGizmos(_target, _color);
                }

                if (!Application.isPlaying)
                {
                    BehaviourModeObject _mode = null;
                    _mode = CreatureControl.Creature.Behaviour.GetBehaviourModeByKey(CreatureControl.Creature.Missions.Patrol.GetBehaviourModeTravelByIndex(i));
                    DrawBehaviourModeGizmos(_target, _mode);

                    _mode = CreatureControl.Creature.Behaviour.GetBehaviourModeByKey(CreatureControl.Creature.Missions.Patrol.GetBehaviourModePatrolByIndex(i));
                    DrawBehaviourModeGizmos(_target, _mode);

                    _mode = CreatureControl.Creature.Behaviour.GetBehaviourModeByKey(CreatureControl.Creature.Missions.Patrol.GetBehaviourModeLeisureByIndex(i));
                    DrawBehaviourModeGizmos(_target, _mode);

                    _mode = CreatureControl.Creature.Behaviour.GetBehaviourModeByKey(CreatureControl.Creature.Missions.Patrol.GetBehaviourModeRendezvousByIndex(i));
                    DrawBehaviourModeGizmos(_target, _mode);
                }
            }
        }
Esempio n. 26
0
 public EssentialsObject()
 {
     m_Target = new TargetObject(TargetType.HOME);
 }
Esempio n. 27
0
        /// <summary>
        /// Sets the active target.
        /// </summary>
        /// <param name="_target">_target.</param>
        public void SetActiveTarget(TargetObject _target)
        {
            if (Status.IsDead || Status.IsSpawning)
            {
                return;
            }

            if (Move.Deadlock.Deadlocked)
            {
                Move.Deadlock.Reset(Owner.transform);
                if (Move.Deadlock.Action == DeadlockActionType.BEHAVIOUR)
                {
                    SetActiveBehaviourModeByKey(Move.Deadlock.Behaviour);
                    return;
                }
                else if (Move.Deadlock.Action == DeadlockActionType.UPDATE && m_ActiveTarget != null)
                {
                    m_ActiveTarget.Move.UpdateRandomOffset();
                }
                else
                {
                    Status.Kill();
                    return;
                }
            }

            if (_target == null || !_target.IsValidAndReady || Status.RecreationRequired)
            {
                _target = Essentials.PrepareTarget(OwnerComponent);
            }

            if (_target == null || !_target.IsValidAndReady)
            {
                if (DebugLogIsEnabled)
                {
                    PrintDebugLog(this, "Sorry, the creature have no valid target!");
                }
                return;
            }

            m_TargetChanged = false;
            if (IsTargetUpdatePermitted(_target))
            {
                // update target
                if (!_target.CompareTarget(m_ActiveTarget, m_ActiveTargetID))
                {
                    // handle previous target
                    ResetActiveTarget();

                    // handle new target
                    m_ActiveTarget           = _target;
                    m_ActiveTargetGameObject = _target.TargetGameObject;
                    m_ActiveTargetID         = _target.TargetID;
                    m_ActiveTargetName       = _target.TargetName;
                    m_ActiveTargetKey        = _target.TargetName + _target.TargetID.ToString();

                    if (m_ActiveTarget != null)
                    {
                        m_ActiveTarget.SetActive(OwnerComponent);

                        if (m_ActiveTarget.EntityComponent != null)
                        {
                            m_ActiveTarget.EntityComponent.AddActiveCounterpart(OwnerComponent as ICECreatureEntity);
                        }

                        if (m_ActiveTarget.GroupMessage.Type != BroadcastMessageType.NONE)
                        {
                            /*
                             * BroadcastMessageDataObject _data = new BroadcastMessageDataObject();
                             *
                             * _data.Type = m_ActiveTarget.GroupMessage.Type;
                             * _data.TargetGameObject = m_ActiveTarget.TargetGameObject;
                             * _data.Command = m_ActiveTarget.GroupMessage.Command;*/

                            ICECreatureEntity _entity = OwnerComponent as ICECreatureEntity;
                            if (_entity != null)
                            {
                                _entity.Message.SendGroupMessage(new BroadcastMessageDataObject(m_ActiveTarget.GroupMessage.Type, m_ActiveTarget.TargetGameObject, m_ActiveTarget.GroupMessage.Command));
                            }
                        }
                    }

                    if (DebugLogIsEnabled)
                    {
                        string _previus = (m_PreviousTargetName != "" ? m_PreviousTargetName + " (" + m_PreviousTargetID + ")": "unknown");
                        string _active  = (m_ActiveTargetName != "" ? m_ActiveTargetName + " (" + m_ActiveTargetID + ")": "unknown");

                        PrintDebugLog(this, "SetActiveTarget - creature changed active target from " + _previus + " to " + _active + ".");
                    }

                    Move.UpdateTargets(m_ActiveTarget, Essentials.Target);

                    m_TargetChanged = true;
                }


                // update target behaviour
                if (m_ActiveTarget != null)
                {
                    string _key = ActiveTarget.Behaviour.CurrentBehaviourModeKey;

                    if (string.IsNullOrEmpty(_key))
                    {
                        // if the active target is not a HOME or if the creature outside the max range it have to travel to reach its target
                        if (!ActiveTarget.TargetInMaxRange(Owner.transform.position))
                        {
                            _key = Essentials.BehaviourModeRun;
                        }

                        // if the creature reached the TargetMovePosition it should do the rendezvous behaviour
                        else if (ActiveTarget.TargetMoveComplete)
                        {
                            _key = Essentials.BehaviourModeIdle;
                        }

                        // in all other case the creature should be standby and do some leisure activities
                        else                         //if( Target.TargetRandomRange > 0 )
                        {
                            _key = Essentials.BehaviourModeWalk;
                        }
                    }

                    SetActiveBehaviourModeByKey(_key);
                }
            }
        }