Ejemplo n.º 1
0
        public bool IsLikelyInsideBlock()
        {
            AABB bb = ModelBB.OffsetPosition(Pos);

            // client collision is very slightly more precise than server
            // so move slightly in to avoid false positives
            bb = bb.Expand(-1);
            return(AABB.IntersectsSolidBlocks(bb, level));
        }
Ejemplo n.º 2
0
        void CheckBlocks(Position pos)
        {
            try {
                Vec3U16 P     = (Vec3U16)pos.BlockCoords;
                AABB    bb    = ModelBB.OffsetPosition(Pos);
                int     index = level.PosToInt(P.X, P.Y, P.Z);

                if (level.Config.SurvivalDeath)
                {
                    PlayerPhysics.Drown(this, bb);
                    PlayerPhysics.Fall(this, bb);
                }
                lastFallY = bb.Min.Y;

                PlayerPhysics.Walkthrough(this, bb);
                oldIndex = index;
            } catch (Exception ex) {
                Logger.LogError(ex);
            }
        }
Ejemplo n.º 3
0
        void DoMove(int steps)
        {
            Position pos = Pos;
            AABB     bb  = ModelBB.OffsetPosition(pos);
            int      dx  = Math.Sign(TargetPos.X - pos.X);
            int      dz  = Math.Sign(TargetPos.Z - pos.Z);

            if (downsCount == -1)
            {
                RecalcDownExtent(ref bb, steps, dx, dz);
                RecalcUpExtent(ref bb, steps, dx, dz);
            }

            // Advance the AABB to the bot's next position
            bb = bb.Offset(dx, 0, dz);
            AABB bbCopy = bb;

            // Attempt to drop the bot down up to 1 block
            int hitY = -32;

            for (int dy = 0; dy >= -32; dy--)
            {
                bool intersectsAny = false;
                for (int i = 0; i < downsCount; i++)
                {
                    if (AABB.Intersects(ref bb, ref downs[i]))
                    {
                        intersectsAny = true; break;
                    }
                }

                if (intersectsAny)
                {
                    hitY = dy + 1; break;
                }
                bb.Min.Y--; bb.Max.Y--;
            }

            // Does the bot fall down a block
            if (hitY < 0)
            {
                pos.X += dx; pos.Y += hitY; pos.Z += dz; Pos = pos;
                RecalcDownExtent(ref bb, steps, dx, dz);
                RecalcUpExtent(ref bb, steps, dx, dz);
                return;
            }

            // Attempt to move the bot up to 1 block
            bb = bbCopy;

            for (int dy = 0; dy <= 32; dy++)
            {
                bool intersectsAny = false;
                for (int i = 0; i < upsCount; i++)
                {
                    if (AABB.Intersects(ref bb, ref ups[i]))
                    {
                        intersectsAny = true; break;
                    }
                }

                if (!intersectsAny)
                {
                    pos.X += dx; pos.Y += dy; pos.Z += dz; Pos = pos;

                    if (dy != 0)
                    {
                        RecalcDownExtent(ref bb, steps, dx, dz);
                        RecalcUpExtent(ref bb, steps, dx, dz);
                    }
                    return;
                }
                bb.Min.Y++; bb.Max.Y++;
            }
        }
Ejemplo n.º 4
0
        public bool CheckIfInsideBlock()
        {
            AABB bb = ModelBB.OffsetPosition(Pos);

            return(AABB.IntersectsSolidBlocks(bb, level));
        }