00001 // Copyright (c) 1998-2014 by Tech Soft 3D, Inc. 00002 // 00003 // The information contained herein is confidential and proprietary to Tech Soft 3D, Inc., 00004 // and considered a trade secret as defined under civil and criminal statutes. 00005 // Tech Soft 3D, Inc. shall pursue its civil and criminal remedies in the event of 00006 // unauthorized use or misappropriation of its trade secrets. Use of this information 00007 // by anyone other than authorized employees of Tech Soft 3D, Inc. is granted only under 00008 // a written non-disclosure agreement, expressly prescribing the scope and manner of such use. 00009 00010 #ifndef _H_HBhvSensor_H 00011 #define _H_HBhvSensor_H 00012 00013 #ifdef H_PACK_8 00014 #pragma pack(push) 00015 #pragma pack(8) 00016 #endif 00017 00018 #include "HTools.h" 00019 #include "HEventListener.h" 00020 00021 class HBhvBehaviorManager; 00022 class HBhvCondition; 00023 class HBhvAction; 00024 class HBhvTargetObject; 00025 00026 00027 00029 00033 class MVO_API HBhvSensor 00034 { 00035 public: 00036 00043 HBhvSensor(const char *name, bool active, HBhvBehaviorManager *BehaviorManager); 00044 virtual ~HBhvSensor(); 00045 00050 void AddCondition(HBhvCondition *condition); 00051 00055 static void *XMLCallback(HUtilityXMLTag *xt, bool open, void *m_pExtraData); 00056 00060 void Serialize(HUtilityXMLGenerator *xmlgen); 00061 00063 HBhvBehaviorManager * GetBehaviorManager() { return m_pBehaviorManager; } 00064 00070 void Activate(int delay = 0); 00071 00075 void DeActivate(); 00076 00078 bool GetDefaultActive() { return m_bDefaultActive; } 00079 00081 bool GetCurrentlyActive() { return m_bCurrentlyActive; } 00082 00087 bool Evaluate(); 00088 00093 void AddAction(HBhvAction *action); 00094 00096 const char * GetName() { return m_Name; } 00097 00101 void Tick(); 00102 00103 00104 protected: 00105 char m_Name[256]; 00106 HBhvBehaviorManager * m_pBehaviorManager; 00108 struct vlist_s* m_ConditionList; 00109 struct vlist_s* m_ActionList; 00111 bool m_bCurrentlyActive; 00112 bool m_bDefaultActive; 00114 int m_Delay; 00115 }; 00116 00117 00119 class MVO_API HBhvCondition 00120 { 00121 public: 00122 00131 HBhvCondition(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00132 virtual ~HBhvCondition(); 00133 00138 virtual void SetTarget(const char *target); 00139 00141 virtual HBhvSensor * GetSensor() { return m_pSensor; } 00142 00146 virtual void Register() { } 00147 00151 virtual void UnRegister() { } 00152 00158 virtual void Evaluate(bool &and_flag, bool &or_flag); 00159 00163 static void *XMLCallback(HUtilityXMLTag *xt, bool open, void *m_pExtraData); 00164 00168 virtual void Serialize(HUtilityXMLGenerator *xmlgen, HUtilityXMLTag *xmlt); 00169 00173 virtual void Serialize(HUtilityXMLGenerator *xmlgen); 00174 00175 protected: 00176 char m_Event[256]; 00177 HBhvTargetObject* m_pTarget; 00178 bool m_bConditionMet; 00179 HBhvSensor* m_pSensor; 00180 bool m_bInvert; 00181 char m_Value[256]; 00183 }; 00184 00185 00187 class MVO_API HBhvConditionAnimationRunning : public HBhvCondition 00188 { 00189 public: 00198 HBhvConditionAnimationRunning(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00199 00206 virtual void Evaluate(bool &and_flag, bool &or_flag); 00207 00211 virtual void Serialize(HUtilityXMLGenerator *xmlgen); 00212 00213 }; 00214 00216 class MVO_API HBhvConditionSensorActive : public HBhvCondition 00217 { 00218 public: 00219 00228 HBhvConditionSensorActive(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00229 00236 virtual void Evaluate(bool &and_flag, bool &or_flag); 00237 00241 virtual void Serialize(HUtilityXMLGenerator *xmlgen); 00242 00243 protected: 00244 }; 00245 00246 00247 00249 class MVO_API HBhvConditionMouse : public HBhvCondition, public HMouseListener 00250 { 00251 public: 00252 00261 HBhvConditionMouse(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00262 00266 virtual void Register(); 00267 00271 virtual void UnRegister(); 00272 00273 00281 bool IsClicked(HC_KEY target, float x, float y); 00282 00283 00284 }; 00285 00287 class MVO_API HBhvConditionAnimation : public HBhvCondition, public HAnimationListener 00288 { 00289 public: 00290 00299 HBhvConditionAnimation(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00300 00304 virtual void Register(); 00305 00309 virtual void UnRegister(); 00310 protected: 00311 }; 00312 00314 class MVO_API HBhvConditionSensor : public HBhvCondition, public HSensorListener 00315 { 00316 public: 00317 00326 HBhvConditionSensor(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00327 00331 virtual void Register(); 00332 00336 virtual void UnRegister(); 00337 }; 00338 00339 00341 class MVO_API HBhvConditionSensorActivated : public HBhvConditionSensor 00342 { 00343 public: 00344 00353 HBhvConditionSensorActivated(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00354 00359 virtual int SensorActivatedEvent(HBhvSensor * ainst); 00360 00364 virtual void Serialize(HUtilityXMLGenerator *xmlgen); 00365 00366 }; 00367 00368 00369 00371 class MVO_API HBhvConditionSensorAction : public HBhvConditionSensor 00372 { 00373 public: 00382 HBhvConditionSensorAction(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00383 00388 virtual int SensorActionEvent(const char * action); 00389 00393 virtual void Serialize(HUtilityXMLGenerator *xmlgen); 00394 00395 }; 00396 00398 class MVO_API HBhvConditionAnimationFinished : public HBhvConditionAnimation 00399 { 00400 public: 00409 HBhvConditionAnimationFinished(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00410 00415 virtual int AnimationFinishedEvent(HBhvAnimation * animation); 00416 00420 virtual void Serialize(HUtilityXMLGenerator *xmlgen); 00421 00422 00423 }; 00424 00425 00426 00428 class MVO_API HBhvConditionONLCLICK : public HBhvConditionMouse 00429 { 00430 public: 00431 00440 HBhvConditionONLCLICK(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00441 00449 virtual int OnLButtonDown(HEventInfo &hevent); 00450 00454 virtual void Serialize(HUtilityXMLGenerator *xmlgen); 00455 00456 protected: 00457 }; 00458 00459 00460 00462 class MVO_API HBhvConditionONMOUSEENTER : public HBhvConditionMouse 00463 { 00464 public: 00465 00474 HBhvConditionONMOUSEENTER(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00475 00481 virtual int OnMouseMove(HEventInfo &hevent); 00482 00486 void UnRegister(); 00487 00491 virtual void Serialize(HUtilityXMLGenerator *xmlgen); 00492 00493 protected: 00494 HC_KEY m_OldKey; 00495 }; 00496 00498 class MVO_API HBhvConditionONMOUSELEAVE : public HBhvConditionMouse 00499 { 00500 public: 00501 00510 HBhvConditionONMOUSELEAVE(const char *target, const char *hevent, bool invert, HBhvSensor *sensor); 00511 00517 virtual int OnMouseMove(HEventInfo &hevent); 00518 00522 void UnRegister(); 00523 00527 virtual void Serialize(HUtilityXMLGenerator *xmlgen); 00528 00529 protected: 00530 HC_KEY m_OldKey; 00531 }; 00532 00533 00534 00536 00572 class MVO_API HBhvAction 00573 { 00574 public: 00575 00583 HBhvAction(const char *target, const char *type, const char *value, HBhvSensor *sensor); 00584 00588 virtual ~HBhvAction(); 00589 00590 00595 void SetTargetByPath(const char *targetpath); 00596 00600 static void *XMLCallback(HUtilityXMLTag *xt, bool open, void *m_pExtraData); 00601 00602 00606 void DoAction(); 00607 00611 void Serialize(HUtilityXMLGenerator *xmlgen); 00612 00613 protected: 00614 char m_Type[256]; 00615 char m_Value[MVO_BUFFER_SIZE]; 00616 HBhvSensor* m_pSensor; 00617 HBhvTargetObject* m_pTarget; 00620 }; 00621 00622 00623 00624 00625 #ifdef H_PACK_8 00626 #pragma pack(pop) 00627 #endif 00628 00629 #endif