Beispiel #1
0
void CSectionHandler::PaintBackground(CGraphicOnscreen& goTarget,CGraphic* pgBackground)
{
	if(GetWidthOffset()==0 && GetHeightOffset()==0)
		pgBackground->Copy(&goTarget,0,0);
	else if(GetHeightOffset()==0)
	{
		pgBackground->Copy(&goTarget,0,0,0,0,GetSplitX(),GetHeight());
		for(int i=0;i<GetWidthOffset();i++)
		{
			pgBackground->Copy(&goTarget,GetSplitX()+i,0,GetSplitX(),0,1,GetHeight());
		}
		pgBackground->Copy(&goTarget,GetSplitX()+GetWidthOffset(),0,GetSplitX(),0,GetWidth()-GetSplitX(),GetHeight());
	}
	else if(GetWidthOffset()==0)
	{
		pgBackground->Copy(&goTarget,0,0,0,0,GetWidth(),GetSplitY());
		for(int i=0;i<GetHeightOffset();i++)
		{
			pgBackground->Copy(&goTarget,0,GetSplitY()+i,0,GetSplitY(),GetWidth(),1);
		}
		pgBackground->Copy(&goTarget,0,GetSplitY()+GetHeightOffset(),0,GetSplitY(),GetWidth(),GetHeight()-GetSplitY());
	}
	else
	{
		// Draw order

		//  1    5a    2
		//
		//
		//  6a   7     6b
		//
		//
		//  3    5b    4


		// 1-4
		pgBackground->Copy(&goTarget,0,0,0,0,GetSplitX(),GetSplitY());
		pgBackground->Copy(&goTarget,GetSplitX()+GetWidthOffset(),0,GetSplitX(),0,GetWidth()-GetSplitX(),GetSplitY());
		pgBackground->Copy(&goTarget,0,GetSplitY()+GetHeightOffset(),0,GetSplitY(),GetSplitX(),GetHeight()-GetSplitY());
		pgBackground->Copy(&goTarget,GetSplitX()+GetWidthOffset(),GetSplitY()+GetHeightOffset(),GetSplitX(),GetSplitY(),GetWidth()-GetSplitX(),GetHeight()-GetSplitY());

		// 5a,b
		for(int iX=0;iX<GetWidthOffset();iX++)
		{
			pgBackground->Copy(&goTarget,GetSplitX()+iX,0,GetSplitX(),0,1,GetSplitY());
			pgBackground->Copy(&goTarget,GetSplitX()+iX,GetSplitY()+GetHeightOffset(),GetSplitX(),GetSplitY(),1,GetHeight()-GetSplitY());
		}
		// 6a,b
		for(int iY=0;iY<GetHeightOffset();iY++)
		{
			pgBackground->Copy(&goTarget,0,GetSplitY()+iY,0,GetSplitY(),GetSplitX(),1);
			pgBackground->Copy(&goTarget,GetSplitX()+GetWidthOffset(),GetSplitY()+iY,GetSplitX(),GetSplitY(),GetWidth()-GetSplitX(),1);
		}

		// 7
		goTarget.FillRect(GetSplitX(),GetSplitY(),GetWidthOffset(),GetHeightOffset(),pgBackground->GetPixel(GetSplitX(),GetSplitY()));
	}
}
Beispiel #2
0
	virtual void SetHeightOffset(entity_pos_t dy)
	{
		// subtract the offset and replace with a new offset
		m_LastYDifference = dy - GetHeightOffset();
		m_Y += m_LastYDifference;
		AdvertiseInterpolatedPositionChanges();
	}
Beispiel #3
0
	virtual void UpdateTurretPosition()
	{
		if (m_TurretParent == INVALID_ENTITY)
			return;
		CmpPtr<ICmpPosition> cmpPosition(GetSimContext(), m_TurretParent);
		if (!cmpPosition)
		{
			LOGERROR("Turret with parent without position component");
			return;
		}
		if (!cmpPosition->IsInWorld())
			MoveOutOfWorld();
		else
		{
			CFixedVector2D rotatedPosition = CFixedVector2D(m_TurretPosition.X, m_TurretPosition.Z);
			rotatedPosition = rotatedPosition.Rotate(cmpPosition->GetRotation().Y);
			CFixedVector2D rootPosition = cmpPosition->GetPosition2D();
			entity_pos_t x = rootPosition.X + rotatedPosition.X;
			entity_pos_t z = rootPosition.Y + rotatedPosition.Y;
			if (!m_InWorld || m_X != x || m_Z != z)
				MoveTo(x, z);
			entity_pos_t y = cmpPosition->GetHeightOffset() + m_TurretPosition.Y;
			if (!m_InWorld || GetHeightOffset() != y)
				SetHeightOffset(y);
			m_InWorld = true;
		}
	}
Beispiel #4
0
	virtual void SetHeightRelative(bool relative)
	{
		// move y to use the right offset (from terrain or from map origin)
		m_Y = relative ? GetHeightOffset() : GetHeightFixed();
		m_RelativeToGround = relative;
		m_LastYDifference = entity_pos_t::Zero();
		AdvertiseInterpolatedPositionChanges();
	}
Beispiel #5
0
// Returns true if given co-ordinate is in this area
BOOL CSectionHandler::HasPoint(int iX,int iY)
{
	return (iX>=m_iX && iY>=m_iY &&
		iX<m_iX+GetWidth()+GetWidthOffset() && iY<m_iY+GetHeight()+GetHeightOffset());
}