CCPUDoEnableComponentEventHandler.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /****************************************************************************
  2. Copyright (C) 2013 Henry van Merode. All rights reserved.
  3. Copyright (c) 2015-2016 Chukong Technologies Inc.
  4. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  5. http://www.cocos2d-x.org
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. THE SOFTWARE.
  21. ****************************************************************************/
  22. #ifndef __CC_PU_PARTICLE_3D_DO_ENABLE_COMPONENT_EVENT_HANDLER_H__
  23. #define __CC_PU_PARTICLE_3D_DO_ENABLE_COMPONENT_EVENT_HANDLER_H__
  24. #include "base/CCRef.h"
  25. #include "math/CCMath.h"
  26. #include "extensions/Particle3D/PU/CCPUParticleSystem3D.h"
  27. #include "extensions/Particle3D/PU/CCPUEventHandler.h"
  28. #include <vector>
  29. #include <string>
  30. NS_CC_BEGIN
  31. struct PUParticle3D;
  32. class PUObserver;
  33. class PUParticleSystem3D;
  34. class CC_DLL PUDoEnableComponentEventHandler : public PUEventHandler
  35. {
  36. public:
  37. static PUDoEnableComponentEventHandler* create();
  38. /** Get the name of the component that must be enabled or disabled.
  39. */
  40. const std::string& getComponentName(void) const {return _componentName;};
  41. /** Set the name of the component that must be enabled or disables.
  42. */
  43. void setComponentName(const std::string& componentName){_componentName = componentName;};
  44. /** Get the value that identifies whether the component must be enabled or disabled.
  45. */
  46. bool isComponentEnabled(void) const {return _componentEnabled;};
  47. /** Set the value that identifies whether the component must be enabled or disabled.
  48. */
  49. void setComponentEnabled(bool enabled){_componentEnabled = enabled;};
  50. /** Get the value that identifies whether the component must be enabled or disabled.
  51. */
  52. PUComponentType getComponentType(void) const {return _componentType;};
  53. /** Set the value that identifies whether the component must be enabled or disabled.
  54. */
  55. void setComponentType(PUComponentType componentType){_componentType = componentType;};
  56. /** If the _handle() function of this class is invoked (by an Observer), it searches the
  57. ParticleEmitter, ParticleAffector or ParticleTechnique defined by the its name.
  58. The ParticleEmitter/Affector is either part of the ParticleTechnique in which the
  59. DoEnableComponentEventHandler is defined, or if the ParticleEmitter/Affector is not
  60. found, other ParticleTechniques are searched.
  61. */
  62. virtual void handle (PUParticleSystem3D* particleSystem, PUParticle3D* particle, float timeElapsed) override;
  63. virtual void copyAttributesTo (PUEventHandler* eventHandler) override;
  64. CC_CONSTRUCTOR_ACCESS:
  65. PUDoEnableComponentEventHandler(void);
  66. virtual ~PUDoEnableComponentEventHandler(void) {};
  67. protected:
  68. // Identifies the name of component
  69. std::string _componentName;
  70. // Identifies the type of component
  71. PUComponentType _componentType;
  72. /** Determines whether the Component must be enabled or disabled.
  73. */
  74. bool _componentEnabled;
  75. };
  76. NS_CC_END
  77. #endif