All Classes Namespaces Functions Variables Enumerations Enumerator Properties
plyBloxKit.plyBlox Class Reference

A plyBlox object is the main worker in the plyBlox Visual Scripting kit. It contains all the States, Events and Blocks that gives behaviour to an object. More...

Inherits MonoBehaviour.

Public Member Functions

void CopyTo (plyBlox o)
 
bool SetCurrentState (string name)
 Sets the current state by name. Returns false if the named state is not present in this plyBlox object. More...
 
bool SetCurrentState (plyState state)
 Sets the current state. Returns false if the state is not part of this plyBlox object. More...
 
plyEvent GetEvent (string name)
 Return the first event with the given name and in the currently active State. Return null if not found. Keep in mind that Events can have the same name in the same State. More...
 
bool RunEvent (string name)
 Run the named Event's blocks. Returns true of the State changed while it was running. More...
 
bool RunEvent (plyEvent ev)
 Run the Event's blocks. Returns true of the State changed while it was running. More...
 
void RunEvent (plyEvent ev, float afterTimeout)
 Run the Event's blocks after specified timeout More...
 
bool GlobalVariableDefined (string name)
 Returns True if variable defined, else False More...
 
plyVar GetGlobalVariable (string name)
 Return a reference to the named Global Variable. Will return null if the variable does not exist. This is a shortcut to BloxGlobal.GetVariable() More...
 
object GetGlobalVarValue (string name)
 Return the value of a Global Variable. Return null if it does not exist. Keep in mind that the value might simply be null. This is a shortcut to BloxGlobal.GetVarValue() More...
 
plyVar SetGlobalVarValue (string name, object val)
 Set the value of a Global Variable. Will create it if it does not exist. Return reference to the variable. Return null if failed to create. This is a shortcut to BloxGlobal.SetVarValue() More...
 
string EncodeGlobalVariables (bool includeNotPersistVariables)
 Encode the global variables and data into a string. This can be saved to later send to DecodeGlobalVariables. (char)30 and (char)31 are used as separators. GameObject, SystemObject and UnityObject will not be encoded. More...
 
void DecodeGlobalVariables (string data_s)
 Decode a string that was previously encoded by EncodeGlobalVariables More...
 
bool LocalVariableDefined (string name)
 Returns True if variable defined, else False More...
 
plyVar GetLocalVariable (string name)
 Return a reference to the named Local Variable. Will return null if the variable does not exist. More...
 
object GetLocalVarValue (string name)
 Return the value of a Local Variable. Return null if it does not exist. Keep in mind that the value might simply be null. More...
 
plyVar SetLocalVarValue (string name, object val)
 Set the value of a Local Variable. Will create it if it does not exist. Return reference to the variable. Return null if failed to create. More...
 
plyVar SetLocalVarValue (string name, object val, bool persist)
 Set the value of a Local Variable. Will create it if it does not exist. Return reference to the variable. Return null if failed to create. persist will only be applied if it is a new variable. More...
 
string EncodeLocalVariables (bool includeNotPersistVariables)
 Encode the local variables and data into a string. This can be saved to later send to DecodeLocalVariables. (char)30 and (char)31 are used as separators. GameObject, SystemObject and UnityObject will not be encoded. More...
 
void DecodeLocalVariables (string data_s)
 Decode a string that was previously encoded by EncodeLocalVariables More...
 

Static Public Member Functions

static plyBlox GetBloxFrom (object o)
 Try and return the plyBlox object from the given Object which can be a GameObject or Component. Returns null if failed. More...
 
static GameObject GetGameObjectFrom (object o)
 Try and return a GameObject from the given Object which can be the GameObject itself or a Component on the GameObject. Return null if failed. More...
 
static string EncodeVariables (List< plyVar > vars, bool includeNotPersistVariables)
 Encode the variables and data into a string. This can be saved to later send to DecodeVariables. (char)30 and (char)31 are used as separators. GameObject, SystemObject and UnityObject will not be encoded. More...
 
static List< plyVarDecodeVariables (string data_s)
 Decode a string that was previously encoded by EncodeVariables and return a list of variables. More...
 

Public Attributes

const int LOOP_MAX = 1000
 how many times a loop can repeat before forcing it to exit (to prevent a dead-lock)
 
GameObject plyBloxGlobalPrefab
 The blox system's global object prefab. This is needed to gain access to Global Variables and other Settings. You will not access this at runtime, use BloxGlobal.
 
List< plyStatestates = new List<plyState>(0)
 All the states defined for the Blox object.
 
List< plyVarvars = new List<plyVar>(0)
 A list of all the Local Variables defined in the Blox' inspector. Do not access this directly, use the provided functions.
 
int uniqueIdOnObject = -1
 Used to uniquely identify this Blox when there is more than one on the same object.
 
bool NeedObjectActive = false
 This is set to be a hint to code that want to know. If true then the blox' GameObject should not be made inactive else it could cause some events to fail. Update or Collision events could fail for example. This is only used to give a clue to whom ever is interested in knowing and do not mean the object may not be made inactive at all. More...
 

Protected Member Functions

void Awake ()
 
IEnumerator Start ()
 
void Update ()
 
void LateUpdate ()
 
void FixedUpdate ()
 
void OnEnable ()
 
void OnDisable ()
 
void OnDestroy ()
 

Properties

plyState CurrentState [get]
 The currently active state More...
 
plyBloxGlobal BloxGlobal [get]
 Runtime reference to the blox system's global object. It contains the global variables and blox system settings. More...
 
Dictionary< string, plyVarLocalVars [get]
 

Detailed Description

A plyBlox object is the main worker in the plyBlox Visual Scripting kit. It contains all the States, Events and Blocks that gives behaviour to an object.

Member Function Documentation

void plyBloxKit.plyBlox.DecodeGlobalVariables ( string  data_s)

Decode a string that was previously encoded by EncodeGlobalVariables

void plyBloxKit.plyBlox.DecodeLocalVariables ( string  data_s)

Decode a string that was previously encoded by EncodeLocalVariables

static List<plyVar> plyBloxKit.plyBlox.DecodeVariables ( string  data_s)
static

Decode a string that was previously encoded by EncodeVariables and return a list of variables.

string plyBloxKit.plyBlox.EncodeGlobalVariables ( bool  includeNotPersistVariables)

Encode the global variables and data into a string. This can be saved to later send to DecodeGlobalVariables. (char)30 and (char)31 are used as separators. GameObject, SystemObject and UnityObject will not be encoded.

string plyBloxKit.plyBlox.EncodeLocalVariables ( bool  includeNotPersistVariables)

Encode the local variables and data into a string. This can be saved to later send to DecodeLocalVariables. (char)30 and (char)31 are used as separators. GameObject, SystemObject and UnityObject will not be encoded.

static string plyBloxKit.plyBlox.EncodeVariables ( List< plyVar vars,
bool  includeNotPersistVariables 
)
static

Encode the variables and data into a string. This can be saved to later send to DecodeVariables. (char)30 and (char)31 are used as separators. GameObject, SystemObject and UnityObject will not be encoded.

static plyBlox plyBloxKit.plyBlox.GetBloxFrom ( object  o)
static

Try and return the plyBlox object from the given Object which can be a GameObject or Component. Returns null if failed.

plyEvent plyBloxKit.plyBlox.GetEvent ( string  name)

Return the first event with the given name and in the currently active State. Return null if not found. Keep in mind that Events can have the same name in the same State.

static GameObject plyBloxKit.plyBlox.GetGameObjectFrom ( object  o)
static

Try and return a GameObject from the given Object which can be the GameObject itself or a Component on the GameObject. Return null if failed.

plyVar plyBloxKit.plyBlox.GetGlobalVariable ( string  name)

Return a reference to the named Global Variable. Will return null if the variable does not exist. This is a shortcut to BloxGlobal.GetVariable()

object plyBloxKit.plyBlox.GetGlobalVarValue ( string  name)

Return the value of a Global Variable. Return null if it does not exist. Keep in mind that the value might simply be null. This is a shortcut to BloxGlobal.GetVarValue()

plyVar plyBloxKit.plyBlox.GetLocalVariable ( string  name)

Return a reference to the named Local Variable. Will return null if the variable does not exist.

object plyBloxKit.plyBlox.GetLocalVarValue ( string  name)

Return the value of a Local Variable. Return null if it does not exist. Keep in mind that the value might simply be null.

bool plyBloxKit.plyBlox.GlobalVariableDefined ( string  name)

Returns True if variable defined, else False

bool plyBloxKit.plyBlox.LocalVariableDefined ( string  name)

Returns True if variable defined, else False

bool plyBloxKit.plyBlox.RunEvent ( string  name)

Run the named Event's blocks. Returns true of the State changed while it was running.

bool plyBloxKit.plyBlox.RunEvent ( plyEvent  ev)

Run the Event's blocks. Returns true of the State changed while it was running.

void plyBloxKit.plyBlox.RunEvent ( plyEvent  ev,
float  afterTimeout 
)

Run the Event's blocks after specified timeout

bool plyBloxKit.plyBlox.SetCurrentState ( string  name)

Sets the current state by name. Returns false if the named state is not present in this plyBlox object.

bool plyBloxKit.plyBlox.SetCurrentState ( plyState  state)

Sets the current state. Returns false if the state is not part of this plyBlox object.

plyVar plyBloxKit.plyBlox.SetGlobalVarValue ( string  name,
object  val 
)

Set the value of a Global Variable. Will create it if it does not exist. Return reference to the variable. Return null if failed to create. This is a shortcut to BloxGlobal.SetVarValue()

plyVar plyBloxKit.plyBlox.SetLocalVarValue ( string  name,
object  val 
)

Set the value of a Local Variable. Will create it if it does not exist. Return reference to the variable. Return null if failed to create.

plyVar plyBloxKit.plyBlox.SetLocalVarValue ( string  name,
object  val,
bool  persist 
)

Set the value of a Local Variable. Will create it if it does not exist. Return reference to the variable. Return null if failed to create. persist will only be applied if it is a new variable.

Member Data Documentation

bool plyBloxKit.plyBlox.NeedObjectActive = false

This is set to be a hint to code that want to know. If true then the blox' GameObject should not be made inactive else it could cause some events to fail. Update or Collision events could fail for example. This is only used to give a clue to whom ever is interested in knowing and do not mean the object may not be made inactive at all.

Property Documentation

plyBloxGlobal plyBloxKit.plyBlox.BloxGlobal
get

Runtime reference to the blox system's global object. It contains the global variables and blox system settings.

plyState plyBloxKit.plyBlox.CurrentState
get

The currently active state