3 * ***** BEGIN GPL LICENSE BLOCK *****
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
20 * All rights reserved.
22 * The Original Code is: all of this file.
24 * Contributor(s): none yet.
26 * ***** END GPL LICENSE BLOCK *****
29 #if defined(WIN32) && !defined(FREE_WINDOWS)
30 // This warning tells us about truncation of __long__ stl-generated names.
31 // It can occasionally cause DevStudio to have internal compiler warnings.
32 #pragma warning( disable : 4786 )
35 #include "SCA_TimeEventManager.h"
37 #include "SCA_LogicManager.h"
38 #include "FloatValue.h"
40 SCA_TimeEventManager::SCA_TimeEventManager(SCA_LogicManager* logicmgr)
41 : SCA_EventManager(NULL, TIME_EVENTMGR)
47 SCA_TimeEventManager::~SCA_TimeEventManager()
49 for (vector<CValue*>::iterator it = m_timevalues.begin();
50 !(it == m_timevalues.end()); ++it)
58 void SCA_TimeEventManager::RegisterSensor(SCA_ISensor* sensor)
63 void SCA_TimeEventManager::RemoveSensor(SCA_ISensor* sensor)
70 void SCA_TimeEventManager::NextFrame(double curtime, double fixedtime)
72 if (m_timevalues.size() > 0 && fixedtime > 0.0)
74 CFloatValue* floatval = new CFloatValue(curtime);
76 // update sensors, but ... need deltatime !
77 for (vector<CValue*>::iterator it = m_timevalues.begin();
78 !(it == m_timevalues.end()); ++it)
80 float newtime = (*it)->GetNumber() + fixedtime;
81 floatval->SetFloat(newtime);
82 (*it)->SetValue(floatval);
91 void SCA_TimeEventManager::AddTimeProperty(CValue* timeval)
94 m_timevalues.push_back(timeval);
99 void SCA_TimeEventManager::RemoveTimeProperty(CValue* timeval)
101 for (vector<CValue*>::iterator it = m_timevalues.begin();
102 !(it == m_timevalues.end()); ++it)
104 if ((*it) == timeval)
106 this->m_timevalues.erase(it);