CEL: Crystal Entity Layer: physicallayer/pl.h Source File (CEL: Crystal Entity Layer Public API Reference)

| ## Public API Reference

- Main Page
- Classes
- Files

# 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
    00028 struct iObject;
    00029 struct iCelEntity;
    00030 struct iCelEntityList;
    00031 struct iCelDataBuffer;
    00032 struct iCelMessage;
    00033 struct iCelPropertyClass;
    00034 struct iCelPropertyClassFactory;
    00035 struct iCelBlLayer;
    00036 struct iCelBehaviour;
    00037 struct iCelEntityTemplate;
    00038 struct iSector;
    00039 struct iCamera;
    00040 class csVector3;
    00041 class csBox3;
    00042 class csString;
    00043
    00044 #define CEL_EVENT_PRE 0
    00045 #define CEL_EVENT_VIEW 1
    00046 #define CEL_EVENT_POST 2
    00047
    00048 #define CEL_PROPCLASS_END (void*)0
    00049 #define CEL_PARAM_END (void*)0
    00050
    00052 typedef csHash<csStrKey, csStrKey> celEntityTemplateParams;
    00053
    00054 struct iCelEntityTracker;
    00055
    00060 struct iCelNewEntityCallback : public virtual iBase
    00061 {
    00062   SCF_INTERFACE (iCelNewEntityCallback, 0, 0, 2);
    00063
    00065   virtual void NewEntity (iCelEntity* entity) = 0;
    00066 };
    00067
    00072 struct iCelEntityRemoveCallback : public virtual iBase
    00073 {
    00074   SCF_INTERFACE (iCelEntityRemoveCallback, 0, 0, 2);
    00075
    00077   virtual void RemoveEntity (iCelEntity* entity) = 0;
    00078 };
    00079
    00080
    00085 struct iCelTimerListener : public virtual iBase
    00086 {
    00087   SCF_INTERFACE (iCelTimerListener, 0, 0, 1);
    00088
    00093   virtual void TickEveryFrame () = 0;
    00094
    00099   virtual void TickOnce () = 0;
    00100 };
    00101
    00102 SCF_VERSION (iCelPlLayer, 0, 3, 2);
    00103
    00107 struct iCelPlLayer : public iBase
    00108 {
    00114   virtual csPtr<iCelEntity> CreateEntity () = 0;
    00115
    00120   virtual csPtr<iCelEntity> CreateEntityInScope (int scope) = 0;
    00121
    00127   virtual csPtr<iCelEntity> CreateEntity (uint id) = 0;
    00128
    00144   virtual csPtr<iCelEntity> CreateEntity (const char* entname,
    00145         iCelBlLayer* bl, const char* bhname, ...) = 0;
    00146
    00150   virtual void RemoveEntity (iCelEntity* entity) = 0;
    00151
    00155   virtual void RemoveEntities () = 0;
    00156
    00161   virtual iCelEntityTemplate* CreateEntityTemplate (const char* factname) = 0;
    00162
    00166   virtual void RemoveEntityTemplate (iCelEntityTemplate* entfact) = 0;
    00167
    00171   virtual void RemoveEntityTemplates () = 0;
    00172
    00176   virtual iCelEntityTemplate* FindEntityTemplate (const char* factname) = 0;
    00177
    00181   virtual size_t GetEntityTemplateCount () const = 0;
    00182
    00186   virtual iCelEntityTemplate* GetEntityTemplate (size_t idx) const = 0;
    00187
    00195   virtual iCelEntity* CreateEntity (iCelEntityTemplate* factory,
    00196         const char* name, const celEntityTemplateParams& params) = 0;
    00197
    00207   virtual iCelEntity* CreateEntity (iCelEntityTemplate* factory,
    00208         const char* name, ...) = 0;
    00209
    00216   virtual csPtr<iCelDataBuffer> CreateDataBuffer (long serialnr) = 0;
    00217
    00223   virtual void AttachEntity (iObject* object, iCelEntity* entity) = 0;
    00224
    00228   virtual void UnattachEntity (iObject* object, iCelEntity* entity) = 0;
    00229
    00233   virtual iCelEntity* GetEntity (uint id) = 0;
    00234
    00238   virtual size_t GetEntityCount () const = 0;
    00239
    00243   virtual iCelEntity* GetEntityByIndex (size_t idx) const = 0;
    00244
    00250   virtual iCelEntity* FindEntity (const char* name) = 0;
    00251
    00256   virtual iCelBehaviour* GetBehaviour (uint id) = 0;
    00257
    00261   virtual iCelEntity* FindAttachedEntity (iObject* object) = 0;
    00262
    00268   virtual csPtr<iCelEntityList> FindNearbyEntities (iSector* sector,
    00269         const csVector3& pos, float radius, bool do_invisible = false) = 0;
    00270
    00276   virtual csPtr<iCelEntityList> FindNearbyEntities (iSector* sector,
    00277         const csBox3& box, bool do_invisible = false) = 0;
    00278
    00284   virtual csPtr<iCelEntityList> FindNearbyEntities (iSector* sector,
    00285         const csVector3& start, const csVector3& end,
    00286         bool do_invisible = false) = 0;
    00287
    00293   virtual iCelEntity* GetHitEntity (iCamera* camera, int x, int y) = 0;
    00294
    00298   virtual csPtr<iCelEntityList> CreateEmptyEntityList () = 0;
    00299
    00304   virtual iCelEntityTracker* CreateEntityTracker (const char* name) = 0;
    00305
    00309   virtual iCelEntityTracker* FindEntityTracker (const char* name) = 0;
    00310
    00314   virtual void RemoveEntityTracker (iCelEntityTracker* tracker) = 0;
    00315
    00323   virtual void SetEntityAddonAllowed (bool allow) = 0;
    00324
    00328   virtual bool IsEntityAddonAllowed () const = 0;
    00329
    00330   //-------------------------------------------------------------------------
    00331
    00337   virtual bool LoadPropertyClassFactory (const char* plugin_id) = 0;
    00338
    00345   virtual void RegisterPropertyClassFactory (iCelPropertyClassFactory* pf) = 0;
    00346
    00350   virtual void UnregisterPropertyClassFactory (
    00351         iCelPropertyClassFactory* pf) = 0;
    00352
    00356   virtual size_t GetPropertyClassFactoryCount () const = 0;
    00357
    00361   virtual iCelPropertyClassFactory* GetPropertyClassFactory (size_t idx)
    00362         const = 0;
    00363
    00367   virtual iCelPropertyClassFactory* FindPropertyClassFactory (
    00368         const char* name) const = 0;
    00369
    00375   virtual iCelPropertyClass* CreatePropertyClass
    00376       (iCelEntity* entity, const char* propname) = 0;
    00377
    00383   virtual iCelPropertyClass* CreateTaggedPropertyClass
    00384       (iCelEntity* entity, const char* propname, const char* tagname) = 0;
    00385
    00386   //-------------------------------------------------------------------------
    00387
    00391   virtual void RegisterBehaviourLayer (iCelBlLayer* bl) = 0;
    00392
    00396   virtual void UnregisterBehaviourLayer (iCelBlLayer* bl) = 0;
    00397
    00401   virtual size_t GetBehaviourLayerCount () const = 0;
    00402
    00406   virtual iCelBlLayer* GetBehaviourLayer (size_t idx) const = 0;
    00407
    00411   virtual iCelBlLayer* FindBehaviourLayer (const char* name) const = 0;
    00412
    00413   //-------------------------------------------------------------------------
    00414
    00420   virtual void Cache (iBase* object) = 0;
    00421
    00425   virtual void Uncache (iBase* object) = 0;
    00426
    00432   virtual void CleanCache () = 0;
    00433
    00434   //-------------------------------------------------------------------------
    00435
    00446   virtual csStringID FetchStringID (const char* str) = 0;
    00447
    00452   virtual const char* FetchString (csStringID id) = 0;
    00453
    00458   virtual void AddEntityRemoveCallback (iCelEntityRemoveCallback* clback) = 0;
    00459
    00463   virtual void RemoveEntityRemoveCallback (
    00464         iCelEntityRemoveCallback* clback) = 0;
    00465
    00470   virtual void AddNewEntityCallback (iCelNewEntityCallback* clback) = 0;
    00471
    00475   virtual void RemoveNewEntityCallback (iCelNewEntityCallback* clback) = 0;
    00476
    00477   //-------------------------------------------------------------------------
    00478
    00492   virtual void CallbackEveryFrame (iCelTimerListener* listener, int where) = 0;
    00493
    00508   virtual void CallbackOnce (iCelTimerListener* listener, csTicks delta,
    00509         int where) = 0;
    00510
    00514   virtual void RemoveCallbackEveryFrame (iCelTimerListener* listener,
    00515         int where) = 0;
    00516
    00520   virtual void RemoveCallbackOnce (iCelTimerListener* listener, int where) = 0;
    00521
    00528   virtual int AddScope (csString version, int size) = 0;
    00529 };
    00530
    00531 SCF_VERSION (iCelEntityTracker, 0, 0, 1);
    00532
    00538 struct iCelEntityTracker : public iBase
    00539 {
    00543   virtual const char* GetName () const = 0;
    00544
    00550   virtual bool AddEntity (iCelEntity* entity) = 0;
    00551
    00555   virtual void RemoveEntity (iCelEntity* entity) = 0;
    00556
    00560   virtual void RemoveEntities () = 0;
    00561
    00566   virtual csPtr<iCelEntityList> FindNearbyEntities (iSector* sector,
    00567         const csVector3& pos, float radius) = 0;
    00568 };
    00569
    00570 #endif // __CEL_PL_PL__
    00571