示例#1
0
void CBreakableObject::CheckHitBreak(float power,ALife::EHitType hit_type)
{
	if( hit_type!=ALife::eHitTypeStrike)
	{
		float res_power=power*m_immunity_factor;
		if(power>m_health_threshhold) fHealth-=res_power;
	}
	if(fHealth<=0.f)	
	{
		Break();return;
	}

	if(hit_type==ALife::eHitTypeStrike)Break();
}
void move(int direction, int speed, int distance, int FBbreakspd){
	revolutions = 360*(distance/wheelCircumference);
	switch (direction) {

	case forward:
		zeroEncoders();
		while(getDTEncoderAverage() < revolutions){
			setDriveMotors(127,127,127, 127);
			setFBMotors(FBbreakspd);
		}
		zeroEncoders();
		Break(forward);
		break;

	case turnLeft: //int FLSpeed, int FRspeed, int BRspeed, int BLspeed
		zeroEncoders();
		while(getDTEncoderAverage() < revolutions){
			setDriveMotors(-127, 127, 127, -127);
			setFBMotors(FBbreakspd);

		}
		Break(turnLeft);
		break;

	case turnRight: //int FLSpeed, int FRspeed, int BRspeed, int BLspeed
		zeroEncoders();
		while(getDTEncoderAverage() < revolutions){
			setDriveMotors(127, -127, -127, 127);
			setFBMotors(FBbreakspd);
		}
		Break(turnRight);
		break;

	case backwards:
		zeroEncoders();
		while(getDTEncoderAverage() < revolutions){
			setDriveMotors(-127, -127, -127, -127);
			setFBMotors(FBbreakspd);

		}
		Break(backwards);
		break;

	default:
		setDriveMotors(0,0,0,0);
		zeroEncoders();

	}
	zeroEncoders();
}
void ofxOscReceiver::setup( int listen_port )
{
    if( osc::UdpSocket::GetUdpBufferSize() == 0 ){
    	osc::UdpSocket::SetUdpBufferSize(65535);
    }
    
	// if we're already running, shutdown before running again
	if ( listen_socket ){
		shutdown();
	}
	
	// create socket
	auto socket = new osc::UdpListeningReceiveSocket( osc::IpEndpointName( osc::IpEndpointName::ANY_ADDRESS, listen_port ), this, allowReuse );
	auto deleter = [](osc::UdpListeningReceiveSocket*socket){
		// tell the socket to shutdown
		socket->Break();
		delete socket;
	};
	auto new_ptr = std::unique_ptr<osc::UdpListeningReceiveSocket, decltype(deleter)>(socket, deleter);
	listen_socket = std::move(new_ptr);

	listen_thread = std::thread([this]{
		listen_socket->Run();
	});

	// detach thread so we don't have to wait on it before creating a new socket
	// or on destruction, the custom deleter for the socket unique_ptr already
	// does the right thing
	listen_thread.detach();

	this->listen_port = listen_port;
}
示例#4
0
void    FCPause( void ) {
//=======================

// Process PAUSE statement.

    Break( RT_PAUSE );
}
示例#5
0
void    FCStop( void ) {
//======================

// Process STOP statement.

    Break( RT_STOP );
}
示例#6
0
// get user options, process and save.
void
Options::onbtnSave()
{
	int dontsplash = optSplash.Get();    // get the value from option control
	int savewinpos = optSaveWinPos.Get();// get the value from option control

	Ctrl* owner = GetOwner(); // get a handle to the Options dislog owner which is MyUppApp main window.
	Rect rc;                  // create a struct to store window position and size

	if ( savewinpos != 1 ) {  // if Save Window option is not checked.
		rc.left = 0;          // set window position x to 0
		rc.top = 0;           // set window position y to 0
	} else {
		rc = owner->GetRect(); // get the position and size of MyUppApp main window
	}

	String cfg;  // create a string to store config data
	cfg << "Splash="     << dontsplash << "\n"    // save user's choice
	       "SaveWinPos=" << savewinpos << "\n"    // save user's choice
	       "PosX="       << rc.left    << "\n"    // save window x position
	       "PosY="       << rc.top     << "\n";   // save window y position

	if( !SaveFile(cfgfile, cfg) )  // save the config file
		Exclamation("Error saving configuration!"); // if failed show error dialog
	else
	    PromptOK("Options saved!");  // show success dialog

	Break(IDOK); // close this dialog
}
示例#7
0
void CObject::Explode()
{
    CVector pos = Placeable.GetPos();
    pos.z += 0.5;
    CExplosion::AddExplosion(this, getPlayerPed(-1), 9, pos, 100, 1, -1.0, 0);
    if(m_colDamageEffect == 0xCA || m_colDamageEffect == 0xc8)
    {
        pos.z -= 1.0;
        Break(10000.0, pos, 0, getPlayerPed(-1), 51);
    }
    else if(!bDisableFriction)
    {
        m_vecLinearVelocity.z += 0.5;
        m_vecLinearVelocity.x += (rand() - 128) * 0.000199999994947575;
        m_vecLinearVelocity.y += (rand() - 128) * 0.000199999994947575;
        if(bIsStatic || bIsStaticWaitingForCollision)
        {
            SetIsStatic(false);
            AddToMovingList();
        }
    }
    if(m_pObjectInfo->fxType == 2)
    {
        CMatrix pos = CMatrix::FromXYZ(m_xyz);
        // to object space
        CVector fx_obj_pos = pos * m_pObjectInfo->fxOffset;
        fx_obj_pos += GetPos(); // to world space
        FxSystem_c *sys = FxManager.InitialiseFxSystem(m_pObjectInfo->pFxSystemBP, fx_obj_pos, 0, 0);
        if(sys)
        {
            sys->Start();
        }
    }
}
示例#8
0
/*
================
idBrittleFracture::Shatter
================
*/
void idBrittleFracture::Shatter( const idVec3 &point, const idVec3 &impulse, const int time ) {
	int i;
	idVec3 dir;
	shard_t *shard;
	float m;

	if ( gameLocal.isServer ) {
		idBitMsg	msg;
		byte		msgBuf[MAX_EVENT_PARAM_SIZE];

		msg.Init( msgBuf, sizeof( msgBuf ) );
		msg.BeginWriting();
		msg.WriteFloat( point[0] );
		msg.WriteFloat( point[1] );
		msg.WriteFloat( point[2] );
		msg.WriteFloat( impulse[0] );
		msg.WriteFloat( impulse[1] );
		msg.WriteFloat( impulse[2] );
		ServerSendEvent( EVENT_SHATTER, &msg, true, -1 );
	}

	if ( time > ( gameLocal.time - SHARD_ALIVE_TIME ) ) {
		StartSound( "snd_shatter", SND_CHANNEL_ANY, 0, false, NULL );
	}

	if ( !IsBroken() ) {
		Break();
	}

	if ( fxFracture.Length() ) {
		idEntityFx::StartFx( fxFracture, &point, &GetPhysics()->GetAxis(), this, true );
	}

	dir = impulse;
	m = dir.Normalize();

	for ( i = 0; i < shards.Num(); i++ ) {
		shard = shards[i];

		if ( shard->droppedTime != -1 ) {
			continue;
		}

		if ( ( shard->clipModel->GetOrigin() - point ).LengthSqr() > Square( maxShatterRadius ) ) {
			continue;
		}

		DropShard( shard, point, dir, m, time );
	}

	DropFloatingIslands( point, impulse, time );

	//trigger it.
	if (!firedTargets)
	{
		firedTargets = true;
		ActivateTargets(this);
	}
}
示例#9
0
bool TopWindow::AcceptBreak(int ID)
{
	if(Accept()) {
		Break(ID);
		return true;
	}
	return false;
}
示例#10
0
/*
================
idBrittleFracture::Event_Activate
================
*/
void idBrittleFracture::Event_Activate( idEntity* activator )
{
	disableFracture = false;
	if( health <= 0 )
	{
		Break();
	}
}
示例#11
0
void DbgGdb::SetBreakpoints()
{
    for ( size_t i=0; i< m_bpList.size(); i++ ) {
        // Without the 'unnecessary' cast in the next line, bpinfo.bp_type is seen as (e.g.) 4 instead of BP_type_tempbreak, ruining switch statments :/
        BreakpointInfo bpinfo = ( BreakpointInfo )m_bpList.at( i );
        Break( bpinfo );
    }
}
示例#12
0
/*
================
idBrittleFracture::Killed
================
*/
void idBrittleFracture::Killed( idEntity* inflictor, idEntity* attacker, int damage, const idVec3& dir, int location )
{
	if( !disableFracture )
	{
		ActivateTargets( this );
		Break();
	}
}
示例#13
0
//-----------------------------------------------------------------------------
// Purpose: Take damage will break the rope
//-----------------------------------------------------------------------------
int CRopeKeyframe::OnTakeDamage( const CTakeDamageInfo &info )
{
	// Only allow this if it's been marked
	if( !(m_RopeFlags & ROPE_BREAKABLE) )
		return false;

	Break();
	return 0;
}
示例#14
0
void CLogger::Error(char* szText)
{
	Add("ERROR", szText);

	if (msConfig.bBreakOnError)
	{
		Break();
	}
}
示例#15
0
void cyclic::Click()
{
  for(int i=0;i<16;i++)
  {
      dc[i]=cols[i].GetData();
  }
  par.change(colnum, dc);
  Break(IDOK);
}
示例#16
0
/////////////////////////////////////////////////////////////////////////////////////
// create handler
void TPdfFrontend::onCreate(void)
{

	FileSel fs;
	
	// if no documents, just do nothing
	if(!Documents.GetCount())
		return;
	
	// first, gets last browsed path (if any)
	String cfgPath = GetPdfConfigPath() + "lastpath";
	if(FileExists(cfgPath))
	{
		FileIn f(cfgPath);
		fs.Set(f.GetLine());
	}
	
	// gets the output file name, returns if cancelled
	fs.DefaultExt(".pdf").Type("documenti pdf", "*.pdf");
	if(!fs.ExecuteSaveAs("Nome del documento pdf:"))
		return;

	// stores last active output path
	RealizeDirectory(GetPdfConfigPath());
	FileOut f(cfgPath);
	f.PutLine(fs.Get());

	// creates the command line and executes ghostscript
	String FileName = fs.Get();
    String args =
		"-q -dBATCH -dAutoFilterColorImages=false -sColorImageFilter=FlateEncode -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=\"" +
    	FileName + "\" \"" +
    	Documents[0] + "\"";
    for(int i = 1 ; i < Documents.GetCount(); i++)
    	args = args + " \"" + Documents[i] + "\"";
    String OutStr, ErrStr;
	bool res = SysExec("gs", args, Environment(), OutStr, ErrStr);

	// creates progress bar and hooks inside client
//	Progress progress("Creazione pdf in corso....");
//	Client.setProgress(progress);
//	progress.Create();
	
//	Client.setProgress(0);
//	if(progress.Canceled())
//		res = false;
	// if error, does nothing	
	if(!res)
		return;
	
	// clear collected documents
	ClearDocuments();
	
	// closes application
	Break(0);
	
} // END TPdfFrontend::onCreate()
示例#17
0
	bool CheckWrap(size_t len)
	{
		if (len + Column > WrapWidth)
		{
			Break();
			return true;
		}
		return false;
	}
示例#18
0
 void Box::Damage(const int dmg, const int dmg_kind) {
     if ( dmg_kind >= DAMAGE_PUSH_UP ) {
         Push(X(), Y(), Z(), dmg_kind);
         if ( Sub()==DIFFERENT && IsEmpty() ) {
             Break();
         }
     } else {
         Block::Damage(dmg, dmg_kind);
     }
 }
示例#19
0
/////////////////////////////////////////////////////////////////////////////////////
// cancel pdf creation handler
void TPdfFrontend::onCancel(void)
{
	if(DocumentList.GetCount() == 0 || PromptYesNo("Annullare la generazione ?"))
	{
		// remove pending poststript documents and closes app
		ClearDocuments();
		Break(0);
	}
	
} // END TPdfFrontend::onCancel()
示例#20
0
文件: ide.cpp 项目: kolyden/mirror
void Ide::Exit()
{
	if(debugger)
		debugger->Stop();
	SaveFile();
	SaveWorkspace();
	FlushFile();
	console.Kill();
	Break(IDOK);
	IdeExit = true;
}
示例#21
0
void XMLMenuEditor::okCb(void)
{
	// updates edited toolbars
	if(iFace)
	{
		iFace->SetCommands(commands);
		iFace->SetMenuBars(menusEditor.GetToolBars());
		iFace->SetToolBars(barsEditor.GetToolBars());
	}
	Break(IDOK);
	Close();
}
void C_PhysPropClientside::OnTakeDamage( int iDamage ) // very simple version
{
	if ( m_takedamage == DAMAGE_NO )
		return;

	m_iHealth -= iDamage;

	if (m_iHealth <= 0)
	{
		Break();
	}
}
/*
================
idBrittleFracture::Killed
================
*/
void idBrittleFracture::Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location ) {
	bool bPlayerResponsible( false );
	if( !disableFracture ) {
		ActivateTargets( this );
		Break();
	}
	if( attacker && attacker->IsType( idPlayer::Type ) ) {
		bPlayerResponsible = ( attacker == gameLocal.GetLocalPlayer() );
	} else if( attacker && attacker->m_SetInMotionByActor.GetEntity() ) {
		bPlayerResponsible = ( attacker->m_SetInMotionByActor.GetEntity() == gameLocal.GetLocalPlayer() );
	}
	gameLocal.m_MissionData->MissionEvent( COMP_DESTROY, this, bPlayerResponsible );
}
示例#24
0
void OutMode::Export(int kind)
{
	String ep = ~export_dir;
	if(IsNull(ep)) {
		Exclamation("Missing output directory!");
		return;
	}
	if(kind == 2)
		ide.ExportMakefile(ep);
	else
		ide.ExportProject(ep, kind, true);
	Break(IDOK);
}
示例#25
0
void DataListDefinitionDlg::OnSave()
{
	theDefList.name = ~edListName ;
	theDefList.fields.Clear() ;

	theDefList.fields.Add("NAME") ;
	theDefList.fields.Add("EMAIL") ;

	for (int i = 0; i < grid.GetCount(); i++)
		theDefList.fields.Add( grid.Get(i,0)) ;

	theDefList.Save() ;
	Break(IDOK) ;
}
示例#26
0
文件: Script.c 项目: maxmitti/SGGP
func Check()
{
	if(!target) return RemoveObject();
  if(!update)
  {
   if(temp > 100)
   {
    Break();
   }
  }
  else
  {
   if(temp > 200)
   {
    Break();
   }
  }
  SetPosition(target->GetX()+55,target->GetY()+40);
  if(target->~IsPegasusGate() && !update)
  {
  	Update();
  }
  return(1);
}
示例#27
0
文件: lterra.cpp 项目: AdrianGin/ivan
void olterrain::ReceiveDamage(character* Villain, int Damage, int)
{
  if(CanBeDestroyed() && Damage > GetStrengthValue())
  {
    EditHP(GetStrengthValue() - Damage);

    if(HP <= 0)
    {
      room* Room = GetRoom();
      Break();

      if(Room)
        Room->DestroyTerrain(Villain);
    }
  }
}
示例#28
0
/*
================
c4tnt: now fractures can be broken at start
idBrittleFracture::StartBroken
================
*/
void idBrittleFracture::StartBroken( const float part, float disperse) {
	int i, counter;
	shard_t *shard;
	shard_t *shardorg;
	idVec3 point;

	if ( disperse > 0.9) disperse = 0.9f;

	if ( !IsBroken() ) {
		Break();
	}
	
	counter = shards.Num() * part;
	if ( counter > shards.Num()) counter = shards.Num();

	while (counter > 0) {
		for ( i = 0; i < shards.Num(); i++ ) {
			shardorg = shards[i];

			if ( shardorg->droppedTime != -1 ) {
				continue;
			}
			if (gameLocal.random.RandomFloat() > disperse) {
				counter--;
				point = shardorg->clipModel->GetOrigin();

				for ( i = 0; i < shards.Num(); i++ ) {
					shard = shards[i];

					if ( shard->droppedTime != -1 || shard == shardorg) {
						continue;
					}

					if ( ( shard->clipModel->GetOrigin() - point ).LengthSqr() > Square( maxShatterRadius ) ) {
						continue;
					}

					counter--;
					DropShard( shard );
				}
				DropShard( shardorg );
				DropFloatingIslands( &counter );
			}
		}
	}
}
示例#29
0
bool LoopManager::Continue(ScriptExecutionState* state, COMMAND_ARGS)
{
	if (!m_loops.size())
		return false;

	LoopInfo* loopInfo = &m_loops.top();

	if (!loopInfo->loop->Update(PASS_COMMAND_ARGS))
	{
		Break(state, PASS_COMMAND_ARGS);
		return true;
	}

	RestoreStack(state, &loopInfo->ipInfo);
	opcodeOffsetPtr[kDataDeltaStackOffset] += loopInfo->ipInfo.ip - (*opcodeOffsetPtr);

	return true;
}
示例#30
0
	void Step(Settings* settings)
	{
		if (m_break)
		{
			Break();
			m_broke = true;
			m_break = false;
		}

		// Cache velocities to improve movement on breakage.
		if (m_broke == false)
		{
			m_velocity = m_body1->GetLinearVelocity();
			m_angularVelocity = m_body1->GetAngularVelocity();
		}

		Test::Step(settings);
	}