TargetVisibilityPatch.h

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 ////////////////////////////////////////////////////////////////////////////////
00020 
00021 #if !defined(__INCLUDE_TargetVisibilityPatchh_INCLUDE__)
00022 #define __INCLUDE_TargetVisibilityPatchh_INCLUDE__
00023 
00024 #include <common/Vector.h>
00025 #include <set>
00026 
00027 class Target;
00028 class TargetVisibilityPatch
00029 {
00030 public:
00031         TargetVisibilityPatch();
00032         ~TargetVisibilityPatch();
00033 
00034         void setLocation(int x, int y);
00035         bool setVisible(float distance);
00036         void setNotVisible();
00037 
00038         bool hasTrees() { return !trees_.empty(); }
00039         bool hasTargets() { return !targets_.empty(); }
00040 
00041         float getDistance() { return distance_; }
00042         Vector &getPosition() { return position_; }
00043         bool getVisible() { return visible_; }
00044 
00045         static std::set<void *> &getLargeTargets() { return largeTargets_; }
00046         static void addLargeTarget(Target *target) { largeTargets_.insert(target); }
00047         static void removeLargeTarget(Target *target) { largeTargets_.erase(target); }
00048 
00049         std::set<void *> &getTargets() { return targets_; }
00050         void addTarget(Target *target) { targets_.insert(target); }
00051         void removeTarget(Target *target) { targets_.erase(target); }
00052 
00053         std::set<void *> &getTrees() { return trees_; }
00054         void addTree(Target *target) { trees_.insert(target); }
00055         void removeTree(Target *target) { trees_.erase(target); }       
00056 
00057         std::set<void *> &getTooltips() { return tooltips_; }
00058         void addTooltip(Target *target) { tooltips_.insert(target); }
00059         void removeTooltip(Target *target) { tooltips_.erase(target); } 
00060 
00061 protected:
00062         int x_, y_;
00063         bool visible_;
00064         float distance_;
00065         Vector position_;
00066         std::set<void *> trees_, targets_, tooltips_;
00067         static std::set<void *> largeTargets_;
00068 };
00069 
00070 class TargetVisibilityIterator
00071 {
00072 public:
00073         void init(std::set<void *> &set)
00074         {
00075                 set_ = &set;
00076                 lastItor = set_->end();
00077                 itor = set_->begin();
00078         }
00079 
00080         void *getNext()
00081         {
00082                 if (itor == lastItor) return 0;
00083                 void *result = *itor;
00084                 ++itor;
00085                 return result;
00086         }
00087 
00088 private:
00089         std::set<void *> *set_;
00090         std::set<void *>::iterator lastItor;
00091         std::set<void *>::iterator itor;
00092 };
00093 
00094 #endif // __INCLUDE_TargetVisibilityPatchh_INCLUDE__

Generated on Mon Feb 16 15:14:47 2009 for Scorched3D by  doxygen 1.5.3