Beispiel #1
0
	void Scene::RelayNoteTo(const std::string &tag, const std::string &note)
	{
		std::list<Entity*>* taggedEntities = GetAllTag(tag);
		for (std::list<Entity*>::iterator i = (*taggedEntities).begin(); i != (*taggedEntities).end(); ++i)
		{
			//if ((*i) != fromEntity)
			(*i)->ReceiveNote(tag, note);//, fromEntity);
		}
	}
Beispiel #2
0
	Entity* Scene::GetNearestEntityByControlPoint(const Vector2 &position, const std::string &tag, Entity *ignoreEntity)
	{
		float smallestSqrMag = -1.0f;

		Entity *nearestEntity = NULL;

		std::list<Entity*> *entities = &this->entities;

		if (tag != "")
		{
			entities = GetAllTag(tag);
		}

		if (entities != NULL)
		{
			for (std::list<Entity*>::iterator i = entities->begin(); i != entities->end(); ++i)
			{
				if ((*i) != ignoreEntity)
				{
					Vector2 diff = (*i)->GetWorldPosition() - position;
					if (diff.IsInRange(ENTITY_CONTROLPOINT_SIZE))
					{
						float sqrMag = diff.GetSquaredMagnitude();
						if (smallestSqrMag == -1 || sqrMag < smallestSqrMag)
						{
							smallestSqrMag = sqrMag;
							nearestEntity = (*i);
						}
					}
				}

				//Entity *nearestChild = (*i)->GetNearestEntityByControlPoint(position, tag, ignoreEntity, smallestSqrMag);
				//if (nearestChild)
				//{
				//	nearestEntity = nearestChild;
				//}
			}
		}


		return nearestEntity;
	}