00001 // 00002 // Copyright (c) 2000 by Tech Soft 3D, LLC. 00003 // The information contained herein is confidential and proprietary to 00004 // Tech Soft 3D, LLC., and considered a trade secret as defined under 00005 // civil and criminal statutes. Tech Soft 3D shall pursue its civil 00006 // and criminal remedies in the event of unauthorized use or misappropriation 00007 // of its trade secrets. Use of this information by anyone other than 00008 // authorized employees of Tech Soft 3D, LLC. is granted only under a 00009 // written non-disclosure agreement, expressly prescribing the scope and 00010 // manner of such use. 00011 // 00012 // $Id$ 00013 // 00014 00015 #ifndef _H_HBhvSensor_H 00016 #define _H_HBhvSensor_H 00017 00018 #ifdef H_PACK_8 00019 #pragma pack(push) 00020 #pragma pack(8) 00021 #endif 00022 00023 #include "HTools.h" 00024 #include "HEventListener.h" 00025 00026 class HBhvBehaviorManager; 00027 class HBhvCondition; 00028 class HBhvAction; 00029 class HBhvTargetObject; 00030 00031 00032 00034 00038 class MVO_API HBhvSensor 00039 { 00040 public: 00041 00048 HBhvSensor(const char *name, bool active, HBhvBehaviorManager *BehaviorManager); 00049 virtual ~HBhvSensor(); 00050 00055 void AddCondition(HBhvCondition *condition); 00056 00060 static void *XMLCallback(HUtilityXMLTag *xt, bool open, void *m_pExtraData); 00061 00065 void Serialize(HUtilityXMLGenerator *xmlgen); 00066 00068 HBhvBehaviorManager * GetBehaviorManager() { return m_pBehaviorManager; } 00069 00075 void Activate(int delay = 0); 00076 00080 void DeActivate(); 00081 00083 bool GetDefaultActive() { return m_bDefaultActive; } 00084 00086 bool GetCurrentlyActive() { return m_bCurrentlyActive; } 00087 00092 bool Evaluate(); 00093 00098 void AddAction(HBhvAction *action); 00099 00101 const char * GetName() { return m_Name; } 00102 00106 void Tick(); 00107 00108 00109 protected: 00110 char m_Name[256]; 00111 HBhvBehaviorManager * m_pBehaviorManager; 00113 struct vlist_s* m_ConditionList; 00114 struct vlist_s* m_ActionList; 00116 bool m_bCurrentlyActive; 00117 bool m_bDefaultActive; 00119 int m_Delay; 00120 }; 00121 00122 00124 class MVO_API HBhvCondition 00125 { 00126 public: 00127 00136 HBhvCondition(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00137 virtual ~HBhvCondition(); 00138 00143 virtual void SetTarget(const char *target); 00144 00146 virtual HBhvSensor * GetSensor() { return m_pSensor; } 00147 00151 virtual void Register() { } 00152 00156 virtual void UnRegister() { } 00157 00163 virtual void Evaluate(bool &and_flag, bool &or_flag); 00164 00168 static void *XMLCallback(HUtilityXMLTag *xt, bool open, void *m_pExtraData); 00169 00173 virtual void Serialize(HUtilityXMLGenerator *xmlgen, HUtilityXMLTag *xmlt); 00174 00178 virtual void Serialize(HUtilityXMLGenerator *xmlgen); 00179 00180 protected: 00181 char m_Event[256]; 00182 HBhvTargetObject* m_pTarget; 00183 bool m_bConditionMet; 00184 HBhvSensor* m_pSensor; 00185 bool m_bInvert; 00186 char m_Value[256]; 00188 }; 00189 00190 00192 class MVO_API HBhvConditionAnimationRunning : public HBhvCondition 00193 { 00194 public: 00203 HBhvConditionAnimationRunning(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00204 00211 virtual void Evaluate(bool &and_flag, bool &or_flag); 00212 00216 virtual void Serialize(HUtilityXMLGenerator *xmlgen); 00217 00218 }; 00219 00221 class MVO_API HBhvConditionSensorActive : public HBhvCondition 00222 { 00223 public: 00224 00233 HBhvConditionSensorActive(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00234 00241 virtual void Evaluate(bool &and_flag, bool &or_flag); 00242 00246 virtual void Serialize(HUtilityXMLGenerator *xmlgen); 00247 00248 protected: 00249 }; 00250 00251 00252 00254 class MVO_API HBhvConditionMouse : public HBhvCondition, public HMouseListener 00255 { 00256 public: 00257 00266 HBhvConditionMouse(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00267 00271 virtual void Register(); 00272 00276 virtual void UnRegister(); 00277 00278 00286 bool IsClicked(HC_KEY target, float x, float y); 00287 00288 00289 }; 00290 00292 class MVO_API HBhvConditionAnimation : public HBhvCondition, public HAnimationListener 00293 { 00294 public: 00295 00304 HBhvConditionAnimation(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00305 00309 virtual void Register(); 00310 00314 virtual void UnRegister(); 00315 protected: 00316 }; 00317 00319 class MVO_API HBhvConditionSensor : public HBhvCondition, public HSensorListener 00320 { 00321 public: 00322 00331 HBhvConditionSensor(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00332 00336 virtual void Register(); 00337 00341 virtual void UnRegister(); 00342 }; 00343 00344 00346 class MVO_API HBhvConditionSensorActivated : public HBhvConditionSensor 00347 { 00348 public: 00349 00358 HBhvConditionSensorActivated(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00359 00364 virtual int SensorActivatedEvent(HBhvSensor * ainst); 00365 00369 virtual void Serialize(HUtilityXMLGenerator *xmlgen); 00370 00371 }; 00372 00373 00374 00376 class MVO_API HBhvConditionSensorAction : public HBhvConditionSensor 00377 { 00378 public: 00387 HBhvConditionSensorAction(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00388 00393 virtual int SensorActionEvent(const char * action); 00394 00398 virtual void Serialize(HUtilityXMLGenerator *xmlgen); 00399 00400 }; 00401 00403 class MVO_API HBhvConditionAnimationFinished : public HBhvConditionAnimation 00404 { 00405 public: 00414 HBhvConditionAnimationFinished(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00415 00420 virtual int AnimationFinishedEvent(HBhvAnimation * animation); 00421 00425 virtual void Serialize(HUtilityXMLGenerator *xmlgen); 00426 00427 00428 }; 00429 00430 00431 00433 class MVO_API HBhvConditionONLCLICK : public HBhvConditionMouse 00434 { 00435 public: 00436 00445 HBhvConditionONLCLICK(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00446 00454 virtual int OnLButtonDown(HEventInfo &hevent); 00455 00459 virtual void Serialize(HUtilityXMLGenerator *xmlgen); 00460 00461 protected: 00462 }; 00463 00464 00465 00467 class MVO_API HBhvConditionONMOUSEENTER : public HBhvConditionMouse 00468 { 00469 public: 00470 00479 HBhvConditionONMOUSEENTER(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00480 00486 virtual int OnMouseMove(HEventInfo &hevent); 00487 00491 void UnRegister(); 00492 00496 virtual void Serialize(HUtilityXMLGenerator *xmlgen); 00497 00498 protected: 00499 HC_KEY m_OldKey; 00500 }; 00501 00503 class MVO_API HBhvConditionONMOUSELEAVE : public HBhvConditionMouse 00504 { 00505 public: 00506 00515 HBhvConditionONMOUSELEAVE(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00516 00522 virtual int OnMouseMove(HEventInfo &hevent); 00523 00527 void UnRegister(); 00528 00532 virtual void Serialize(HUtilityXMLGenerator *xmlgen); 00533 00534 protected: 00535 HC_KEY m_OldKey; 00536 }; 00537 00538 00539 00541 00577 class MVO_API HBhvAction 00578 { 00579 public: 00580 00588 HBhvAction(const char *target, const char *type, const char *value, HBhvSensor *sensor); 00589 00593 virtual ~HBhvAction(); 00594 00595 00600 void SetTargetByPath(const char *targetpath); 00601 00605 static void *XMLCallback(HUtilityXMLTag *xt, bool open, void *m_pExtraData); 00606 00607 00611 void DoAction(); 00612 00616 void Serialize(HUtilityXMLGenerator *xmlgen); 00617 00618 protected: 00619 char m_Type[256]; 00620 char m_Value[MVO_BUFFER_SIZE]; 00621 HBhvSensor* m_pSensor; 00622 HBhvTargetObject* m_pTarget; 00625 }; 00626 00627 00628 00629 00630 #ifdef H_PACK_8 00631 #pragma pack(pop) 00632 #endif 00633 00634 #endif