Enfusion Script API
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
Class Interface Reference

Super root of all classes in Enforce script. More...

Public Member Functions

proto native external bool IsInherited (TypeName type)
 Returns true when instance is of the type, or inherited one.
 
proto native external int GetSizeOf ()
 Get actual size of instance including size of all referenced objects.
 
proto native owned external string ClassName ()
 Returns name of class-type.
 
proto native external TypeName Type ()
 Returns typename of object's class.
 
proto external string ToString ()
 
proto native external int GetRefCount ()
 Get actual count of references holding this instance. If instance is not managed, zero is returned.
 

Static Public Member Functions

static proto Class Cast (Class from)
 Try to safely down-cast base class to child class.
 

Detailed Description

Super root of all classes in Enforce script.

Member Function Documentation

◆ Cast()

static proto Class Class.Cast ( Class  from)
static

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

Returns
Down-cast from pointer when cast is successful (classes are related), or null if casting is invalid.

Example:

// assume that Man inherits from Object
Object obj = g_Game.GetPlayer();
Man player = Man.Cast(obj);
if (player)
{
// hooray!
}

◆ ClassName()

proto native owned external string Class.ClassName ( )

Returns name of class-type.

Returns
class-type

Example:

Man player = g_Game.GetPlayer();
string className = player.ClassName();
Print(className);
>> className = 'Man'
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.

◆ GetRefCount()

proto native external int Class.GetRefCount ( )

Get actual count of references holding this instance. If instance is not managed, zero is returned.

◆ GetSizeOf()

proto native external int Class.GetSizeOf ( )

Get actual size of instance including size of all referenced objects.

◆ IsInherited()

proto native external bool Class.IsInherited ( TypeName  type)

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

Parameters
typeClass type
Returns
true when clType is the same as type, or inherited one.

Example:

if (inst && inst.IsInherited(Widget))
{
Print("inst is inherited from Widget class!");
}
Definition: Widget.c:13

◆ ToString()

proto external string Class.ToString ( )

◆ Type()

proto native external TypeName Class.Type ( )

Returns typename of object's class.

Returns
class-type

Example:

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

The documentation for this interface was generated from the following file: