• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ BG_Buildable函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: G_AddMomentumForBuilding

/**
 * Adds momentum for building a buildable.
 *
 * Will save the reward with the buildable.
 */
float G_AddMomentumForBuilding(gentity_t* buildable) {
    float value, reward;
    team_t team;
    gentity_t* builder;

    if (!buildable || buildable->s.eType != ET_BUILDABLE) {
        return 0.0f;
    }

    value = BG_Buildable(buildable->s.modelindex)->buildPoints;
    team = BG_Buildable(buildable->s.modelindex)->team;

    if (buildable->builtBy->slot != -1) {
        builder = &g_entities[buildable->builtBy->slot];
    } else {
        builder = nullptr;
    }

    reward = AddMomentum(CONF_BUILDING, team, value, builder, false);

    // Save reward with buildable so it can be reverted
    buildable->momentumEarned = reward;

    return reward;
}
开发者ID:Kangz,项目名称:Unvanquished,代码行数:30,代码来源:sg_momentum.cpp


示例2: AngleVectors

/*
===============
CG_BuildableInRange
===============
*/
static entityState_t *CG_BuildableInRange( playerState_t *ps, float *healthFraction )
{
	vec3_t        view, point;
	trace_t       trace;
	entityState_t *es;
	int           health;

	AngleVectors( cg.refdefViewAngles, view, nullptr, nullptr );
	VectorMA( cg.refdef.vieworg, 64, view, point );
	CG_Trace( &trace, cg.refdef.vieworg, nullptr, nullptr, point, ps->clientNum, MASK_SHOT, 0 );

	es = &cg_entities[ trace.entityNum ].currentState;

	if ( healthFraction )
	{
		health = es->generic1;
		*healthFraction = ( float ) health / BG_Buildable( es->modelindex )->health;
	}

	if ( es->eType == ET_BUILDABLE &&
	     ps->persistant[ PERS_TEAM ] == BG_Buildable( es->modelindex )->team )
	{
		return es;
	}
	else
	{
		return nullptr;
	}
}
开发者ID:BlueMustache,项目名称:Unvanquished,代码行数:34,代码来源:cg_tutorial.cpp


示例3: CG_Creep

/*
==================
CG_Creep
==================
*/
static void CG_Creep( centity_t *cent )
{
  int           msec;
  float         size, frac;
  trace_t       tr;
  vec3_t        temp, origin;
  int           scaleUpTime = BG_Buildable( cent->currentState.modelindex )->buildTime;
  int           time;
  // int creepSize;
  time = cent->currentState.time;

  //should the creep be growing or receding?
  if( time >= 0 )
  {
    msec = cg.time - time;
    if( msec >= 0 && msec < scaleUpTime )
      frac = (float)msec / scaleUpTime;
    else
      frac = 1.0f;
  }
  else if( time < 0 )
  {
    msec = cg.time + time;
    if( msec >= 0 && msec < CREEP_SCALEDOWN_TIME )
      frac = 1.0f - ( (float)msec / CREEP_SCALEDOWN_TIME );
    else
      frac = 0.0f;
  }

  VectorCopy( cent->currentState.origin2, temp );
  VectorScale( temp, -CREEP_DISTANCE, temp );
  VectorAdd( temp, cent->lerpOrigin, temp );

  
  
  CG_Trace( &tr, cent->lerpOrigin, NULL, NULL, temp, cent->currentState.number, MASK_PLAYERSOLID );
  VectorCopy( tr.endpos, origin );
  

//  size = CREEP_SIZE * frac;
size = BG_Buildable( cent->currentState.modelindex )->creepSize * frac;

  if( size > 0.0f && tr.fraction < 1.0f )
    CG_ImpactMark( cgs.media.creepShader, //qhandle_t markShader
								  origin, //const vec3_t origin 
			  cent->currentState.origin2, //const vec3_t dir
									0.0f, //float orientation
									1.0f, //red
									1.0f, //green
									1.0f, //blue
									1.0f, //float alpha
								  qtrue, //qboolean alphaFade
								    size, //float radius
								   qtrue);//qboolean temporary
								   
					   

}
开发者ID:ppetr,项目名称:new-edge,代码行数:63,代码来源:cg_buildable.c


示例4: CG_BuildableParticleEffects

/*
==================
CG_BuildableParticleEffects
==================
*/
static void CG_BuildableParticleEffects( centity_t *cent )
{
  entityState_t   *es = &cent->currentState;
  team_t          team = BG_Buildable( es->modelindex )->team;
  int             health = es->generic1;
  float           healthFrac = (float)health / BG_Buildable( es->modelindex )->health;

  if( !( es->eFlags & EF_B_SPAWNED ) )
    return;
	
	
	    //ORGANIC BULB LIGHT / BA_H_LIGHT - VIA PS
    if( es->modelindex == BA_A_ORGANIC_BULB )
  {
    if( !CG_IsParticleSystemValid( &cent->buildablePS ) )
    {
      cent->buildablePS = CG_SpawnNewParticleSystem( cgs.media.organicbulbPS );

      if( CG_IsParticleSystemValid( &cent->buildablePS ) )
      {
        CG_SetAttachmentCent( &cent->buildablePS->attachment, cent );
        CG_AttachToCent( &cent->buildablePS->attachment );
      }
    }
  }

  else if( team == TEAM_HUMANS )
  {
    if( healthFrac < 0.33f && !CG_IsParticleSystemValid( &cent->buildablePS ) )
    {
      cent->buildablePS = CG_SpawnNewParticleSystem( cgs.media.humanBuildableDamagedPS );

      if( CG_IsParticleSystemValid( &cent->buildablePS ) )
      {
        CG_SetAttachmentCent( &cent->buildablePS->attachment, cent );
        CG_AttachToCent( &cent->buildablePS->attachment );
      }
    }
    else if( healthFrac >= 0.33f && CG_IsParticleSystemValid( &cent->buildablePS ) )
      CG_DestroyParticleSystem( &cent->buildablePS );
  }
  else if( team == TEAM_ALIENS )
  {
    if( healthFrac < 0.33f && !CG_IsParticleSystemValid( &cent->buildablePS ) )
    {
      cent->buildablePS = CG_SpawnNewParticleSystem( cgs.media.alienBuildableDamagedPS );

      if( CG_IsParticleSystemValid( &cent->buildablePS ) )
      {
        CG_SetAttachmentCent( &cent->buildablePS->attachment, cent );
        CG_SetParticleSystemNormal( cent->buildablePS, es->origin2 );
        CG_AttachToCent( &cent->buildablePS->attachment );
      }
    }
    else if( healthFrac >= 0.33f && CG_IsParticleSystemValid( &cent->buildablePS ) )
      CG_DestroyParticleSystem( &cent->buildablePS );
  }
}
开发者ID:ppetr,项目名称:new-edge,代码行数:63,代码来源:cg_buildable.c


示例5: G_Bounce

/*
================
G_Bounce

================
*/
static void G_Bounce( gentity_t *ent, trace_t *trace )
{
	vec3_t   velocity;
	float    dot;
	int      hitTime;
	float    minNormal;
	qboolean invert = qfalse;

	// reflect the velocity on the trace plane
	hitTime = level.previousTime + ( level.time - level.previousTime ) * trace->fraction;
	BG_EvaluateTrajectoryDelta( &ent->s.pos, hitTime, velocity );
	dot = DotProduct( velocity, trace->plane.normal );
	VectorMA( velocity, -2 * dot, trace->plane.normal, ent->s.pos.trDelta );

	if ( ent->s.eType == ET_BUILDABLE )
	{
		minNormal = BG_Buildable( ent->s.modelindex )->minNormal;
		invert = BG_Buildable( ent->s.modelindex )->invertNormal;
	}
	else
	{
		minNormal = 0.707f;
	}

	// cut the velocity to keep from bouncing forever
	if ( ( trace->plane.normal[ 2 ] >= minNormal ||
	       ( invert && trace->plane.normal[ 2 ] <= -minNormal ) ) &&
	     trace->entityNum == ENTITYNUM_WORLD )
	{
		VectorScale( ent->s.pos.trDelta, ent->physicsBounce, ent->s.pos.trDelta );
	}
	else
	{
		VectorScale( ent->s.pos.trDelta, 0.3f, ent->s.pos.trDelta );
	}

	if ( VectorLength( ent->s.pos.trDelta ) < 10 )
	{
		VectorMA( trace->endpos, 0.5f, trace->plane.normal, trace->endpos );  // make sure it is off ground
		G_SetOrigin( ent, trace->endpos );
		ent->s.groundEntityNum = trace->entityNum;
		VectorCopy( trace->plane.normal, ent->s.origin2 );
		VectorSet( ent->s.pos.trDelta, 0.0f, 0.0f, 0.0f );
		return;
	}

	VectorCopy( ent->r.currentOrigin, ent->s.pos.trBase );
	VectorAdd( ent->r.currentOrigin, trace->plane.normal, ent->r.currentOrigin );
	ent->s.pos.trTime = level.time;
}
开发者ID:Asvarox,项目名称:Unvanquished,代码行数:56,代码来源:g_physics.c


示例6: CG_HumanCkitText

/*
===============
CG_HumanCkitText
===============
*/
static void CG_HumanCkitText( char *text, playerState_t *ps )
{
  buildable_t   buildable = ps->stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT;
  entityState_t *es;

  if( buildable > BA_NONE )
  {
    Q_strcat( text, MAX_TUTORIAL_TEXT,
        va( "Press %s to place the %s\n",
          CG_KeyNameForCommand( "+attack" ),
          BG_Buildable( buildable )->humanName ) );

    Q_strcat( text, MAX_TUTORIAL_TEXT,
        va( "Press %s to cancel placing the %s\n",
          CG_KeyNameForCommand( "+button5" ),
          BG_Buildable( buildable )->humanName ) );
  }
  else
  {
    Q_strcat( text, MAX_TUTORIAL_TEXT,
        va( "Press %s to build a structure\n",
          CG_KeyNameForCommand( "+attack" ) ) );
  }

  if( ( es = CG_BuildableInRange( ps, NULL ) ) )
  {
    if( cgs.markDeconstruct )
    {
      if( es->eFlags & EF_B_MARKED )
      {
        Q_strcat( text, MAX_TUTORIAL_TEXT,
            va( "Press %s to unmark this structure\n",
              CG_KeyNameForCommand( "deconstruct" ) ) );
      }
      else
      {
        Q_strcat( text, MAX_TUTORIAL_TEXT,
            va( "Press %s to mark this structure\n",
              CG_KeyNameForCommand( "deconstruct" ) ) );
      }
    }
    else
    {
      Q_strcat( text, MAX_TUTORIAL_TEXT,
          va( "Press %s to destroy this structure\n",
            CG_KeyNameForCommand( "deconstruct" ) ) );
    }
  }
}
开发者ID:librelous,项目名称:librelous,代码行数:54,代码来源:cg_tutorial.c


示例7: G_RemoveMomentumForDecon

/**
 * Removes momentum for deconstructing a buildable.
 */
float G_RemoveMomentumForDecon( gentity_t *buildable, gentity_t *deconner )
{
	float     value;
	team_t    team;

	// sanity check buildable
	if ( !buildable || buildable->s.eType != entityType_t::ET_BUILDABLE )
	{
		return 0.0f;
	}
	team = BG_Buildable( buildable->s.modelindex )->team;

	if ( buildable->momentumEarned )
	{
		value = buildable->momentumEarned;
	}
	else
	{
		// assume the buildable has just been placed
		value = G_PredictMomentumForBuilding( buildable );
	}

	// Remove only partial momentum as the lost health fraction awards momentum to the enemy.
	value *= buildable->entity->Get<HealthComponent>()->HealthFraction();

	return AddMomentum( CONF_DECONSTRUCTING, team, -value, deconner, false );
}
开发者ID:jaytersen,项目名称:Unvanquished,代码行数:30,代码来源:sg_momentum.cpp


示例8: buildFire

/*
===============
buildFire
===============
*/
void buildFire( gentity_t *ent, dynMenu_t menu )
{
	//TODO find a solution to move dependency of ent->s.number and &ent->eventTime outside this function
	playerState_t *ps=&ent->client->ps;
	buildable_t buildable = ( ps->stats[ STAT_BUILDABLE ]
	                          & ~SB_VALID_TOGGLEBIT );

	if ( buildable > BA_NONE )
	{
		if ( ps->stats[ STAT_MISC ] > 0 )
		{
			G_AddPlayerEvent( ps, EV_BUILD_DELAY, ps->clientNum, ent->s.number, &ent->eventTime );
			return;
		}

		if ( G_BuildIfValid( ent, buildable ) )
		{
			if ( !g_cheats.integer )
			{
				ps->stats[ STAT_MISC ] +=
				  BG_Buildable( buildable )->buildTime;
			}

			ps->stats[ STAT_BUILDABLE ] = BA_NONE;
		}

		return;
	}

	G_TriggerMenu( ps->clientNum, menu );
}
开发者ID:bmorel,项目名称:Unvanquished,代码行数:36,代码来源:g_weapon.c


示例9: CG_Rocket_DFCMHumanBuildables

static void CG_Rocket_DFCMHumanBuildables( int handle, const char *data )
{
	buildable_t buildable = ( buildable_t ) atoi( Info_ValueForKey( data, "1" ) );
	const char *Class = "";
	const char *Icon = "";
	const char *action = "";
	int value, valueMarked;

	value = cg.snap->ps.persistant[ PERS_BP ];
	valueMarked = cg.snap->ps.persistant[ PERS_MARKEDBP ];

	if ( BG_BuildableDisabled( buildable ) || !BG_BuildableUnlocked( buildable ) )
	{
		Class = "locked";
		//Padlock icon. UTF-8 encoding of \uf023
		Icon = "<icon>\xEF\x80\xA3</icon>";
	}
	else if ( BG_Buildable( buildable )->buildPoints > value + valueMarked )
	{
		Class = "expensive";
		//$1 bill icon. UTF-8 encoding of \uf0d6
		Icon = "<icon>\xEF\x83\x96</icon>";
	}
	else
	{
		Class = "available";
		action = va( "onClick='Cmd.exec(\"build %s\") Events.pushevent(\"hide %s\", event)'", BG_Buildable( buildable )->name, rocketInfo.menu[ ROCKETMENU_HUMANBUILD ].id );
	}

	Rocket_DataFormatterFormattedData( handle, va( "<button class='%s' onMouseover='Events.pushevent(\"setDS humanBuildList default %s\", event)' %s>%s<img src='/%s'/></button>", Class, Info_ValueForKey( data, "2" ), action, Icon, CG_GetShaderNameFromHandle( cg_buildables[ buildable ].buildableIcon ) ), false );
}
开发者ID:norfenstein,项目名称:unvqx,代码行数:31,代码来源:cg_rocket_dataformatter.cpp


示例10: buildFire

/*
===============
buildFire
===============
*/
void buildFire( gentity_t *ent, dynMenu_t menu )
{
  buildable_t buildable = ( ent->client->ps.stats[ STAT_BUILDABLE ]
                            & ~SB_VALID_TOGGLEBIT );

  if( buildable > BA_NONE )
  {
    if( ent->client->ps.stats[ STAT_BUILD_TIMER ] > 0 )
    {
      G_AddEvent( ent, EV_BUILD_DELAY, ent->client->ps.clientNum );
      return;
    }

    if( G_BuildIfValid( ent, buildable ) )
    {
      if( !g_cheats.integer )
      {
        ent->client->ps.stats[ STAT_BUILD_TIMER ] +=
          BG_Buildable( buildable )->buildTime;
      }

      ent->client->ps.stats[ STAT_BUILDABLE ] = BA_NONE;
    }

    return;
  }

  G_TriggerMenu( ent->client->ps.clientNum, menu );
}
开发者ID:massivehaxxor,项目名称:new-edge,代码行数:34,代码来源:g_weapon.c


示例11: while

/*
================
G_SelectSpawnBuildable

find the nearest buildable of the right type that is
spawned/healthy/unblocked etc.
================
*/
static gentity_t *G_SelectSpawnBuildable( vec3_t preference, buildable_t buildable )
{
    gentity_t *search, *spot;

    search = spot = NULL;

    while( ( search = G_Find( search, FOFS( classname ),
                              BG_Buildable( buildable )->entityName ) ) != NULL )
    {
        if( !search->spawned )
            continue;

        if( search->health <= 0 )
            continue;

        if( !search->s.groundEntityNum )
            continue;

        if( search->clientSpawnTime > 0 )
            continue;

        if( G_CheckSpawnPoint( search->s.number, search->s.origin,
                               search->s.origin2, buildable, NULL ) != NULL )
            continue;

        if( !spot || DistanceSquared( preference, search->s.origin ) <
                DistanceSquared( preference, spot->s.origin ) )
            spot = search;
    }

    return spot;
}
开发者ID:GrangerHub,项目名称:tremulous,代码行数:40,代码来源:g_client.c


示例12: G_PredictMomentumForBuilding

/**
 * Predicts the momentum reward for building a buildable.
 *
 * Is used for the buildlog entry, which is written before the actual reward
 *happens.
 * Also used to calculate the deconstruction penalty for preplaced buildables.
 */
float G_PredictMomentumForBuilding(gentity_t* buildable) {
    if (!buildable || buildable->s.eType != ET_BUILDABLE) {
        return 0.0f;
    }

    return BG_Buildable(buildable->s.modelindex)->buildPoints *
           MomentumMod(CONF_BUILDING);
}
开发者ID:Kangz,项目名称:Unvanquished,代码行数:15,代码来源:sg_momentum.cpp


示例13: G_FindZapChainTargets

/*
===============
G_FindZapChainTargets
===============
*/
static void G_FindZapChainTargets( zap_t *zap )
{
	gentity_t *ent = zap->targets[ 0 ]; // the source
	int       entityList[ MAX_GENTITIES ];
	vec3_t    range = { LEVEL2_AREAZAP_CHAIN_RANGE,
	                    LEVEL2_AREAZAP_CHAIN_RANGE,
	                    LEVEL2_AREAZAP_CHAIN_RANGE
	                  };
	vec3_t    mins, maxs;
	int       i, num;
	gentity_t *enemy;
	trace_t   tr;
	float     distance;

	VectorAdd( ent->s.origin, range, maxs );
	VectorSubtract( ent->s.origin, range, mins );

	num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES );

	for ( i = 0; i < num; i++ )
	{
		enemy = &g_entities[ entityList[ i ] ];

		// don't chain to self; noclippers can be listed, don't chain to them either
		if ( enemy == ent || ( enemy->client && enemy->client->noclip ) )
		{
			continue;
		}

		distance = Distance( ent->s.origin, enemy->s.origin );

		if ( ( ( enemy->client &&
		         enemy->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ) ||
		       ( enemy->s.eType == ET_BUILDABLE &&
		         BG_Buildable( enemy->s.modelindex )->team == TEAM_HUMANS ) ) &&
		     enemy->health > 0 && // only chain to living targets
		     distance <= LEVEL2_AREAZAP_CHAIN_RANGE )
		{
			// world-LOS check: trace against the world, ignoring other BODY entities
			trap_Trace( &tr, ent->s.origin, NULL, NULL,
			            enemy->s.origin, ent->s.number, CONTENTS_SOLID );

			if ( tr.entityNum == ENTITYNUM_NONE )
			{
				zap->targets[ zap->numTargets ] = enemy;
				zap->distances[ zap->numTargets ] = distance;

				if ( ++zap->numTargets >= LEVEL2_AREAZAP_MAX_TARGETS )
				{
					return;
				}
			}
		}
	}
}
开发者ID:bmorel,项目名称:Unvanquished,代码行数:60,代码来源:g_weapon.c


示例14: G_BuildableDeconValue

int G_BuildableDeconValue(gentity_t *ent)
{
	HealthComponent* healthComponent = ent->entity->Get<HealthComponent>();

	if (!healthComponent->Alive()) {
		return 0;
	}

	return (int)roundf((float)BG_Buildable(ent->s.modelindex)->buildPoints
	                   * healthComponent->HealthFraction());
}
开发者ID:jaytersen,项目名称:Unvanquished,代码行数:11,代码来源:sg_buildpoints.cpp


示例15: FireBuild

static void FireBuild( gentity_t *self, dynMenu_t menu )
{
	buildable_t buildable;

	if ( !self->client )
	{
		return;
	}

	buildable = (buildable_t) ( self->client->ps.stats[ STAT_BUILDABLE ] & SB_BUILDABLE_MASK );

	// open build menu
	if ( buildable <= BA_NONE )
	{
		G_TriggerMenu( self->client->ps.clientNum, menu );
		return;
	}

	// can't build just yet
	if ( self->client->ps.stats[ STAT_MISC ] > 0 )
	{
		G_AddEvent( self, EV_BUILD_DELAY, self->client->ps.clientNum );
		return;
	}

	// build
	if ( G_BuildIfValid( self, buildable ) )
	{
		if ( !g_cheats.integer )
		{
			int buildTime = BG_Buildable( buildable )->buildTime;

			switch ( self->client->ps.persistant[ PERS_TEAM ] )
			{
				case TEAM_ALIENS:
					buildTime *= ALIEN_BUILDDELAY_MOD;
					break;

				case TEAM_HUMANS:
					buildTime *= HUMAN_BUILDDELAY_MOD;
					break;

				default:
					break;
			}

			self->client->ps.stats[ STAT_MISC ] += buildTime;
		}

		self->client->ps.stats[ STAT_BUILDABLE ] = BA_NONE;
	}
}
开发者ID:Xecantur,项目名称:Unvanquished,代码行数:52,代码来源:g_weapon.cpp


示例16: switch

static const char *UnlockableHumanName( unlockable_t *unlockable )
{
	switch ( unlockable->type )
	{
		case UNLT_WEAPON:    return BG_Weapon( unlockable->num )->humanName;
		case UNLT_UPGRADE:   return BG_Upgrade( unlockable->num )->humanName;
		case UNLT_BUILDABLE: return BG_Buildable( unlockable->num )->humanName;
		case UNLT_CLASS:     return BG_ClassModelConfig( unlockable->num )->humanName;
	}

	Com_Error( ERR_FATAL, "UnlockableHumanName: Unlockable has unknown type" );
	return nullptr;
}
开发者ID:JacksonTech,项目名称:Unvanquished,代码行数:13,代码来源:bg_teamprogress.cpp


示例17: CG_CompleteBuild

static void CG_CompleteBuild( void )
{
	int i;

	for ( i = 0; i < BA_NUM_BUILDABLES; i++ )
	{
		const buildableAttributes_t *item = BG_Buildable( i );
		if ( item->team == cgs.clientinfo[ cg.clientNum ].team )
		{
			trap_CompleteCallback( item->name );
		}
	}
}
开发者ID:Sixthly,项目名称:Unvanquished,代码行数:13,代码来源:cg_consolecmds.c


示例18: CG_PlayerIsBuilder

/*
==================
CG_PlayerIsBuilder
==================
*/
static qboolean CG_PlayerIsBuilder( buildable_t buildable )
{
  switch( cg.predictedPlayerState.weapon )
  {
    case WP_ABUILD:
    case WP_HBUILD:
      return BG_Buildable( buildable )->team ==
             BG_Weapon( cg.predictedPlayerState.weapon )->team;

    default:
      return qfalse;
  }
}
开发者ID:ppetr,项目名称:new-edge,代码行数:18,代码来源:cg_buildable.c


示例19: CG_BuildableAnimation

/*
===============
CG_BuildableAnimation
===============
*/
static void CG_BuildableAnimation( centity_t *cent, int *old, int *now, float *backLerp )
{
  entityState_t *es = &cent->currentState;

  //if no animation is set default to idle anim
  if( cent->buildableAnim == BANIM_NONE )
    cent->buildableAnim = es->torsoAnim;

  //display the first frame of the construction anim if not yet spawned
  if( !( es->generic1 & B_SPAWNED_TOGGLEBIT ) )
  {
    animation_t *anim = &cg_buildables[ es->modelindex ].animations[ BANIM_CONSTRUCT1 ];

    //so that when animation starts for real it has sensible numbers
    cent->lerpFrame.oldFrameTime =
      cent->lerpFrame.frameTime =
      cent->lerpFrame.animationTime =
      cg.time;

    *old      = cent->lerpFrame.oldFrame = anim->firstFrame;
    *now      = cent->lerpFrame.frame    = anim->firstFrame;
    *backLerp = cent->lerpFrame.backlerp = 0.0f;

    //ensure that an animation is triggered once the buildable has spawned
    cent->oldBuildableAnim = BANIM_NONE;
  }
  else
  {
    if( ( cent->oldBuildableAnim ^ es->legsAnim ) & ANIM_TOGGLEBIT )
    {
      if( cg_debugAnim.integer )
        CG_Printf( "%d->%d l:%d t:%d %s(%d)\n",
                   cent->oldBuildableAnim, cent->buildableAnim,
                   es->legsAnim, es->torsoAnim,
                   BG_Buildable( es->modelindex )->humanName, es->number );

      if( cent->buildableAnim == es->torsoAnim || es->legsAnim & ANIM_FORCEBIT )
        cent->buildableAnim = cent->oldBuildableAnim = es->legsAnim;
      else
        cent->buildableAnim = cent->oldBuildableAnim = es->torsoAnim;
    }

    CG_RunBuildableLerpFrame( cent );

    *old      = cent->lerpFrame.oldFrame;
    *now      = cent->lerpFrame.frame;
    *backLerp = cent->lerpFrame.backlerp;
  }
}
开发者ID:AlienHoboken,项目名称:Tremulous-xserverx-tremded,代码行数:54,代码来源:cg_buildable.c


示例20: G_Kill

void AlienBuildableComponent::Think(int timeDelta) {
	// TODO: Port gentity_t.powered.
	entity.oldEnt->powered = (G_ActiveOvermind() != nullptr);

	// Suicide if creep is gone.
	if (BG_Buildable(entity.oldEnt->s.modelindex)->creepTest && !G_FindCreep(entity.oldEnt)) {
		G_Kill(entity.oldEnt, entity.oldEnt->powerSource ? &g_entities[entity.oldEnt->powerSource->killedBy] : nullptr, MOD_NOCREEP);
	}

	// TODO: Find an elegant way to access per-buildable configuration.
	float creepSize = (float)BG_Buildable((buildable_t)entity.oldEnt->s.modelindex)->creepSize;

	// Slow close humans.
	ForEntities<HumanClassComponent>([&] (Entity& other, HumanClassComponent& humanClassComponent) {
		// TODO: Add LocationComponent.
		if (G_Distance(entity.oldEnt, other.oldEnt) > creepSize) return;

		// TODO: Send (Creep)Slow message instead.
		if (other.oldEnt->flags & FL_NOTARGET) return;
		if (other.oldEnt->client->ps.groundEntityNum == ENTITYNUM_NONE) return;
		other.oldEnt->client->ps.stats[STAT_STATE] |= SS_CREEPSLOWED;
		other.oldEnt->client->lastCreepSlowTime = level.time;
	});
}
开发者ID:BlueMustache,项目名称:Unvanquished,代码行数:24,代码来源:AlienBuildableComponent.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ BG_Class函数代码示例发布时间:2022-05-30
下一篇:
C++ BGP_DEBUG函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap