コード例 #1
0
unsigned int Forest::onCollideJumper(unsigned int id, Matrix4f* matrix, void* data)
{
    Forest* __this = reinterpret_cast<Forest*>( data );

    // determine obb of instance
    NxBox instanceOBB = calculateOBB( 
        __this->_canopyBatch->getBatchScheme()->lodGeometry[0], 
        *matrix,
        __this->_desc.collScale
    );
    __this->_debugBoxes.push_back( instanceOBB );

    // collide obbs
    if( NxBoxBoxIntersect( instanceOBB, __this->_jumperOBB ) )
    {
        Jumper* jumper = dynamic_cast<Jumper*>( __this->_currentJumper );
        // add impulse to jumper body
        NxVec3 linearVelocity = __this->_currentJumperActor->getLinearVelocity();
        NxVec3 impulse = linearVelocity * getCore()->getRandToolkit()->getUniform( __this->_desc.minImpulseFactor, __this->_desc.maxImpulseFactor ) * -1;
        NxVec3 localPos(
            __this->_jumperOBB.extents.x * getCore()->getRandToolkit()->getUniform( -1, 1 ),
            __this->_jumperOBB.extents.y * getCore()->getRandToolkit()->getUniform( -1, 1 ),
            __this->_jumperOBB.extents.z * getCore()->getRandToolkit()->getUniform( -1, 1 )
        );
        __this->_currentJumperActor->addForceAtLocalPos( impulse, localPos, NX_IMPULSE );
        // damage jumper
        jumper->damage( __this->_desc.damageFactor * impulse.magnitude(), 0.0f, linearVelocity.magnitude() );
        // play rustle sound
        __this->playRustleSound( __this->_currentJumperCollision->getFrame()->getPos() );
    }

    return id;
}
コード例 #2
0
void Activity::updateCooperativeActivity(float dt)
{
    // cooperative work
    engine::DeviceState deviceState = Gameplay::iEngine->handleCooperativeLevel();
    switch( deviceState )
    {
    case engine::dsLost:
    case engine::dsNotReset:
        Sleep( 50 );
        return;
    case engine::dsDriverInternalError:
        getCore()->logMessage( "Driver internal error occured during cooperative work!" );
        PostQuitMessage( 0 );
        return;
    }
    if( !Gameplay::iEngine->canRestoreDevice() )
    {
        getCore()->logMessage( "Error during full screen cooperative work!" );
        Gameplay::iGameplay->setUnsafeCleanup( true );
        PostQuitMessage( 0 );
    }

    // abstract activity
    updateActivity( dt );
}
コード例 #3
0
void		Federation::Ship::stricken(int damage) {
  int	n;
  n = damage;
  damage = n;
  if (getCore())
    getCore()->setStability(false);
}
コード例 #4
0
void NPCCameraman_DZ::onUpdate(float dt)
{

	//getCore()->logMessage("NPCCameraman_DZ::onUpdate");

    // follow cat toy untile it is roaming
    if( false && getNPC()->getJumper()->getPhase() == ::jpRoaming )
    {
		getCore()->logMessage("call NPCFollow");
        call( new NPCFollow( getNPC(), 100.0f ) );
    }
    // frefall for cat toy until it is in freefall
    else if( getNPC()->getJumper()->getPhase() == ::jpRoaming || getNPC()->getJumper()->getPhase() == ::jpFreeFalling )
    {
		//getCore()->logMessage("call NPCFreefall_DZ");
        call( new NPCFreefall_DZ( getNPC() ) );
    }
    // flight for cat toy
    else 
    {
		getCore()->logMessage("call NPCFlight_DZ");

        bool canopyIsSkydiving = database::Canopy::getRecord( getNPC()->getJumper()->getVirtues()->equipment.canopy.id )->skydiving;
        if( canopyIsSkydiving )
        {
            call( new NPCFlight_DZ( getNPC(), 75.0f, 50.0f ) );
        }
        else
        {
            call( new NPCFlight_DZ( getNPC(), 25.0f, 7.5f ) );
        }
    }
}
コード例 #5
0
void castingCallback_AngelFallsNoWings(Actor* parent)
{
    Mission* mission = dynamic_cast<Mission*>( parent ); assert( mission );    

    // exit point
    Enclosure* exitPoint = parent->getScene()->getExitPointEnclosure( mission->getMissionInfo()->exitPointId );

    // cast player on exit point
    mission->setPlayer( new Jumper( mission, NULL, exitPoint, NULL, NULL, NULL ) );

    // setup full signature for player
    mission->getPlayer()->setSignatureType( stFull );

    // select NPCs
    std::vector<unsigned int> npcs;
    selectNPCs( mission->getPlayer(), 0.25f, npcs );

    // load first ghost & cast NPC
    CatToy* catToy01 = CatToy::loadGhostCatToy( "./usr/cattoys/angelfalls/nowings01.cattoy" ); assert( catToy01 );
    NPC* ghost01 = ::castGhostNPC( mission, exitPoint, catToy01, npcs ); assert( ghost01 );

    // load second ghost & cast NPC
    CatToy* catToy02 = CatToy::loadGhostCatToy( "./usr/cattoys/angelfalls/nowings02.cattoy" ); assert( catToy02 );
    NPC* ghost02 = ::castGhostNPC( mission, exitPoint, catToy02, npcs ); assert( ghost02 );

    // in this mission can participate third character. sometimes.
    if( getCore()->getRandToolkit()->getUniform(0,1) > 0.33f )
    {
        CatToy* catToy03 = NULL;
        if( getCore()->getRandToolkit()->getUniform(0,1) > 0.5f )
        {
            catToy03 = CatToy::wrap( ghost01->getJumper() );
        }
        else
        {
            catToy03 = CatToy::wrap( ghost02->getJumper() );
        }
        NPC* ghost03 = ::castGhostNPC( mission, exitPoint, catToy03, npcs ); assert( ghost03 );
    }

    // cast script
    new script::AngelFalls_NoWings( mission->getPlayer(), catToy02 );

    // cast goals
    new GoalStateOfHealth( mission->getPlayer() );
    new GoalStateOfGear( mission->getPlayer() );
    new GoalLanding( mission->getPlayer() );
    new GoalExperience( mission->getPlayer() );
    new GoalBonus( mission->getPlayer(), Gameplay::iLanguage->getUnicodeString(533), btProgressive, 2.5f );
	new GoalOpening( mission->getPlayer() );
	new GoalFreeFallTime( mission->getPlayer() );
	new GoalCanopyTime( mission->getPlayer() );

    // play original music for this mission
    Gameplay::iGameplay->playSoundtrack( "./res/sounds/music/dirty_moleculas_i_degrade.ogg" );
}
コード例 #6
0
static Vector3f generateRandomPosition(const Vector3f& v0, const Vector3f& e0, const Vector3f& v1, const Vector3f& e1)
{
    e0Scaled = e0 * getCore()->getRandToolkit()->getUniform( 0,1 );
    e1Scaled = e1 * getCore()->getRandToolkit()->getUniform( 0,1 );
    e0Pos = e0Scaled + v0;
    e1Pos = e1Scaled + v1;
    eCross = e0Pos - e1Pos;
    eCrossScaled = eCross * getCore()->getRandToolkit()->getUniform( 0,1 );
    return e1Pos + eCrossScaled;
}
コード例 #7
0
	void ScanFolderPlugin::load()
	{
		LogSystemManager::instance().registerSystem(i18nc("plugin name","Scan Folder"),SYS_SNF);
		tlq = new TorrentLoadQueue(getCore(),this);
		scanner = new ScanThread();
		connect(scanner, SIGNAL(found(KUrl::List)), tlq, SLOT(add(KUrl::List)),Qt::QueuedConnection);
		pref = new ScanFolderPrefPage(this,0);
		getGUI()->addPrefPage(pref);
		connect(getCore(),SIGNAL(settingsChanged()),this,SLOT(updateScanFolders()));
		scanner->start(QThread::IdlePriority);
		updateScanFolders();
	}
コード例 #8
0
bool GoalApproach::met()
{
    //get coords of source and target
    //TODO: for met and act, DO NOT DO IT LIKE THIS! Will break if target or source is now null! Get comp* first then try for vector2d if not null
    Vector2d sourceCo = getCore()->getCoordsSub()->getComponent(getSourceId())->getCoords();
    Vector2d targetCo = getCore()->getCoordsSub()->getComponent(getTargetId())->getCoords();

    if (sourceCo.getDistance(targetCo) <= minDistToTarget_)
    {
        return true;
    }

    return false;
}
コード例 #9
0
void Node::getToWorld(Matrix &result)
{
    if(getParent() != NULL)
    {
        getParent()->getToWorld(result);
    }
    else
    {
        result.setIdentity();
    }

    if(getCore() != NULL)
        getCore()->accumulateMatrix(result);
}
コード例 #10
0
Vector3f generateRandomPosition(Vector3f* vertices, Vector3f* edges)
{
    if( getCore()->getRandToolkit()->getUniform( 0,1 ) < oneDivThree )
    {
        return generateRandomPosition( vertices[0], edges[0], vertices[0], edges[1] );
    }
    else if( getCore()->getRandToolkit()->getUniform( 0,1 ) < oneDivTwo )
    {
        return generateRandomPosition( vertices[0], edges[0], vertices[1], edges[2] );
    }
    else
    {
        return generateRandomPosition( vertices[1], edges[2], vertices[0], edges[1] );
    }
}
コード例 #11
0
void Forest::playSqueakSound(const Vector3f& pos)
{
    if( !_squeakSound )
    {
        const char* squeakSounds[2] =
        {
            "./res/sounds/wood/squeak01.ogg",
            "./res/sounds/wood/squeak02.ogg"
        };
        _squeakSound = Gameplay::iAudio->createStaticSound( squeakSounds[ getCore()->getRandToolkit()->getUniformInt() % 2 ] ); 
        _squeakSound->setDistanceModel( 1000.0f, 25000.0f, 1.0f );
        database::LocationInfo::Reverberation* reverb = getScene()->getReverberation();
        if( reverb )
        {
            _squeakSound->setReverberation(
                reverb->inGain,
                reverb->reverbMixDB,
                reverb->reverbTime,
                reverb->hfTimeRatio
            );
        }            
        _squeakSound->play();
        _squeakSound->place( pos );
    }
    else
    {
        _squeakSound->place( pos );
    }
}
コード例 #12
0
void castSkybaserForGhost(Mission* mission, Airplane* airplane, CatToy* ghost)
{
    assert( ghost );

    // detect cattoy level
    float cattoyLevel = 0.25f * (
        ghost->getVirtues()->getEnduranceSkill() + 
        ghost->getVirtues()->getPerceptionSkill() +
        ghost->getVirtues()->getRiggingSkill() +
        ghost->getVirtues()->getTrackingSkill()
    );

    // detect player is a LICENSED_CHAR
    bool playerIsLicensed = mission->getScene()->getCareer()->getLicensedFlag();

    // build list of same level npc    
    std::vector<unsigned int> npcs;
    database::NPCInfo::select( cattoyLevel, 0.126f, !playerIsLicensed, npcs );

    // select NPC
    unsigned int index = getCore()->getRandToolkit()->getUniformInt() % npcs.size();
    unsigned int npcId = npcs[index];
    
    // create NPC
    NPC* npc = new NPC( mission, npcId, airplane, NULL, ghost );

    // devote ghost
    npc->devoteCattoy();

    // setup cameraman behaviour
    npc->setProgram( new NPCCameraman( npc ) );

    // setup brief signature
    npc->getJumper()->setSignatureType( stBrief );
}
コード例 #13
0
GoalStateOfHealth::~GoalStateOfHealth()
{
    if( _player->isOverActivity() )
    {	
        Virtues* virtues = getScene()->getCareer()->getVirtues();
        assert( _finite( getGoalScore() ) );
        virtues->evolution.score += getGoalScore();
        if( virtues->evolution.score < 0 )
        {
            virtues->evolution.score = 0;
        }
        if( virtues->evolution.health == 0 )
        {
            bool creditsIsAffected = true;            
            // credits is not affected for licensed character
            creditsIsAffected = !_scene->getCareer()->getLicensedFlag();
            // credits is not affected in developer edition
			if ( Gameplay::iGameplay->_cheatsEnabled )
			{
				creditsIsAffected = false;
			}
            #ifdef GAMEPLAY_DEVELOPER_EDITION
                creditsIsAffected = false;
            #endif
            getCore()->logMessage( "creditsIsAffected=%d", creditsIsAffected );

            if( creditsIsAffected ) virtues->evolution.credits--;
            if( virtues->evolution.credits > 0 )
            {
                virtues->evolution.health = 0.125f;
            }
        }
    }
}
コード例 #14
0
ファイル: virtues.cpp プロジェクト: Jan123457/d3basejumper
float Virtues::getLinetwistsProbability(float jumperVelocity)
{    
    // probability of linetwists because of weak inflation (slider up)
    float factor = jumperVelocity / weakReferenceVelosity;
    float weakProb = maxiLTProbability / ( 1.0f + pow( factor, 5 ) );
    if( equipment.sliderOption != soUp ) weakProb = 0.0f;

    // probability of linetwists because of irregular inflation (slider down/removed)
    factor = jumperVelocity / irregularReferenceVelosity;
    float irregularProb = maxiLTProbability - ( maxiLTProbability / ( 1.0f + pow( factor, 3 ) ) );
    if( equipment.sliderOption == soUp ) irregularProb = 0.0f;

    // probability of linetwists because of canopy state
    float canopyStateProb = pow( ( 1 - equipment.canopy.state ), 15 );

    // probability of linetwists because of rig state
    float rigStateProb = pow( ( 1 - equipment.rig.state ), 30 );

    // result 
    float result = weakProb + irregularProb + canopyStateProb + rigStateProb;
    result = result > 1 ? 1 : result;

    getCore()->logMessage( "linetwists prob: %3.2f", result );

    return result;
}
コード例 #15
0
ファイル: EntityMgr.cpp プロジェクト: Jan123457/d3basejumper
void EntityMgr::actEntities() {

    // Process trigger handlers for all entities
    for (unsigned i=0; i < chunkEntity.size(); ++i) {
        if (NULL!=chunkEntity[i].entity) {
            for (unsigned int j=0; i<chunkEntity.size() && j<chunkEntity[i].trigevt.size(); ++j) {
                EntityTriggerEvent evt=chunkEntity[i].trigevt[j];
                chunkEntity[i].entity->entityHandleEvent(-1,evt.id,evt.param);
            }
        }
    }
    // Act all entities
    // Also count time statistics for entity and for it's type
    // Also take into account entity's activity rate
    clock_t curMilli = -1;
    for (unsigned i=0; i < chunkEntity.size(); ++i) {
        EntityChunk& ec = chunkEntity[i];
        if (NULL!=ec.entity) {
            assert(ec.actRate >= 0);
            assert(ec.actRate <= ACTIVITY_RATE_MAX);
            if ((ec.actAccumulate += ec.actRate) >= ACTIVITY_RATE_MAX) {
                ec.actAccumulate -= ACTIVITY_RATE_MAX;
                if (curMilli<0) curMilli = ::clock();
                clock_t dc = curMilli - ec.lastMilli;
                if (dc>ACTIVITY_MAX_DELAY_CLOCK) dc=ACTIVITY_MAX_DELAY_CLOCK;
                float dt = dc * (1.0f/CLOCKS_PER_SEC);
                /*
                if( dt < dtConst )
                {
                    Sleep( DWORD( ( dtConst - dt ) * 1000.0f ) );
                    dt = dtConst;
                }
                */
                ec.lastMilli = curMilli;
                if (!ec.entity->entityEverActed()) {
                    getCore()->logMessage("core: acting '%s'[%d]",
                        chunkType[ec.typeId].name, ec.entity->getid());
                }
                ec.entity->entityAct(dt);
                const_cast<unsigned&>(chunkEntity[i].entity->entityNumActs)++;
                clock_t curMilli2 = ::clock();
                clock_t actTime = curMilli2 - curMilli;
                chunkEntity[i].actMilli += actTime;
                chunkType[chunkEntity[i].typeId].actMilli += actTime;
                curMilli = curMilli2;
                // update system timer
                TimeMgr::instance->getSystemTime()->advance(actTime * (1.0f/CLOCKS_PER_SEC));
            }
        }
    }
    /*
    // Manage vtbl transforms
    if (rand() % 16 == 0) {
        vtableDisplace.reset();
    }
    if (rand() % 16 == 0) {
        vtableDisplace.clear();
    }
    */
}
コード例 #16
0
	void WebInterfacePlugin::initServer()
	{
		bt::Uint16 port = WebInterfacePluginSettings::port();
		bt::Uint16 i = 0;
				
		while (i < 10)
		{
			http_server = new HttpServer(getCore(),port + i);
			if (!http_server->ok())
			{
				delete http_server;
				http_server = 0;
			}
			else
				break;
			i++;
		}

		if (http_server)
		{
			if(WebInterfacePluginSettings::forward())
				bt::Globals::instance().getPortList().addNewPort(http_server->port(),net::TCP,true);
			Out(SYS_WEB|LOG_ALL) << "Web server listen on port "<< http_server->port() << endl;
		}
		else
		{
			Out(SYS_WEB|LOG_ALL) << "Cannot bind to port " << port <<" or the 10 following ports. WebInterface plugin cannot be loaded." << endl;
			return;
		}
	}
コード例 #17
0
ファイル: EntityMgr.cpp プロジェクト: Jan123457/d3basejumper
void EntityMgr::destroyEntity(entid_t id) {
    if (id==-1) return;
    // checkId(id);
    // Notify subscribers that entity is to be destroyed
    TrigEntityLife::Param trigParam;
    trigParam.eid = id;
    trigParam.lifeTime = entityPreDestroy;
    trigParam.param = NULL;
    trigParam.entityType = chunkType[chunkEntity[id].typeId].name;
    getCore()->activate(TrigEntityLife::tid,&trigParam);
    // Begin destroying
    EntityChunk& ec = chunkEntity[id];
    entid_t parentId=ec.entity->parentId;
    // Destroy children
    while (ec.children.size()>1) {
        entid_t idChild = ec.children[ec.children.size()-2];
        ec.children.erase(ec.children.begin()+ec.children.size()-2);
        getCore()->destroyEntity(idChild);
    }
    // Destroy entity itself
    EntityTypeChunk& tc = chunkType[ec.typeId];
    for (unsigned int i=0; i < tc.instances.size(); ++i) {
        if (tc.instances[i]==id) {
            tc.instances.erase(tc.instances.begin()+i);
            break;
        }
    }
    // physically destroy entity
    ec.entity->entityDestroy();
    // remove id from parent entity
    if (parentId>=0) {
        EntityChunk& ecParent=chunkEntity[parentId];
        for (unsigned int i=0; i < ecParent.children.size(); ++i) {
            if (ecParent.children[i]==id) {
                ecParent.children.erase(ecParent.children.begin()+i);
                --i;
            }
        }
    }
    // free entity's chunk
    ec.typeId=-1;
    ec.entity = NULL;
    freeChunkEntity.push(id);
    // Notify subscribers that entity has been destroyed
    trigParam.lifeTime = entityDestroyed;
    getCore()->activate(TrigEntityLife::tid,&trigParam);
}
コード例 #18
0
bool Node::unlinkChild (FieldContainer * const pChild,
                        UInt16           const childFieldId )
{
    if(childFieldId == ChildrenFieldId)
    {
        FINFO(("Node::unlinkChild: this [%p] [%u] pChild [%p] [%u]\n",
               this, this->getId(), pChild, 
               pChild != NULL ? pChild->getId() : 0));
               
        Node *pTypedChild = dynamic_cast<Node *>(pChild);
        
        if(pTypedChild != NULL)
        {
            Int32 iChildIdx = _mfChildren.findIndex(pTypedChild);

            if(iChildIdx != -1)
            {
                editMField(ParentFieldMask, _mfChildren);

                _mfChildren.erase(iChildIdx);
                
                return true;
            }
            
            FWARNING(("Node::unlinkChild: Child <-> Parent link "
                      "inconsistent.\n"));
            
            return false;
        }
        
        return false;
    }
    
    if(childFieldId == CoreFieldId)
    {
        NodeCore *pTypedChild = dynamic_cast<NodeCore *>(pChild);
        
        if(pTypedChild != NULL)
        {
            if(pTypedChild == getCore())
            {
                editSField(CoreFieldMask);

                _sfCore.setValue(NULL);
            
                return true;
            }
            
            FWARNING(("Node::unlinkChild: Child <-> Parent link "
                      "inconsistent.\n"));
        
            return false;
        }
        
        return false;
    }
    
    return Inherited::unlinkChild(pChild, childFieldId);
}
コード例 #19
0
float Virtues::getLineoverProbability(float pcFactor)
{
    float result = 0.03125f * ( 1 - pcFactor ) * ( 1 - pcFactor );

    getCore()->logMessage( "lineover prob: %3.2f", result );

    return result;
}
コード例 #20
0
ファイル: webinterfaceplugin.cpp プロジェクト: biwin/ktorrent
    void WebInterfacePlugin::load()
    {
        LogSystemManager::instance().registerSystem(i18n("Web Interface"), SYS_WEB);
        initServer();

        pref = new WebInterfacePrefWidget(0);
        getGUI()->addPrefPage(pref);
        connect(getCore(), SIGNAL(settingsChanged()), this, SLOT(preferencesUpdated()));
    }
コード例 #21
0
NPCFreefall_DZ::NPCFreefall_DZ(NPC* npc) : NPCProgram( npc )
{
    Matrix4f catToyPose = npc->getCatToy()->getCurrentPose();
    _targetPos.set( catToyPose[3][0], catToyPose[3][1], catToyPose[3][2] );
    _positionIsSucceed = false;
    _directionIsSucceed = false;
	_timeUntilJump = getCore()->getRandToolkit()->getUniform(1.0f, 10.0f);
	_timeUntilJump = 2.0f;
}
コード例 #22
0
ファイル: OSGNode.cpp プロジェクト: baibaiwei/OpenSGDevMaster
void Node::updateVolume(void)
{
    // still valid or static, nothing to do
    if(_sfVolume.getValue().isValid () == true   ||
       _sfVolume.getValue().isStatic() == true   ||
       getTravMask()                   == 0x0000   )
    {
        return;
    }

    // be careful to not change the real volume. If two threads
    // are updating the same aspect this will lead to chaos

    BoxVolume vol = _sfVolume.getValue();

    MFUnrecChildNodePtr::const_iterator cIt  = 
        this->getMFChildren()->begin();
    MFUnrecChildNodePtr::const_iterator cEnd = 
        this->getMFChildren()->end();

    vol.setEmpty();

    for(; cIt != cEnd; ++cIt)
    {
        if(*cIt != NULL && (*cIt)->getTravMask())
        {
            (*cIt)->updateVolume();
            vol.extendBy((*cIt)->getVolume());
        }
    }

    // test for null core. Shouldn't happen, but just in case...
    if(getCore() != NULL)
    {
        getCore()->adjustVolume(vol);
    }

    // don't propagate the static flag from children
    vol.setStatic(false);

    editSField(VolumeFieldMask);

    _sfVolume.setValue(vol);
}
コード例 #23
0
	void MediaPlayerPlugin::load()
	{
		LogSystemManager::instance().registerSystem(i18n("Media Player"),SYS_MPL);
		CoreInterface* core = getCore();
		act = new MediaPlayerActivity(core,actionCollection(),0);
		getGUI()->addActivity(act);
		setXMLFile("ktmediaplayerpluginui.rc");
		act->enableActions(0);
		act->loadState(KGlobal::config());
	}
コード例 #24
0
ファイル: db_npc.cpp プロジェクト: Jan123457/d3basejumper
unsigned int database::NPCInfo::getRandomNonLicensedCharacter(float level, float epsilon)
{
    // select characters
    std::vector<unsigned int> selection;
    select( level, epsilon, false, selection );
    assert( selection.size() );

    // return random id
    return selection[ getCore()->getRandToolkit()->getUniformInt() % selection.size() ];
}
コード例 #25
0
	void RssFeedPlugin::load()
	{
		//add the new tab to the gui
		KIconLoader* iload = KGlobal::iconLoader();
		m_rssFeedManager = new RssFeedManager(getCore());
		getGUI()->addTabPage(
			m_rssFeedManager,iload->loadIconSet("player_playlist", KIcon::Small),
			i18n("RSS Feeds"));
		
	}
コード例 #26
0
void Mission::consumePacket(NetworkData *packet) {
	getCore()->logMessage("Revceived packet with data_type: %d", packet->data_type);

	// network id [int]
	if (packet->data_type == 1) {
		memcpy(&this->getPlayer()->network_id, packet->data, sizeof this->network_id);
		this->network_id = this->getPlayer()->network_id;
		
	// add jumper
	} else if (packet->data_type == 2) {
		getCore()->logMessage("Create jumper with net id: %d", packet->receiver_id);
		NPC* npc = new NPC( this, 1, getPlayer()->getAirplane(), getPlayer()->getEnclosure(), CatToy::wrap( getPlayer() ), getPlayer(), true );
		npc->getJumper()->network_id = packet->receiver_id;
		npc->getJumper()->getFreefallActor()->setMass(getPlayer()->getVirtues()->appearance.weight);
		npc->getJumper()->getFreefallActor()->setGlobalPose(getPlayer()->getFreefallActor()->getGlobalPose());
		npc->getJumper()->getFreefallActor()->setLinearVelocity(getPlayer()->getFreefallActor()->getLinearVelocity());
		npc->getJumper()->beginFreefall();	// begins in Jumper
		delete packet;
	}
}
コード例 #27
0
ファイル: EntityMgr.cpp プロジェクト: Jan123457/d3basejumper
IBase * EntityMgr::queryInterface(entid_t eid, iid_t iid, bool softQuery) {
    IBase * pInt = NULL;
    if (eid>=0) {
        checkId(eid);
        pInt = chunkEntity[eid].entity->entityAskInterface(iid);
    }
    if (NULL==pInt && !softQuery) {
        const char * iname = getCore()->getIdName(iid);
        throw Exception("core: Entity {eid=%d} doesn't support Iterface{iid=0x%08X, name='%s'}", eid, iid, iname);
    }
    return (IBase*)vtableDisplace.displaceInterface(pInt);
}
コード例 #28
0
void SelectHome::onGuiMessage(gui::Message* message)
{
    if( strcmp( message->origin->getName(), "OkButton" ) == 0 && 
        message->event == gui::onButtonClick )
    {
        _messageBox->getPanel()->release();
        _messageBox = NULL;
        return;
    }

    if( strcmp( message->origin->getName(), "Geoscape" ) == 0 && 
        message->event == gui::onMouseDown &&
        message->mouseButton == gui::mbLeft &&
        _messageBox == NULL )
    {
        // check location color
        bool homeApproved = true;
        int x = _geoscape->getCursorX();
        int y = _geoscape->getCursorY();
        RGBApixel pixel = _worldMap->GetPixel( x / 2, y / 2 );
        if( pixel.Blue > pixel.Red && pixel.Blue > pixel.Green ) homeApproved = false;
        if( pixel.Red > 200 && pixel.Green > 200 && pixel.Blue > 200 ) homeApproved = false;
        if( homeApproved )
        {
            getCore()->logMessage( "Home approved, %d %d %d", pixel.Red, pixel.Green, pixel.Blue );
        }
        else
        {
            getCore()->logMessage( "Home rejected, %d %d %d", pixel.Red, pixel.Green, pixel.Blue );
        }

        // setup home location
        if( homeApproved )
        {
            _endOfMode = true;
            _homeX = _geoscape->getCursorX();
            _homeY = _geoscape->getCursorY();
        }
    }
}
コード例 #29
0
ファイル: UICanvas.cpp プロジェクト: GrimshawA/Nephilim
/// Draw the UI
void UICanvas::draw(GraphicsDevice* renderer)
{
	/// Draw surfaces bottom to top
	for(std::vector<UIWindow*>::iterator it = m_surfaces.begin(); it != m_surfaces.end(); it++)
	{
		if ((*it)->m_visible)
		{
			//Log("Drawing window: %s", (*it)->getName().c_str());
			(*it)->draw(renderer);
		}
	}


	if (getCore().dragElement)
	{
		getCore().dragElement->drawItself(renderer, mat4::identity);
	}

	if (getCore().contextMenuElement)
	{
		getCore().contextMenuElement->drawItself(renderer, mat4::identity);
	}

	if (!getCore().menuElementStack.empty())
	{
		getCore().menuElementStack[0]->drawItself(renderer, mat4::identity);
	}
};
コード例 #30
0
ファイル: EntityMgr.cpp プロジェクト: Jan123457/d3basejumper
IBase * EntityMgr::queryInterface(const char * entityType, iid_t iid, bool softQuery) {
    int numItems = findByType(entityType);
    IBase * pInt = NULL;
    if (numItems > 0) {
        pInt = queryInterface(entityResult.front(), iid, true);
    }
    if (NULL==pInt && !softQuery) {
        if (numItems==0) throw Exception("core: Entity {type='%s'} not exists", entityType);
        const char * iname = getCore()->getIdName(iid);
        throw Exception("core: Entity {type='%s'} doesn't support Iterface{iid=0x%08X, name='%s'}", entityType, iid, iname);
    }
    return pInt;
}