Ejemplo n.º 1
0
/*!
\brief Creates a new NodeInstace for this NodeMetaInfo

\param metaInfo MetaInfo for which a Instance should be created
\param context QQmlContext which should be used
\returns Internal Pointer of a NodeInstance
\see NodeMetaInfo
*/
Internal::ObjectNodeInstance::Pointer ServerNodeInstance::createInstance(QObject *objectToBeWrapped)
{
    Internal::ObjectNodeInstance::Pointer instance;

    if (objectToBeWrapped == 0)
        instance = Internal::DummyNodeInstance::create();
    else if (isSubclassOf(objectToBeWrapped, "QQuickBasePositioner"))
        instance = Internal::PositionerNodeInstance::create(objectToBeWrapped);
    else if (isSubclassOf(objectToBeWrapped, "QQuickLayout"))
        instance = Internal::LayoutNodeInstance::create(objectToBeWrapped);
    else if (isSubclassOf(objectToBeWrapped, "QQuickItem"))
        instance = Internal::QuickItemNodeInstance::create(objectToBeWrapped);
    else if (isSubclassOf(objectToBeWrapped, "QQmlComponent"))
        instance = Internal::ComponentNodeInstance::create(objectToBeWrapped);
    else if (objectToBeWrapped->inherits("QQmlAnchorChanges"))
        instance = Internal::AnchorChangesNodeInstance::create(objectToBeWrapped);
    else if (isSubclassOf(objectToBeWrapped, "QQuickPropertyChanges"))
        instance = Internal::QmlPropertyChangesNodeInstance::create(objectToBeWrapped);
    else if (isSubclassOf(objectToBeWrapped, "QQuickState"))
        instance = Internal::QmlStateNodeInstance::create(objectToBeWrapped);
    else if (isSubclassOf(objectToBeWrapped, "QQuickTransition"))
        instance = Internal::QmlTransitionNodeInstance::create(objectToBeWrapped);
    else if (isSubclassOf(objectToBeWrapped, "QQuickBehavior"))
        instance = Internal::BehaviorNodeInstance::create(objectToBeWrapped);
    else if (isSubclassOf(objectToBeWrapped, "QQuickWindow"))
        instance = Internal::QuickWindowNodeInstance::create(objectToBeWrapped);
    else if (isSubclassOf(objectToBeWrapped, "QObject"))
        instance = Internal::ObjectNodeInstance::create(objectToBeWrapped);
    else
        instance = Internal::DummyNodeInstance::create();


    return instance;
}
//--------------------------------------------------------------
// Name:		GetBestAvailableWeapon()
// Class:		CombatSubsystem
//
// Description:	Iterates through the actor's inventory list and
//				checks the power rating ( modified by range and armor )
//				of each weapon, returning the best one.
//
// Parameters:	Entity *target -- The target we are trying to shoot
//
// Returns:		None
//--------------------------------------------------------------
WeaponPtr CombatSubsystem::GetBestAvailableWeapon(Entity* target)
{
  Weapon* bestWeapon = nullptr;
  auto bestPowerRating = 0.0f;

  // Try and grab the first item.  If you pass a null into the
  // NextItem() it will attempt to grab the first item in the 
  // inventory list
  auto item = act->NextItem(nullptr);

  // Loop as long as we have inventory items to check
  while (item)
  {
    if (item->isSubclassOf(Weapon))
    {
      auto weapon = dynamic_cast<Weapon*>(item);
      if (weapon)
      {
        auto powerRating = getModifiedPowerRating(target, weapon);
        if (powerRating > bestPowerRating)
        {
          bestPowerRating = powerRating;
          bestWeapon = weapon;
        }
      }
    }

    item = act->NextItem(item);
  }

  return bestWeapon;
}
Ejemplo n.º 3
0
void AbstractClassRep::init()
{
   // Only add the renderable and selectable globals for
   // classes derived from SceneObject which are the only
   // objects for which these work.
   if ( isSubclassOf( "SceneObject" ) )
   {
      Con::addVariable( avar( "$%s::isRenderable", getClassName() ), TypeBool, &mIsRenderEnabled,
         "@brief Disables rendering of all instances of this type.\n\n" );

      Con::addVariable( avar( "$%s::isSelectable", getClassName() ), TypeBool, &mIsSelectionEnabled,
         "@brief Disables selection of all instances of this type.\n\n" );
   }
}
void ForbiddenSubclassingCheck::registerMatchers(MatchFinder *Finder) {
  // this check should only be applied to ObjC sources.
  if (!getLangOpts().ObjC)
    return;

  Finder->addMatcher(
      objcInterfaceDecl(
          isSubclassOf(
              objcInterfaceDecl(
                  hasAnyName(
                      std::vector<StringRef>(
                          ForbiddenSuperClassNames.begin(),
                          ForbiddenSuperClassNames.end())))
              .bind("superclass")))
      .bind("subclass"),
      this);
}
qboolean SensoryPerception::isInLineOfSight( const Vector &position , const int entNum )
{
  auto startPos = act->origin;
	startPos.z += 15;
	
	auto endPos = position;
	endPos.z += 15;
	
	Vector modMins;
	Vector modMaxs;
	
	modMins = act->mins;
	modMins *= 1.5;
	
	modMaxs = act->maxs;
	modMaxs *= 1.5;
	
	auto trace = G_Trace( startPos, modMins, modMaxs, endPos, act, act->edict->clipmask, false, "isInLineOfSight" );
	//G_DebugLine( startPos , trace.endpos, 1.0f, 0.0f, 1.0f, 1.0f );
	
	_lineOfSight.entNum = entNum;
	_lineOfSight.time   = level.time;
	
	if ( trace.entityNum == entNum || entNum == ENTITYNUM_NONE )
	{
		_lineOfSight.inLineOfSight = true;      
	}
	else
	{
		auto traceEnt = G_GetEntity( trace.entityNum );
		_lineOfSight.inLineOfSight = false;
		
		if ( traceEnt && traceEnt->isSubclassOf( Actor) )
		{
			Actor *traceActor;
			traceActor = dynamic_cast<Actor*>(traceEnt);
			
			_lineOfSight.inLineOfSight = traceActor->sensoryPerception->checkInLineOfSight( position , entNum );
		}            
	}
	
	return _lineOfSight.inLineOfSight;
}
Ejemplo n.º 6
0
bool ServerNodeInstance::isSubclassOf(const QString &superTypeName) const
{
    return isSubclassOf(internalObject(), superTypeName.toUtf8());
}
//
// Name:        _traceHitTarget()
// Parameters:  Entity *target
//              const Vector &startPos
// Description: Checks of the a trace hits the target
//
bool CombatSubsystem::_traceHitTarget(Entity* target, const Vector& startPos)
{
  auto targetBone = target->getTargetPos();
  auto targetPos = target->centroid;

  if (targetBone.length())
  {
    if (gi.Tag_NumForName(target->edict->s.modelindex, targetBone) > 0)
    {
      target->GetTag(targetBone.c_str(), &targetPos, nullptr, nullptr, nullptr);
    }
  }

  auto attackDir = targetPos - startPos;
  auto attackDirLength = attackDir.length();
  attackDir.normalize();
  attackDir *= attackDirLength + 32.0f;
  attackDir += startPos;
  targetPos = attackDir;

  auto trace = G_FullTrace(startPos, vec_zero, vec_zero, targetPos, act, MASK_SHOT, false, "CombatSubsystem::_traceHitTarget");
  //G_DebugLine( startPos, targetPos, .5f, 1.0f, .5f, 1.0f );

  if (trace.startsolid)
  {
    if (trace.ent == target->edict)
      return true;

    return false;
  }

  // see if we hit anything at all
  if (!trace.ent)
    return false;

  // If we hit the guy we wanted, then shoot
  if (trace.ent == target->edict)
    return true;

  // If we hit someone else we don't like, then shoot
  auto t = trace.ent->entity;
  if (act->enemyManager->IsValidEnemy(t))
  {
    act->enemyManager->SetCurrentEnemy(trace.ent->entity);
    // We want to return false though, so we don't add
    // the attempted enemy to the hatelist
    return false;
  }


  // if we hit something breakable, check if shooting it will
  // let us shoot someone.
  if (t->isSubclassOf( Object ) || t->isSubclassOf( ScriptModel ))
  {
    trace = G_Trace(Vector(trace.endpos), vec_zero, vec_zero, target->centroid, t, MASK_SHOT, false, "CombatSubsystem::_traceHitTarget 2");
    if (trace.startsolid)
      return false;

    // see if we hit anything at all
    if (!trace.ent)
      return false;

    // If we hit the guy we wanted, then shoot
    if (trace.ent == target->edict)
      return true;

    // If we hit someone else we don't like, then shoot
    if (act->enemyManager->IsValidEnemy(trace.ent->entity))
      return true;

    // Forget it then
    return false;
  }

  return false;
}
Ejemplo n.º 8
0
Item * Item::ItemPickup( Entity *other, qboolean add_to_inventory, qboolean checkautopickup )
{
	Sentient * sent;
	Item * item = NULL;
	str realname;
	
	// Query the gameplay manager and see if we should not auto-pickup this item
	if ( checkautopickup )
	{
		GameplayManager *gpm = GameplayManager::getTheGameplayManager();
		if ( gpm->hasProperty(getArchetype(), "noautopickup") )
			return NULL;
	}
	
	if ( !Pickupable( other ) )
	{
		return NULL;
	}
	
	sent = ( Sentient * )other;
	
	if ( add_to_inventory )
	{
		item = sent->giveItem( model, getAmount(), true );
		
		
		if ( !item )
			return NULL;
	}
	else
	{
		item = this;
	}
	
	//
	// make sure to copy over the coolness factor :)
	//
	item->coolitem = coolitem;
	item->cool_dialog = cool_dialog;
	item->cool_anim = cool_anim;
	item->coolitemforced = coolitemforced;
	
	//
	// let our sent know they received it
	// we put this here so we can transfer information from the original item we picked up
	//

	if ( !isSubclassOf( Weapon ) || add_to_inventory )
		sent->ReceivedItem( item );
	
	realname = GetRandomAlias( "snd_pickup" );
	if ( realname.length() > 1 )
		sent->Sound( realname, CHAN_ITEM );
	
	if ( !Removable() )
	{
		// leave the item for others to pickup
		return item;
	}
	
	look_at_me = false;
	
	CancelEventsOfType( EV_Item_DropToFloor );
	CancelEventsOfType( EV_Item_Respawn );
	CancelEventsOfType( EV_FadeOut );
	
	setSolidType( SOLID_NOT );
	
	if ( animate && animate->HasAnim( "pickup" ) )
		animate->RandomAnimate( "pickup", EV_Item_PickupDone );
	else
	{
		if ( !no_remove )
		{
			if ( _missingSkin )
			{
				ChangeSkin( _missingSkin, true );
			}
			else
			{
				hideModel();
			}
			
			if ( !Respawnable() )
				PostEvent( EV_Remove, FRAMETIME );
		}
	}
	
	if ( Respawnable() )
		PostEvent( EV_Item_Respawn, RespawnTime() );
	
	// fire off any pickup_thread's
	if ( pickup_thread.length() )
	{
		ExecuteThread( pickup_thread );
	}
	
	
	if ( item && multiplayerManager.checkFlag( MP_FLAG_INSTANT_ITEMS ) )
	{
		Event *ev;
		
		ev = new Event( EV_InventoryItem_Use );
		ev->AddEntity( other );
		
		item->ProcessEvent( ev );
	}
	
	return item;
}