Exemple #1
0
        public virtual void smartAdd(cCritter pcritter, cCritter pcritterother)
        {
            cColliderPair pnewpair          = null;
            int           collideswith      = pcritter.collidesWith(pcritterother);
            int           othercollideswith = pcritterother.collidesWith(pcritter);

            if (collideswith == DONTCOLLIDE || othercollideswith == DONTCOLLIDE)
            {
                return;                  //Don't collide if either one is unwilling, even if the other was willing. */
            }
            if (collideswith == COLLIDEASCALLER || collideswith == COLLIDEEITHERWAY)
            {
                pnewpair = new cColliderPair(pcritter, pcritterother);
            }
            else             //(collideswith == cCollider::COLLIDEASARG)
            {
                pnewpair = new cColliderPair(pcritterother, pcritter);
            }
            if ((pnewpair._pcrittercaller.CollidePriority == CP_WALL) ||
                (pnewpair._pcritterarg.CollidePriority == CP_WALL))
            {
                _wallpairs.Add(pnewpair);
            }
            else
            {
                _nonwallpairs.Add(pnewpair);
            }

            //ASSERT(collideswith == -othercollideswith);

            /* We chose the collision type codes to make this ASSERT
             * likely at this point, but it might not always be true.  Only comment it in
             * for testing. Do note that we bail before we hit it if either type is DONTCOLLIDE. */
        }