Exemple #1
0
        public void TakeCover()
        {
            AIStatic cover = AIGame.AIContainer.GetNearestStatic(this.Position, AIStaticType.Cover);

            if (cover == _cover)
            {
                return;
            }

            if (cover.IsAllowedToEnter(this))
            {
                this.MoveTo(cover.Position);
                _cover = cover;
                if (_isShootAt)
                {
                    UpdateFitness(AIParams.FITNESS_INCREASE_GET_TO_COVER);
                }
            }
            else
            {
                _coversBanned.Add(cover);
                TakeCover(AIGame.AIContainer.GetOtherNearestStatic(this.Position, AIStaticType.Cover, _coversBanned));
            }
            OccupyBy(AIAction.TakeCover);
        }
Exemple #2
0
        private void UpdateTakeCover()
        {
            if (_cover != null)
            {
                if (_cover.IsObjectLocatedInside(this) && !_inCover)
                {
                    if (!_cover.IsAllowedToEnter(this))
                    {
                        _coversBanned.Add(_cover);
                        _cover = AIGame.AIContainer.GetOtherNearestStatic(this.Position, AIStaticType.Cover, _coversBanned);
                        TakeCover(_cover);
                        return;
                    }

                    _inCover = true;
                    _coversBanned.Clear();
                    if (!_cover.AIObjects.Contains(this))
                    {
                        _cover.AIObjects.CopyTo(_cover.AIObjects_Prev);
                        _cover.AIObjects.Add(this);
                        _cover.TeamInside = this.Team.TeamType;
                        SetFree();
                    }
                }

                if (!_cover.IsObjectLocatedInside(this) && _inCover)
                {
                    _inCover = false;
                    if (_cover.AIObjects.Contains(this))
                    {
                        _cover.AIObjects.CopyTo(_cover.AIObjects_Prev);
                        _cover.AIObjects.Remove(this);
                        if (_cover.AIObjects.Count == 0)
                        {
                            _cover.TeamInside = AITeamType.NULL;
                        }
                        _cover = null;
                    }
                }
            }
        }
Exemple #3
0
        public void TakeCover(AIStatic cover)
        {
            if (cover == null)
            {
                SetFree();
                _coversBanned.Clear();
                return;
            }

            if (cover.IsAllowedToEnter(this))
            {
                this.MoveTo(cover.Position);
                _cover = cover;
            }
            else
            {
                _coversBanned.Add(cover);
                TakeCover(AIGame.AIContainer.GetOtherNearestStatic(this.Position, AIStaticType.Cover, _coversBanned));
            }
            OccupyBy(AIAction.TakeCover);
        }
Exemple #4
0
        public void TakeCover(AIStatic cover)
        {
            if (cover == null)
            {
                SetFree();
                _coversBanned.Clear();
                return;
            }

            if (cover.IsAllowedToEnter(this))
            {
                this.MoveTo(cover.Position);
                _cover = cover;
            }
            else
            {
                _coversBanned.Add(cover);
                TakeCover(AIGame.AIContainer.GetOtherNearestStatic(this.Position, AIStaticType.Cover, _coversBanned));
            }
            OccupyBy(AIAction.TakeCover);
        }