public void collide_against(icollision target) { var target_types = target.GetType().GetNestedTypes().Union(new Type[] { target.GetType() }); if (target_types.Any(t => t == typeof(base_plane))) collide_against_plane((base_plane)target); //else if (target_types.Any(t => t == typeof(map_block))) // collide_against_map_block((map_block)target); }
public static void collisions(icollision a, icollision b) { if (collisions_test(a, b)) { a.collide_against(b); b.collide_against(a); } }
public static bool collisions_test(icollision a, icollision b) { dynamic ba = a.bounding; dynamic bb = b.bounding; try { return (ba.GetType() == typeof(Plane) || bb.GetType() == typeof(Plane)) ? ba.Intersects(bb) != PlaneIntersectionType.Front : ba.Intersects(bb); } catch (MissingMethodException e) { Debug.Assert( (ba.GetType() == typeof(Plane) && bb.GetType() == typeof(Plane)) || (ba.GetType() == typeof(Plane) && bb.GetType() == typeof(Ray)) || (ba.GetType() == typeof(Ray) && bb.GetType() == typeof(Ray)) , e.Message ); } return false; }
public virtual void collide_against(icollision target) { }