本文整理汇总了C++中GetComponent函数的典型用法代码示例。如果您正苦于以下问题:C++ GetComponent函数的具体用法?C++ GetComponent怎么用?C++ GetComponent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetComponent函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sprintf
//=====================================================================================
// Window for WIND
//=====================================================================================
CFuiWind::CFuiWind(Tag idn, const char *filename)
:CFuiWindow(idn,filename,0,0,0)
{ char erm[128];
sprintf(erm,"Incorrect TEMPLATE file: %",filename);
//---Locate components ------------------------------------
layW = (CFuiList*) GetComponent('layr');
if (0 == layW) gtfo(erm);
errW = (CFuiLabel*) GetComponent('eror');
if (0 == layW) gtfo(erm);
popW = (CFuiPopupMenu*) GetComponent('popm');
if (0 == popW) gtfo(erm);
skyW = (CFuiTextField*) GetComponent('ceil');
if (0 == skyW) gtfo(erm);
//-- Init menu -------------------------------------------
popW->CreatePage(&cMEN,coverMENU);
layer = globals->wtm->GetCloudLayer();
popW->SetButtonText((char*)cMEN.aText[layer]);
//-- Init cloud ceil -------------------------------------
ceil = globals->wtm->GetCloudCeil();
ChangeCeil(0);
//-- Init list box ---------------------------------------
U_INT type = LIST_HAS_TITLE + LIST_NOHSCROLL;
windBOX.SetParameters(this,'layr',type);
windBOX.Display();
Select();
}
示例2: Split2Components
// Splits the calling object into its components.
global func Split2Components()
{
// Safety: can only be called from object context.
if (!this || GetType(this) != C4V_C4Object)
return FatalError(Format("Split2Components must be called from object context and not from %v", this));
// Transfer all contents to container.
var ctr = Contained();
while (Contents())
if (!ctr || !Contents()->Enter(ctr))
Contents()->Exit();
// Split components.
for (var i = 0, compid; compid = GetComponent(nil, i); ++i)
for (var j = 0; j < GetComponent(compid); ++j)
{
var comp = CreateObjectAbove(compid, nil, nil, GetOwner());
if (OnFire()) comp->Incinerate();
if (!ctr || !comp->Enter(ctr))
{
comp->SetR(Random(360));
comp->SetXDir(Random(3) - 1);
comp->SetYDir(Random(3) - 1);
comp->SetRDir(Random(3) - 1);
}
}
return RemoveObject();
}
示例3:
//=====================================================================================
//=====================================================================================
// Weather overview
//=====================================================================================
CFuiWeatherView::CFuiWeatherView(Tag idn, const char *filename)
:CFuiWindow(idn,filename,0,0,0)
{ char *erm = "Invalid template %s";
//---Get window components -------------------------------
datW = (CFuiLabel*)GetComponent('date');
if (0 == datW) gtfo(erm,filename);
timW = (CFuiLabel*)GetComponent('time');
if (0 == datW) gtfo(erm,filename);
utcW = (CFuiLabel*)GetComponent('utc_');
if (0 == utcW) gtfo(erm,filename);
disW = (CFuiLabel*)GetComponent('dist');
if (0 == disW) gtfo(erm,filename);
locW = (CFuiLabel*)GetComponent('loca');
if (0 == locW) gtfo(erm,filename);
winW = (CFuiLabel*)GetComponent('wind');
if (0 == winW) gtfo(erm,filename);
altW = (CFuiLabel*)GetComponent('alti');
if (0 == altW) gtfo(erm,filename);
tmpW = (CFuiLabel*)GetComponent('temp');
if (0 == tmpW) gtfo(erm,filename);
barW = (CFuiLabel*)GetComponent('baro');
if (0 == barW) gtfo(erm,filename);
cldW = (CFuiLabel*)GetComponent('clod');
if (0 == cldW) gtfo(erm,filename);
//---------------------------------------------------------
Apt = 0;
Req.SetWindow(this);
}
示例4: DeSerialize
/////////////////////////////
// DeSerialize
// -Translate the data in the buffer into relevant data for this object
void Player::DeSerialize(char * _buffer)
{
Transform * playerT = (Transform*)GetComponent(C_TRANSFORM);
InputController * playerI = (InputController*)GetComponent(C_INPUT);
// Read ID
unsigned int id = 0;
memcpy(&id, &_buffer[0], sizeof(id));
m_uiID = id;
// Read X
int x = 0;
memcpy(&x, &_buffer[4], sizeof(x));
playerT->SetX(x);
// Read Y
int y = 0;
memcpy(&y, &_buffer[8], sizeof(y));
playerT->SetY(y);
// Read input controller's ID
unsigned int inputID = 0;// playerI->GetID();
memcpy(&inputID, &_buffer[12], sizeof(inputID));
playerI->SetID(inputID);
m_pGame->SetRefresh(true);
}
示例5: BaseEnemy
std::unique_ptr<Entity> EntityFactory::CreateFlyingEnemy(int x, int y, Entity *target)
{
auto e = BaseEnemy(x, y);
e->AddComponent(ComponentType::AI, std::unique_ptr<FlyingAiComponent>(new FlyingAiComponent(target)));
auto g = static_cast<GraphicsComponent *>(e->GetComponent(ComponentType::GRAPHICS));
auto c = static_cast<CollisionComponent *>(e->GetComponent(ComponentType::COLLISION));
g->AddFrame(0, 200028, 5);
g->AddFrame(0, 200032, 5);
c->AddHitbox(0,0,70,35, HitboxType::SOLID);
c->AddHitbox(0,0,70,35, HitboxType::TRIGGER);
std::unique_ptr<SoundComponent> sound(new SoundComponent());
sound->AddSoundEffect(SoundEffectType::DEATH, SOUND_MONSTER_DEATH);
e->AddComponent(ComponentType::SOUND, std::move(sound));
auto spawnHealthPickupOnDeathScript = Compiler::Compile("data/scripts/SpawnHealthPickupOnDeathScript.txt");
RegisterNativeBindings(spawnHealthPickupOnDeathScript);
e->AddVmScript(std::move(spawnHealthPickupOnDeathScript));
return e;
}
示例6: Update
/////////////////////////////
// Update
// -Main loop
void Player::Update()
{
Transform * playerT = (Transform*)GetComponent(C_TRANSFORM);
InputController * input = (InputController*)GetComponent(C_INPUT);
bool changedInput = false;
if (input->GetKeyDown('W'))
{
playerT->SetY(playerT->GetY() - 1);
changedInput = true;
}
if (input->GetKeyDown('A'))
{
playerT->SetX(playerT->GetX() - 1);
changedInput = true;
}
if (input->GetKeyDown('S'))
{
playerT->SetY(playerT->GetY() + 1);
changedInput = true;
}
if (input->GetKeyDown('D'))
{
playerT->SetX(playerT->GetX() + 1);
changedInput = true;
}
if (changedInput)
{
NetworkView * nwView = (NetworkView*)GetComponent(C_NETWORK);
nwView->UpdatePositionMessage(playerT->GetX(), playerT->GetY());
}
UpdateComponents();
}
示例7: TimeRep
TimeRep :: TimeRep( const string & s ) : mSecs( 0 ) {
vector <string> tmp;
ALib::Split( s, ':', tmp );
if ( tmp.size() != 3 ) {
throw Exception( "Invalid time format: " + s );
}
int hrs = GetComponent( tmp[0], 24 );
int mins = GetComponent( tmp[1], 60 );
int secs = GetComponent( tmp[2], 60 );
mSecs = hrs * 60 * 60 + mins * 60 + secs;
}
示例8: Step
bool OMXClock::Step(int steps, bool lock)
{
if (!GetComponent())
return false;
if (lock)
Lock();
OMX_ERRORTYPE omxErr = OMX_ErrorNone;
OMX_PARAM_U32TYPE param;
OMX_INIT_STRUCTURE(param);
param.nPortIndex = OMX_ALL;
param.nU32 = steps;
omxErr = SetConfig(OMX_IndexConfigSingleStep, ¶m);
if (omxErr != OMX_ErrorNone)
{
if (lock)
Unlock();
return false;
}
m_lastMediaTime = 0.0f;
if (lock)
Unlock();
return true;
}
示例9: Start
bool OMXClock::Start(bool lock)
{
if (!GetComponent())
return false;
if (lock)
Lock();
OMX_ERRORTYPE omxErr = OMX_ErrorNone;
OMX_TIME_CONFIG_CLOCKSTATETYPE clock;
OMX_INIT_STRUCTURE(clock);
clock.eState = OMX_TIME_ClockStateRunning;
omxErr = SetConfig(OMX_IndexConfigTimeClockState, &clock);
if (omxErr != OMX_ErrorNone)
{
if (lock)
Unlock();
return false;
}
m_eState = clock.eState;
m_lastMediaTime = 0.0f;
if (lock)
Unlock();
return true;
}
示例10: Stop
bool OMXClock::Stop(bool lock)
{
if (!GetComponent())
return false;
if (lock)
Lock();
OMX_ERRORTYPE omxErr = OMX_ErrorNone;
OMX_TIME_CONFIG_CLOCKSTATETYPE clock;
OMX_INIT_STRUCTURE(clock);
clock.eState = OMX_TIME_ClockStateStopped;
clock.nOffset = ToOMXTime(-1000LL * OMX_PRE_ROLL);
omxErr = SetConfig(OMX_IndexConfigTimeClockState, &clock);
if (omxErr != OMX_ErrorNone)
{
if (lock)
Unlock();
return false;
}
m_eState = clock.eState;
m_lastMediaTime = 0.0f;
if (lock)
Unlock();
return true;
}
示例11: GetComponent
bool MapSystem::OnEntityChangedUniqueId(EntityId id, const std::string& oldUniqueId, const std::string& newUniqueId)
{
if(oldUniqueId == newUniqueId)
{
return true;
}
typedef std::map<std::string, EntityId> UIMap;
MapComponent* comp = GetComponent(id);
assert(comp != NULL);
UIMap::iterator j = mEntitiesByUniqueId.find(newUniqueId);
if(j != mEntitiesByUniqueId.end())
{
return false;
}
UIMap::iterator i = mEntitiesByUniqueId.find(oldUniqueId);
if(i != mEntitiesByUniqueId.end())
{
mEntitiesByUniqueId.erase(i);
}
mEntitiesByUniqueId[newUniqueId] = id;
EntityNameUpdatedMessage msg;
msg.SetAboutEntityId(id);
msg.SetEntityName(comp->GetEntityName());
msg.SetUniqueId(newUniqueId);
GetEntityManager().EmitMessage(msg);
return true;
}
示例12: CS_ASSERT
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void GridLayout::SetNumCols(u32 in_numCols)
{
CS_ASSERT(in_numCols > 0, "Cannot create a grid with 0 columns");
m_numCols = in_numCols;
GetComponent()->OnLayoutChanged();
}
示例13: StateExecute
bool OMXClock::StateExecute(bool lock)
{
if (!GetComponent())
return false;
if (lock)
Lock();
OMX_ERRORTYPE omxErr = OMX_ErrorNone;
if (GetState() != OMX_StateExecuting)
{
StateIdle(false);
omxErr = SetStateForComponent(OMX_StateExecuting);
if (omxErr != OMX_ErrorNone)
{
if (lock)
Unlock();
return false;
}
}
m_lastMediaTime = 0.0f;
if (lock)
Unlock();
return true;
}
示例14: ClockAdjustment
double OMXClock::ClockAdjustment(bool lock)
{
if (!GetComponent())
return 0.0;
if (lock)
Lock();
OMX_ERRORTYPE omxErr = OMX_ErrorNone;
double pts = 0.0;
OMX_TIME_CONFIG_TIMESTAMPTYPE timestamp;
OMX_INIT_STRUCTURE(timestamp);
timestamp.nPortIndex = GetInputPort();
omxErr = GetConfig(OMX_IndexConfigClockAdjustment, ×tamp);
if (omxErr != OMX_ErrorNone)
{
if (lock)
Unlock();
return 0.0;
}
pts = (double)FromOMXTime(timestamp.nTimestamp);
if (lock)
Unlock();
return pts;
}
示例15: Assert
/**
** Draw formatted text with variable value.
**
** @param unit unit with variable to show.
** @param defaultfont default font if no specific font in extra data.
**
** @note text is limited to 256 chars. (enough?)
** @note text must have exactly 1 %d.
** @bug if text format is incorrect.
*/
/* virtual */ void CContentTypeFormattedText::Draw(const CUnit &unit, CFont *defaultfont) const
{
char buf[256];
UStrInt usi1;
CFont &font = this->Font ? *this->Font : *defaultfont;
Assert(&font);
//Wyrmgus start
// CLabel label(font);
CLabel label(font, this->TextColor, this->HighlightColor);
//Wyrmgus end
Assert((unsigned int) this->Index < UnitTypeVar.GetNumberVariable());
usi1 = GetComponent(unit, this->Index, this->Component, 0);
if (usi1.type == USTRINT_STR) {
snprintf(buf, sizeof(buf), this->Format.c_str(), _(usi1.s));
} else {
snprintf(buf, sizeof(buf), this->Format.c_str(), usi1.i);
}
char *pos;
if ((pos = strstr(buf, "~|")) != NULL) {
std::string buf2(buf);
label.Draw(this->Pos.x - font.getWidth(buf2.substr(0, pos - buf)), this->Pos.y, buf);
} else if (this->Centered) {
label.DrawCentered(this->Pos.x, this->Pos.y, buf);
} else {
label.Draw(this->Pos.x, this->Pos.y, buf);
}
}