CEL

Public API Reference

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 
00456   virtual csStringID FetchStringID (const char* str) = 0;
00457 
00462   virtual const char* FetchString (csStringID id) = 0;
00463 
00468   virtual void AddEntityRemoveCallback (iCelEntityRemoveCallback* clback) = 0;
00469 
00473   virtual void RemoveEntityRemoveCallback (
00474         iCelEntityRemoveCallback* clback) = 0;
00475 
00480   virtual void AddNewEntityCallback (iCelNewEntityCallback* clback) = 0;
00481 
00485   virtual void RemoveNewEntityCallback (iCelNewEntityCallback* clback) = 0;
00486 
00487   //-------------------------------------------------------------------------
00488 
00502   virtual void CallbackEveryFrame (iCelTimerListener* listener, int where) = 0;
00503 
00518   virtual void CallbackOnce (iCelTimerListener* listener, csTicks delta,
00519         int where) = 0;
00520 
00524   virtual void RemoveCallbackEveryFrame (iCelTimerListener* listener,
00525         int where) = 0;
00526 
00530   virtual void RemoveCallbackOnce (iCelTimerListener* listener, int where) = 0;
00531 
00538   virtual int AddScope (csString version, int size) = 0;
00539 
00540   /*
00541    * Get a list of all entities with a certain class assigned.
00542    * The list returned is always kept up to date by the physical layer so 
00543    * you can save the reference safely and keep using it.
00544    */
00545   virtual const csRef<iCelEntityList> GetClassEntitiesList (
00546         csStringID classid) = 0;
00547 
00548   /*
00549    * Send a message to all entities in an entity list. Returns the number
00550    * of entities that understood and handled the message.
00551    * Note that this version of SendMessage only sends a message to the
00552    * behaviour of the entity and not the channel. Use the new messaging
00553    * system for sending a message to the channel.
00554    * \deprecated Use SendMessage() for new message system instead.
00555    */
00556   CS_DEPRECATED_METHOD_MSG("Use SendMessage() for new message system instead.")
00557   virtual int SendMessage (iCelEntityList *entlist, const char* msgname,
00558         iCelParameterBlock* params, ...) = 0;
00559 
00560   /*
00561    * Send a message to all entities in an entity list. Returns the number
00562    * of entities that understood and handled the message.
00563    * Note that this version of SendMessage only sends a message to the
00564    * behaviour of the entity and not the channel. Use the new messaging
00565    * system for sending a message to the channel.
00566    * \deprecated Use SendMessage() for new message system instead.
00567    */
00568   CS_DEPRECATED_METHOD_MSG("Use SendMessage() for new message system instead.")
00569   virtual int SendMessageV (iCelEntityList *entlist, const char* msgname,
00570         iCelParameterBlock* params, va_list arg) = 0;
00571 
00572   /*
00573    * Send a message to all entities in an entity list. Returns the number
00574    * of entities that understood and handled the message.
00575    * Note that this version of SendMessage() sends a message to the channel
00576    * of the entity only and not the behaviour (unless the behaviour also
00577    * happens to subscribe to the channel).
00578    * \param msgid is the message ID.
00579    * \param sender is the sender from this message.
00580    * \param params contains the parameters for this message.
00581    * \param ret if this is not 0 then it can be used to collect information
00582    * from the receivers. If 0 then information from the receivers is simply
00583    * ignored.
00584    */
00585   virtual int SendMessage (const char* msgid, iMessageSender* sender,
00586       iCelEntityList *entlist, iCelParameterBlock* params,
00587       iCelDataArray* ret = 0) = 0;
00588 
00593   virtual iMessageSender* QueryMessageSender () = 0;
00594 };
00595 
00601 struct iCelEntityTracker : public virtual iBase
00602 {
00603   SCF_INTERFACE (iCelEntityTracker, 0, 0, 3);
00604 
00608   virtual const char* GetName () const = 0;
00609 
00615   virtual bool AddEntity (iCelEntity* entity) = 0;
00616 
00620   virtual void RemoveEntity (iCelEntity* entity) = 0;
00621 
00625   virtual void RemoveEntities () = 0;
00626 
00633   virtual csPtr<iCelEntityList> FindNearbyEntities (iSector* sector,
00634         const csVector3& pos, float radius,
00635         csStringID cls = csInvalidStringID) = 0;
00636 
00640   virtual csPtr<iCelEntityIterator> GetIterator () = 0;
00641 
00645   virtual void AddEntities (iCelEntityTracker* tracker) = 0;
00646 
00650   virtual void RemoveEntities (iCelEntityTracker* tracker) = 0;
00651 };
00652 
00653 #endif // __CEL_PL_PL__
00654 

Generated for CEL: Crystal Entity Layer 2.0 by doxygen 1.7.6.1