コード例 #1
0
        protected override bool OnContact(ref MyRBSolverConstraint constraint)
        {
            MyEntity collidedEntity = constraint.GetOtherEntity(this);

            /*
             * // we take the closest collided entity
             * if (m_collidedEntity == null || Vector3.Distance(this.GetPosition(), constraint.m_ContactPoint) < Vector3.Distance(this.GetPosition(), m_collisionPoint.Value))
             * {
             *  m_collisionPoint = constraint.m_ContactPoint;
             *  if (collidedEntity != m_collidedEntity)
             *  {
             *      m_collidedEntity = collidedEntity;
             *      if (m_collidedEntity is MyVoxelMap && m_usedAmmo.AmmoType == MyMwcObjectBuilder_SmallShip_Ammo_TypesEnum.Cannon_Tunnel_Buster)
             *      {
             *          if (m_penetratedVoxelMap == null)
             *          {
             *              m_penetratedVoxelMap = m_collidedEntity as MyVoxelMap;
             *              m_penetrationOrigin = GetPosition();
             *              m_wasPenetration = true;
             *          }
             *
             *          return false;
             *      }
             *  }
             * }
             *
             * if (m_penetratedVoxelMap != null)
             *  return false;
             */
            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Gets the other entity from contact.
        /// </summary>
        /// <param name="eventInfo">The event info.</param>
        /// <param name="sourceEntity">Entity that we knows and for wich we want opposite entity.</param>
        /// <returns></returns>
        internal static MyEntity GetOtherEntity(this MyRBSolverConstraint eventInfo, MyEntity sourceEntity)
        {
            MyPhysicsBody ps1 = (MyPhysicsBody)eventInfo.m_SolverBody1.m_RigidBody.m_UserData;
            MyPhysicsBody ps2 = (MyPhysicsBody)eventInfo.m_SolverBody2.m_RigidBody.m_UserData;

            if (ps1.Entity == sourceEntity)
            {
                return(ps2.Entity);
            }

            return(ps1.Entity);
        }
コード例 #3
0
 /// <summary>
 /// Called when contact
 /// </summary>
 /// <param name="constraint"></param>
 /// <returns>false if contact has to be refused</returns>
 public virtual bool OnContact(ref MyRBSolverConstraint constraint)
 {
     return(this.Entity.NotifyContact(ref constraint));
 }