physicallayer/pl.h
00001 /* 00002 Crystal Space Entity Layer 00003 Copyright (C) 2001-2005 by Jorrit Tyberghein 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library 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 GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public 00016 License along with this library; if not, write to the Free 00017 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 */ 00019 00020 #ifndef __CEL_PL_PL__ 00021 #define __CEL_PL_PL__ 00022 00023 #include "cstypes.h" 00024 #include "csutil/scf.h" 00025 #include "csutil/strset.h" 00026 #include "csutil/ref.h" 00027 #include "csutil/csstring.h" 00028 #include "physicallayer/messaging.h" 00029 00030 struct iObject; 00031 struct iCelEntity; 00032 struct iCelEntityList; 00033 struct iCelEntityIterator; 00034 struct iCelDataBuffer; 00035 struct iCelParameterBlock; 00036 struct iCelPropertyClass; 00037 struct iCelPropertyClassFactory; 00038 struct iCelBlLayer; 00039 struct iCelBehaviour; 00040 struct iCelEntityTemplate; 00041 struct iSector; 00042 struct iCamera; 00043 class csVector3; 00044 class csBox3; 00045 class csString; 00046 00047 #define CEL_EVENT_PRE 0 00048 #define CEL_EVENT_VIEW 1 00049 #define CEL_EVENT_POST 2 00050 00051 #define CEL_PROPCLASS_END (void*)0 00052 #define CEL_PARAM_END (void*)0 00053 00055 typedef csHash<csStringFast<12>, csStringFast<12> > celEntityTemplateParams; 00056 00057 struct iCelEntityTracker; 00058 00063 struct iCelNewEntityCallback : public virtual iBase 00064 { 00065 SCF_INTERFACE (iCelNewEntityCallback, 0, 0, 2); 00066 00068 virtual void NewEntity (iCelEntity* entity) = 0; 00069 }; 00070 00075 struct iCelEntityRemoveCallback : public virtual iBase 00076 { 00077 SCF_INTERFACE (iCelEntityRemoveCallback, 0, 0, 2); 00078 00080 virtual void RemoveEntity (iCelEntity* entity) = 0; 00081 }; 00082 00083 00088 struct iCelTimerListener : public virtual iBase 00089 { 00090 SCF_INTERFACE (iCelTimerListener, 0, 0, 2); 00091 00096 virtual void TickEveryFrame () = 0; 00097 00102 virtual void TickOnce () = 0; 00103 }; 00104 00108 struct iCelPlLayer : public virtual iBase 00109 { 00110 SCF_INTERFACE (iCelPlLayer, 0, 4, 2); 00111 00117 virtual csPtr<iCelEntity> CreateEntity () = 0; 00118 00123 virtual csPtr<iCelEntity> CreateEntityInScope (int scope) = 0; 00124 00130 virtual csPtr<iCelEntity> CreateEntity (uint id) = 0; 00131 00147 virtual csPtr<iCelEntity> CreateEntity (const char* entname, 00148 iCelBlLayer* bl, const char* bhname, ...) = 0; 00149 00155 virtual void RemoveEntity (iCelEntity* entity) = 0; 00156 00160 virtual void RemoveEntities () = 0; 00161 00166 virtual iCelEntityTemplate* CreateEntityTemplate (const char* factname) = 0; 00167 00171 virtual void RemoveEntityTemplate (iCelEntityTemplate* entfact) = 0; 00172 00176 virtual void RemoveEntityTemplates () = 0; 00177 00181 virtual iCelEntityTemplate* FindEntityTemplate (const char* factname) = 0; 00182 00186 virtual size_t GetEntityTemplateCount () const = 0; 00187 00191 virtual iCelEntityTemplate* GetEntityTemplate (size_t idx) const = 0; 00192 00200 virtual iCelEntity* CreateEntity (iCelEntityTemplate* factory, 00201 const char* name, const celEntityTemplateParams& params) = 0; 00202 00212 virtual iCelEntity* CreateEntity (iCelEntityTemplate* factory, 00213 const char* name, ...) = 0; 00214 00221 virtual csPtr<iCelDataBuffer> CreateDataBuffer (long serialnr) = 0; 00222 00228 virtual void AttachEntity (iObject* object, iCelEntity* entity) = 0; 00229 00233 virtual void UnattachEntity (iObject* object, iCelEntity* entity) = 0; 00234 00238 virtual iCelEntity* GetEntity (uint id) = 0; 00239 00243 virtual size_t GetEntityCount () const = 0; 00244 00248 virtual iCelEntity* GetEntityByIndex (size_t idx) const = 0; 00249 00255 virtual iCelEntity* FindEntity (const char* name) = 0; 00256 00261 virtual iCelBehaviour* GetBehaviour (uint id) = 0; 00262 00266 virtual iCelEntity* FindAttachedEntity (iObject* object) = 0; 00267 00275 virtual csPtr<iCelEntityList> FindNearbyEntities (iSector* sector, 00276 const csVector3& pos, float radius, bool do_invisible = false, 00277 csStringID cls = csInvalidStringID) = 0; 00278 00286 virtual csPtr<iCelEntityList> FindNearbyEntities (iSector* sector, 00287 const csBox3& box, bool do_invisible = false, 00288 csStringID cls = csInvalidStringID) = 0; 00289 00297 virtual csPtr<iCelEntityList> FindNearbyEntities (iSector* sector, 00298 const csVector3& start, const csVector3& end, 00299 bool do_invisible = false, 00300 csStringID cls = csInvalidStringID) = 0; 00301 00307 virtual iCelEntity* GetHitEntity (iCamera* camera, int x, int y) = 0; 00308 00312 virtual csPtr<iCelEntityList> CreateEmptyEntityList () = 0; 00313 00318 virtual iCelEntityTracker* CreateEntityTracker (const char* name) = 0; 00319 00323 virtual iCelEntityTracker* FindEntityTracker (const char* name) = 0; 00324 00328 virtual void RemoveEntityTracker (iCelEntityTracker* tracker) = 0; 00329 00337 virtual void SetEntityAddonAllowed (bool allow) = 0; 00338 00342 virtual bool IsEntityAddonAllowed () const = 0; 00343 00344 //------------------------------------------------------------------------- 00345 00351 virtual bool LoadPropertyClassFactory (const char* plugin_id) = 0; 00352 00359 virtual void RegisterPropertyClassFactory (iCelPropertyClassFactory* pf, 00360 const char* altname = 0) = 0; 00361 00365 virtual void UnregisterPropertyClassFactory ( 00366 iCelPropertyClassFactory* pf) = 0; 00367 00371 virtual size_t GetPropertyClassFactoryCount () const = 0; 00372 00376 virtual iCelPropertyClassFactory* GetPropertyClassFactory (size_t idx) 00377 const = 0; 00378 00382 virtual iCelPropertyClassFactory* FindPropertyClassFactory ( 00383 const char* name) const = 0; 00384 00390 virtual iCelPropertyClass* CreatePropertyClass (iCelEntity* entity, 00391 const char* propname, const char* tagname = 0) = 0; 00392 00398 virtual iCelPropertyClass* CreateTaggedPropertyClass 00399 (iCelEntity* entity, const char* propname, const char* tagname) = 0; 00400 00401 //------------------------------------------------------------------------- 00402 00406 virtual void RegisterBehaviourLayer (iCelBlLayer* bl) = 0; 00407 00411 virtual void UnregisterBehaviourLayer (iCelBlLayer* bl) = 0; 00412 00416 virtual size_t GetBehaviourLayerCount () const = 0; 00417 00421 virtual iCelBlLayer* GetBehaviourLayer (size_t idx) const = 0; 00422 00426 virtual iCelBlLayer* FindBehaviourLayer (const char* name) const = 0; 00427 00428 //------------------------------------------------------------------------- 00429 00435 virtual void Cache (iBase* object) = 0; 00436 00440 virtual void Uncache (iBase* object) = 0; 00441 00447 virtual void CleanCache () = 0; 00448 00449 //------------------------------------------------------------------------- 00450 00461 virtual csStringID FetchStringID (const char* str) = 0; 00462 00467 virtual const char* FetchString (csStringID id) = 0; 00468 00473 virtual void AddEntityRemoveCallback (iCelEntityRemoveCallback* clback) = 0; 00474 00478 virtual void RemoveEntityRemoveCallback ( 00479 iCelEntityRemoveCallback* clback) = 0; 00480 00485 virtual void AddNewEntityCallback (iCelNewEntityCallback* clback) = 0; 00486 00490 virtual void RemoveNewEntityCallback (iCelNewEntityCallback* clback) = 0; 00491 00492 //------------------------------------------------------------------------- 00493 00507 virtual void CallbackEveryFrame (iCelTimerListener* listener, int where) = 0; 00508 00523 virtual void CallbackOnce (iCelTimerListener* listener, csTicks delta, 00524 int where) = 0; 00525 00529 virtual void RemoveCallbackEveryFrame (iCelTimerListener* listener, 00530 int where) = 0; 00531 00535 virtual void RemoveCallbackOnce (iCelTimerListener* listener, int where) = 0; 00536 00543 virtual int AddScope (csString version, int size) = 0; 00544 00545 /* 00546 * Get a list of all entities with a certain class assigned. 00547 * The list returned is always kept up to date by the physical layer so 00548 * you can save the reference safely and keep using it. 00549 */ 00550 virtual const csRef<iCelEntityList> GetClassEntitiesList ( 00551 csStringID classid) = 0; 00552 00553 /* 00554 * Send a message to all entities in an entity list. Returns the number 00555 * of entities that understood and handled the message. 00556 * Note that this version of SendMessage only sends a message to the 00557 * behaviour of the entity and not the channel. Use the new messaging 00558 * system for sending a message to the channel. 00559 * \deprecated Use SendMessage() for new message system instead. 00560 */ 00561 CS_DEPRECATED_METHOD_MSG("Use SendMessage() for new message system instead.") 00562 virtual int SendMessage (iCelEntityList *entlist, const char* msgname, 00563 iCelParameterBlock* params, ...) = 0; 00564 00565 /* 00566 * Send a message to all entities in an entity list. Returns the number 00567 * of entities that understood and handled the message. 00568 * Note that this version of SendMessage only sends a message to the 00569 * behaviour of the entity and not the channel. Use the new messaging 00570 * system for sending a message to the channel. 00571 * \deprecated Use SendMessage() for new message system instead. 00572 */ 00573 CS_DEPRECATED_METHOD_MSG("Use SendMessage() for new message system instead.") 00574 virtual int SendMessageV (iCelEntityList *entlist, const char* msgname, 00575 iCelParameterBlock* params, va_list arg) = 0; 00576 00577 /* 00578 * Send a message to all entities in an entity list. Returns the number 00579 * of entities that understood and handled the message. 00580 * Note that this version of SendMessage() sends a message to the channel 00581 * of the entity only and not the behaviour (unless the behaviour also 00582 * happens to subscribe to the channel). 00583 * \param msgid is the message ID. 00584 * \param sender is the sender from this message. 00585 * \param params contains the parameters for this message. 00586 * \param ret if this is not 0 then it can be used to collect information 00587 * from the receivers. If 0 then information from the receivers is simply 00588 * ignored. 00589 */ 00590 virtual int SendMessage (const char* msgid, iMessageSender* sender, 00591 iCelEntityList *entlist, iCelParameterBlock* params, 00592 iCelDataArray* ret = 0) = 0; 00593 00598 virtual iMessageSender* QueryMessageSender () = 0; 00599 }; 00600 00606 struct iCelEntityTracker : public virtual iBase 00607 { 00608 SCF_INTERFACE (iCelEntityTracker, 0, 0, 3); 00609 00613 virtual const char* GetName () const = 0; 00614 00620 virtual bool AddEntity (iCelEntity* entity) = 0; 00621 00625 virtual void RemoveEntity (iCelEntity* entity) = 0; 00626 00630 virtual void RemoveEntities () = 0; 00631 00638 virtual csPtr<iCelEntityList> FindNearbyEntities (iSector* sector, 00639 const csVector3& pos, float radius, 00640 csStringID cls = csInvalidStringID) = 0; 00641 00645 virtual csPtr<iCelEntityIterator> GetIterator () = 0; 00646 00650 virtual void AddEntities (iCelEntityTracker* tracker) = 0; 00651 00655 virtual void RemoveEntities (iCelEntityTracker* tracker) = 0; 00656 }; 00657 00658 #endif // __CEL_PL_PL__ 00659
Generated for CEL: Crystal Entity Layer 1.4.1 by doxygen 1.7.1