Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.58 KB | None | 0 0
  1. package Game.Pworld.Pmapping;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.HashSet;
  6.  
  7. import Game.Pworld.Pentities.EntityData;
  8. import Game.Pworld.Pentitydefinitions.EntityAttribute;
  9. import Game.Pworld.Pentitydefinitions.GameObjects;
  10.  
  11. public class TotalEntityMap{
  12.  
  13.     GameObjects gObjs = new GameObjects();
  14.    
  15.     Indexer EntityIndX = new Indexer();
  16.     Indexer SectionIndX = new Indexer();
  17.    
  18.     /**
  19.      *  This holds a HashSet of Entity Tags (Int)
  20.      *  Referenced by an EntityAttribute Key.
  21.      *  
  22.      *  @EntityAttribute
  23.      *  Entity Classification
  24.      *  @Integer
  25.      *  Entity Tag Set
  26.      */
  27.    
  28.     HashMap<EntityAttribute, HashSet<Integer>>
  29.                     EntityAttributeSet = new HashMap<EntityAttribute, HashSet<Integer>>();
  30.    
  31.    
  32.     /**
  33.      *  This holds an EntityData object
  34.      *  Referenced by an Entity Tag (Int) Key.
  35.      *  
  36.      *  @Integer
  37.      *  Entity Tag
  38.      *  @EntityData
  39.      *  Entity Variables
  40.      */
  41.    
  42.     HashMap<Integer,EntityData>
  43.                     EntityDataMap = new HashMap<Integer,EntityData>();
  44.  
  45.    
  46.     /**
  47.      *  This holds an Entity Name/Label (String)
  48.      *  Referenced by an Entity Tag (Int) Key.
  49.      *  
  50.      *  @Integer
  51.      *  Entity Tag
  52.      *  @EntityData
  53.      *  Entity Name
  54.      */
  55.    
  56.     HashMap<Integer,String>
  57.                     EntityTagNameMap = new HashMap<Integer,String>();  
  58.    
  59.     /**
  60.      *  This holds a HashSet of Entity Tags (Int)
  61.      *  Referenced by a Section Tag (Int) Key.
  62.      *  
  63.      *  @Integer
  64.      *  Section Tag
  65.      *  @EntityData
  66.      *  Entity Tag Set
  67.      */
  68.        
  69.     HashMap<Integer, HashSet<Integer>>
  70.                     SectionEntitySet = new HashMap<Integer, HashSet<Integer>>();
  71.    
  72.     /**
  73.      *  This holds a SectionInfo Object
  74.      *  Referenced by a Section Tag (Int) Key.
  75.      *  
  76.      *  @Integer
  77.      *  Section Tag
  78.      *  @EntityData
  79.      *  SectionInfo Object
  80.      */
  81.    
  82.     HashMap<Integer, SectionInfo>
  83.                     SectionInfoMap = new HashMap<Integer, SectionInfo>();
  84.    
  85.    
  86.     public TotalEntityMap(){           
  87.         for(int i = 0; i < EntityAttribute.values().length; i++){
  88.             EntityAttributeSet.put(EntityAttribute.values()[i],new HashSet<Integer>());
  89.         }      
  90.     }
  91.    
  92.    
  93.     /**
  94.      *
  95.      * Adds an Entity to the maps.
  96.      * If the tag exists, generated from {@link #EntityIndX} then it will not store the Entity and return.
  97.      *
  98.      * @param entityData
  99.      */
  100.    
  101.     public void addEntity(EntityData entityData){
  102.         int tag = EntityIndX.getNextTag();     
  103.        
  104.         if(EntityTagNameMap.containsKey(tag)){
  105.             System.out.println("Tag in use... "+tag+": ");
  106.             System.out.println("In Class: "+ this.getClass().getSimpleName()+": Method  addEntity");
  107.             return;
  108.         }
  109.        
  110.         EntityDataMap.put(tag, entityData);
  111.        
  112.         EntityTagNameMap.put(tag, entityData.getName());
  113.        
  114.         for(int i = 0; i < EntityAttribute.values().length; i++){
  115.             if(gObjs.getGameObject(entityData.getName()).getAttributes().containsKey(EntityAttribute.values()[i])){
  116.                 EntityAttributeSet.get(EntityAttribute.values()[i]).add(tag);
  117.             }
  118.         }
  119.     }
  120.    
  121.     /**
  122.      *
  123.      * Adds a Section to the maps.
  124.      * If the tag exists, generated from {@link #SectionIndX} then is will not store the Entity and return.
  125.      * This requires a HashSet of SectionEntities and SectionInfo to be complete on creation.
  126.      * @param SectionEntities
  127.      * @param sectionInfo
  128.      */
  129.    
  130.     public void addSection(HashSet<Integer> SectionEntities, SectionInfo sectionInfo){
  131.         int tag = EntityIndX.getNextTag();
  132.        
  133.         if(SectionEntitySet.containsKey(tag)){
  134.             System.out.println("Tag in use... "+tag+": ");
  135.             System.out.println("In Class: "+ this.getClass().getSimpleName()+": Method  addSection");
  136.             return;
  137.         }
  138.        
  139.         SectionEntitySet.put(tag, SectionEntities);
  140.         SectionInfoMap.put(tag, sectionInfo);
  141.        
  142.     }
  143.    
  144.    
  145.    
  146.    
  147.    
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement