This page has been translated automatically.
Programming
Fundamentials
Setting Up Development Environment
UnigineScript
High-Level Systems
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine and Tools
GUI
Double Precision Coordinates
API
Bounds-Related Classes
Containers
Controls-Related Classes
Core Library
Engine-Related Classes
GUI-Related Classes
Node-Related Classes
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
Rendering-Related Classes
Utility Classes
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Property Class

This class is used to create properties that allow to control game logic-related parameter values and states. They are stored in a separate XML file with a .prop extension and can be adjusted in the editor as well. When a property parameter value is modified for a single node, an instanced property is saved into the .world, but it only contains the modified parameter rather than a whole parameters list.

To create a property, do the following:

  1. Manually create an XML file with .prop extension. Properties use inheritance: a child property overrides some parameters of its parent or adds new ones, while all other parameters stay the same as specified in the parent property. For example:
    Source code(XML)
    <?xml version="1.0" encoding="utf-8"?>
    <properties version="1.00">
    	<property editable="0" name="GameObjectsUnit">
    		<state name=weapon_type" type="switch" items="air,land,all_types">0</state>
    		<state name="attack" type="toggle">1</state>
    		<parameter name="damage" type="int" max="1000">1</parameter>
    		<parameter name="velocity" type="float" max="100">30</parameter>
    		<parameter name="material" type="string"/>
    	</property>
    	<property editable="1" name="GameObjectsNavy" parent="GameObjectUnit">
    		<state name="weapon_type">2</state>
    		<parameter name="damage">120</parameter>
    		<parameter name="material"/>military_navy</parameter>
    		<parameter name="material_color" type="color"/>1.0 1.0 1.0 1.0</parameter>
    	</property>
    </properties>
  2. Set the order of loading of properties. It is important when properties are stored in several files, because child properties cannot load before their parents. This can be done in via the script using engine.properties.addWorldLibrary_string():
    Source code(UnigineScript)
    engine.properties.addWorldLibrary("project/game_objects.prop");
    engine.properties.addWorldLibrary("project/game_objects_unit.prop");
    engine.properties.addWorldLibrary("project/game_objects_unit_weapon.prop");
    Or the properties to load and their order can be specified directly in the .world file:
    Source code(XML)
    <world version="1.11">
    <materials>
    	...
    </materials>
    <properties>
    <library>project/game_objects.prop</library>
    <library>project/game_objects_unit.prop</library>
    <library>project/game_objects_unit_weapon.prop</library>
    </properties>
    ...

Here, the created child property overrides some of the parent parameters and states and adds a new one:

Property states

Property parameters

Property Class

Members


int getParameterIntMinValue (int num)

Returns the minimum allowed value of an integer parameter.

Arguments

  • int num - Number of the target parameter.

Return value

Minimum value.

int getParameterMask (int num)

Returns the current value of a given mask parameter.

Arguments

  • int num - Number of the target parameter in range from 0 to the total number of parameters.

Return value

Current value of the parameter.

void setState (variable variable, int value)

Updates the value of the given state.

Arguments

  • variable variable - State to be updated. It can either be:
    • int - Number of the target state.
    • string - name of the target state.
  • int value - New value of the state.

vec4 getParameterVec4 (int num)

Returns the current value of a given vec4 parameter.

Arguments

  • int num - Number of the target parameter.

Return value

Current value.

string getParameterSwitchItem (int num, int item)

Returns a string value for a switch item of a given parameter.

Arguments

  • int num - Number of the target parameter.
  • int item - Number of the target item.

Return value

Value of the item or NULL (0), if an error occurred.

Property clone (string name)

Clones the property.

Arguments

  • string name - New property name.

Return value

Cloned property.

int findState (string name, int fast_id)

Searches for a state by a name among all states of the current property.

Arguments

  • string name - Name of the parameter.
  • int fast_id - State's fast identifier (hash of a name).

Return value

ID number of the parameter, if it is found; otherwise, -1.

int getIntersection ()

Returns a value indicating if intersection test is enabled for objects with the assigned property. The object will collide only if it has surface intersection flag and property intersection flag at the same time.

Return value

Positive number if intersection test is enabled; otherwise, 0.

void setParameterDouble (int num, double value)

Updates the value of a given double parameter.

Arguments

  • int num - Number of the target parameter.
  • double value - New value of the parameter.

int loadWorld (Xml xml)

Loads property settings from the Xml.

Arguments

  • Xml xml - Xml smart pointer.

Return value

1 if the property settings are loaded successfully; otherwise, 0.

int restoreState (Stream stream, int force = 0)

Restores the state of a given property (all of its options, states and parameters) from a binary stream.

Arguments

  • Stream stream - The stream with saved property data.
  • int force - Forced restoring of property settings.

Return value

1 if the property state is restored successfully; otherwise, 0.

string getName ()

Returns the property name.

Return value

Name of the property.

int isHidden ()

Returns a value indicating if the property is hidden.

Return value

1 if the property is hidden; otherwise, 0.

int getStateType (int num)

Returns the type of a given state.

Arguments

  • int num - Number of the target state.

Return value

One of the PROPERTY_STATE_* pre-defined variables or -1, if an error occurred.

void setParameterMask (int num, int value)

Updates the value of a given mask parameter.

Arguments

  • int num - Number of the target parameter in range from 0 to the total number of parameters.
  • int value - New value of the mask parameter.

int getNumParameters ()

Returns the number of property parameters.

Return value

Number of property parameters.

int getState (variable variable)

Returns the value of the given state.

Arguments

  • variable variable - State to be updated. It can either be:
    • int - Number of the target state.
    • string - name of the target state.

Return value

State value.

double getParameterDoubleMaxValue (int num)

Returns the maximum allowed value of a double parameter.

Arguments

  • int num - Number of the target parameter.

Return value

Maximum value.

vec4 getParameterColor (int num)

Returns the current color of a given color parameter.

Arguments

  • int num - Number of the target parameter.

Return value

Current color.

int getParameterType (int num)

Returns the type of a given parameter.

Arguments

  • int num - Number of the target parameter.

Return value

One of the PROPERTY_PARAMETER_* pre-defined variables or -1, if an error occurred.

int getNumChildren ()

Returns the number of children of the property.

Return value

Number of children properties.

int findParameter (string name)

Searches for a parameter by a name among all parameters of the current property.

Arguments

  • string name - Name of the parameter.

Return value

ID number of the parameter, if it is found; otherwise, -1.

Property getParent ()

Returns the parent property.

Return value

Parent property or NULL (0), if the current property has no parent.

int getParameterInt (int num)

Returns the current value of a given float parameter.

Arguments

  • int num - Number of the target parameter.

Return value

Current value.

int getParameterSliderMaxExpand (int num)

Returns a value indicating if the maximum value of a given parameter can be increased.

Arguments

  • int num - Number of the target parameter.

Return value

Positive number if the maximum value can be changed; otherwise, 0.

Property inherit (string name)

Creates a new property with a specified name and sets the current property as its parent.

Arguments

  • string name - New property name.

Return value

Inherited property.

double getParameterDouble (int num)

Returns the current value of a given double parameter.

Arguments

  • int num - Number of the target parameter.

Return value

Current value.

int getParameterIntMaxValue (int num)

Returns the maximum allowed value of an integer parameter.

Arguments

  • int num - Number of the target parameter.

Return value

Maximum value.

int isParent (string name)

Returns a value indicating if the property is parent.

Arguments

  • string name - Name of the property.

Return value

1 if the property is parent, otherwise - 0.

void setParameterToggle (int num, int value)

Updates the value of a given toggle parameter.

Arguments

  • int num - Number of the target parameter.
  • int value - New value of the parameter.

string getParameterString (int num)

Returns the current value of a given string parameter.

Arguments

  • int num - Number of the target parameter.

Return value

Current value.

bool setParameter (int num, Variable value)

Updates the value of a given parameter.

Arguments

  • int num - Parameter to be updated. It can either be:
    • int - Number of the target parameter.
    • string - name of the target parameter.
  • Variable value - New value of the parameter.

Return value

float getParameterFloat (int num)

Returns the current value of a given float parameter.

Arguments

  • int num - Number of the target parameter.

Return value

Current value.

Property getCompare ()

Returns the parent property, which has been changed.

Return value

Parent property.

string getStateName (int num)

Returns the name of a given state.

Arguments

  • int num - Number of the target state.

Return value

Name of the state.

int getParameterSliderLog10 (int num)

Returns a value indicating if a given parameter uses a logarithmic scale (with the base ten).

Arguments

  • int num - Number of the target parameter.

Return value

Positive number if the parameter uses a logarithmic scale; otherwise, 0.

float getParameterFloatMaxValue (int num)

Returns the maximum allowed value of a float parameter.

Arguments

  • int num - Number of the target parameter.

Return value

Maximum value.

int getParameterToggle (int num)

Returns the current value of a given toggle parameter.

Arguments

  • int num - Number of the target parameter.

Return value

Toggle parameter value.

Property getChild (int num)

Returns a child property with a given number.

Arguments

  • int num - Number of the target child property.

Return value

Child property.

int getParameterSwitch (int num)

Returns the current value of a given switch parameter.

Arguments

  • int num - Number of the target parameter.

Return value

Switch parameter value.

int isEditable ()

Returns a value indicating if the property can be edited.

Return value

1 if the property is editable; otherwise, 0.

int saveState (Stream stream, int force = 0)

Saves the state of the given property (all of its options, states and parameters) into a binary stream.

Arguments

  • Stream stream - The stream to save property state data.
  • int force - Forced saving of property settings.

Return value

1 if the property state is saved successfully; otherwise, 0.

void setParameterVec3 (int num, vec3 value)

Updates the value of a given vec3 parameter.

Arguments

  • int num - Number of the target parameter.
  • vec3 value - New value of the parameter.

Variable getParameter (int num)

Returns the value of a given parameter.

Arguments

  • int num - Parameter to be updated. It can either be:
    • int - Number of the target parameter.
    • string - name of the target parameter.

Return value

Parameter value.

vec3 getParameterVec3 (int num)

Returns the current value of a given vec3 parameter.

Arguments

  • int num - Number of the target parameter.

Return value

Current value.

float getParameterFloatMinValue (int num)

Returns the minimum allowed value of a float parameter.

Arguments

  • int num - Number of the target parameter.

Return value

Minimum value.

int isStateHidden (int num)

Returns a value indicating if a given state is hidden.

Arguments

  • int num - Number of the target state.

Return value

1 if the state is hidden; otherwise, 0.

double getParameterDoubleMinValue (int num)

Returns the minimum allowed value of a double parameter.

Arguments

  • int num - Number of the target parameter.

Return value

Minimum value.

int getStateSwitchNumItems (int num)

Returns the number of switch items of a given state.

Arguments

  • int num - Number of the target state.

Return value

Number of switch items.

string getStateSwitchItem (int num, int item)

Returns a string value for a switch item of a given state.

Arguments

  • int num - Number of the target state.
  • int item - Number of the target item.

Return value

Value of the item or NULL (0), if an error occurred.

int findParameter (string name, int fast_id)

Searches for a parameter by a name among all parameters of the current property.

Arguments

  • string name - Name of the parameter.
  • int fast_id - Parameter's fast identifier (hash of a name).

Return value

ID number of the parameter, if it is found; otherwise, -1.

void setIntersection (int enable)

Updates a value indicating if intersection test is enabled for objects with the assigned property. The object will collide only if it has surface intersection flag and property intersection flag at the same time.

Arguments

  • int enable - Positive number to enable intersection test, 0 to disable.

int getCollision ()

Returns a value indicating if collision test is enabled for objects with the assigned property. The object will collide only if it has collider node flag, surface collision flag and property collision flag at the same time.

Return value

Positive number if collision test is enabled; otherwise, 0.

void setParameterColor (int num, vec4 value)

Updates the color of a given color parameter.

Arguments

  • int num - Number of the target parameter.
  • vec4 value - New color value.

void setParameterFloat (int num, float value)

Updates the value of a given float parameter.

Arguments

  • int num - Number of the target parameter.
  • float value - New value of the parameter.

int getParameterSwitchNumItems (int num)

Returns the number of switch items of a given parameter.

Arguments

  • int num - Number of the target parameter.

Return value

Number of switch items.

string getParameterName (int num)

Returns the name of a given parameter.

Arguments

  • int num - Number of the target parameter.

Return value

Name of the parameter.

void setParameterSwitch (int num, int value)

Updates the value of a given switch parameter.

Arguments

  • int num - Number of the target parameter.
  • int value - New value of the parameter.

int isParameterHidden (int num)

Returns a value indicating if a given parameter is hidden.

Arguments

  • int num - Number of the target parameter.

Return value

1 if the parameter is hidden; otherwise, 0.

int getParameterStringFile (int num)

Returns a value indicating if a given string parameter has a file flag. For example, it is used in the Properties Editor: it allows you to specify the file for the parameter by the double-click.

Arguments

  • int num - Number of the target parameter.

Return value

1 if the target parameter has a file flag; otherwise 0.

int findState (string name)

Searches for a state by a name among all states of the current property.

Arguments

  • string name - Name of the parameter.

Return value

ID number of the parameter, if it is found; otherwise, -1.

void setParameterVec4 (int num, vec4 value)

Updates the value of a given vec4 parameter.

Arguments

  • int num - Number of the target parameter.
  • vec4 value - New value of the parameter.

int saveWorld (Xml xml, int force = 0)

Saves property settings into the Xml.

Arguments

  • Xml xml - Xml smart pointer.
  • int force - Forced saving of property settings.

Return value

1 if the property settings are saved successfully; otherwise, 0.

void setParameterString (int num, string value)

Updates the value of a given string parameter.

Arguments

  • int num - Number of the target parameter.
  • string value - New value of the parameter.

int getParameterSliderMinExpand (int num)

Returns a value indicating if the minimum value of a given parameter can be decreased.

Arguments

  • int num - Number of the target parameter.

Return value

Positive number if the minimum value can be changed; otherwise, 0.

void setCollision (int enable)

Updates a value indicating if collision test is enabled for objects with the assigned property. The object will collide only if it has collider node flag, surface collision flag and property collision flag at the same time.

Arguments

  • int enable - 1 to enable collision test, 0 to disable.

int getNumStates ()

Returns the number of property states.

Return value

Number of property states.

void setParameterInt (int num, int value)

Updates the value of a given int parameter.

Arguments

  • int num - Number of the target parameter.
  • int value - New value of the parameter.

int PROPERTY_STATE_TOGGLE

Description

State of this type allows only two possible values.

int PROPERTY_STATE_SWITCH

Description

State of this type allows specifying a set of several possible values (more than two).

int PROPERTY_PARAMETER_INT

Description

Parameter of this type accepts any integer value in a given range.

int PROPERTY_PARAMETER_FLOAT

Description

Parameter of this type accepts any float value in a given range.

int PROPERTY_PARAMETER_DOUBLE

Description

Parameter of this type accepts any double value in a given range.

int PROPERTY_PARAMETER_TOGGLE

Description

Parameter of this type allows only two possible values.

int PROPERTY_PARAMETER_SWITCH

Description

Parameter of this type allows specifying a set of several possible values (more than two).

int PROPERTY_PARAMETER_STRING

Description

Parameter of this type accepts any string value.

int PROPERTY_PARAMETER_COLOR

Description

Parameter of this type allows specifying the material color.

int PROPERTY_PARAMETER_VEC3

Description

Parameter of this type accepts any vec3 value.

int PROPERTY_PARAMETER_VEC4

Description

Parameter of this type accepts any vec4 value.

int PROPERTY_PARAMETER_MASK

Description

Parameter of this type allows specifying a mask.

int PROPERTY_PARAMETER_AUX

Description

Parameter of the auxiliary type.

int PROPERTY_STATE_AUX

Description

State of the auxiliary type.
Last update: 2017-07-03
Build: ()