View Javadoc

1   /*
2    * Copyright (C) 2014 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic
3    *
4    * This program is free software: you can redistribute it and/or modify
5    * it under the terms of the GNU General Public License as published by
6    * the Free Software Foundation, either version 3 of the License, or
7    * (at your option) any later version.
8    *
9    * This program is distributed in the hope that it will be useful,
10   * but WITHOUT ANY WARRANTY; without even the implied warranty of
11   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12   * GNU General Public License for more details.
13   *
14   * You should have received a copy of the GNU General Public License
15   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16   */
17  package cz.cuni.amis.pogamut.ut3.agent.module.sensor;
18  
19  import cz.cuni.amis.pogamut.base.communication.worldview.IWorldView;
20  import cz.cuni.amis.pogamut.base.communication.worldview.event.IWorldEventListener;
21  import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
22  import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.AgentInfo;
23  import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.visibility.Visibility;
24  import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
25  import cz.cuni.amis.pogamut.ut2004.communication.messages.ItemType;
26  //import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.SeeVolume;
27  import java.util.ArrayList;
28  import java.util.HashMap;
29  import java.util.logging.Logger;
30  
31  /**
32   *
33   * @author Evers
34   */
35  public class UT3Visibility extends Visibility {
36          
37          /**
38           * Returns the unreal id's of the given itemtype.
39           * TODO: Add getVisibleVolumes
40           */
41      /*
42          public ArrayList<UnrealId> getVisibleVolumeNavPoints(ItemType itemType) {
43                  if(seeVolumeListener.visible.containsKey(itemType))
44                          return seeVolumeListener.visible.get(itemType);
45                  else
46                          return new ArrayList<UnrealId>();
47          }
48  
49          private class SeeVolumeListener implements IWorldEventListener<SeeVolume>
50          {
51                  private HashMap<ItemType, ArrayList<UnrealId>> visible = new HashMap<ItemType, ArrayList<UnrealId>>();
52                  
53                  @Override
54                  public void notify(SeeVolume event)
55                  {
56                          // get the type of volume
57                          if(!visible.containsKey(event.getType()))
58                                  visible.put(event.getType(), new ArrayList<UnrealId>());
59                          ArrayList<UnrealId> ids = visible.get(event.getType());
60                          // get the corresponding ids
61                          if(event.isVisible() && !ids.contains(event.getId()))
62                                  ids.add(event.getId());
63                          if(!event.isVisible() && ids.contains(event.getId()))
64                                  ids.remove(event.getId());
65                  }
66                  
67                  public SeeVolumeListener(IWorldView worldView)
68                  {
69                          worldView.addEventListener(SeeVolume.class, this);
70                  }
71          }
72         
73          SeeVolumeListener seeVolumeListener;
74          */
75          public UT3Visibility(UT2004Bot bot, AgentInfo info) {
76  		this(bot, info, null);
77  	}
78          
79          public UT3Visibility(UT2004Bot bot, AgentInfo info, Logger log)
80          {
81                  super(bot, info, log);
82                  //seeVolumeListener = new SeeVolumeListener(worldView);
83          }        
84  }