Isaac 2D  1.0
NumericTrigger.h
1 // // IsaacFramework //
3 // //////////////////////
4 //
5 // Copyright (c) 2014 Horatiu Condrea
6 //
7 // This software is provided 'as-is', without any express or implied warranty.
8 // In no event will the authors be held liable for any damages arising from the use of this software.
9 //
10 // Permission is granted to anyone to use this software for any purpose, including commercial applications,
11 // and to alter it and redistribute it freely, subject to the following restrictions:
12 //
13 // 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. a
14 // If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
15 //
16 // 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
17 //
18 // 3. This notice may not be removed or altered from any source distribution.
19 //
21 /*
22 Copyright @ 2014
23 Author Horatiu Condrea [ horiacondrea.com ]
24 Revision | Who | Date | Comment
25 ------------------------------------------------------------------------------------------------------------------------------------------
26 1.0 | hc | June 2016| Created
27 */
28 // Headers
30 #pragma once
31 #include <ITrigger.h>
32 
33 namespace isaac
34 {
39  template <class type>
40  class EXPORT_API CNumericTrigger : public isaac::ITrigger
41  {
42  public:
46  struct NumericProp
47  {
48  isaac::Signs mv_Signs;
49  type mv_typeValue;
50  };
51 
52  private:
53  mutable NumericProp mv_NumericProp;
54  mutable type mv_typeTheValue;
55  public:
56  CNumericTrigger(std::string ac_szTriggerName)
57  {
58  mv_NumericProp = { isaac::Signs::en_UnknowPosition, std::numeric_limits<type>::quiet_NaN };
59  }
60 
64  void mp_InitTrigger(type& av_TheValue, const NumericProp& ac_NumericProp) const
65  {
66  mv_typeTheValue = av_TheValue;
67  mv_NumericProp = ac_NumericProp;
68  }
69 
70  const bool mf_bCheckTrigger(sf::Event) const override
71  {
72  switch (mv_NumericProp.mv_Signs)
73  {
74  case isaac::Signs::en_EqualWith:
75  {
76  if (mv_typeTheValue == mv_NumericProp.mv_typeValue)
77  return true;
78  return false;
79  break;
80  }
81  case isaac::Signs::en_GraterThen:
82  {
83  if (mv_typeTheValue > mv_NumericProp.mv_typeValue)
84  return true;
85  return false;
86  break;
87  }
88  case isaac::Signs::en_LessThen:
89  {
90  if (mv_typeTheValue < mv_NumericProp.mv_typeValue)
91  return true;
92  return false;
93  break;
94  }
95  case isaac::Signs::en_UnknowPosition:
96  return false;
97  default:
98  break;
99  }
100  }
101 
102  virtual ~CNumericTrigger();
103  };
104 }
Definition: BlankScene.cpp:32
Definition: NumericTrigger.h:46
const bool mf_bCheckTrigger(sf::Event) const override
Definition: NumericTrigger.h:70
Signs
Definition: ITrigger.h:43
Definition: ITrigger.h:62
void mp_InitTrigger(type &av_TheValue, const NumericProp &ac_NumericProp) const
Definition: NumericTrigger.h:64
Definition: NumericTrigger.h:40