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


C++ GetDefaultByType函数代码示例

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


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

示例1: AddOneKey

static void AddOneKey(Keygroup *keygroup, PClassActor *mi, FScanner &sc)
{
	if (mi)
	{
		// Any inventory item can be used to unlock a door
		if (mi->IsDescendantOf(RUNTIME_CLASS(AInventory)))
		{
			OneKey k = {mi,1};
			keygroup->anykeylist.Push (k);

			//... but only keys get key numbers!
			if (mi->IsDescendantOf(RUNTIME_CLASS(AKey)))
			{
				if (!ignorekey &&
					static_cast<AKey*>(GetDefaultByType(mi))->KeyNumber == 0)
				{
					static_cast<AKey*>(GetDefaultByType(mi))->KeyNumber=++currentnumber;
				}
			}
		}
		else
		{
			sc.ScriptError("'%s' is not an inventory item", sc.String);
		}
	}
	else
	{
		sc.ScriptError("Unknown item '%s'", sc.String);
	}
}
开发者ID:Accusedbold,项目名称:zdoom,代码行数:30,代码来源:a_keys.cpp

示例2: SetKeyTypes

static void SetKeyTypes()
{
	for(unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); i++)
	{
		PClass *ti = PClassActor::AllActorClasses[i];
		auto kt = PClass::FindActor(NAME_Key);

		if (ti->IsDescendantOf(kt))
		{
			PClassActor *tia = static_cast<PClassActor *>(ti);
			AInventory *key = (AInventory*)(GetDefaultByType(tia));

			if (key->Icon.isValid() && key->special1 > 0)
			{
				KeyTypes.Push(tia);
			}
			else 
			{
				UnassignedKeyTypes.Push(tia);
			}
		}
	}
	if (KeyTypes.Size())
	{
		qsort(&KeyTypes[0], KeyTypes.Size(), sizeof(KeyTypes[0]), ktcmp);
	}
	else
	{
		// Don't leave the list empty
		KeyTypes.Push(PClass::FindActor(NAME_Key));
	}
}
开发者ID:gamegenten,项目名称:GZDoom-GPL,代码行数:32,代码来源:shared_hud.cpp

示例3: GetClass

void AScriptedMarine::SetSprite (PClassActor *source)
{
	if (source == NULL)
	{ // A valid actor class wasn't passed, so use the standard sprite
		SpriteOverride = sprite = GetClass()->OwnedStates[0].sprite;
		// Copy the standard scaling
		scaleX = GetDefault()->scaleX;
		scaleY = GetDefault()->scaleY;
	}
	else
	{ // Use the same sprite and scaling the passed class spawns with
		SpriteOverride = sprite = GetDefaultByType (source)->SpawnState->sprite;
		scaleX = GetDefaultByType(source)->scaleX;
		scaleY = GetDefaultByType(source)->scaleY;
	}
}
开发者ID:Edward850,项目名称:zdoom,代码行数:16,代码来源:a_scriptedmarine.cpp

示例4: ClearLocks

static void ClearLocks()
{
	unsigned int i;
	for(i = 0; i < PClassActor::AllActorClasses.Size(); i++)
	{
		if (PClassActor::AllActorClasses[i]->IsDescendantOf(RUNTIME_CLASS(AKey)))
		{
			AKey *key = static_cast<AKey*>(GetDefaultByType(PClassActor::AllActorClasses[i]));
			if (key != NULL)
			{
				key->KeyNumber = 0;
			}
		}
	}
	for(i = 0; i < 256; i++)
	{
		if (locks[i] != NULL) 
		{
			delete locks[i];
			locks[i] = NULL;
		}
	}
	currentnumber = 0;
	keysdone = false;
}
开发者ID:Accusedbold,项目名称:zdoom,代码行数:25,代码来源:a_keys.cpp

示例5: DEFINE_ACTION_FUNCTION

DEFINE_ACTION_FUNCTION(AActor, A_PotteryExplode)
{
	AActor *mo = NULL;
	int i;

	for(i = (pr_pottery()&3)+3; i; i--)
	{
		mo = Spawn ("PotteryBit", self->x, self->y, self->z, ALLOW_REPLACE);
		if (mo)
		{
			mo->SetState (mo->SpawnState + (pr_pottery()%5));
			mo->velz = ((pr_pottery()&7)+5)*(3*FRACUNIT/4);
			mo->velx = (pr_pottery.Random2())<<(FRACBITS-6);
			mo->vely = (pr_pottery.Random2())<<(FRACBITS-6);
		}
	}
	S_Sound (mo, CHAN_BODY, "PotteryExplode", 1, ATTN_NORM);
	// Spawn an item?
	const PClass *type = P_GetSpawnableType(self->args[0]);
	if (type != NULL)
	{
		if (!((level.flags2 & LEVEL2_NOMONSTERS) || (dmflags & DF_NO_MONSTERS))
		|| !(GetDefaultByType (type)->flags3 & MF3_ISMONSTER))
		{ // Only spawn monsters if not -nomonsters
			Spawn (type, self->x, self->y, self->z, ALLOW_REPLACE);
		}
	}
}
开发者ID:1Akula1,项目名称:gzdoom,代码行数:28,代码来源:a_hexenspecialdecs.cpp

示例6: gl_FindModelFrame

FSpriteModelFrame * gl_FindModelFrame(const PClass * ti, int sprite, int frame)
{
	// [BB] The user doesn't want to use models, so just pretend that there is no model for this frame.
	if ( gl_use_models == false )
		return NULL;

	if (GetDefaultByType(ti)->hasmodel)
	{
		FSpriteModelFrame smf;

		memset(&smf, 0, sizeof(smf));
		smf.type=ti;
		smf.sprite=sprite;
		smf.frame=frame;

		int hash = SpriteModelHash[ModelFrameHash(&smf) % SpriteModelFrames.Size()];

		while (hash>=0)
		{
			FSpriteModelFrame * smff = &SpriteModelFrames[hash];
			if (smff->type==ti && smff->sprite==sprite && smff->frame==frame) return smff;
			hash=smff->hashnext;
		}
	}
	return NULL;
}
开发者ID:WChrisK,项目名称:Zandronum,代码行数:26,代码来源:gl_models.cpp

示例7: SetKeyTypes

static void SetKeyTypes()
{
	for(unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); i++)
	{
		PClass *ti = PClassActor::AllActorClasses[i];

		if (ti->IsDescendantOf(RUNTIME_CLASS(AKey)))
		{
			PClassActor *tia = static_cast<PClassActor *>(ti);
			AKey *key = (AKey*)GetDefaultByType(tia);

			if (key->Icon.isValid() && key->KeyNumber>0)
			{
				KeyTypes.Push(tia);
			}
			else 
			{
				UnassignedKeyTypes.Push(tia);
			}
		}
	}
	if (KeyTypes.Size())
	{
		qsort(&KeyTypes[0], KeyTypes.Size(), sizeof(KeyTypes[0]), ktcmp);
	}
	else
	{
		// Don't leave the list empty
		PClassActor *ti = RUNTIME_CLASS(AKey);
		KeyTypes.Push(ti);
	}
}
开发者ID:Edward850,项目名称:zdoom,代码行数:32,代码来源:shared_hud.cpp

示例8: TryPickup

bool AClericWeaponPiece::TryPickup (AActor *&toucher)
{
	if (!toucher->IsKindOf (PClass::FindClass(NAME_MagePlayer)) &&
		!toucher->IsKindOf (PClass::FindClass(NAME_FighterPlayer)))
	{
		return Super::TryPickup(toucher);
	}
	else
	{ // Wrong class, but try to pick up for ammo
		if (ShouldStay())
		{
			// Can't pick up weapons for other classes in coop netplay
			return false;
		}

		AWeapon * Defaults=(AWeapon*)GetDefaultByType(WeaponClass);

		bool gaveSome = !!(toucher->GiveAmmo (Defaults->AmmoType1, Defaults->AmmoGive1) +
						   toucher->GiveAmmo (Defaults->AmmoType2, Defaults->AmmoGive2));

		if (gaveSome)
		{
			GoAwayAndDie ();
		}
		return gaveSome;
	}
}
开发者ID:WChrisK,项目名称:Zandronum,代码行数:27,代码来源:a_clericholy.cpp

示例9: gl_InitializeActorLights

void gl_InitializeActorLights()
{
	for(unsigned int i=0;i<LightAssociations.Size();i++)
	{
		const PClass * ti = PClass::FindClass(LightAssociations[i].ActorName());
		if (ti)
		{
			ti = GetRealType(ti);
			AActor * defaults = GetDefaultByType(ti);
			if (defaults)
			{
				FInternalLightAssociation * iasso = new FInternalLightAssociation(&LightAssociations[i]);

				if (!defaults->lightassociations)
				{
					TDeletingArray<FInternalLightAssociation*> *p =new TDeletingArray<FInternalLightAssociation*>;
					defaults->lightassociations = p;
					AssoDeleter.Push(p);
				}
				TDeletingArray<FInternalLightAssociation *> * lights = gl_GetActorLights(defaults);
				if (iasso->Light()==NULL)
				{
					// The definition was not valid.
					delete iasso;
				}
				else
				{
					lights->Push(iasso);
				}
			}
		}
	}
	// we don't need the parser data for the light associations anymore
	LightAssociations.Clear();
	LightAssociations.ShrinkToFit();

	StateLights.Resize(ParsedStateLights.Size()+1);
	for(unsigned i=0; i<ParsedStateLights.Size();i++)
	{
		if (ParsedStateLights[i] != NAME_None)
		{
			StateLights[i] = (FLightDefaults*)-1;	// something invalid that's not NULL.
			for(unsigned int j=0;j<LightDefaults.Size();j++)
			{
				if (LightDefaults[j]->GetName() == ParsedStateLights[i])
				{
					StateLights[i] = LightDefaults[j];
					break;
				}
			}
		}
		else StateLights[i] = NULL;
	}
	StateLights[StateLights.Size()-1] = NULL;	// terminator
	ParsedStateLights.Clear();
	ParsedStateLights.ShrinkToFit();
}
开发者ID:loismustdie555,项目名称:GZDoom-GPL,代码行数:57,代码来源:gl_dynlight.cpp

示例10: IsMonster

static bool IsMonster(const FDropItem *di)
{
	const PClass *pclass = PClass::FindClass(di->Name);

	if (NULL == pclass)
	{
		return false;
	}

	return 0 != (GetDefaultByType(pclass)->flags3 & MF3_ISMONSTER);
}
开发者ID:BenJamesbabala,项目名称:ViZDoom,代码行数:11,代码来源:a_randomspawner.cpp

示例11: CreateCopy

AInventory *ABackpackItem::CreateCopy (AActor *other)
{
	// Find every unique type of ammo. Give it to the player if
	// he doesn't have it already, and double its maximum capacity.
	for (unsigned int i = 0; i < PClassActor::AllActorClasses.Size(); ++i)
	{
		PClass *type = PClassActor::AllActorClasses[i];

		if (type->ParentClass == RUNTIME_CLASS(AAmmo))
		{
			PClassActor *atype = static_cast<PClassActor *>(type);
			AAmmo *ammo = static_cast<AAmmo *>(other->FindInventory(atype));
			int amount = static_cast<AAmmo *>(GetDefaultByType(type))->BackpackAmount;
			// extra ammo in baby mode and nightmare mode
			if (!(ItemFlags&IF_IGNORESKILL))
			{
				amount = int(amount * G_SkillProperty(SKILLP_AmmoFactor));
			}
			if (amount < 0) amount = 0;
			if (ammo == NULL)
			{ // The player did not have the ammo. Add it.
				ammo = static_cast<AAmmo *>(Spawn(atype));
				ammo->Amount = bDepleted ? 0 : amount;
				if (ammo->BackpackMaxAmount > ammo->MaxAmount)
				{
					ammo->MaxAmount = ammo->BackpackMaxAmount;
				}
				if (ammo->Amount > ammo->MaxAmount)
				{
					ammo->Amount = ammo->MaxAmount;
				}
				ammo->AttachToOwner (other);
			}
			else
			{ // The player had the ammo. Give some more.
				if (ammo->MaxAmount < ammo->BackpackMaxAmount)
				{
					ammo->MaxAmount = ammo->BackpackMaxAmount;
				}
				if (!bDepleted && ammo->Amount < ammo->MaxAmount)
				{
					ammo->Amount += amount;
					if (ammo->Amount > ammo->MaxAmount)
					{
						ammo->Amount = ammo->MaxAmount;
					}
				}
			}
		}
	}
	return Super::CreateCopy (other);
}
开发者ID:Accusedbold,项目名称:zdoom,代码行数:52,代码来源:a_pickups.cpp

示例12: GetAmmoTextLengths

static void GetAmmoTextLengths(player_t *CPlayer, int& ammocur, int& ammomax)
{
	for (auto type : orderedammos)
	{
		auto ammoitem = CPlayer->mo->FindInventory(type);
		auto inv = nullptr == ammoitem
			? static_cast<AInventory*>(GetDefaultByType(type))
			: ammoitem;
		assert(nullptr != inv);

		ammocur = MAX(ammocur, nullptr == ammoitem ? 0 : ammoitem->Amount);
		ammomax = MAX(ammomax, inv->MaxAmount);
	}

	ammocur = GetDigitCount(ammocur);
	ammomax = GetDigitCount(ammomax);
}
开发者ID:gamegenten,项目名称:GZDoom-GPL,代码行数:17,代码来源:shared_hud.cpp

示例13: Init

void DIntermissionScreenCast::Init(FIntermissionAction *desc, bool first)
{
	Super::Init(desc, first);
	mName = static_cast<FIntermissionActionCast*>(desc)->mName;
	mClass = PClass::FindClass(static_cast<FIntermissionActionCast*>(desc)->mCastClass);
	if (mClass != NULL) mDefaults = GetDefaultByType(mClass);
	else
	{
		mDefaults = NULL;
		caststate = NULL;
		return;
	}

	mCastSounds.Resize(static_cast<FIntermissionActionCast*>(desc)->mCastSounds.Size());
	for (unsigned i=0; i < mCastSounds.Size(); i++)
	{
		mCastSounds[i].mSequence = static_cast<FIntermissionActionCast*>(desc)->mCastSounds[i].mSequence;
		mCastSounds[i].mIndex = static_cast<FIntermissionActionCast*>(desc)->mCastSounds[i].mIndex;
		mCastSounds[i].mSound = static_cast<FIntermissionActionCast*>(desc)->mCastSounds[i].mSound;
	}
	caststate = mDefaults->SeeState;
	if (mClass->IsDescendantOf(RUNTIME_CLASS(APlayerPawn)))
	{
		advplayerstate = mDefaults->MissileState;
		casttranslation = translationtables[TRANSLATION_Players][consoleplayer];
	}
	else
	{
		advplayerstate = NULL;
		casttranslation = NULL;
		if (mDefaults->Translation != 0)
		{
			casttranslation = translationtables[GetTranslationType(mDefaults->Translation)]
												[GetTranslationIndex(mDefaults->Translation)];
		}
	}
	castdeath = false;
	castframes = 0;
	castonmelee = 0;
	castattacking = false;
	if (mDefaults->SeeSound)
	{
		S_Sound (CHAN_VOICE | CHAN_UI, mDefaults->SeeSound, 1, ATTN_NONE);
	}
}
开发者ID:ChillyDoom,项目名称:zdoom,代码行数:45,代码来源:intermission.cpp

示例14: DEFINE_ACTION_FUNCTION_PARAMS

DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnFly)
{
	FSoundID sound;

	ACTION_PARAM_START(1);
	ACTION_PARAM_CLASS(spawntype, 0);

	if (spawntype != NULL) 
	{
		sound = GetDefaultByType(spawntype)->SeeSound;
	}
	else
	{
		spawntype = PClass::FindClass ("SpawnFire");
		sound = "brain/spawn";
	}
	SpawnFly(self, spawntype, sound);
}
开发者ID:1Akula1,项目名称:gzdoom,代码行数:18,代码来源:a_bossbrain.cpp

示例15: P_FreeStrifeConversations

void P_FreeStrifeConversations ()
{
	FStrifeDialogueNode *node;

	while (StrifeDialogues.Pop (node))
	{
		delete node;
	}

	for (int i = 0; i < 344; ++i)
	{
		if (StrifeTypes[i] != NULL)
		{
			GetDefaultByType (StrifeTypes[i])->Conversation = NULL;
		}
	}

	CurNode = NULL;
	PrevNode = NULL;
}
开发者ID:doomtech,项目名称:zdoom-old,代码行数:20,代码来源:p_conversation.cpp


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