- Adjust VisibleToPlayerClass to accept multiple classes as well as work with inheritance.

SVN r3291 (trunk)
This commit is contained in:
Braden Obrzut 2011-09-10 04:24:40 +00:00
parent c013e72caa
commit faa122ede3
4 changed files with 22 additions and 9 deletions

View file

@ -820,9 +820,6 @@ public:
// [BB] If 0, everybody can see the actor, if > 0, only members of team (VisibleToTeam-1) can see it.
DWORD VisibleToTeam;
// [BB] If NAME_None, all players can see the actor, else only players whose playerclass name is VisibleToPlayerClass can see it.
FNameNoInit VisibleToPlayerClass;
int special1; // Special info
int special2; // Special info
int health;

View file

@ -210,6 +210,7 @@ struct FActorInfo
PainChanceList *PainChances;
PainFlashList *PainFlashes;
FPlayerColorSetMap *ColorSets;
TArray<const PClass *> VisibleToPlayerClass;
};
class FDoomEdMap

View file

@ -892,9 +892,21 @@ bool AActor::IsVisibleToPlayer() const
const player_t* pPlayer = players[consoleplayer].camera->player;
if ( ( VisibleToPlayerClass != NAME_None )
&& pPlayer && pPlayer->mo && ( VisibleToPlayerClass != pPlayer->mo->GetClass()->TypeName ) )
return false;
if(pPlayer && pPlayer->mo && GetClass()->ActorInfo->VisibleToPlayerClass.Size() > 0)
{
bool visible = false;
for(unsigned int i = 0;i < GetClass()->ActorInfo->VisibleToPlayerClass.Size();++i)
{
const PClass *cls = GetClass()->ActorInfo->VisibleToPlayerClass[i];
if(cls && pPlayer->mo->GetClass()->IsDescendantOf(cls))
{
visible = true;
break;
}
}
if(!visible)
return false;
}
// [BB] Passed all checks.
return true;

View file

@ -1246,10 +1246,13 @@ DEFINE_PROPERTY(visibletoteam, I, Actor)
//==========================================================================
// [BB]
//==========================================================================
DEFINE_PROPERTY(visibletoplayerclass, S, Actor)
DEFINE_PROPERTY(visibletoplayerclass, S_s, Actor)
{
PROP_STRING_PARM(n, 0);
defaults->VisibleToPlayerClass = n;
for(unsigned int i = 0;i < PROP_PARM_COUNT;++i)
{
PROP_STRING_PARM(n, i);
info->VisibleToPlayerClass.Push(FindClassTentative(n, "PlayerPawn"));
}
}
//==========================================================================