2008-06-23 20:41:18 +00:00
|
|
|
/**
|
|
|
|
* 'Nand' together all inputs
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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.
|
2008-06-23 20:41:18 +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.
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "SCA_NANDController.h"
|
|
|
|
#include "SCA_ISensor.h"
|
|
|
|
#include "SCA_LogicManager.h"
|
|
|
|
#include "BoolValue.h"
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* Native functions */
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
2009-06-28 11:22:26 +00:00
|
|
|
SCA_NANDController::SCA_NANDController(SCA_IObject* gameobj)
|
2008-06-23 20:41:18 +00:00
|
|
|
:
|
2009-06-28 11:22:26 +00:00
|
|
|
SCA_IController(gameobj)
|
2008-06-23 20:41:18 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SCA_NANDController::~SCA_NANDController()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SCA_NANDController::Trigger(SCA_LogicManager* logicmgr)
|
|
|
|
{
|
|
|
|
|
|
|
|
bool sensorresult = false;
|
|
|
|
|
|
|
|
for (vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin();
|
|
|
|
!(is==m_linkedsensors.end());is++)
|
|
|
|
{
|
|
|
|
SCA_ISensor* sensor = *is;
|
2009-06-08 20:08:19 +00:00
|
|
|
if (!sensor->GetState())
|
2008-06-23 20:41:18 +00:00
|
|
|
{
|
|
|
|
sensorresult = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (vector<SCA_IActuator*>::const_iterator i=m_linkedactuators.begin();
|
|
|
|
!(i==m_linkedactuators.end());i++)
|
|
|
|
{
|
2009-06-08 20:08:19 +00:00
|
|
|
SCA_IActuator* actua = *i;
|
|
|
|
logicmgr->AddActiveActuator(actua,sensorresult);
|
2008-06-23 20:41:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CValue* SCA_NANDController::GetReplica()
|
|
|
|
{
|
|
|
|
CValue* replica = new SCA_NANDController(*this);
|
|
|
|
// this will copy properties and so on...
|
2009-06-08 20:08:19 +00:00
|
|
|
replica->ProcessReplica();
|
2008-06-23 20:41:18 +00:00
|
|
|
|
|
|
|
return replica;
|
|
|
|
}
|
|
|
|
|
2009-09-29 21:42:40 +00:00
|
|
|
#ifndef DISABLE_PYTHON
|
2008-06-23 20:41:18 +00:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
/* Python functions */
|
|
|
|
/* ------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* Integration hooks ------------------------------------------------------- */
|
|
|
|
PyTypeObject SCA_NANDController::Type = {
|
2009-06-08 20:08:19 +00:00
|
|
|
PyVarObject_HEAD_INIT(NULL, 0)
|
2008-06-23 20:41:18 +00:00
|
|
|
"SCA_NANDController",
|
2009-04-20 15:06:46 +00:00
|
|
|
sizeof(PyObjectPlus_Proxy),
|
2008-06-23 20:41:18 +00:00
|
|
|
0,
|
2009-04-20 15:06:46 +00:00
|
|
|
py_base_dealloc,
|
2008-06-23 20:41:18 +00:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
2009-04-20 15:06:46 +00:00
|
|
|
py_base_repr,
|
2009-06-29 12:06:46 +00:00
|
|
|
0,0,0,0,0,0,0,0,0,
|
2009-06-28 11:22:26 +00:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
|
|
|
|
0,0,0,0,0,0,0,
|
|
|
|
Methods,
|
|
|
|
0,
|
|
|
|
0,
|
2009-06-29 12:06:46 +00:00
|
|
|
&SCA_IController::Type,
|
|
|
|
0,0,0,0,0,0,
|
|
|
|
py_base_new
|
2008-06-23 20:41:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
PyMethodDef SCA_NANDController::Methods[] = {
|
|
|
|
{NULL,NULL} //Sentinel
|
|
|
|
};
|
|
|
|
|
2009-02-26 09:04:06 +00:00
|
|
|
PyAttributeDef SCA_NANDController::Attributes[] = {
|
|
|
|
{ NULL } //Sentinel
|
|
|
|
};
|
|
|
|
|
2009-09-29 21:42:40 +00:00
|
|
|
#endif
|
|
|
|
|
2008-06-23 20:41:18 +00:00
|
|
|
/* eof */
|