Planeshift
|
00001 /* 00002 * psproxlist.h 00003 * 00004 * Copyright (C) 2001 Atomic Blue ([email protected], http://www.atomicblue.org) 00005 * 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation (version 2 of the License) 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 * 00018 * 00019 */ 00020 #ifndef __PS_IMP_PROXIMITYLIST__ 00021 #define __PS_IMP_PROXIMITYLIST__ 00022 00023 //============================================================================= 00024 // Crystal Space Includes 00025 //============================================================================= 00026 #include <cstypes.h> 00027 #include <iutil/comp.h> 00028 #include <csutil/hash.h> 00029 #include <csutil/scf.h> 00030 #include <net/netbase.h> 00031 00032 //============================================================================= 00033 // Project Includes 00034 //============================================================================= 00035 #include "util/psconst.h" 00036 00037 //============================================================================= 00038 // Local Includes 00039 //============================================================================= 00040 00041 class gemObject; 00042 struct iObjectRegistry; 00043 class EntityManager; 00044 00045 /* ProximityList must maintain following properties: 00046 * - values in objectsThatWatchMe are unique 00047 * - values in objectsThatIWatch are unique 00048 * - object X is in objectsThatWatchMe of object Y <===> object Y must be in objectsThatIWatch of X 00049 * - objects with GetClientID()==0 have empty objectsThatIWatch 00050 * - correspondence between objectsThatWatchMe and objectsThatWatchMe_touched 00051 * objectsThatIWatch and objectsThatIWatch_touched 00052 */ 00053 00054 class ProximityList 00055 { 00056 protected: 00057 gemObject* self; 00058 00059 csArray<PublishDestination> objectsThatWatchMe; 00060 csArray<gemObject*> objectsThatIWatch; 00061 csArray<csTicks> destRangeTimer; 00062 00063 csArray<bool> objectsThatWatchMe_touched; 00064 csArray<bool> objectsThatIWatch_touched; 00065 00066 int clientnum; 00067 bool firstFrame; 00068 csVector3 oldPos; 00069 InstanceID oldInstance; 00070 00071 EntityManager* entityManager; 00072 00074 void AddWatcher(gemObject* interestedobject, float range); 00075 00077 void RemoveWatcher(gemObject* object); 00078 00079 bool IsNear(iSector* sector,csVector3 &pos,gemObject* object,float radius); 00080 bool FindObject(gemObject* object); 00081 PublishDestination* FindObjectThatWatchesMe(gemObject* object, uint &x); 00082 bool FindObjectThatIWatch(gemObject* object); 00083 00084 void TouchObjectThatWatchesMe(gemObject* object,float newrange); 00085 00086 00087 void UpdatePublishDestRange(PublishDestination* pd, 00088 gemObject* myself, 00089 gemObject* object, 00090 uint objIdx, 00091 float newrange); 00092 00093 public: 00094 ProximityList(iObjectRegistry* object_reg, gemObject* parent, EntityManager* entitymanager); 00095 ~ProximityList(); 00096 00097 bool Initialize(int cnum,gemObject* parent); 00098 00101 bool StartWatching(gemObject* object, float range); 00102 00104 void EndWatching(gemObject* object); 00105 00107 bool StartMutualWatching(int othercnum, gemObject* otherObject,float range); 00108 00110 bool EndMutualWatching(gemObject* fromobject); 00111 00112 csArray<PublishDestination> &GetClients() 00113 { 00114 return objectsThatWatchMe; 00115 } 00116 int GetClientID() 00117 { 00118 return clientnum; 00119 } 00120 00121 bool FindClient(uint32_t cnum); 00122 gemObject* FindObjectName(const char* name); 00123 00127 bool CheckUpdateRequired(); 00128 float RangeTo(gemObject* object, bool ignoreY = false, bool ignoreInstance = false); 00129 void DebugDumpContents(csString &out); 00130 00131 void ClearTouched(); 00132 bool GetUntouched_ObjectThatWatchesMe(gemObject* &object); 00133 bool GetUntouched_ObjectThatIWatch(gemObject* &object); 00134 }; 00135 00136 #endif 00137