Exemplo n.º 1
0
	GLvoid CBlock::init()
	{
		// 1. setup visible surfaces		
		if (isLow())
		{
			visible[BFS_TOP]		= false;			
			visible[BFS_WATER_LAVA]	= isWater() || isLava();
			visible[BFS_BOTTOM]		= !visible[BFS_WATER_LAVA];
			visible[BFS_CEILING]	= true;
		}
		else
		{
			visible[BFS_TOP]		= true;
			visible[BFS_BOTTOM]		= false;
			visible[BFS_WATER_LAVA]	= false;
			visible[BFS_CEILING]	= false;
		}

		//visible[BFS_TOP]		= false; // uncomment to see the optimization

		vector2i tests[4] =
		{
			vector2i(0,1),	// BFS_FRONT
			vector2i(0,-1), // BFS_BACK
			vector2i(-1,0), // BFS_LEFT
			vector2i(1,0),	// BFS_RIGHT
		};  

		CBlock *testBlock = NULL;
		for (GLint i=BFS_FRONT; i<=BFS_RIGHT; i++)
		{
			testBlock = CV_GAME_MANAGER->getLevelManager()->getBlock(logicalPosition+tests[i]);
			visible[i] = isLow()?false:(testBlock && testBlock->isLow() || !testBlock);

			if (water || lava)
			{
				// since water and lava are submerged by 1 level we nned to handle them differently
				visible[i] = testBlock && (!testBlock->low || 
											testBlock->type==CV_BLOCK_TYPE_CLAIMED_LAND_ID ||
											testBlock->type==CV_BLOCK_TYPE_UNCLAIMED_LAND_ID);	
			}
		}

		// tmp 
		/*for (GLint v=BFS_FRONT+1; v<=BFS_WATER_LAVA; v++)
		{
			//if (v!=BFS_BOTTOM)
			{
				visible[v]=false;
			}
		}*/

		/*
			For every block change you must call:
			- block init
			- calc block height if needed
			- finalize
		*/
	}
Exemplo n.º 2
0
	GLint CBlock::getFreeFaces(GLint faces[4])
	{
		GLint cnt = 0;

		if (isLow())
		{
			// a special type of light. could be described as a torch in the air.
			return -1;
		}

		CLevelManager *lManager = CV_GAME_MANAGER->getLevelManager();

		if (lManager->getBlock(logicalPosition+vector2i(0,1))->isLow())
		{
			faces[cnt++]=BFS_FRONT;
		}

		if (lManager->getBlock(logicalPosition+vector2i(0,-1))->isLow())
		{
			faces[cnt++]=BFS_BACK;
		}

		if (lManager->getBlock(logicalPosition+vector2i(1,0))->isLow())
		{
			faces[cnt++]=BFS_LEFT;
		}

		if (lManager->getBlock(logicalPosition+vector2i(-1,0))->isLow())
		{
			faces[cnt++]=BFS_RIGHT;
		}

		return cnt;
	}
 TPinOpenDrain<WatchDog_T, Port_T, Bit_T>::waitToGetHigh(void)
 {
   while (isLow())
     {
       WatchDog::reload();
     }
 }
void InnerNode::removeItem( int index )
{
    PRECONDITION( index >= 1 && index <= last );
    for( int to = index; to < last; to++ )
        item[to] = item[to+1];
    last--;
    if( isLow() )
        {
        if( parent == 0 )
            {
            // then this is the root; when only one child, make the child
            // the root
            if( Psize() == 0 )
                tree->rootIsEmpty();
            }
        else
            parent->isLow( this );
        }
}