00001 /* 00002 Copyright 2003 - 2005 Elliott Kleinrock, Dan Neely, Kurt W. Over, Damon Domjan 00003 00004 This file is part of FreeStars, a free clone of the Stars! game. 00005 00006 FreeStars 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 FreeStars 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 FreeStars; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 00020 The full GPL Copyright notice should be in the file COPYING.txt 00021 00022 Contact: 00023 Email Elliott at 9jm0tjj02@sneakemail.com 00024 */ 00025 00030 //Dan Neely 00031 //2-9-03 fully debuged 00032 //2-11-03 changed to inherit from GameObject 00033 //2-13-03 reordered methods to be consistant in .h and .cpp 00034 00035 #ifndef FREESTARS_MINEFIELD_HEADER_INCLUDED 00036 #define FREESTARS_MINEFIELD_HEADER_INCLUDED 00037 00038 #include "Location.h" 00039 00040 // todo shift center if mines deployed elsehwere in field. how is this done? 00041 // size zero fields aren't destroyed. I think that it should be a container 00042 // function 00043 // Collision damage 00044 //mesage generation 00045 00050 class MineField : public CargoHolder 00051 { 00052 public: 00053 MineField(int mineType, const Location & L, int num, Player * owner); 00054 ~MineField();//only to make gameobject happy. mmineType points to an 00055 //element in a reference list not a unique object in the class 00056 00057 int GetNumMines() const { return mNumMines; } 00058 void AddMines(const Location & L, int n); 00059 void Sweep(const Fleet * F); 00060 void Decay(int numPlanets); 00061 void ReduceFieldCollision(); 00062 bool TestCollide(const Location & L, int warp); 00063 bool CollisionPossible(const Location & L1, const Location & L2); 00064 bool InField(int x, int y); // is x,y in the field 00065 bool InField(const Location & L); // is x,y in the field 00066 int GetMineType() const { return mMineType; } 00067 double GetRadius() const { return sqrt(double(mNumMines)); } 00068 bool IsEmpty() const { return mNumMines == 0; } 00069 00070 virtual long GetCargoCapacity() const { return 0; } 00071 virtual double GetMaxTachyon() const { return 1.0; } 00072 virtual long GetScanPen() const { return -1; } 00073 virtual long GetScanSpace() const; 00074 virtual bool CanLoadBy(const Player *) const { return false; } 00075 virtual void SetCanLoadBy(const Player *) {} 00076 virtual long GetCloak(const Player * p, bool pen) const; 00077 00078 protected: 00079 deque<bool> mHadSeen; 00080 int mNumMines; 00081 int mMineType; // 0 = standard, 1 heavy, 2 speedtrap 00082 Player * mOwner; 00083 bool RectFilter(int x1, int y1, int x2, int y2); //true if rectange 00084 //intersect. this indicates colision is possible 00085 //this is the preliminary step in colisions possible 00086 00087 00088 // don't think I need either of these, just leaving them incase I'm wrong 00089 // void CollisionPathFindEdge(int &x1, int &y1, int x2, int y2); 00090 // x1,y1 and x2,y2 straddle a minefield edge 00091 // returns the boundary in the coord that was originally 00092 // outside the field second coord contains garbage 00093 // x2,y2 must be in field, x1,y1 in open space. 00094 // errortrap aborts program if not true 00095 // void CollisionPath(int &x1, int &y1, int &x2, int &y2); 00096 //takes the start/end points of the path and returns the start/end 00097 //end points of the path segment through the minefield the boundary 00098 //is defined as the 1st/last points of the path in the field 00099 00100 }; 00101 00102 #endif //#ifndef FREESTARS_MINEFIELD_HEADER_INCLUDED