コード例 #1
0
        /// <summary>
        /// sets the active path data if path is 100% unique compared to old path, checks to adjust path for sun avoiding
        /// ents and stores end coords
        /// </summary>
        public virtual bool SetPath(PathEntity par1PathEntity, float par2)
        {
            if (par1PathEntity == null)
            {
                CurrentPath = null;
                return(false);
            }

            if (!par1PathEntity.Func_48647_a(CurrentPath))
            {
                CurrentPath = par1PathEntity;
            }

            if (NoSunPathfind)
            {
                RemoveSunnyPath();
            }

            if (CurrentPath.GetCurrentPathLength() == 0)
            {
                return(false);
            }
            else
            {
                Speed = par2;
                Vec3D vec3d = GetEntityPosition();
                TicksAtLastPos      = TotalTicks;
                LastPosCheck.XCoord = vec3d.XCoord;
                LastPosCheck.YCoord = vec3d.YCoord;
                LastPosCheck.ZCoord = vec3d.ZCoord;
                return(true);
            }
        }
コード例 #2
0
        /// <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);
        }