Ejemplo n.º 1
0
	BodyPart *BodyParts::getNextWeaponPart(bool &looped)
	{
		int len = static_cast<int>(mPartList.size());
		int startIndex = mAttackIndex;
		looped = false;
		if (startIndex < 0 || startIndex >= len)
		{
			startIndex = len - 1;
		}
		mAttackIndex++;
		if (mAttackIndex >= len)
		{
			mAttackIndex = 0;
		}

		BodyPart *result = nullptr;
		while (mAttackIndex != startIndex)
		{
			BodyPart *part = mPartList[mAttackIndex];
			// Has to be a weapon part and not currently holding something else.
			if (part->isWeaponPart() && !part->isHoldingOnto())
			{
				result = part;
				break;
			}
			mAttackIndex++;
			if (mAttackIndex >= len)
			{
				mAttackIndex = 0;
				looped = true;
			}
		}
		return result;
	}