Exemplo n.º 1
0
        public TransitionState CheckOtherCells(ObjCell currCell)
        {
            var result = TransitionState.OK;

            SpherePath.CellArrayValid   = true;
            SpherePath.HitsInteriorCell = false;
            ObjCell newCell = new ObjCell();    // null check?

            ObjCell.find_cell_list(CellArray, ref newCell, SpherePath);

            foreach (var cell in CellArray.Cells.Values)
            {
                if (cell == null || cell.Equals(currCell))
                {
                    continue;
                }
                var collides = cell.FindCollisions(this);
                switch (collides)
                {
                case TransitionState.Slid:
                    CollisionInfo.ContactPlaneValid   = false;
                    CollisionInfo.ContactPlaneIsWater = false;
                    return(collides);

                case TransitionState.Collided:
                case TransitionState.Adjusted:
                    return(collides);
                }
            }

            SpherePath.CheckCell = newCell;

            if (newCell != null)
            {
                SpherePath.AdjustCheckPos(newCell.ID);
                return(result);
            }
            if (SpherePath.StepDown)
            {
                return(TransitionState.Collided);
            }

            var checkPos = SpherePath.CheckPos;

            if ((checkPos.ObjCellID & 0xFFFF) < 0x100)
            {
                LandDefs.AdjustToOutside(checkPos);
            }

            if (checkPos.ObjCellID != 0)
            {
                SpherePath.AdjustCheckPos(checkPos.ObjCellID);
                SpherePath.SetCheckPos(checkPos, null);

                SpherePath.CellArrayValid = true;

                return(result);
            }
            return(TransitionState.Collided);
        }
Exemplo n.º 2
0
        public TransitionState CheckOtherCells(ObjCell currCell)
        {
            if (DateTime.Now > MaxTime)
            {
                if (ShowDebugInfo)
                {
                    Debug();
                    ShowDebugInfo = false;
                    Bailout       = true;
                }
                return(TransitionState.OK);
            }

            var result = TransitionState.OK;

            SpherePath.CellArrayValid   = true;
            SpherePath.HitsInteriorCell = false;

            //ObjCell newCell = null;
            var newCell = new ObjCell();    // null check?

            ObjCell.find_cell_list(CellArray, ref newCell, SpherePath);

            for (var i = 0; i < CellArray.Cells.Count; i++)
            {
                var cell = CellArray.Cells.Values.ElementAt(i);
                if (cell == null || cell.Equals(currCell))
                {
                    continue;
                }

                var collides = cell.FindCollisions(this);
                switch (collides)
                {
                case TransitionState.Slid:
                    CollisionInfo.ContactPlaneValid   = false;
                    CollisionInfo.ContactPlaneIsWater = false;
                    return(collides);

                case TransitionState.Collided:
                case TransitionState.Adjusted:
                    return(collides);
                }
            }
            SpherePath.CheckCell = newCell;

            if (newCell != null)
            {
                SpherePath.AdjustCheckPos(newCell.ID);
                return(result);
            }

            if (SpherePath.StepDown)
            {
                return(TransitionState.Collided);
            }

            var checkPos = new Position(SpherePath.CheckPos);

            if ((checkPos.ObjCellID & 0xFFFF) < 0x100)
            {
                LandDefs.AdjustToOutside(checkPos);
            }

            if (checkPos.ObjCellID != 0)
            {
                SpherePath.AdjustCheckPos(checkPos.ObjCellID);
                SpherePath.SetCheckPos(checkPos, null);

                SpherePath.CellArrayValid = true;

                return(result);
            }
            return(TransitionState.Collided);
        }