Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 2nd, 2013  |  syntax: C#  |  size: 1.23 KB  |  views: 28  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. public class EntityContainer
  2.     {
  3.         public GameWorld GW;
  4.         public Dictionary<int, BaseEntity> All;
  5.         public Dictionary<Segment, List<BaseEntity>> BySegment;
  6.         public Dictionary<EntitySchematic, List<BaseEntity>> BySchematic;
  7.  
  8.         public EntityContainer(GameWorld parent)
  9.         {
  10.             GW = parent;
  11.             All = new Dictionary<int, BaseEntity>();
  12.             BySegment = new Dictionary<Segment, List<BaseEntity>>();
  13.             foreach (Segment segment in GameWorld.Segments)
  14.             {
  15.                 BySegment.Add(segment, new List<BaseEntity>());
  16.             }
  17.  
  18.             BySchematic = new Dictionary<EntitySchematic, List<BaseEntity>>();
  19.             BySchematic.Add(EntitySchematics.Tree, new List<BaseEntity>());
  20.         }
  21.  
  22.         public void AddEntitiy(BaseEntity entity)
  23.         {
  24.             All.Add(entity.ID, entity);
  25.             BySegment[entity.GetSegment()].Add(entity);
  26.             BySchematic[entity.Schematic].Add(entity);
  27.         }
  28.  
  29.         public void RemoveEntitiy(BaseEntity entity)
  30.         {
  31.             All.Remove(entity);
  32.             BySegment[entity.GetSegment()].Remove(entity);
  33.             BySchematic[entity.Schematic].Remove(entity);
  34.         }
  35.     }
clone this paste RAW Paste Data