Cooldown_Connector.inl
Go to the documentation of this file.
1 namespace iv
2 {
3 
4 template< class T >
6  Transform_ConnectorI< T, T >( inst ),
7  cm( inst, this, "Cooldown_Connector" ),
8  _cooldown_increasing( 0.0 ),
9  _cooldown_decreasing( 0.0 ),
10  _time( 0.0 )
11 {
13 }
14 
15 template< class T >
17 {
18  this->_cooldown_increasing = value;
19  this->Activate();
20  return this;
21 }
22 
23 template< class T >
25 {
26  return this->_cooldown_increasing;
27 }
28 
29 template< class T >
31 {
32  this->_cooldown_decreasing = value;
33  this->Activate();
34  return this;
35 }
36 
37 template< class T >
39 {
40  return this->_cooldown_decreasing;
41 }
42 
43 template< class T >
45 {
46  if( !this->parent || !this->child )
47  return;
48 
49  //
50  this->_time += this->parent->Step();
51 
52  //
53  auto current_target = this->child->Target();
54  auto next_target = this->parent->Target();
55  if( next_target != current_target )
56  {
57  this->cm.log( SRC_INFO, ::iv::Defs::Log::Animation_ConnectorUpdate, "UpdatePass_Down | cooldown." );
58 
59  // requires compare operator
60  Anim_float cooldown;
61  if( next_target < current_target )
62  cooldown = this->_cooldown_decreasing;
63  else
64  cooldown = this->_cooldown_increasing;
65 
66  //
67  if( this->_time >= cooldown )
68  {
69  this->cm.log( SRC_INFO, ::iv::Defs::Log::Animation_Events, "Transfer target to child." );
70  this->child->Target( next_target );
71  this->_time = 0.0;
72  }
73  }
74  else
75  {
76  this->cm.log( SRC_INFO, ::iv::Defs::Log::Animation_ConnectorUpdate, "UpdatePass_Down | identified, step ", this->parent->Step(), "." );
77  this->child->Connector_RequestStep( this->parent->Step() );
78  }
79 }
80 
81 template< class T >
83 {
84  if( !this->parent || !this->child )
85  return;
86 
87  auto current_target = this->child->Target();
88  auto next_target = this->parent->Target();
89  if( next_target != current_target )
90  {
91 
92  // requires compare operator
93  Anim_float cooldown;
94  if( next_target < current_target )
95  cooldown = this->_cooldown_decreasing;
96  else
97  cooldown = this->_cooldown_increasing;
98 
99  //
100  Anim_float distance = std::max( this->_time - cooldown, std::numeric_limits< Anim_float >::epsilon() );
101 
102  //
103  this->cm.log( SRC_INFO, ::iv::Defs::Log::Animation_ConnectorUpdate, "UpdatePass_Up | cooldown ", cooldown, ", distance ", distance, "." );
104 
105  //
106  this->parent->Connector_UpdateDistance( distance );
107  }
108  else
109  {
110  Anim_float distance = this->child->Distance();
111  if( this->_time < std::max( this->cooldown_increasing(), this->cooldown_decreasing() ) )
112  distance = std::max( distance, std::numeric_limits< Anim_float >::epsilon() );
113 
114  this->cm.log( SRC_INFO, ::iv::Defs::Log::Animation_ConnectorUpdate, "UpdatePass_Up | identified, distance ", distance, "." );
115 
116  this->parent->Connector_UpdateDistance( distance );
117  }
118 }
119 
120 }