Exemplo n.º 1
0
        public override void StateEnter()
        {
            base.StateEnter();
            attack = GetEntity();
            BaseEntity baseEntity = brain.Events.Memory.Entity.Get(brain.Events.CurrentInputMemorySlot);

            if (baseEntity != null)
            {
                BaseCombatEntity target       = baseEntity as BaseCombatEntity;
                Vector3          aimDirection = GetAimDirection(GetEntity(), target);
                brain.Navigator.SetFacingDirectionOverride(aimDirection);
                if (attack.CanAttack(baseEntity))
                {
                    StartAttacking(baseEntity);
                }
                brain.Navigator.SetDestination(baseEntity.transform.position, BaseNavigator.NavigationSpeed.Fast);
            }
        }
Exemplo n.º 2
0
        public override StateStatus StateThink(float delta)
        {
            base.StateThink(delta);
            BaseEntity baseEntity = brain.Events.Memory.Entity.Get(brain.Events.CurrentInputMemorySlot);

            if (attack == null)
            {
                return(StateStatus.Error);
            }
            if (baseEntity == null)
            {
                brain.Navigator.ClearFacingDirectionOverride();
                StopAttacking();
                return(StateStatus.Finished);
            }
            if (brain.Senses.ignoreSafeZonePlayers)
            {
                BasePlayer basePlayer = baseEntity as BasePlayer;
                if (basePlayer != null && basePlayer.InSafeZone())
                {
                    return(StateStatus.Error);
                }
            }
            if (!brain.Navigator.SetDestination(baseEntity.transform.position, BaseNavigator.NavigationSpeed.Fast, 0.25f, (baseEntity is BasePlayer && attack != null) ? attack.EngagementRange() : 0f))
            {
                return(StateStatus.Error);
            }
            BaseCombatEntity target       = baseEntity as BaseCombatEntity;
            Vector3          aimDirection = GetAimDirection(GetEntity(), target);

            brain.Navigator.SetFacingDirectionOverride(aimDirection);
            if (attack.CanAttack(baseEntity))
            {
                StartAttacking(baseEntity);
            }
            else
            {
                StopAttacking();
            }
            return(StateStatus.Running);
        }