Exemplo n.º 1
0
CValue* SCA_ExpressionController::FindIdentifier(const STR_String& identifiername)
{

	CValue* identifierval = NULL;

	for (vector<SCA_ISensor*>::const_iterator is=m_linkedsensors.begin();
	!(is==m_linkedsensors.end());is++)
	{
		SCA_ISensor* sensor = *is;
		if (sensor->GetName() == identifiername)
		{
			identifierval = new CBoolValue(sensor->GetState());
			//identifierval = sensor->AddRef();
		}

		//if (!sensor->IsPositiveTrigger())
		//{
		//	sensorresult = false;
		//	break;
		//}
	}

	if (identifierval)
		return identifierval;

	return  GetParent()->FindIdentifier(identifiername);

}
Exemplo n.º 2
0
static PyObjectPlus * KX_PythonSeq_subscript__internal(PyObject *self, char *key)
{
	PyObjectPlus *self_plus= BGE_PROXY_REF(((KX_PythonSeq *)self)->base);
	
	switch(((KX_PythonSeq *)self)->type) {
		case KX_PYGENSEQ_CONT_TYPE_SENSORS:
		{
			vector<SCA_ISensor*>& linkedsensors = ((SCA_IController *)self_plus)->GetLinkedSensors();
			SCA_ISensor* sensor;
			for (unsigned int index=0;index<linkedsensors.size();index++) {
				sensor = linkedsensors[index];
				if (sensor->GetName() == key)
					return static_cast<PyObjectPlus *>(sensor);
				
			}
			break;
		}
		case KX_PYGENSEQ_CONT_TYPE_ACTUATORS:
		{
			vector<SCA_IActuator*>& linkedactuators = ((SCA_IController *)self_plus)->GetLinkedActuators();
			SCA_IActuator* actuator;
			for (unsigned int index=0;index<linkedactuators.size();index++) {
				actuator = linkedactuators[index];
				if (actuator->GetName() == key)
					return static_cast<PyObjectPlus *>(actuator);
			}
			break;
		}
		case KX_PYGENSEQ_OB_TYPE_SENSORS:
		{
			SCA_SensorList& linkedsensors= ((KX_GameObject *)self_plus)->GetSensors();
			SCA_ISensor *sensor;
			for (unsigned int index=0;index<linkedsensors.size();index++) {
				sensor= linkedsensors[index];
				if (sensor->GetName() == key)
					return static_cast<PyObjectPlus *>(sensor);
			}
			break;
		}
		case KX_PYGENSEQ_OB_TYPE_CONTROLLERS:
		{
			SCA_ControllerList& linkedcontrollers= ((KX_GameObject *)self_plus)->GetControllers();
			SCA_IController *controller;
			for (unsigned int index=0;index<linkedcontrollers.size();index++) {
				controller= linkedcontrollers[index];
				if (controller->GetName() == key)
					return static_cast<PyObjectPlus *>(controller);
			}
			break;
		}
		case KX_PYGENSEQ_OB_TYPE_ACTUATORS:
		{
			SCA_ActuatorList& linkedactuators= ((KX_GameObject *)self_plus)->GetActuators();
			SCA_IActuator *actuator;
			for (unsigned int index=0;index<linkedactuators.size();index++) {
				actuator= linkedactuators[index];
				if (actuator->GetName() == key)
					return static_cast<PyObjectPlus *>(actuator);
			}
			break;
		}
		case KX_PYGENSEQ_OB_TYPE_CONSTRAINTS:
		{
			return ((BL_ArmatureObject*)self_plus)->GetConstraint(key);
		}
		case KX_PYGENSEQ_OB_TYPE_CHANNELS:
		{
			return ((BL_ArmatureObject*)self_plus)->GetChannel(key);
		}
	}
	
	return NULL;
}