| 
									
										
										
										
											2011-02-23 10:52:22 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2008-06-23 20:41:18 +00:00
										 |  |  |  * 'Xor' 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 ***** | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-25 13:32:11 +00:00
										 |  |  | /** \file gameengine/GameLogic/SCA_XORController.cpp
 | 
					
						
							|  |  |  |  *  \ingroup gamelogic | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-23 20:41:18 +00:00
										 |  |  | #include "SCA_XORController.h"
 | 
					
						
							|  |  |  | #include "SCA_ISensor.h"
 | 
					
						
							|  |  |  | #include "SCA_LogicManager.h"
 | 
					
						
							|  |  |  | #include "BoolValue.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* ------------------------------------------------------------------------- */ | 
					
						
							|  |  |  | /* Native functions                                                          */ | 
					
						
							|  |  |  | /* ------------------------------------------------------------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-28 11:22:26 +00:00
										 |  |  | SCA_XORController::SCA_XORController(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_XORController::~SCA_XORController() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void SCA_XORController::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
										 |  |  | 		{ | 
					
						
							|  |  |  | 			if (sensorresult == true) | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  |                 sensorresult = false; | 
					
						
							|  |  |  | 				break; | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  |             sensorresult = true; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	 | 
					
						
							|  |  |  | 	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_XORController::GetReplica() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	CValue* replica = new SCA_XORController(*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; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-31 04:11:39 +00:00
										 |  |  | #ifdef WITH_PYTHON
 | 
					
						
							| 
									
										
										
										
											2008-06-23 20:41:18 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | /* ------------------------------------------------------------------------- */ | 
					
						
							|  |  |  | /* Python functions                                                          */ | 
					
						
							|  |  |  | /* ------------------------------------------------------------------------- */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* Integration hooks ------------------------------------------------------- */ | 
					
						
							|  |  |  | PyTypeObject SCA_XORController::Type = { | 
					
						
							| 
									
										
										
										
											2009-06-08 20:08:19 +00:00
										 |  |  | 	PyVarObject_HEAD_INIT(NULL, 0) | 
					
						
							| 
									
										
										
										
											2008-06-23 20:41:18 +00:00
										 |  |  | 	"SCA_XORController", | 
					
						
							| 
									
										
										
										
											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_XORController::Methods[] = { | 
					
						
							|  |  |  | 	{NULL,NULL} //Sentinel
 | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-02-26 09:04:06 +00:00
										 |  |  | PyAttributeDef SCA_XORController::Attributes[] = { | 
					
						
							|  |  |  | 	{ NULL }	//Sentinel
 | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2010-10-31 04:11:39 +00:00
										 |  |  | #endif // WITH_PYTHON
 | 
					
						
							| 
									
										
										
										
											2009-02-26 09:04:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-23 20:41:18 +00:00
										 |  |  | /* eof */ |