예제 #1
0
////////////////////////////////////////////////////////////////////////////////
// onAttach
//virtual
void GaGameComponent::onAttach( ScnEntityWeakRef Parent )
{
	Super::onAttach( Parent );	

	Parent->attach( EmoteMaterialComponent_ );
}
//////////////////////////////////////////////////////////////////////////
// onAttach
//virtual
void ScnParticleSystemComponent::onAttach( ScnEntityWeakRef Parent )
{
	Parent->attach( MaterialComponent_ );

	Super::onAttach( Parent );
}
예제 #3
0
//////////////////////////////////////////////////////////////////////////
// GaGameComponent
//virtual
void GaGameComponent::onAttach( ScnEntityWeakRef Parent )
{
	// Find canvas component on parent. TODO: Make a utility function for this.
	for( BcU32 Idx = 0; Idx < Parent->getNoofComponents(); ++Idx )
	{
		CanvasComponent_ = Parent->getComponent( Idx );

		if( CanvasComponent_.isValid() )
		{
			break;
		}
	}

	// Materials.
	ScnMaterialRef Material;
	if( CsCore::pImpl()->requestResource( "game", "default", Material ) )
	{
		if( CsCore::pImpl()->createResource( BcName::INVALID, DefaultMaterial_, Material, BcErrorCode ) )
		{
			Parent->attach( DefaultMaterial_ );
		}
	}
	if( CsCore::pImpl()->requestResource( "game", "background", Material ) )
	{
		if( CsCore::pImpl()->createResource( BcName::INVALID, BackgroundMaterial_, Material, BcErrorCode ) )
		{
			Parent->attach( BackgroundMaterial_ );
		}
	}
	if( CsCore::pImpl()->requestResource( "game", "spritesheet0", Material ) )
	{
		if( CsCore::pImpl()->createResource( BcName::INVALID, SpriteSheetMaterials_[ 0 ], Material, BcErrorCode ) )
		{
			Parent->attach( SpriteSheetMaterials_[ 0 ] );
		}
	}
	if( CsCore::pImpl()->requestResource( "game", "spritesheet1", Material ) )
	{
		if( CsCore::pImpl()->createResource( BcName::INVALID, SpriteSheetMaterials_[ 1 ], Material, BcErrorCode ) )
		{
			Parent->attach( SpriteSheetMaterials_[ 1 ] );
		}
	}
	if( CsCore::pImpl()->requestResource( "game", "hud", Material ) )
	{
		if( CsCore::pImpl()->createResource( BcName::INVALID, HUDMaterial_, Material, BcErrorCode ) )
		{
			Parent->attach( HUDMaterial_ );
		}
	}

	// Font
	ScnFontRef Font;
	if( CsCore::pImpl()->requestResource( "game", "default", Font ) && CsCore::pImpl()->requestResource( "game", "font", Material ) )
	{
		if( CsCore::pImpl()->createResource( BcName::INVALID, Font_, Font, Material ) )
		{
			FontMaterial_ = Font_->getMaterialComponent();
			Parent->attach( Font_ );
		}
	}
	
	// Bind input events.
	//if( TeamID_ == 0 )
	{
		OsEventInputMouse::Delegate OnMouseEvent = OsEventInputMouse::Delegate::bind< GaGameComponent, &GaGameComponent::onMouseEvent >( this );
		OsEventInputKeyboard::Delegate OnKeyEvent = OsEventInputKeyboard::Delegate::bind< GaGameComponent, &GaGameComponent::onKeyEvent >( this );
		OsCore::pImpl()->subscribe( osEVT_INPUT_MOUSEUP, OnMouseEvent );
		OsCore::pImpl()->subscribe( osEVT_INPUT_MOUSEMOVE, OnMouseEvent );
		OsCore::pImpl()->subscribe( osEVT_INPUT_MOUSEDOWN, OnMouseEvent );
		OsCore::pImpl()->subscribe( osEVT_INPUT_KEYDOWN, OnKeyEvent );
		OsCore::pImpl()->subscribe( osEVT_INPUT_KEYUP, OnKeyEvent );
	}

	// Don't forget to attach!
	Super::onAttach( Parent );
}