当前位置: 首页>>代码示例>>C++>>正文


C++ Opt类代码示例

本文整理汇总了C++中Opt的典型用法代码示例。如果您正苦于以下问题:C++ Opt类的具体用法?C++ Opt怎么用?C++ Opt使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Opt类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: compare

bool compare(Opt& o1, Opt& o2){
    if(o1.is_initialized()){
        return o2.is_initialized() && *o1 == *o2;
    } else {
        return !o2.is_initialized();
    }
}
开发者ID:shenyanjun,项目名称:eddic,代码行数:7,代码来源:Address.cpp

示例2: attachedActor

void AttachableSystem::Update( double DeltaTime )
{
    for (auto actor : mScene.GetActorsFromMap( GetType_static() ))
    {
        Opt<IAttachableComponent> attachableC = actor->Get<IAttachableComponent>();
        if ( !attachableC.IsValid() )
        {
            continue;
        }
        Opt<Actor> attachedActor( mScene.GetActor( attachableC->GetAttachedGUID() ) );
        if ( attachableC->GetAttachedGUID() == -1 )
        {
            continue;
        }

        if ( !attachedActor.IsValid() )
        {
            attachableC->SetAttachedGUID( -1 );
            EventServer< AttachStateChangedEvent>::Get().SendEvent( AttachStateChangedEvent( AttachStateChangedEvent::Detached, -1, actor->GetGUID() ) );
            continue;
        }

        Opt<IHealthComponent> attachedHealthC( attachedActor->Get<IHealthComponent>() );
        if ( attachedHealthC.IsValid() )
        {
            if ( !attachedHealthC->IsAlive() )
            {
                if (attachableC->IsRemoveOnAttachedDeath())
                {
                    Opt<IHealthComponent> healthC( actor->Get<IHealthComponent>() );
                    if (healthC.IsValid())
                    {
                        healthC->SetHP( 0 );
                    }
                }
                attachableC->SetAttachedGUID( -1 );
                EventServer<AttachStateChangedEvent>::Get().SendEvent( AttachStateChangedEvent( AttachStateChangedEvent::Detached, attachedActor->GetGUID(), actor->GetGUID() ) );
                continue;
            }
        }

        Opt<IPositionComponent> attachedPositionC( attachedActor->Get<IPositionComponent>() );
        if ( !attachedPositionC.IsValid() )
        {
            continue;
        }
        Opt<IPositionComponent> positionC( actor->Get<IPositionComponent>() );
        if ( !positionC.IsValid() )
        {
            continue;
        }
        glm::vec2 rvec = glm::rotate(glm::vec2(attachableC->GetPositionX(), attachableC->GetPositionY()), float( attachedPositionC->GetOrientation() ) );
        positionC->SetX( attachedPositionC->GetX() + rvec.x );
        positionC->SetY( attachedPositionC->GetY() + rvec.y );
        if (attachableC->IsInheritOrientation())
        {
            positionC->SetOrientation( attachedPositionC->GetOrientation() + boost::math::double_constants::pi );
        }
    }
}
开发者ID:HalalUr,项目名称:Reaping2,代码行数:60,代码来源:attachable_system.cpp

示例3: AddToActorColors

void EditorSelectSystem::AddToActorColors( int32_t actorGUID, ActorColors_t &actorColors, Opt<ActorColors_t> colorShaders /*= nullptr*/ )
{
    static Scene& scene=Scene::Get();
    auto actor( scene.GetActor( actorGUID ) );
    if (actor.IsValid())
    {
        auto renderableC( actor->Get<IRenderableComponent>() );
        auto color = renderableC.IsValid() ? renderableC->GetColor() : glm::vec4( 1.0 );
        if (colorShaders.IsValid())
        {
            auto found = colorShaders->find( actor->GetGUID() );
            if (found != colorShaders->end())
            {
                // this actor is already selected so the color is the selected color. taking color from the selected and saved colors
                color = found->second;
            }
        }
        if (renderableC.IsValid()&&renderableC->GetColor()==EditorVisibilitySystem::InvisibleColor)
        {
            // do not add to actorColors an invisible actor. That's the point in being invisible
        }
        else
        {
            actorColors.emplace( actor->GetGUID(), color );

        }
    }
}
开发者ID:Reaping2,项目名称:Reaping2,代码行数:28,代码来源:editor_select_system.cpp

示例4: Update

void PlayerControllerMessageSenderSystem::Update( double DeltaTime )
{
    MessageSenderSystem::Update( DeltaTime );
    if ( !IsTime() )
    {
        return;
    }
    //TODO: might need optimization
    Opt<Actor> actor = mScene.GetActor( mProgramState.mControlledActorGUID );
    if ( actor.IsValid() )
    {
        Opt<PlayerControllerComponent> playerControllerC = actor->Get<IControllerComponent>();
        if ( playerControllerC.IsValid() )
        {
            std::auto_ptr<PlayerControllerMessage> playerControllerMsg( new PlayerControllerMessage );
            playerControllerMsg->mActorGUID = actor->GetGUID();
            playerControllerMsg->mOrientation = std::floor( playerControllerC->mOrientation * PRECISION );
            playerControllerMsg->mHeading = std::floor( playerControllerC->mHeading * PRECISION );
            playerControllerMsg->mShoot = playerControllerC->mShoot;
            playerControllerMsg->mShootAlt = playerControllerC->mShootAlt;
            playerControllerMsg->mUseNormalItem = playerControllerC->mUseNormalItem;
            playerControllerMsg->mUseReload = playerControllerC->mUseReload;
            playerControllerMsg->mMoving = playerControllerC->mMoving;
            mMessageHolder.AddOutgoingMessage( playerControllerMsg );
        }
    }
}
开发者ID:HalalUr,项目名称:Reaping2,代码行数:27,代码来源:player_controller_message.cpp

示例5: actor

void MouseAdapterSystem::Update( double DeltaTime )
{
    Opt<Actor> actor( mScene.GetActor( mProgramState.mControlledActorGUID ) );
    if ( !actor.IsValid() )
    {
        return;
    }
    int32_t playerId = 1;
    static input::PlayerControlDevice& pcd( input::PlayerControlDevice::Get() );
    if( pcd.GetControlDevice( playerId ) != input::PlayerControlDevice::KeyboardAndMouse )
    {
        return;
    }
    InputState inputState = mInputSystem->GetInputState( playerId );

    Opt<IPositionComponent> actorPositionC = actor->Get<IPositionComponent>();
    inputState.mOrientation = atan2( mY - actorPositionC->GetY(), mX - actorPositionC->GetX() );

    inputState.mCursorX = mX;
    inputState.mCursorY = mY;

    if ( mMouse->IsButtonPressed( MouseSystem::Button_Left ) )
    {
        inputState.mShoot = true;
    }
    else if ( mMouse->IsButtonPressed( MouseSystem::Button_Right ) )
    {
        inputState.mShootAlt = true;
    }
    mInputSystem->SetInputState( playerId, inputState );
}
开发者ID:abannerth,项目名称:Reaping2,代码行数:31,代码来源:mouse_adapter_system.cpp

示例6: parent

void NotifyParentOnDeathSystem::Update( double DeltaTime )
{
    for ( auto actor : mScene.GetActorsFromMap( GetType_static() ) )
    {
        Opt<INotifyParentOnDeathComponent> notifyParentOnDeathC = actor->Get<INotifyParentOnDeathComponent>();
        if ( !notifyParentOnDeathC.IsValid() )
        {
            continue;
        }
        Opt<Actor> parent( mScene.GetActor( notifyParentOnDeathC->GetParentGUID() ) );
        Opt<Actor> killer( mScene.GetActor( notifyParentOnDeathC->GetKillerGUID() ) );

        if( !parent.IsValid() )
        {
            continue;
        }

        Opt<IHealthComponent> healthC = actor->Get<IHealthComponent>();
        if( !healthC.IsValid() || healthC->IsAlive() )
        {
            continue;
        }
        if( !killer.IsValid() )
        {
            continue;
        }
        Opt<IListenChildDeathComponent> listenChildDeathC = parent->Get<IListenChildDeathComponent>();
        if ( !listenChildDeathC.IsValid() )
        {
            continue;
        }
        listenChildDeathC->SetKillerOfChildGUID( killer->GetGUID() );
    }
}
开发者ID:HalalUr,项目名称:Reaping2,代码行数:34,代码来源:notify_parent_on_death_system.cpp

示例7: teamC

CloakSystem::CloakState CloakSystem::GetCloakState( const Actor& actor )
{
    Opt<ICloakComponent> cloakC = actor.Get<ICloakComponent>();
    if ( !cloakC.IsValid() || !cloakC->IsActive() )
    {
        return Visible;
    }
    static core::ProgramState& mProgramState = core::ProgramState::Get();
    if ( mProgramState.mControlledActorGUID == actor.GetGUID() )
    {
        return Cloaked;
    }
    Opt<ITeamComponent> teamC( actor.Get<ITeamComponent>() );
    if ( teamC.IsValid() )
    {
        static Scene& mScene = Scene::Get();
        Opt<Actor> controlledActor = mScene.GetActor( mProgramState.mControlledActorGUID );
        if ( controlledActor.IsValid() )
        {
            Opt<ITeamComponent> controlledTeamC( controlledActor->Get<ITeamComponent>() );
            if ( controlledTeamC.IsValid() && controlledTeamC->GetTeam() == teamC->GetTeam() )
            {
                return Cloaked;
            }
            else
            {
                return Invisible;
            }
        }
    }
    return Visible;
}
开发者ID:HalalUr,项目名称:Reaping2,代码行数:32,代码来源:cloak_system.cpp

示例8: test_one_arg

void test_one_arg() {
    using Opt = std::optional<T>;
    {
        Opt opt;
        auto & v = opt.emplace();
        static_assert( std::is_same_v<T&, decltype(v)>, "" );
        assert(static_cast<bool>(opt) == true);
        assert(*opt == T(0));
        assert(&v == &*opt);
    }
    {
        Opt opt;
        auto & v = opt.emplace(1);
        static_assert( std::is_same_v<T&, decltype(v)>, "" );
        assert(static_cast<bool>(opt) == true);
        assert(*opt == T(1));
        assert(&v == &*opt);
    }
    {
        Opt opt(2);
        auto & v = opt.emplace();
        static_assert( std::is_same_v<T&, decltype(v)>, "" );
        assert(static_cast<bool>(opt) == true);
        assert(*opt == T(0));
        assert(&v == &*opt);
    }
    {
        Opt opt(2);
        auto & v = opt.emplace(1);
        static_assert( std::is_same_v<T&, decltype(v)>, "" );
        assert(static_cast<bool>(opt) == true);
        assert(*opt == T(1));
        assert(&v == &*opt);
    }
}
开发者ID:ingowald,项目名称:llvm-project,代码行数:35,代码来源:emplace.pass.cpp

示例9: main

int main(int argc, char *argv[])
{
	Opt *options = new Opt();
	int count,i,status,opt_status;
	pid_t process;

	signal(SIGINT, main_signal_reaction); // Registrace funkce pro odchyt signalu

	opt_status = options->load(argc,argv);

	if(opt_status == HELP) return EXIT_SUCCESS; // Vypis napovedy a konec
	else if(opt_status == OPTION_FAIL) return EXIT_FAILURE; // Chyba v parametrech, konec

	if((options->check()) == OPTION_FAIL) return EXIT_FAILURE;

	vector<Service*> services;

	count = options->addresses.size();
	if(count == 1)
	{// jedna sluzba

		Service *a = new Service();
		a->start(options, 0);

		delete a;
		delete options;
	}
	else
	{// vice sluzeb

		for(i=0; i<count; i++)
		{
			process = fork();

			if(process == 0)
			{// Nova sluzba
				Service *a = new Service();
				a->start(options, i);

				delete a;
				delete options;

				exit(0); // sluzba konci
			}
			else
			{// Rodic ulozi pid potomka do vektoru
				main_children.push_back(process);
			}
		}

		for(i=0; i<count; i++)
		{// Cekani na ukonceni sluzeb (v normalnim pripade)

			waitpid(-1, &status, 0); // Cekani na jakehokoli potomka, az se ukonci
		}		
	}

	return EXIT_SUCCESS;
}
开发者ID:johnik55,项目名称:TFTPv2-server,代码行数:59,代码来源:main.cpp

示例10: AutoId

void IRoom::PlaceLevelEndPoint( RoomDesc &roomDesc, glm::vec2 pos )
{
    auto endPoint = ActorFactory::Get()( AutoId( "platform" ) );
    Opt<IPositionComponent> positionC = endPoint->Get<IPositionComponent>();
    positionC->SetX( pos.x );
    positionC->SetY( pos.y );
    mScene.AddActor( endPoint.release() );
}
开发者ID:Reaping2,项目名称:Reaping2,代码行数:8,代码来源:i_room.cpp

示例11: Cmd

//}}}
//{{{ class SysPwdCmd    method
SysPwdCmd::SysPwdCmd(const char *const name) : Cmd(name) {
    optMgr_.setShortDes("print name of current directory");
    optMgr_.setDes("prints the full filename of the current working directory");
    Opt *opt = new Opt(Opt::BOOL, "print usage", "");
    opt->addFlag("h");
    opt->addFlag("help");
    optMgr_.regOpt(opt);
}
开发者ID:ATeamMember,项目名称:Algo_PA3,代码行数:10,代码来源:sys_cmd.cpp

示例12: Update

void BounceCollisionSubSystem::Update( Actor& actor, double DeltaTime )
{
    Opt<BounceCollisionComponent> bounceCC = actor.Get<BounceCollisionComponent>();
    if (mShotCollisionSubSystem.IsValid()&&bounceCC->IsUseShotCollision())
    {
        mShotCollisionSubSystem->Update(actor, DeltaTime);
    }
}
开发者ID:abannerth,项目名称:Reaping2,代码行数:8,代码来源:bounce_collision_sub_system.cpp

示例13: Update

void AccelerationSystem::Update( double DeltaTime )
{
    for( ActorList_t::iterator it = mScene.GetActors().begin(), e = mScene.GetActors().end(); it != e; ++it )
    {
        Actor& actor = **it;
        Opt<IMoveComponent> moveC = actor.Get<IMoveComponent>();
        if ( !moveC.IsValid() )
        {
            continue;
        }
        Opt<IAccelerationComponent> accelerationC = actor.Get<IAccelerationComponent>();
        if ( !accelerationC.IsValid() )
        {
            continue;
        }

        double speed = moveC->GetSpeed().mBase.Get();
        double acceleration = accelerationC->GetAcceleration();
        speed += acceleration * DeltaTime;
        speed = ( acceleration > 0.0 ) ?
                std::min( speed, accelerationC->GetMaxSpeed() ) :
                std::max( speed, accelerationC->GetMinSpeed() );
        moveC->GetSpeed().mBase.Set( speed );
    }

}
开发者ID:abannerth,项目名称:Reaping2,代码行数:26,代码来源:acceleration_system.cpp

示例14: orientationMessage

std::auto_ptr<OrientationMessage> OrientationMessageSenderSystem::GenerateOrientationMessage( Actor& actor )
{
    Opt<IPositionComponent> positionC = actor.Get<IPositionComponent>();
    if ( !positionC.IsValid() )
    {
        return std::auto_ptr<OrientationMessage>();
    }
    std::auto_ptr<OrientationMessage> orientationMessage( new OrientationMessage );
    orientationMessage->mOrientation = std::floor( positionC->GetOrientation() * PRECISION );
    orientationMessage->mActorGUID = actor.GetGUID();
    return orientationMessage;
}
开发者ID:,项目名称:,代码行数:12,代码来源:

示例15: borderMsg

std::auto_ptr<BorderMessage> BorderMessageSenderSystem::GenerateBorderMessage( Actor& actor )
{
    Opt<IBorderComponent> borderC = actor.Get<IBorderComponent>();
    if ( !borderC.IsValid() )
    {
        return std::auto_ptr<BorderMessage>();
    }
    std::auto_ptr<BorderMessage> borderMsg( new BorderMessage );
    borderMsg->mActorGUID = actor.GetGUID();
    borderMsg->mBorders = borderC->GetBorders();
    borderMsg->mOuterBorders = borderC->GetOuterBorders();
    return borderMsg;
}
开发者ID:HalalUr,项目名称:Reaping2,代码行数:13,代码来源:border_message.cpp


注:本文中的Opt类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。