本文整理汇总了C++中Spawn函数的典型用法代码示例。如果您正苦于以下问题:C++ Spawn函数的具体用法?C++ Spawn怎么用?C++ Spawn使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Spawn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DEFINE_ACTION_FUNCTION
DEFINE_ACTION_FUNCTION(AActor, A_TossArm)
{
AActor *foo = Spawn("InquisitorArm", self->x, self->y, self->z + 24*FRACUNIT, ALLOW_REPLACE);
foo->angle = self->angle - ANGLE_90 + (pr_inq.Random2() << 22);
foo->velx = FixedMul (foo->Speed, finecosine[foo->angle >> ANGLETOFINESHIFT]) >> 3;
foo->vely = FixedMul (foo->Speed, finesine[foo->angle >> ANGLETOFINESHIFT]) >> 3;
foo->velz = pr_inq() << 10;
}
示例2: Rotate
void Shielder::Update()
{
fixed s = _power ? M_PT_ZERO_ONE * 12 : M_PT_ZERO_ONE * 4;
Rotate( s );
GetShape( 9 ).Rotate( -2 * s );
for ( int i = 0; i < 8; i++ )
GetShape( i ).Rotate( -s );
bool onScreen = false;
if ( GetPosition()._x < 0 )
_dir.Set( 1, 0 );
else if ( GetPosition()._x > Lib::WIDTH )
_dir.Set( -1, 0 );
else if ( GetPosition()._y < 0 )
_dir.Set( 0, 1 );
else if ( GetPosition()._y > Lib::HEIGHT )
_dir.Set( 0, -1 );
else
onScreen = true;
if ( !onScreen && _rotate ) {
_timer = 0;
_rotate = false;
}
fixed speed = SPEED + ( _power ? M_PT_ONE * 3 : M_PT_ONE * 2 ) * ( 16 - GetHP() );
if ( _rotate ) {
Vec2 d( _dir );
d.Rotate( ( _rDir ? 1 : -1 ) * ( TIMER - _timer ) * M_PI / ( M_TWO * TIMER ) );
_timer--;
if ( _timer <= 0 ) {
_timer = 0;
_rotate = false;
_dir.Rotate( ( _rDir ? 1 : -1 ) * M_PI / M_TWO );
}
Move( d * speed );
}
else {
_timer++;
if ( _timer > TIMER * 2 ) {
_timer = TIMER;
_rotate = true;
_rDir = GetLib().RandInt( 2 ) != 0;
}
if ( IsOnScreen() && _timer % TIMER == TIMER / 2 && _power ) {
Player* p = GetNearestPlayer();
Vec2 v = GetPosition();
Vec2 d = p->GetPosition() - v;
d.Normalise();
Spawn( new SBBossShot( v, d * M_THREE, 0x33cc99ff ) );
PlaySoundRandom( Lib::SOUND_BOSS_FIRE );
}
Move( _dir * speed );
}
_dir.Normalise();
}
示例3: start4
int start4(char *arg)
{
int pid, status, i;
char buf[12];
char name[] = "ChildS";
USLOSS_Console("start4(): Spawning 5 children to sleep\n");
for (i = 0; i < 5; i++) {
sprintf(buf, "%d", i);
name[5] = buf[0];
status = Spawn(name, ChildS, buf, USLOSS_MIN_STACK,2, &pid);
}
USLOSS_Console("start4(): Spawning 2 children to termfuncs\n");
status = Spawn("ChildTR", ChildTR, NULL, USLOSS_MIN_STACK,2, &pid);
status = Spawn("ChildTW", ChildTW, NULL, USLOSS_MIN_STACK,2, &pid);
USLOSS_Console("start4(): Spawning 4 children to diskfuncs\n");
status = Spawn("ChildDW0", ChildDW0, NULL, USLOSS_MIN_STACK,2, &pid);
status = Spawn("ChildDW1", ChildDW1, NULL, USLOSS_MIN_STACK,2, &pid);
status = Spawn("ChildDR0", ChildDR0, NULL, USLOSS_MIN_STACK,4, &pid);
status = Spawn("ChildDR1", ChildDR1, NULL, USLOSS_MIN_STACK,4, &pid);
for (i = 0; i < 11; i++) {
Wait(&pid, &status);
}
USLOSS_Console("start4(): done.\n");
Terminate(1);
return 0;
} /* start4 */
示例4: DEFINE_ACTION_FUNCTION
DEFINE_ACTION_FUNCTION(AActor, A_Bang4Cloud)
{
fixed_t spawnx, spawny;
spawnx = self->x + (pr_bang4cloud.Random2() & 3) * 10240;
spawny = self->y + (pr_bang4cloud.Random2() & 3) * 10240;
Spawn("Bang4Cloud", spawnx, spawny, self->z, ALLOW_REPLACE);
}
示例5: LaunchPlayer
//this shouldn't really be in here, but the decision to launch an player happens in the 'DisplayProgress' function
void LaunchPlayer()
{
char *Tempstr=NULL;
Tempstr=MCopyStr(Tempstr,Player," ",OutputFilesGetFilePath(),NULL);
PlayerPid=Spawn(Tempstr);
DestroyString(Tempstr);
}
示例6: Child1
int Child1(char *arg)
{
int pid, status;
USLOSS_Console("Child1() starting\n");
Spawn("Child2", Child2, "Child2", USLOSS_MIN_STACK, 5, &pid);
USLOSS_Console("Child1(): spawned process %d\n", pid);
Wait(&pid, &status);
USLOSS_Console("Child1(): child %d returned status of %d\n", pid, status);
Spawn("Child3", Child2, "Child3", USLOSS_MIN_STACK, 5, &pid);
USLOSS_Console("Child1(): spawned process %d\n", pid);
Wait(&pid, &status);
USLOSS_Console("Child1(): child %d returned status of %d\n", pid, status);
USLOSS_Console("Child1(): done\n");
Terminate(9);
return 0;
} /* Child1 */
示例7: P_MorphMonster
bool P_MorphMonster (AActor *actor, const PClass *spawntype, int duration, int style, const PClass *enter_flash, const PClass *exit_flash)
{
AMorphedMonster *morphed;
if (actor == NULL || actor->player || spawntype == NULL ||
actor->flags3 & MF3_DONTMORPH ||
!(actor->flags3 & MF3_ISMONSTER) ||
!spawntype->IsDescendantOf (RUNTIME_CLASS(AMorphedMonster)))
{
return false;
}
morphed = static_cast<AMorphedMonster *>(Spawn (spawntype, actor->x, actor->y, actor->z, NO_REPLACE));
DObject::StaticPointerSubstitution (actor, morphed);
morphed->tid = actor->tid;
morphed->angle = actor->angle;
morphed->UnmorphedMe = actor;
morphed->alpha = actor->alpha;
morphed->RenderStyle = actor->RenderStyle;
morphed->Score = actor->Score;
morphed->UnmorphTime = level.time + ((duration) ? duration : MORPHTICS) + pr_morphmonst();
morphed->MorphStyle = style;
morphed->MorphExitFlash = (exit_flash) ? exit_flash : RUNTIME_CLASS(ATeleportFog);
morphed->FlagsSave = actor->flags & ~MF_JUSTHIT;
morphed->special = actor->special;
memcpy (morphed->args, actor->args, sizeof(actor->args));
morphed->CopyFriendliness (actor, true);
morphed->flags |= actor->flags & MF_SHADOW;
morphed->flags3 |= actor->flags3 & MF3_GHOST;
if (actor->renderflags & RF_INVISIBLE)
{
morphed->FlagsSave |= MF_JUSTHIT;
}
morphed->AddToHash ();
actor->RemoveFromHash ();
actor->special = 0;
actor->tid = 0;
actor->flags &= ~(MF_SOLID|MF_SHOOTABLE);
actor->flags |= MF_UNMORPHED;
actor->renderflags |= RF_INVISIBLE;
Spawn(((enter_flash) ? enter_flash : RUNTIME_CLASS(ATeleportFog)), actor->x, actor->y, actor->z + TELEFOGHEIGHT, ALLOW_REPLACE);
return true;
}
示例8: Update
virtual ActionResult<CTFBot> Update(CTFBot *actor, float dt) override
{
TRACE("[this: %08x] [actor: #%d]", (uintptr_t)this, ENTINDEX(actor));
if (this->m_hHint == nullptr) {
return ActionResult<CTFBot>::Done("No hint entity");
}
INextBot *nextbot = rtti_cast<INextBot *>(actor);
if (nextbot->IsRangeGreaterThan(this->m_hHint->GetAbsOrigin(), 25.0f)) {
TRACE_MSG("range_to_hint > 25: pathing\n");
if (this->m_ctRecomputePath.IsElapsed()) {
TRACE_MSG("recomputing path\n");
this->m_ctRecomputePath.Start(RandomFloat(1.0f, 2.0f));
CTFBotPathCost cost_func(actor, FASTEST_ROUTE);
this->m_PathFollower.Compute(nextbot, this->m_hHint->GetAbsOrigin(), cost_func, 0.0f, true);
}
this->m_PathFollower.Update(nextbot);
if (!this->m_PathFollower.IsValid()) {
return ActionResult<CTFBot>::Done("Path failed");
}
return ActionResult<CTFBot>::Continue();
}
TRACE_MSG("at hint: creating dispenser entity\n");
CBaseEntity *ent = CreateEntityByName("obj_dispenser");
if (ent == nullptr) {
return ActionResult<CTFBot>::Done("Couldn't create entity");
}
auto dispenser = rtti_cast<CObjectDispenser *>(ent);
dispenser->SetName(this->m_hHint->GetEntityName());
dispenser->m_nDefaultUpgradeLevel = 2;
dispenser->SetAbsOrigin(this->m_hHint->GetAbsOrigin());
dispenser->SetAbsAngles(this->m_hHint->GetAbsAngles());
dispenser->Spawn();
dispenser->StartPlacement(actor);
suppress_speak = true;
dispenser->StartBuilding(actor);
suppress_speak = false;
this->m_hHint->SetOwnerEntity(dispenser);
actor->SpeakConceptIfAllowed(MP_CONCEPT_BUILDING_OBJECT, "objtype:dispenser");
return ActionResult<CTFBot>::Done("Built a dispenser");
}
示例9: main
int main( int argc, char *argv[] ) {
//======================================
// Call user's program.
argc = argc; argv = argv;
RTSysInit();
Spawn( &FMAIN );
return( 0 );
}
示例10: DEFINE_ACTION_FUNCTION
DEFINE_ACTION_FUNCTION(AActor, A_BishopPuff)
{
AActor *mo;
mo = Spawn ("BishopPuff", self->PosPlusZ(40*FRACUNIT), ALLOW_REPLACE);
if (mo)
{
mo->velz = FRACUNIT/2;
}
}
示例11: ProcInput
bool ProcInput( void )
{
bool ret;
_SwitchOn( SW_WND_DOING_INPUT );
ret = Spawn( DoProcPending );
DUIProcPendingPaint();
_SwitchOff( SW_WND_DOING_INPUT );
return( ret );
}
示例12: DEFINE_ACTION_FUNCTION
DEFINE_ACTION_FUNCTION(AActor, A_SorcererRise)
{
AActor *mo;
self->flags &= ~MF_SOLID;
mo = Spawn("Sorcerer2", self->x, self->y, self->z, ALLOW_REPLACE);
mo->SetState (mo->FindState("Rise"));
mo->angle = self->angle;
mo->CopyFriendliness (self, true);
}
示例13: SetMoveType
void CSDKPlayer::State_Enter_ACTIVE()
{
SetMoveType( MOVETYPE_WALK );
RemoveSolidFlags( FSOLID_NOT_SOLID );
m_Local.m_iHideHUD = 0;
PhysObjectWake();
//Tony; call spawn again now -- remember; when we add respawn timers etc, to just put them into the spawn queue, and let the queue respawn them.
Spawn();
}
示例14: DEFINE_ACTION_FUNCTION
DEFINE_ACTION_FUNCTION(AActor, A_TossArm)
{
PARAM_ACTION_PROLOGUE;
AActor *foo = Spawn("InquisitorArm", self->PosPlusZ(24.), ALLOW_REPLACE);
foo->Angles.Yaw = self->Angles.Yaw - 90. + pr_inq.Random2() * (360./1024.);
foo->VelFromAngle(foo->Speed / 8);
foo->Vel.Z = pr_inq() / 64.;
return 0;
}
示例15: DEFINE_ACTION_FUNCTION
DEFINE_ACTION_FUNCTION(AActor, A_SpectralLightningTail)
{
PARAM_ACTION_PROLOGUE;
AActor *foo = Spawn("SpectralLightningHTail", self->Vec3Offset(-self->Vel.X, -self->Vel.Y, 0.), ALLOW_REPLACE);
foo->Angles.Yaw = self->Angles.Yaw;
foo->FriendPlayer = self->FriendPlayer;
return 0;
}