Esempio n. 1
0
 public void Despawn(Entity e)
 {
     Entities.Remove(e);
     if (e.Ticks)
     {
         Tickers.Remove(e);
     }
     if (e.CastShadows)
     {
         ShadowCasters.Remove(e);
     }
     if (e is PhysicsEntity)
     {
         PhysicsEntity pe = e as PhysicsEntity;
         pe.DestroyBody();
         for (int i = 0; i < pe.Joints.Count; i++)
         {
             DestroyJoint(pe.Joints[i]);
         }
         if (pe.GenBlockShadows)
         {
             PhysicsEntity[] neo   = new PhysicsEntity[GenShadowCasters.Length - 1];
             int             x     = 0;
             bool            valid = true;
             for (int i = 0; i < GenShadowCasters.Length; i++)
             {
                 if (GenShadowCasters[i] != pe)
                 {
                     neo[x++] = GenShadowCasters[i];
                     if (x == GenShadowCasters.Length)
                     {
                         valid = false;
                         return;
                     }
                 }
             }
             if (valid)
             {
                 GenShadowCasters = neo;
             }
         }
     }
     else if (e is PrimitiveEntity)
     {
         ((PrimitiveEntity)e).Destroy();
     }
 }