Ejemplo n.º 1
0
void
Entity::ScriptLinearToPosition( const float x, const float y, const float z, const LinearMovement movement, const char* animation )
{
    Ogre::Vector3 pos = Ogre::Vector3( x, y, z );
    SetLinear( pos, movement, animation );

    LOG_TRIVIAL( "[SCRIPT] Entity \"" + m_Name + "\" set linear move to position \"" + Ogre::StringConverter::toString( pos ) + "\" with animation \"" + animation + "\"." );
}
Ejemplo n.º 2
0
void
Entity::ScriptJumpToPosition( const float x, const float y, const float z, const float seconds )
{
    Ogre::Vector3 jump_to( x, y, z );
    SetJump( jump_to, seconds );

    LOG_TRIVIAL( "[SCRIPT] Entity \"" + m_Name + "\" set jump to position \"" + Ogre::StringConverter::toString( jump_to ) + "\" in " + Ogre::StringConverter::toString( seconds ) + " seconds." );
}
Ejemplo n.º 3
0
Entity::~Entity()
{
    delete m_SolidCollision;
    delete m_TalkCollision;

    m_SceneNode->removeAndDestroyAllChildren();

    LOG_TRIVIAL( "Entity \"" + m_Name + "\" destroyed." );
}
Ejemplo n.º 4
0
int
Entity::ScriptTurnSync()
{
    ScriptId script = ScriptManager::getSingleton().GetCurrentScriptId();

    LOG_TRIVIAL( "[SCRIPT] Wait entity \"" + m_Name + "\" turn for function \"" + script.function + "\" in script entity \"" + script.entity + "\"." );

    m_TurnSync.push_back( script );
    return -1;
}
Ejemplo n.º 5
0
void
Entity::ScriptMoveToPosition( const float x, const float y )
{
    m_State = Entity::WALKMESH;

    m_MovePosition = Ogre::Vector3( x, y, 0 );
    m_MoveEntity = NULL;
    m_MoveStopDistance = 0;
    LOG_TRIVIAL( "[SCRIPT] Entity \"" + m_Name + "\" set move to walkmesh position \"" + Ogre::StringConverter::toString( m_MovePosition ) + "\"." );
}
Ejemplo n.º 6
0
void
Entity::ScriptMoveToEntity( Entity* entity )
{
    m_State = Entity::WALKMESH;

    m_MovePosition = entity->GetPosition();
    m_MoveEntity = entity;
    m_MoveStopDistance = GetSolidRadius() + entity->GetSolidRadius();
    LOG_TRIVIAL( "[SCRIPT] Entity \"" + m_Name + "\" set move to entity \"" + entity->GetName() + "\"." );
}
Ejemplo n.º 7
0
//------------------------------------------------------------------------------
int
Background2D::ScriptScrollSync()
{
    ScriptId script = ScriptManager::getSingleton().GetCurrentScriptId();

    LOG_TRIVIAL( "[SCRIPT] Wait Background2d scroll for function \"" + script.function + "\" in script entity \"" + script.entity + "\"." );

    m_ScrollSync.push_back( script );
    return -1;
}
Ejemplo n.º 8
0
void
Entity::ScriptTurnToEntity( Entity* entity, const TurnDirection turn_direction, const float seconds )
{
    if( entity == NULL || entity == this )
    {
        LOG_ERROR("[SCRIPT] Turn to entity: Invalid entity pointer (NUUL or this).");
        return;
    }

    Ogre::Degree angle = GetDirectionToEntity( entity );
    SetTurn( angle, entity, turn_direction, AT_SMOOTH, seconds );
    LOG_TRIVIAL( "[SCRIPT] Entity \"" + m_Name + "\" turn to entity \"" + entity->GetName() + ".");
}
Ejemplo n.º 9
0
                static void Write(::std::stringstream* ss, Parameter* param)
                {
                    LOG_TRIVIAL(trace) << "Writing parameter with name " << param->GetName();
                    ITypedParameter<T>* typedParam = dynamic_cast<ITypedParameter<T>*>(param);
                    
                    if (typedParam)
                    {
                        (*ss) << "[" << param->GetTypeInfo().name() << "]";
						(*ss) << param->GetTreeName() << "#";
                        Serializer<T>::Serialize(ss, typedParam->Data());
                        (*ss) << "\n";
                    }
                }
Ejemplo n.º 10
0
                static void Read(::std::string* ss, Parameter* param)
                {
					LOG_TRIVIAL(trace) << "Reading parameter with name " << param->GetName();
                    ITypedParameter<T>* typedParam = dynamic_cast<ITypedParameter<T>*>(param);
                    if (typedParam)
                    {
						if(Serializer<T>::DeSerialize(ss, typedParam->Data()))
                        {
                            typedParam->changed = true;
                            typedParam->UpdateSignal(nullptr);
                        }
						param->changed = true;
						param->UpdateSignal(nullptr);
                    }
                }
Ejemplo n.º 11
0
AudioManager::~AudioManager()
{
    MusicStop();

    if( m_Initialized )
    {
        m_ThreadContinue = false;
        m_UpdateThread->join();
        delete m_UpdateThread;
        delete[] m_Buffer;

        alcMakeContextCurrent( NULL );
        alcDestroyContext( m_ALContext );
        alcCloseDevice( m_ALDevice );
        LOG_TRIVIAL( "AudioManager destroyed." );
    }
}
Ejemplo n.º 12
0
AudioManager::AudioManager():
    m_Initialized( false ),
    m_ThreadContinue( true ),
    m_UpdateMutex(),
    m_Music( &m_UpdateMutex )
{
    m_ALDevice = alcOpenDevice( NULL );
    if( m_ALDevice != NULL )
    {
        m_ALContext = alcCreateContext( m_ALDevice, NULL );
        if( m_ALContext != NULL )
        {
            alcMakeContextCurrent( m_ALContext );

            // listeners
            ALfloat position[ 3 ] = { 0.0f, 0.0f, 0.0f };
            ALfloat velocity[ 3 ] = { 0.0f, 0.0f, 0.0f };
            ALfloat orientation[ 6 ] = { 0.0f, 0.0f, -1.0f,  0.0f, 1.0f, 0.0f };
            alListenerfv( AL_POSITION, position );
            alListenerfv( AL_VELOCITY, velocity );
            alListenerfv( AL_ORIENTATION, orientation );
            m_Initialized = true;

            m_Buffer       = new char[ m_ChannelBufferSize ];
            m_UpdateThread = new boost::thread( boost::ref( *this ) );

            LOG_TRIVIAL( "AudioManager initialised." );
        }
        else
        {
            LOG_ERROR( "AudioManager failed to initialised. Could not create context for sound device." );
        }
    }
    else
    {
        LOG_ERROR( "AudioManager failed to initialised. There's no default sound device." );
    }



    // Load musics
    XmlMusicsFile musics( "./data/musics.xml" );
    musics.LoadMusics();
}
Ejemplo n.º 13
0
void
Entity::ScriptOffsetToPosition( const float x, const float y, const float z, const ActionType type, const float seconds )
{
    LOG_TRIVIAL( "[SCRIPT] Entity \"" + m_Name + "\" set offset to position \"" + Ogre::StringConverter::toString( Ogre::Vector3( x, y, z ) ) + "'." );

    Ogre::Vector3 position = Ogre::Vector3( x, y, z );

    if( type == AT_NONE )
    {
        this->SetOffset( position );
        return;
    }

    m_OffsetPositionStart = GetOffset();
    m_OffsetPositionEnd = position;
    m_OffsetType = type;
    m_OffsetSeconds = seconds;
    m_OffsetCurrentSeconds = 0;
}
Ejemplo n.º 14
0
//------------------------------------------------------------------------------
void
Background2D::ScriptScrollToPosition( const float x, const float y, const ScrollType type, const float seconds )
{
    LOG_TRIVIAL( "[SCRIPT] Background2d set scroll to position \"" + Ogre::StringConverter::toString( Ogre::Vector2( x, y ) ) + "\"." );

    Ogre::Vector2 position = Ogre::Vector2( x, y );

    m_ScrollEntity = NULL;

    if( type == Background2D::NONE )
    {
        SetScroll( position );
        return;
    }

    m_ScrollPositionStart = m_Position;
    m_ScrollPositionEnd = position;
    m_ScrollType = type;
    m_ScrollSeconds = seconds;
    m_ScrollCurrentSeconds = 0;
}
Ejemplo n.º 15
0
void
Entity::ScriptTurnToDirection( const float direction, const TurnDirection turn_direction, const ActionType turn_type, const float seconds )
{
    SetTurn( Ogre::Degree( direction ), NULL, turn_direction, turn_type, seconds );
    LOG_TRIVIAL("[SCRIPT] Entity \"" + m_Name + "\" turn to angle \"" + Ogre::StringConverter::toString( direction ) + "\".");
}
Ejemplo n.º 16
0
Entity::Entity( const Ogre::String& name, Ogre::SceneNode* node ):
    m_Name( name ),
    m_SceneNode( node ),

    m_Height( 1 ),

    m_SolidRadius( 0.24 ),
    m_Solid( false ),

    m_TalkRadius( 0.45f ),
    m_Talkable( false ),

    m_State( Entity::NONE ),

    m_MoveAutoSpeed( 0.7f ),
    m_MoveWalkSpeed( 0.7f ),
    m_MoveRunSpeed( 0.8f ),
    m_MovePosition( Ogre::Vector3( 0, 0, 0 ) ),
    m_MoveEntity( NULL ),
    m_MoveStopDistance( 0 ),
    m_MoveTriangleId( -1 ),
    m_MoveAutoRotation( true ),
    m_MoveAutoAnimation( true ),
    m_MoveAnimationWalk( "Walk" ),
    m_MoveAnimationRun( "Run" ),

    m_LinearMovement( LM_UP_TO_DOWN ),
    m_LinearStart( 0.0f, 0.0f, 0.0f ),
    m_LinearEnd( 0.0f, 0.0f, 0.0f ),

    m_JumpStart( 0.0f, 0.0f, 0.0f ),
    m_JumpEnd( 0.0f, 0.0f, 0.0f ),
    m_JumpSeconds( 0 ),
    m_JumpCurrentSeconds( 0 ),

    m_OffsetPositionStart( 0.0f, 0.0f, 0.0f ),
    m_OffsetPositionEnd( 0.0f, 0.0f, 0.0f ),
    m_OffsetType( AT_NONE ),
    m_OffsetSeconds( 0 ),
    m_OffsetCurrentSeconds( 0 ),

    m_TurnDirection( TD_CLOSEST ),
    m_TurnDirectionStart( 0 ),
    m_TurnDirectionEnd( 0 ),
    m_TurnEntity( NULL ),
    m_TurnType( AT_NONE ),
    m_TurnSeconds( 0 ),
    m_TurnCurrentSeconds( 0 ),

    m_AnimationSpeed( 1 ),
    m_AnimationDefault( "Idle" ),
    m_AnimationCurrentName( "" ),
    m_AnimationAutoPlay( true )
{
    m_model_root_node = m_SceneNode->createChildSceneNode();
    m_ModelNode = m_model_root_node->createChildSceneNode();

    m_Direction = new EntityDirection();
    m_Direction->setMaterial( "entity/direction" );
    m_DirectionNode = m_SceneNode->createChildSceneNode();
    m_DirectionNode->attachObject( m_Direction );

    m_SolidCollision = new EntityCollision();
    m_SolidCollision->setMaterial( "entity/solid_collision" );
    m_SolidCollisionNode = m_SceneNode->createChildSceneNode();
    m_SolidCollisionNode->setScale( m_SolidRadius, m_SolidRadius, m_Height );
    m_SolidCollisionNode->attachObject( m_SolidCollision );

    m_TalkCollision = new EntityCollision();
    m_TalkCollision->setMaterial( "entity/talk_collision" );
    m_TalkCollisionNode = m_SceneNode->createChildSceneNode();
    m_TalkCollisionNode->setScale( m_TalkRadius, m_TalkRadius, m_Height );
    m_TalkCollisionNode->attachObject( m_TalkCollision );

    m_model_root_node->setPosition( Ogre::Vector3::ZERO );
    m_ModelNode->setPosition( Ogre::Vector3::ZERO );
    m_SceneNode->setPosition( Ogre::Vector3::ZERO );

    LOG_TRIVIAL( "Entity \"" + m_Name + "\" created." );
}