So, let's take two examples:
Using a base class pointer to call a virtual function:
Code:
class Mob
{
virtual bool Something() { return false; }
}
class Client : public Mob
{
virtual bool Something() { return true; }
}
bool DoSomething( Mob* TheMob )
{
return TheMob->Something();
}
In this case if TheMob is a pointer to a Mob it will call the function that returns false, but if TheMob is a pointer to a client it will call the function that returns true. This is generally the best way to handle things if the function can be implemented in the base class and overridden in children classes where a different behavior is desired.
Conditionally calling a child only function:
Code:
class Mob
{
}
class Client : public Mob
{
virtual void ClientOnlyFunction() { /*Do something exciting here*/ }
}
void DoSomething( Mob* TheMob )
{
if( TheMob->IsClient() )
{
TheMob->CastToClient()->ClientOnlyFunction();
}
}
If for whatever reason you can't implement a function in the base class then this is the way you'd need to make sure you only call it on clients. Generally this isn't the best way to handle things, since accidentally calling CastToClient() on something that isn't a client will probably crash, but even if it doesn't it is undefined behavior. A safer way to handle it would be to use dynamic_cast to cast to the child, check if it succeeded, and if it did then use that pointer to call the child only function. Of course, such safety comes with a price as dynamic_cast has a cost where static_cast doesn't.
To answer your specific question, I would guess you probably want to make IsEngaged() virtual in Mob and override it in the Client and possible Bot cases. Then you would just call it using a Mob pointer without any IsClient or CastToClient involved. This would change the behavior of anyplace that calls that function though, so you'd need to be sure nobody was calling it on a client and expecting the existing result.