//----------------------------------------------------------------------
 //Clear From Registry
 //----------------------------------------------------------------------
 public static void ClearAllForceIntegrators(PhysicsObject obj)
 {
     List<KeyValuePair<PhysicsObject, ForceIntegratorParams>> directory;
     List<KeyValuePair<PhysicsObject, ForceIntegratorParams>> toRemove = new List<KeyValuePair<PhysicsObject, ForceIntegratorParams>>();
     foreach (ForceIntegrator.Type type in Enum.GetValues(typeof(ForceIntegrator.Type)).Cast<ForceIntegrator.Type>())
     {
         if (registry.ContainsKey(type))
         {
             if (registry.TryGetValue(type, out directory))
             {
                 foreach (KeyValuePair<PhysicsObject, ForceIntegratorParams> pair in directory)
                 {
                     if (pair.Key.Equals(obj) || pair.Value.Equals(obj))
                     {
                         toRemove.Add(pair);
                     }
                 }
                 foreach (KeyValuePair<PhysicsObject, ForceIntegratorParams> trash in toRemove)
                 {
                     directory.Remove(trash);
                 }
             }
         }
     }
 }
 public bool Equals(PhysicsObject obj)
 {
     if (obj.ID == this.ID)
     {
         return true;
     }
     return false;
 }
        //----------------------------------------------------------------------
        //Add To Registry
        //----------------------------------------------------------------------
        public static void AddToRegistry(PhysicsObject obj1, ForceIntegratorParams obj2, ForceIntegrator.Type type)
        {
            List<KeyValuePair<PhysicsObject, ForceIntegratorParams>> directory;
            if (registry.ContainsKey(type))
            {
                if (registry.TryGetValue(type, out directory))
                {
                    directory.Add(new KeyValuePair<PhysicsObject, ForceIntegratorParams>(obj1, obj2));
                    return;
                }
            }

            directory = new List<KeyValuePair<PhysicsObject, ForceIntegratorParams>>();
            directory.Add(new KeyValuePair<PhysicsObject, ForceIntegratorParams>(obj1, obj2));
            registry.Add(type, directory);
        }
Exemplo n.º 4
0
 public FighterJet(Texture2D jet)
 {
     image = jet;
     model = new PhysicsObject();
     model.SetMass(FIGHTER_JET_MASS);
 }
 public SmallAirplane(Texture2D air)
 {
     image = air;
     model = new PhysicsObject();
     model.SetMass(SMALL_AIRPLANE_MASS);
 }
 public PaperAirplane(Texture2D paper)
 {
     image = paper;
     model = new PhysicsObject();
     model.SetMass(PAPER_AIRPLANE_MASS);
 }
 //----------------------------------------------------------------------
 //Remove From Registry
 //----------------------------------------------------------------------
 public static void RemoveFromRegistry(PhysicsObject obj1, ForceIntegratorParams obj2, ForceIntegrator.Type type)
 {
     List<KeyValuePair<PhysicsObject, ForceIntegratorParams>> directory;
     KeyValuePair<PhysicsObject, ForceIntegratorParams> pair = (new KeyValuePair<PhysicsObject, ForceIntegratorParams>(obj1, obj2));
     if (registry.ContainsKey(type))
     {
         if (registry.TryGetValue(type, out directory))
         {
             if (directory.Contains(pair))
             {
                 directory.Remove(pair);
             }
         }
     }
 }