2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
|
|
|
|
2011-02-25 13:32:11 +00:00
|
|
|
/** \file gameengine/GameLogic/SCA_TimeEventManager.cpp
|
|
|
|
* \ingroup gamelogic
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2010-09-15 16:13:32 +00:00
|
|
|
#if defined(WIN32) && !defined(FREE_WINDOWS)
|
2002-10-12 11:37:38 +00:00
|
|
|
// This warning tells us about truncation of __long__ stl-generated names.
|
|
|
|
// It can occasionally cause DevStudio to have internal compiler warnings.
|
|
|
|
#pragma warning( disable : 4786 )
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "SCA_TimeEventManager.h"
|
|
|
|
|
|
|
|
#include "SCA_LogicManager.h"
|
|
|
|
#include "FloatValue.h"
|
|
|
|
|
|
|
|
SCA_TimeEventManager::SCA_TimeEventManager(SCA_LogicManager* logicmgr)
|
2009-09-25 16:30:15 +00:00
|
|
|
: SCA_EventManager(NULL, TIME_EVENTMGR)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCA_TimeEventManager::~SCA_TimeEventManager()
|
|
|
|
{
|
|
|
|
for (vector<CValue*>::iterator it = m_timevalues.begin();
|
2009-05-10 20:53:58 +00:00
|
|
|
!(it == m_timevalues.end()); ++it)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
(*it)->Release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SCA_TimeEventManager::RegisterSensor(SCA_ISensor* sensor)
|
|
|
|
{
|
|
|
|
// not yet
|
|
|
|
}
|
|
|
|
|
2008-07-30 17:41:47 +00:00
|
|
|
void SCA_TimeEventManager::RemoveSensor(SCA_ISensor* sensor)
|
|
|
|
{
|
|
|
|
// empty
|
|
|
|
}
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
|
2004-10-16 11:41:50 +00:00
|
|
|
void SCA_TimeEventManager::NextFrame(double curtime, double fixedtime)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2004-10-16 11:41:50 +00:00
|
|
|
if (m_timevalues.size() > 0 && fixedtime > 0.0)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
CFloatValue* floatval = new CFloatValue(curtime);
|
|
|
|
|
|
|
|
// update sensors, but ... need deltatime !
|
|
|
|
for (vector<CValue*>::iterator it = m_timevalues.begin();
|
2009-05-10 20:53:58 +00:00
|
|
|
!(it == m_timevalues.end()); ++it)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2004-10-16 11:41:50 +00:00
|
|
|
float newtime = (*it)->GetNumber() + fixedtime;
|
2002-10-12 11:37:38 +00:00
|
|
|
floatval->SetFloat(newtime);
|
|
|
|
(*it)->SetValue(floatval);
|
|
|
|
}
|
|
|
|
|
|
|
|
floatval->Release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SCA_TimeEventManager::AddTimeProperty(CValue* timeval)
|
|
|
|
{
|
|
|
|
timeval->AddRef();
|
|
|
|
m_timevalues.push_back(timeval);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SCA_TimeEventManager::RemoveTimeProperty(CValue* timeval)
|
|
|
|
{
|
|
|
|
for (vector<CValue*>::iterator it = m_timevalues.begin();
|
2009-05-10 20:53:58 +00:00
|
|
|
!(it == m_timevalues.end()); ++it)
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
|
|
|
if ((*it) == timeval)
|
|
|
|
{
|
|
|
|
this->m_timevalues.erase(it);
|
|
|
|
timeval->Release();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-02-21 23:44:11 +00:00
|
|
|
|
|
|
|
vector<CValue*> SCA_TimeEventManager::GetTimeValues()
|
|
|
|
{
|
|
|
|
return m_timevalues;
|
|
|
|
}
|
|
|
|
|