当前位置: 首页>>代码示例>>C++>>正文


C++ PClassActor::IsDescendantOf方法代码示例

本文整理汇总了C++中PClassActor::IsDescendantOf方法的典型用法代码示例。如果您正苦于以下问题:C++ PClassActor::IsDescendantOf方法的具体用法?C++ PClassActor::IsDescendantOf怎么用?C++ PClassActor::IsDescendantOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PClassActor的用法示例。


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

示例1: P_SetupWeapons_ntohton

void P_SetupWeapons_ntohton()
{
	unsigned int i;
	PClassWeapon *cls;

	Weapons_ntoh.Clear();
	Weapons_hton.Clear();

	cls = NULL;
	Weapons_ntoh.Push(cls);		// Index 0 is always NULL.
	for (i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
	{
		PClassActor *cls = PClassActor::AllActorClasses[i];

		if (cls->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
		{
			Weapons_ntoh.Push(static_cast<PClassWeapon *>(cls));
		}
	}
	qsort(&Weapons_ntoh[1], Weapons_ntoh.Size() - 1, sizeof(Weapons_ntoh[0]), ntoh_cmp);
	for (i = 0; i < Weapons_ntoh.Size(); ++i)
	{
		Weapons_hton[Weapons_ntoh[i]] = i;
	}
}
开发者ID:Jayman2000,项目名称:zdoom-pull,代码行数:25,代码来源:a_weapons.cpp

示例2: cht_Take

void cht_Take (player_t *player, const char *name, int amount)
{
    bool takeall;
    PClassActor *type;

    if (player->mo == NULL || player->health <= 0)
    {
        return;
    }

    takeall = (stricmp (name, "all") == 0);

    if (!takeall && stricmp (name, "health") == 0)
    {
        if (player->mo->health - amount <= 0
                || player->health - amount <= 0
                || amount == 0)
        {

            cht_Suicide (player);

            if (player == &players[consoleplayer])
                C_HideConsole ();

            return;
        }

        if (amount > 0)
        {
            if (player->mo)
            {
                player->mo->health -= amount;
                player->health = player->mo->health;
            }
            else
            {
                player->health -= amount;
            }
        }

        if (!takeall)
            return;
    }

    if (takeall || stricmp (name, "backpack") == 0)
    {
        // Take away all types of backpacks the player might own.
        for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
        {
            PClass *type = PClassActor::AllActorClasses[i];

            if (type->IsDescendantOf(RUNTIME_CLASS (ABackpackItem)))
            {
                AInventory *pack = player->mo->FindInventory(static_cast<PClassActor *>(type));

                if (pack)
                    pack->Destroy();
            }
        }

        if (!takeall)
            return;
    }

    if (takeall || stricmp (name, "ammo") == 0)
    {
        for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
        {
            PClass *type = PClassActor::AllActorClasses[i];

            if (type->ParentClass == RUNTIME_CLASS (AAmmo))
            {
                AInventory *ammo = player->mo->FindInventory(static_cast<PClassActor *>(type));

                if (ammo)
                    ammo->DepleteOrDestroy();
            }
        }

        if (!takeall)
            return;
    }

    if (takeall || stricmp (name, "armor") == 0)
    {
        for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
        {
            type = PClassActor::AllActorClasses[i];

            if (type->IsDescendantOf (RUNTIME_CLASS (AArmor)))
            {
                AInventory *armor = player->mo->FindInventory(static_cast<PClassActor *>(type));

                if (armor)
                    armor->DepleteOrDestroy();
            }
        }

        if (!takeall)
            return;
//.........这里部分代码省略.........
开发者ID:MajorCooke,项目名称:GZDoom,代码行数:101,代码来源:m_cheat.cpp

示例3: P_UndoPlayerMorph


//.........这里部分代码省略.........
	else // killed when morphed so stay dead
	{
		mo->health = player->health;
	}

	player->mo = mo;
	if (player->camera == pmo)
	{
		player->camera = mo;
	}

	// [MH]
	// If the player that was morphed is the one
	// taking events, reset up the face, if any;
	// this is only needed for old-skool skins
	// and for the original DOOM status bar.
	if (player == &players[consoleplayer])
	{
		FString face = pmo->GetClass()->Face;
		if (face.IsNotEmpty() && strcmp(face, "None") != 0)
		{
			// Assume root-level base skin to begin with
			size_t skinindex = 0;
			// If a custom skin was in use, then reload it
			// or else the base skin for the player class.
			if ((unsigned int)player->userinfo.GetSkin() >= PlayerClasses.Size () &&
				(size_t)player->userinfo.GetSkin() < numskins)
			{

				skinindex = player->userinfo.GetSkin();
			}
			else if (PlayerClasses.Size () > 1)
			{
				const PClass *whatami = player->mo->GetClass();
				for (unsigned int i = 0; i < PlayerClasses.Size (); ++i)
				{
					if (PlayerClasses[i].Type == whatami)
					{
						skinindex = i;
						break;
					}
				}
			}
		}
	}

	angle = mo->angle >> ANGLETOFINESHIFT;
	AActor *eflash = NULL;
	if (exit_flash != NULL)
	{
		eflash = Spawn(exit_flash, pmo->Vec3Offset(20*finecosine[angle], 20*finesine[angle], TELEFOGHEIGHT), ALLOW_REPLACE);
		if (eflash)	eflash->target = mo;
	}
	mo->SetupWeaponSlots();		// Use original class's weapon slots.
	beastweap = player->ReadyWeapon;
	if (player->PremorphWeapon != NULL)
	{
		player->PremorphWeapon->PostMorphWeapon ();
	}
	else
	{
		player->ReadyWeapon = player->PendingWeapon = NULL;
	}
	if (correctweapon)
	{ // Better "lose morphed weapon" semantics
		PClassActor *morphweapon = PClass::FindActor(pmo->MorphWeapon);
		if (morphweapon != NULL && morphweapon->IsDescendantOf(RUNTIME_CLASS(AWeapon)))
		{
			AWeapon *OriginalMorphWeapon = static_cast<AWeapon *>(mo->FindInventory (morphweapon));
			if ((OriginalMorphWeapon != NULL) && (OriginalMorphWeapon->GivenAsMorphWeapon))
			{ // You don't get to keep your morphed weapon.
				if (OriginalMorphWeapon->SisterWeapon != NULL)
				{
					OriginalMorphWeapon->SisterWeapon->Destroy ();
				}
				OriginalMorphWeapon->Destroy ();
			}
		}
 	}
	else // old behaviour (not really useful now)
	{ // Assumptions made here are no longer valid
		if (beastweap != NULL)
		{ // You don't get to keep your morphed weapon.
			if (beastweap->SisterWeapon != NULL)
			{
				beastweap->SisterWeapon->Destroy ();
			}
			beastweap->Destroy ();
		}
	}
	pmo->tracer = NULL;
	pmo->Destroy ();
	// Restore playerclass armor to its normal amount.
	AHexenArmor *hxarmor = mo->FindInventory<AHexenArmor>();
	if (hxarmor != NULL)
	{
		hxarmor->Slots[4] = mo->GetClass()->HexenArmor[0];
	}
	return true;
}
开发者ID:ibm5155,项目名称:zdoom,代码行数:101,代码来源:a_morph.cpp

示例4: cht_Give


//.........这里部分代码省略.........
    {
        if (gameinfo.gametype != GAME_Hexen)
        {
            ABasicArmorPickup *armor = Spawn<ABasicArmorPickup> ();
            armor->SaveAmount = 100*deh.BlueAC;
            armor->SavePercent = gameinfo.Armor2Percent > 0? gameinfo.Armor2Percent : 0.5;
            if (!armor->CallTryPickup (player->mo))
            {
                armor->Destroy ();
            }
        }
        else
        {
            for (i = 0; i < 4; ++i)
            {
                AHexenArmor *armor = Spawn<AHexenArmor> ();
                armor->health = i;
                armor->Amount = 0;
                if (!armor->CallTryPickup (player->mo))
                {
                    armor->Destroy ();
                }
            }
        }

        if (!giveall)
            return;
    }

    if (giveall || stricmp (name, "keys") == 0)
    {
        for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
        {
            if (PClassActor::AllActorClasses[i]->IsDescendantOf (RUNTIME_CLASS(AKey)))
            {
                AKey *key = (AKey *)GetDefaultByType (PClassActor::AllActorClasses[i]);
                if (key->KeyNumber != 0)
                {
                    key = static_cast<AKey *>(Spawn(static_cast<PClassActor *>(PClassActor::AllActorClasses[i])));
                    if (!key->CallTryPickup (player->mo))
                    {
                        key->Destroy ();
                    }
                }
            }
        }
        if (!giveall)
            return;
    }

    if (giveall || stricmp (name, "weapons") == 0)
    {
        AWeapon *savedpending = player->PendingWeapon;
        for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
        {
            type = PClassActor::AllActorClasses[i];
            // Don't give replaced weapons unless the replacement was done by Dehacked.
            if (type != RUNTIME_CLASS(AWeapon) &&
                    type->IsDescendantOf (RUNTIME_CLASS(AWeapon)) &&
                    (static_cast<PClassActor *>(type)->GetReplacement() == type ||
                     static_cast<PClassActor *>(type)->GetReplacement()->IsDescendantOf(RUNTIME_CLASS(ADehackedPickup))))
            {
                // Give the weapon only if it belongs to the current game or
                if (player->weapons.LocateWeapon(static_cast<PClassWeapon*>(type), NULL, NULL))
                {
                    AWeapon *def = (AWeapon*)GetDefaultByType (type);
开发者ID:MajorCooke,项目名称:GZDoom,代码行数:67,代码来源:m_cheat.cpp

示例5: if

//==========================================================================
//
// Starts a new actor definition
//
//==========================================================================
PClassActor *CreateNewActor(const FScriptPosition &sc, FName typeName, FName parentName, bool native)
{
	PClassActor *replacee = NULL;
	PClassActor *ti = NULL;

	PClassActor *parent = RUNTIME_CLASS(AActor);

	if (parentName != NAME_None)
	{
		parent = PClass::FindActor(parentName);
		
		PClassActor *p = parent;
		while (p != NULL)
		{
			if (p->TypeName == typeName)
			{
				sc.Message(MSG_ERROR, "'%s' inherits from a class with the same name", typeName.GetChars());
				break;
			}
			p = dyn_cast<PClassActor>(p->ParentClass);
		}

		if (parent == NULL)
		{
			sc.Message(MSG_ERROR, "Parent type '%s' not found in %s", parentName.GetChars(), typeName.GetChars());
			parent = RUNTIME_CLASS(AActor);
		}
		else if (!parent->IsDescendantOf(RUNTIME_CLASS(AActor)))
		{
			sc.Message(MSG_ERROR, "Parent type '%s' is not an actor in %s", parentName.GetChars(), typeName.GetChars());
			parent = RUNTIME_CLASS(AActor);
		}
	}

	if (native)
	{
		ti = PClass::FindActor(typeName);
		if (ti == NULL)
		{
			extern void DumpTypeTable();
			DumpTypeTable();
			sc.Message(MSG_ERROR, "Unknown native actor '%s'", typeName.GetChars());
			goto create;
		}
		else if (ti != RUNTIME_CLASS(AActor) && ti->ParentClass->NativeClass() != parent->NativeClass())
		{
			sc.Message(MSG_ERROR, "Native class '%s' does not inherit from '%s'", typeName.GetChars(), parentName.GetChars());
			parent = RUNTIME_CLASS(AActor);
			goto create;
		}
		else if (ti->Defaults != NULL)
		{
			sc.Message(MSG_ERROR, "Redefinition of internal class '%s'", typeName.GetChars());
			goto create;
		}
		ti->InitializeNativeDefaults();
		ti->ParentClass->DeriveData(ti);
	}
	else
	{
	create:
		ti = static_cast<PClassActor *>(parent->CreateDerivedClass (typeName, parent->Size));
	}

	ti->Replacee = ti->Replacement = NULL;
	ti->DoomEdNum = -1;
	return ti;
}
开发者ID:Accusedbold,项目名称:zdoom,代码行数:73,代码来源:thingdef.cpp


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