Example #1
0
 public EntityAIAvoidEntity(EntityCreature par1EntityCreature, Type par2Class, float par3, float par4, float par5)
 {
     TheEntity          = par1EntityCreature;
     TargetEntityClass  = par2Class;
     Field_48241_e      = par3;
     Field_48242_b      = par4;
     Field_48243_c      = par5;
     EntityPathNavigate = par1EntityCreature.GetNavigator();
     SetMutexBits(1);
 }
        /// <summary>
        /// Returns whether the EntityAIBase should begin execution.
        /// </summary>
        public override bool ShouldExecute()
        {
            if (!TheEntity.IsCollidedHorizontally)
            {
                return(false);
            }

            PathNavigate pathnavigate = TheEntity.GetNavigator();
            PathEntity   pathentity   = pathnavigate.GetPath();

            if (pathentity == null || pathentity.IsFinished() || !pathnavigate.Func_48665_b())
            {
                return(false);
            }

            for (int i = 0; i < Math.Min(pathentity.GetCurrentPathIndex() + 2, pathentity.GetCurrentPathLength()); i++)
            {
                PathPoint pathpoint = pathentity.GetPathPointFromIndex(i);
                EntityPosX = pathpoint.XCoord;
                EntityPosY = pathpoint.YCoord + 1;
                EntityPosZ = pathpoint.ZCoord;

                if (TheEntity.GetDistanceSq(EntityPosX, TheEntity.PosY, EntityPosZ) > 2.25D)
                {
                    continue;
                }

                TargetDoor = Func_48318_a(EntityPosX, EntityPosY, EntityPosZ);

                if (TargetDoor != null)
                {
                    return(true);
                }
            }

            EntityPosX = MathHelper2.Floor_double(TheEntity.PosX);
            EntityPosY = MathHelper2.Floor_double(TheEntity.PosY + 1.0D);
            EntityPosZ = MathHelper2.Floor_double(TheEntity.PosZ);
            TargetDoor = Func_48318_a(EntityPosX, EntityPosY, EntityPosZ);
            return(TargetDoor != null);
        }