DIFF

class ClassSource

Part of Enforce script essentials

Super root of all classes in Enforce script

Methods 10

proto native external bool IsInherited(typename type)

Returns true when instance is of the type, or inherited one.

type
Class type

Returns: bool true when 'clType' is the same as 'type', or inherited one.

if (inst && inst.IsInherited(Widget))
{
	Print("inst is inherited from Widget class!");
}
proto native external typename Type()

Returns typename of object's class

Returns: typename class-type

Man player = g_Game.GetPlayer();
typename type = player.Type();
Print(type.ToString());

>> 'Man'
proto external static typename StaticType()

Returns typename of object's reference

Returns: typename class-type

EntityAI e;
Print(e.StaticType());

>> 'EntityAI'
static typename StaticGetType(typename t)

Returns typename of class even without a variable or instance

Returns: typename class-type

typename eAITypename = StaticGetType(EntityAI);
proto static Class Cast(Class from)

Try to safely down-cast base class to child class.

Returns: down-casted 'from' pointer when cast is successfull (classes are related), or null if casting is invalid

// assume that Man inheites from Object
Object obj = g_Game.GetPlayer();
Man player = Man.Cast(obj);

if (player)
{
	// horay!
}
proto static bool CastTo(out Class to, Class from)

Try to safely down-cast base class to child class.

Returns: bool true when 'from' is not null and cast successfull, false when casting is not valid or 'from' is null

// assume that Man inheites from Object
Object obj = g_Game.GetPlayer();
Man player;

if (Class.CastTo(player, obj))
{
	// horay!
}
private proto static bool SafeCastType(Class type, out Class to, Class from)

This function is for internal script usage