lib/gamebox/core/arbiter.rb
# This reads terribly and violates open-closed principle,
# but does perform better than any dynamic lookup based on shape_types
This reads terribly and violates open-closed principle,
but does perform better than any dynamic lookup based on shape_types
This reads terribly and violates open - closed principle but does perform better than any dynamic lookup based on shape_types
def collide?(object, other)
    case object.shape_type
    when :circle
      case other.shape_type
      when :circle
        collide_circle_circle? object, other
      when :aabb
        collide_circle_aabb? object, other
      when :polygon
        collide_circle_polygon? object, other
      end
    when :aabb
      case other.shape_type
      when :circle
        collide_aabb_circle? object, other
      when :aabb
        collide_aabb_aabb? object, other
      when :polygon
        collide_aabb_polygon? object, other
      end
    when :polygon
      case other.shape_type
      when :circle
        collide_polygon_circle? object, other
      when :aabb
        collide_polygon_aabb? object, other
      when :polygon
        collide_polygon_polygon? object, other
      end
    end
  end
def collide? ( object , other ) case object . shape_type when :circle case other . shape_type when :circle collide_circle_circle? object , other when :aabb collide_circle_aabb? object , other when :polygon collide_circle_polygon? object , other end when :aabb case other . shape_type when :circle collide_aabb_circle? object , other when :aabb collide_aabb_aabb? object , other when :polygon collide_aabb_polygon? object , other end when :polygon case other . shape_type when :circle collide_polygon_circle? object , other when :aabb collide_polygon_aabb? object , other when :polygon collide_polygon_polygon? object , other end end end
This reads terribly and violates open-closed principle,
but does perform better than any dynamic lookup based on shape_types
This reads terribly and violates open - closed principle but does perform better than any dynamic lookup based on shape_types
object
<not_specific>
other
<not_specific>