CEL

Public API Reference

tools/triggers.h
00001 /*
00002     Crystal Space Entity Layer
00003     Copyright (C) 2004-2006 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_TRIGGERS__
00021 #define __CEL_TRIGGERS__
00022 
00023 #include "behaviourlayer/behave.h"
00024 #include "tools/parameters.h"
00025 #include "tools/sequences.h"
00026 
00027 //-------------------------------------------------------------------------
00028 // Triggers
00029 //-------------------------------------------------------------------------
00030 
00031 struct iTrigger;
00032 
00037 struct iTriggerCallback : public virtual iBase
00038 {
00039   SCF_INTERFACE (iTriggerCallback, 0, 0, 1);
00040 
00042   virtual void TriggerFired (iTrigger* trigger, iCelParameterBlock* params) = 0;
00043 };
00044 
00052 struct iTrigger : public virtual iBase
00053 {
00054   SCF_INTERFACE (iTrigger, 0, 0, 1);
00055 
00060   virtual void RegisterCallback (iTriggerCallback* callback) = 0;
00061 
00065   virtual void ClearCallback () = 0;
00066 
00070   virtual void ActivateTrigger () = 0;
00071 
00075   virtual void DeactivateTrigger () = 0;
00076 
00084   virtual bool Check () = 0;
00085 
00091   virtual bool LoadAndActivateTrigger (iCelDataBuffer* databuf) = 0;
00092 
00096   virtual void SaveTriggerState (iCelDataBuffer* databuf) = 0;
00097 };
00098 
00103 struct iTriggerFactory : public virtual iBase
00104 {
00105   SCF_INTERFACE (iTriggerFactory, 0, 0, 1);
00106 
00112   virtual csPtr<iTrigger> CreateTrigger (
00113         const celParams& params) = 0;
00114 
00120   virtual bool Load (iDocumentNode* node) = 0;
00121 };
00122 
00131 struct iTriggerType : public virtual iBase
00132 {
00133   SCF_INTERFACE (iTriggerType, 0, 0, 1);
00134 
00138   virtual const char* GetName () const = 0;
00139   
00143   virtual csPtr<iTriggerFactory> CreateTriggerFactory () = 0;
00144 };
00145 
00146 //-------------------------------------------------------------------------
00147 // Specific trigger implementations.
00148 //-------------------------------------------------------------------------
00169 struct iEnterSectorTriggerFactory : public virtual iBase
00170 {
00171   SCF_INTERFACE (iEnterSectorTriggerFactory, 0, 0, 1);
00172 
00181   virtual void SetEntityParameter (const char* entity, const char* tag = 0) = 0;
00182 
00189   virtual void SetSectorParameter (const char* sector) = 0;
00190 };
00191 
00213 struct iInventoryTriggerFactory : public virtual iBase
00214 {
00215   SCF_INTERFACE (iInventoryTriggerFactory, 0, 0, 1);
00216 
00225   virtual void SetEntityParameter (const char* entity, const char* tag = 0) = 0;
00226 
00234   virtual void SetChildEntityParameter (const char* child_entity) = 0;
00235 };
00236 
00255 struct iMeshSelectTriggerFactory : public virtual iBase
00256 {
00257   SCF_INTERFACE (iMeshSelectTriggerFactory, 0, 0, 1);
00258 
00267   virtual void SetEntityParameter (const char* entity, const char* tag = 0) = 0;
00268 };
00269 
00284 struct iMessageTriggerFactory : public virtual iBase
00285 {
00286   SCF_INTERFACE (iMessageTriggerFactory, 0, 0, 1);
00287 
00293   virtual void SetEntityParameter (const char* entity) = 0;
00294 
00301   virtual void SetMaskParameter (const char* mask) = 0;
00302 };
00303 
00304 
00328 struct iOperationTriggerFactory : public virtual iBase
00329 {
00330   SCF_INTERFACE (iOperationTriggerFactory, 0, 0, 1);
00331 
00338   virtual void SetOperationParameter (const char* operation) = 0;
00343   virtual csRefArray<iTriggerFactory> &GetTriggerFactories () = 0;
00344 };
00345 
00383 struct iPropertyChangeTriggerFactory : public virtual iBase
00384 {
00385   SCF_INTERFACE (iPropertyChangeTriggerFactory, 0, 0, 1);
00386 
00395   virtual void SetEntityParameter (const char* entity, const char* tag = 0) = 0;
00396 
00402   virtual void SetPropertyParameter (const char* prop) = 0;
00403 
00410   virtual void SetValueParameter (const char* value) = 0;
00411 
00417   virtual void SetOperationParameter (const char* op) = 0;
00418 
00425   virtual void SetOnChangeOnly (bool on_change) = 0;
00426 };
00427 
00445 struct iSequenceFinishTriggerFactory : public virtual iBase
00446 {
00447   SCF_INTERFACE (iSequenceFinishTriggerFactory, 0, 0, 1);
00448 
00457   virtual void SetEntityParameter (const char* entity, const char* tag = 0) = 0;
00458 
00466   virtual void SetSequenceParameter (const char* sequence) = 0;
00467 
00473   virtual void SetSequence (iCelSequence* sequence) = 0;
00474 };
00475 
00488 struct iTimeoutTriggerFactory : public virtual iBase
00489 {
00490   SCF_INTERFACE (iTimeoutTriggerFactory, 0, 0, 1);
00491 
00497   virtual void SetTimeoutParameter (const char* timeout_par) = 0;
00498 };
00499 
00500 
00521 struct iTriggerTriggerFactory : public virtual iBase
00522 {
00523   SCF_INTERFACE (iTriggerTriggerFactory, 0, 0, 1);
00524 
00533   virtual void SetEntityParameter (const char* entity, const char* tag = 0) = 0;
00534 
00539   virtual void EnableLeave () = 0;
00540 };
00541 
00567 struct iWatchTriggerFactory : public virtual iBase
00568 {
00569   SCF_INTERFACE (iWatchTriggerFactory, 0, 0, 1);
00570 
00579   virtual void SetEntityParameter (const char* entity, const char* tag = 0) = 0;
00580 
00589   virtual void SetTargetEntityParameter (const char* entity,
00590       const char* tag = 0) = 0;
00591 
00599   virtual void SetChecktimeParameter (const char* time) = 0;
00600 
00607   virtual void SetRadiusParameter (const char* radius) = 0;
00608 
00616   virtual void SetOffsetParameter (const char* offsetx,
00617       const char* offsety, const char* offsetz) = 0;
00618 };
00619 
00620 //-------------------------------------------------------------------------
00621 
00625 #define CEL_DECLARE_TRIGGERTYPE(name,id)                                \
00626 class cel##name##TriggerType : public scfImplementation2<               \
00627                 cel##name##TriggerType,iTriggerType,iComponent>         \
00628 {                                                                       \
00629 public:                                                                 \
00630   iObjectRegistry* object_reg;                                          \
00631   csWeakRef<iCelPlLayer> pl;                                            \
00632   cel##name##TriggerType (iBase* parent);                       \
00633   virtual ~cel##name##TriggerType () { }                                \
00634   virtual bool Initialize (iObjectRegistry*);                   \
00635   virtual const char* GetName () const { return id; }                   \
00636   virtual csPtr<iTriggerFactory> CreateTriggerFactory ();               \
00637 };
00638 
00642 #define CEL_IMPLEMENT_TRIGGERTYPE(name)                                 \
00643 cel##name##TriggerType::cel##name##TriggerType (                                \
00644         iBase* parent) : scfImplementationType (this, parent),  \
00645         object_reg(0)                                                                                   \
00646 {                                                                                                                       \
00647 }                                                                                                                       \
00648 bool cel##name##TriggerType::Initialize (                                       \
00649         iObjectRegistry* object_reg)                                                    \
00650 {                                                                       \
00651   cel##name##TriggerType::object_reg = object_reg;                      \
00652   pl = csQueryRegistry<iCelPlLayer> (object_reg);                       \
00653   return true;                                                                                          \
00654 }                                                                       \
00655 csPtr<iTriggerFactory> cel##name##TriggerType::CreateTriggerFactory () \
00656 {                                                                       \
00657   cel##name##TriggerFactory* fact = new cel##name##TriggerFactory (this); \
00658   return fact;                                                          \
00659 }
00660 
00661 #endif // __CEL_TRIGGERS__

Generated for CEL: Crystal Entity Layer 2.0 by doxygen 1.7.6.1