本文整理汇总了C++中GetDefaultByType函数的典型用法代码示例。如果您正苦于以下问题:C++ GetDefaultByType函数的具体用法?C++ GetDefaultByType怎么用?C++ GetDefaultByType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetDefaultByType函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: FinishThingdef
static void FinishThingdef()
{
int errorcount = StateParams.ResolveAll();
for (unsigned i = 0;i < PClass::m_Types.Size(); i++)
{
PClass * ti = PClass::m_Types[i];
// Skip non-actors
if (!ti->IsDescendantOf(RUNTIME_CLASS(AActor))) continue;
if (ti->Size == (unsigned)-1)
{
Printf("Class %s referenced but not defined\n", ti->TypeName.GetChars());
errorcount++;
continue;
}
AActor *def = GetDefaultByType(ti);
if (!def)
{
Printf("No ActorInfo defined for class '%s'\n", ti->TypeName.GetChars());
errorcount++;
continue;
}
}
if (errorcount > 0)
{
I_Error("%d errors during actor postprocessing", errorcount);
}
// Since these are defined in DECORATE now the table has to be initialized here.
for(int i=0;i<31;i++)
{
char fmt[20];
mysnprintf(fmt, countof(fmt), "QuestItem%d", i+1);
QuestItemClasses[i] = PClass::FindClass(fmt);
}
}
开发者ID:loismustdie555,项目名称:GZDoom-GPL,代码行数:40,代码来源:thingdef.cpp
示例17: gl_FindModelFrame
FSpriteModelFrame * gl_FindModelFrame(const PClass * ti, int sprite, int frame, bool dropped)
{
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;
}
}
// Check for voxel replacements
if (r_drawvoxels)
{
spritedef_t *sprdef = &sprites[sprite];
if (frame < sprdef->numframes)
{
spriteframe_t *sprframe = &SpriteFrames[sprdef->spriteframes + frame];
if (sprframe->Voxel != nullptr)
{
int index = sprframe->Voxel->VoxeldefIndex;
if (dropped && sprframe->Voxel->DroppedSpin !=sprframe->Voxel->PlacedSpin) index++;
return &SpriteModelFrames[index];
}
}
}
return nullptr;
}
开发者ID:nashmuhandes,项目名称:GZDoom-GPL,代码行数:38,代码来源:gl_models.cpp
示例18: AddAmmoToList
static void AddAmmoToList(AWeapon * weapdef)
{
for(int i=0; i<2;i++)
{
PClassAmmo * ti = i==0? weapdef->AmmoType1 : weapdef->AmmoType2;
if (ti)
{
AAmmo * ammodef=(AAmmo*)GetDefaultByType(ti);
if (ammodef && !(ammodef->ItemFlags&IF_INVBAR))
{
unsigned int j;
for(j=0;j<orderedammos.Size();j++)
{
if (ti == orderedammos[j]) break;
}
if (j==orderedammos.Size()) orderedammos.Push(ti);
}
}
}
}
开发者ID:Edward850,项目名称:zdoom,代码行数:23,代码来源:shared_hud.cpp
示例19: gl_FindModelFrame
FSpriteModelFrame * gl_FindModelFrame(const PClass * ti, int sprite, int frame)
{
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:Xeomuz,项目名称:Doom-Port-Source-Code,代码行数:24,代码来源:gl_models.cpp
示例20: LoadActors
void LoadActors()
{
cycle_t timer;
timer.Reset(); timer.Clock();
FScriptPosition::ResetErrorCounter();
InitThingdef();
FScriptPosition::StrictErrors = true;
ParseScripts();
FScriptPosition::StrictErrors = false;
ParseAllDecorate();
FunctionBuildList.Build();
if (FScriptPosition::ErrorCounter > 0)
{
I_Error("%d errors while parsing DECORATE scripts", FScriptPosition::ErrorCounter);
}
FScriptPosition::ResetErrorCounter();
for (int i = PClassActor::AllActorClasses.Size() - 1; i >= 0; i--)
{
auto ti = PClassActor::AllActorClasses[i];
if (ti->Size == TentativeClass)
{
if (ti->ObjectFlags & OF_Transient)
{
Printf(TEXTCOLOR_ORANGE "Class %s referenced but not defined\n", ti->TypeName.GetChars());
FScriptPosition::WarnCounter++;
DObject::StaticPointerSubstitution(ti, nullptr);
PClassActor::AllActorClasses.Delete(i);
}
else
{
Printf(TEXTCOLOR_RED "Class %s referenced but not defined\n", ti->TypeName.GetChars());
FScriptPosition::ErrorCounter++;
}
continue;
}
if (GetDefaultByType(ti) == nullptr)
{
Printf(TEXTCOLOR_RED "No ActorInfo defined for class '%s'\n", ti->TypeName.GetChars());
FScriptPosition::ErrorCounter++;
continue;
}
CheckStates(ti);
if (ti->bDecorateClass && ti->IsDescendantOf(RUNTIME_CLASS(AStateProvider)))
{
// either a DECORATE based weapon or CustomInventory.
// These are subject to relaxed rules for user variables in states.
// Although there is a runtime check for bogus states, let's do a quick analysis if any of the known entry points
// hits an unsafe state. If we can find something here it can be handled wuth a compile error rather than a runtime error.
CheckForUnsafeStates(ti);
}
}
if (FScriptPosition::ErrorCounter > 0)
{
I_Error("%d errors during actor postprocessing", FScriptPosition::ErrorCounter);
}
timer.Unclock();
if (!batchrun) Printf("script parsing took %.2f ms\n", timer.TimeMS());
// Since these are defined in DECORATE now the table has to be initialized here.
for (int i = 0; i < 31; i++)
{
char fmt[20];
mysnprintf(fmt, countof(fmt), "QuestItem%d", i + 1);
QuestItemClasses[i] = PClass::FindActor(fmt);
}
StateSourceLines.Clear();
}
开发者ID:dwing4g,项目名称:gzdoom,代码行数:79,代码来源:thingdef.cpp
注:本文中的GetDefaultByType函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论