Script.Base

ScriptBase Constructor

Constructor

Syntax

public ScriptBase ()

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


CurrentCoroutine Property

Gets the ICoroutine interface for the current coroutine.

Syntax

protected ICoroutine CurrentCoroutine { get; }

Value

The ICoroutine interface to the currently running coroutine.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


GetAllCoroutines Method

A list of all coroutines for this script.

Syntax

Returns

A list containing all running or waiting coroutines.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


GetCoroutineCount Method

The total number of coroutines running on this script.

Syntax

protected int GetCoroutineCount ()

Returns

The total number of coroutines running on this script.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Init Method

Init() is called after all interfaces have been initialized.

Syntax

[Sansar.Script.NonReflective] public abstract void Init ()

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Lock Method

Use to create a critical section with a using statement, ensuring that no other coroutines or scripts (via Reflective) may enter this code section while one coroutine or script is in it.

Syntax

See Also

Parameters

Token

The object controlling the lock. Recommended to be a private object member.

Returns

A ScopedLock that holds the lock and will release it in IDisposable.Dispose.

Exceptions

TypeReason

Thrown if Token is null.

Remarks

Example

C# Example

            private object BalanceLock = new Object();
            int Balance = 100;
            bool Spend(int value)
            {
                using (Lock(BalanceLock))
                {
                    if (Balance > value)
                    {
                        Balance -= value;
                        return true;
                    }
                    return false;
                }
            }

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Log Property

Gets the script console.

Syntax

[Sansar.Script.NonReflective] public Log Log { protected get; set; }

Value

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


MaxCoroutines Property

The maximum number of coroutines that a single script can run.

Syntax

protected int MaxCoroutines { get; }

Value

The maximum number of coroutines that a single script can run.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Memory Property

Memory information for the pool this script is in.

Syntax

[Sansar.Script.NonReflective] public Memory Memory { protected get; set; }

Value

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


PendingEventCount Property

The number of events currently waiting to be processed.

Syntax

protected int PendingEventCount { get; }

Value

The number of events currently waiting to be processed.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


PostScriptEvent Method

Post the event for all scripts.

Syntax

protected void PostScriptEvent (string message)

Parameters

message

The message id used to direct the event.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


PostScriptEvent Method

Post the event for all scripts.

Syntax

Parameters

message

The message id used to direct the event.

data

The object to be post.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


PostScriptEvent Method

Post the event for the target script.

Syntax

Parameters

targetScriptId

The id of the script to sent the event to. To broadcast the message to all subscripted scripts use ScriptBase.PostScriptEvent(string, Reflective).

message

The message id used to direct the event.

data

The object to be post.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


PostSimpleScriptEvent Method

Syntax

[System.Obsolete("Deprecated. Use PostScriptEvent directly instead.", true)] protected void PostSimpleScriptEvent (string message, object data)

See Also

Parameters

message

The message id used to direct the event.

data

An object to send to scripts subscribed to message.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


PostSimpleScriptEvent Method

Syntax

[System.Obsolete("Deprecated. Use PostScriptEvent directly instead.", true)] protected void PostSimpleScriptEvent (ScriptId targetScriptId, string message, object data)

See Also

Parameters

targetScriptId

The id of the script to sent the event to. To broadcast the message to all subscripted scripts use ScriptBase.PostSimpleScriptEvent(string, object).

message

The message id used to direct the event.

data

An object to send to script targetScriptId if subscribed to message.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


ReleaseLock Method

Release a lock if held.

Syntax

protected void ReleaseLock (object Token)

See Also

Parameters

Token

The object controlling the lock. Recommended to be a private object member.

Exceptions

TypeReason

Thrown if Token is null.

Remarks

Example

C# Example

            private object BalanceLock = new Object();
            int Balance = 100;
            bool Spend(int value)
            {
                WaitForLock(BalanceLock);
                bool success = false;
                if (Balance > value)
                {
                    Balance -= value;
                    success = true;
                }
                ReleaseLock(BalanceLock);
                // Note that any early exit between WaitForLock and ReleaseLock fail to release the lock, creating a deadlock the next time this method is called.
                // For this reason it is highly recommended to instead do: using (Lock(BalanceLock))
                return success;
            }

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Script Property

Script handle to this script.

Syntax

[Sansar.Script.NonReflective] public ScriptHandle Script { protected get; set; }

Value

An opaque type used by certain API methods.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


ScriptEventMessageIdCount Property

Obsolete

Syntax

[System.Obsolete("No longer used as there is no longer a limited number of message ids. Obsoleted 2018-04.", true)] protected static int ScriptEventMessageIdCount { get; }

Value

Always returns 0

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


StartCoroutine Method

Starts a coroutine on the current script.

Syntax

Parameters

coroutine

The coroutine to run.

handler

A callback to know when the coroutine has finished.

Returns

An ICoroutine interface to stop the coroutine or see if it has finished.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


StartCoroutine Generic Method

Starts a coroutine on the current script.

Syntax

Type Parameters

T

Type of the first parameter to pass to the coroutine when it is run. This can usually be derived from the Action.

Parameters

coroutine

The coroutine to run.

arg1

First parameter to pass to the coroutine when it is run.

handler

A callback to know when the coroutine has finished. Will report Success==false only if an exception was thrown by the coroutine. Message will be the name of the coroutine.

Returns

An ICoroutine interface to stop the coroutine or see if it has finished.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


StartCoroutine<T,T1> Generic Method

Starts a coroutine on the current script.

Syntax

Type Parameters

T

Type of the first parameter to pass to the coroutine when it is run. This can usually be derived from the Action.

T1

Type of the second parameter to pass to the coroutine when it is run. This can usually be derived from the Action.

Parameters

coroutine

The coroutine to run.

arg1

First parameter to pass to the coroutine when it is run.

arg2

Second parameter to pass to the coroutine when it is run.

handler

A callback to know when the coroutine has finished. Will report Success==false only if an exception was thrown by the coroutine. Message will be the name of the coroutine.

Returns

An ICoroutine interface to stop the coroutine or see if it has finished.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


StartCoroutine<T,T1,T2> Generic Method

Starts a coroutine on the current script.

Syntax

Type Parameters

T

Type of the first parameter to pass to the coroutine when it is run. This can usually be derived from the Action.

T1

Type of the second parameter to pass to the coroutine when it is run. This can usually be derived from the Action.

T2

Type of the third parameter to pass to the coroutine when it is run. This can usually be derived from the Action.

Parameters

coroutine

The coroutine to run.

arg1

First parameter to pass to the coroutine when it is run.

arg2

Second parameter to pass to the coroutine when it is run.

arg3

Third parameter to pass to the coroutine when it is run.

handler

A callback to know when the coroutine has finished. Will report Success==false only if an exception was thrown by the coroutine. Message will be the name of the coroutine.

Returns

An ICoroutine interface to stop the coroutine or see if it has finished.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


StartCoroutine<T,T1,T2,T3> Generic Method

Starts a coroutine on the current script.

Syntax

protected ICoroutine StartCoroutine<T, T1, T2, T3> (Action<T, T1, T2, T3> coroutine, T arg1, T1 arg2, T2 arg3, T3 arg4, Action handler)

Type Parameters

T

Type of the first parameter to pass to the coroutine when it is run. This can usually be derived from the Action.

T1

Type of the second parameter to pass to the coroutine when it is run. This can usually be derived from the Action.

T2

Type of the third parameter to pass to the coroutine when it is run. This can usually be derived from the Action.

T3

Type of the fourth parameter to pass to the coroutine when it is run. This can usually be derived from the Action.

Parameters

coroutine

The coroutine to run.

arg1

First parameter to pass to the coroutine when it is run.

arg2

Second parameter to pass to the coroutine when it is run.

arg3

Third parameter to pass to the coroutine when it is run.

arg4

Fourth parameter to pass to the coroutine when it is run.

handler

A callback to know when the coroutine has finished. Will report Success==false only if an exception was thrown by the coroutine. Message will be the name of the coroutine.

Returns

An ICoroutine interface to stop the coroutine or see if it has finished.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


SubscribeToScriptEvent Method

Subscribes to events sent by other scripts

Syntax

Parameters

message

The event message to listen for.

callback

Handler to call when the event is generated

persistent

Set to false if a one time event is desired.

Returns

An IEventSubscription that can be used to Unsubscribe from these script events.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


SubscribeToScriptEvent Method

Subscribes to events sent only by a specific script.

Syntax

Parameters

sourceScriptId

Ignore events posted by scripts not matching this id.

message

The event message to listen for.

callback

Handler to call when the event is generated.

persistent

Set to false if a one time event is desired.

Returns

An IEventSubscription that can be used to Unsubscribe from these script events.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Terminate Method

Terminates this script immediately.

Syntax

protected void Terminate (string message)

Parameters

message

The message to write to the log.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Wait Method

Delays execution of the current coroutine for the specified time.

Syntax

Parameters

duration

The length of time to wait before continuing in seconds.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Wait Method

Delays execution of the current coroutine for the specified time.

Syntax

Parameters

duration

The length of time to wait before continuing.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor Method

Block the current coroutine until otherCoroutine finishes.

Syntax

Parameters

otherCoroutine

The coroutine to wait for.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor Method

Use to pause the script until an event happens.

Syntax

Parameters

func

The event-generating API to wait for.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor Method

Use to pause the script until an event happens.

Syntax

Parameters

func

The event-generating API to wait for.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor Method

Use to pause the script until an event happens.

Syntax

Parameters

func

The event-generating API to wait for.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor Method

Use to pause the script until an event happens.

Syntax

Parameters

func

The event-generating API to wait for.

run

An Action to run after subscribing the the event, but before waiting for the event to occurr.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor Generic Method

Use to pause the script until an event happens.

Syntax

Type Parameters

ARG1

The type of the argument to func.

Parameters

func

The event-generating API to wait for.

arg1

An argument to func.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor Generic Method

Use to pause the script until an event happens.

Syntax

Type Parameters

ARG1

The type of the argument to func.

Parameters

func

The event-generating API to wait for.

arg1

An argument to func.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor Generic Method

Use to pause the script until an event happens.

Syntax

Type Parameters

ARG1

The type of the argument to func.

Parameters

func

The event-generating API to wait for.

arg1

An argument to func.

run

An Action to run after subscribing the the event, but before waiting for the event to occurr.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor Generic Method

Use to pause the script until an event happens.

Syntax

Type Parameters

T1

The type of the argument to func.

Parameters

func

The event-generating API to wait for.

t1

An argument to func.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor<ARG1,ARG2> Generic Method

Use to pause the script until an event happens.

Syntax

Type Parameters

ARG1

The type of the argument to func.

ARG2

The type of the argument to func.

Parameters

func

The event-generating API to wait for.

arg1

An argument to func.

arg2

An argument to func.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor<ARG1,ARG2> Generic Method

Use to pause the script until an event happens.

Syntax

Type Parameters

ARG1

The type of the argument to func.

ARG2

The type of the argument to func.

Parameters

func

The event-generating API to wait for.

arg1

An argument to func.

arg2

An argument to func.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor<ARG1,ARG2> Generic Method

Use to pause the script until an event happens.

Syntax

Type Parameters

ARG1

The type of the argument to func.

ARG2

The type of the argument to func.

Parameters

func

The event-generating API to wait for.

arg1

An argument to func.

arg2

An argument to func.

run

An Action to run after subscribing the the event, but before waiting for the event to occurr.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor<T1,T2> Generic Method

Use to pause the script until an event happens.

Syntax

Type Parameters

T1

The type of the argument to func.

T2

The type of the argument to func.

Parameters

func

The event-generating API to wait for.

t1

An argument to func.

t2

An argument to func.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor<ARG1,ARG2,ARG3> Generic Method

Use to pause the script until an event happens.

Syntax

protected EventData WaitFor<ARG1, ARG2, ARG3> (Func<ARG1, ARG2, ARG3, Action, Action<Sansar.Script.CancelData>,System.Boolean,Sansar.Script.IEventSubscription> func, ARG1 arg1, ARG2 arg2, ARG3 arg3)

Type Parameters

ARG1

The type of the argument to func.

ARG2

The type of the argument to func.

ARG3

The type of the argument to func.

Parameters

func

The event-generating API to wait for.

arg1

An argument to func.

arg2

An argument to func.

arg3

An argument to func.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor<ARG1,ARG2,ARG3> Generic Method

Use to pause the script until an event happens.

Syntax

protected EventData WaitFor<ARG1, ARG2, ARG3> (Func<ARG1, ARG2, ARG3, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription> func, ARG1 arg1, ARG2 arg2, ARG3 arg3)

Type Parameters

ARG1

The type of the argument to func.

ARG2

The type of the argument to func.

ARG3

The type of the argument to func.

Parameters

func

The event-generating API to wait for.

arg1

An argument to func.

arg2

An argument to func.

arg3

An argument to func.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor<ARG1,ARG2,ARG3> Generic Method

Use to pause the script until an event happens.

Syntax

protected EventData WaitFor<ARG1, ARG2, ARG3> (Func<ARG1, ARG2, ARG3, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription> func, ARG1 arg1, ARG2 arg2, ARG3 arg3, Action run)

Type Parameters

ARG1

The type of the argument to func.

ARG2

The type of the argument to func.

ARG3

The type of the argument to func.

Parameters

func

The event-generating API to wait for.

arg1

An argument to func.

arg2

An argument to func.

arg3

An argument to func.

run

An Action to run after subscribing the the event, but before waiting for the event to occurr.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor<T1,T2,T3> Generic Method

Use to pause the script until an event happens.

Syntax

Type Parameters

T1

The type of the argument to func.

T2

The type of the argument to func.

T3

The type of the argument to func.

Parameters

func

The event-generating API to wait for.

t1

An argument to func.

t2

An argument to func.

t3

An argument to func.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor<ARG1,ARG2,ARG3,ARG4> Generic Method

Use to pause the script until an event happens.

Syntax

protected EventData WaitFor<ARG1, ARG2, ARG3, ARG4> (Func<ARG1, ARG2, ARG3, ARG4, Action, Action<Sansar.Script.CancelData>,System.Boolean,Sansar.Script.IEventSubscription> func, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4)

Type Parameters

ARG1

The type of the argument to func.

ARG2

The type of the argument to func.

ARG3

The type of the argument to func.

ARG4

The type of the argument to func.

Parameters

func

The event-generating API to wait for.

arg1

An argument to func.

arg2

An argument to func.

arg3

An argument to func.

arg4

An argument to func.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor<ARG1,ARG2,ARG3,ARG4> Generic Method

Use to pause the script until an event happens.

Syntax

protected EventData WaitFor<ARG1, ARG2, ARG3, ARG4> (Func<ARG1, ARG2, ARG3, ARG4, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription> func, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4)

Type Parameters

ARG1

The type of the argument to func.

ARG2

The type of the argument to func.

ARG3

The type of the argument to func.

ARG4

The type of the argument to func.

Parameters

func

The event-generating API to wait for.

arg1

An argument to func.

arg2

An argument to func.

arg3

An argument to func.

arg4

An argument to func.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor<ARG1,ARG2,ARG3,ARG4> Generic Method

Use to pause the script until an event happens.

Syntax

protected EventData WaitFor<ARG1, ARG2, ARG3, ARG4> (Func<ARG1, ARG2, ARG3, ARG4, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription> func, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, Action run)

Type Parameters

ARG1

The type of the argument to func.

ARG2

The type of the argument to func.

ARG3

The type of the argument to func.

ARG4

The type of the argument to func.

Parameters

func

The event-generating API to wait for.

arg1

An argument to func.

arg2

An argument to func.

arg3

An argument to func.

arg4

An argument to func.

run

An Action to run after subscribing the the event, but before waiting for the event to occurr.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor<T1,T2,T3,T4> Generic Method

Use to pause the script until an event happens.

Syntax

protected OperationCompleteEvent WaitFor<T1, T2, T3, T4> (Action<T1, T2, T3, T4, Action> func, T1 t1, T2 t2, T3 t3, T4 t4)

Type Parameters

T1

The type of the argument to func.

T2

The type of the argument to func.

T3

The type of the argument to func.

T4

The type of the argument to func.

Parameters

func

The event-generating API to wait for.

t1

An argument to func.

t2

An argument to func.

t3

An argument to func.

t4

An argument to func.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor<ARG1,ARG2,ARG3,ARG4,ARG5> Generic Method

Use to pause the script until an event happens.

Syntax

protected EventData WaitFor<ARG1, ARG2, ARG3, ARG4, ARG5> (Func<ARG1, ARG2, ARG3, ARG4, ARG5, Action, Action<Sansar.Script.CancelData>,System.Boolean,Sansar.Script.IEventSubscription> func, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5)

Type Parameters

ARG1

The type of the argument to func.

ARG2

The type of the argument to func.

ARG3

The type of the argument to func.

ARG4

The type of the argument to func.

ARG5

The type of the argument to func.

Parameters

func

The event-generating API to wait for.

arg1

An argument to func.

arg2

An argument to func.

arg3

An argument to func.

arg4

An argument to func.

arg5

An argument to func.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor<ARG1,ARG2,ARG3,ARG4,ARG5> Generic Method

Use to pause the script until an event happens.

Syntax

protected EventData WaitFor<ARG1, ARG2, ARG3, ARG4, ARG5> (Func<ARG1, ARG2, ARG3, ARG4, ARG5, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription> func, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5)

Type Parameters

ARG1

The type of the argument to func.

ARG2

The type of the argument to func.

ARG3

The type of the argument to func.

ARG4

The type of the argument to func.

ARG5

The type of the argument to func.

Parameters

func

The event-generating API to wait for.

arg1

An argument to func.

arg2

An argument to func.

arg3

An argument to func.

arg4

An argument to func.

arg5

An argument to func.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitFor<ARG1,ARG2,ARG3,ARG4,ARG5> Generic Method

Use to pause the script until an event happens.

Syntax

protected EventData WaitFor<ARG1, ARG2, ARG3, ARG4, ARG5> (Func<ARG1, ARG2, ARG3, ARG4, ARG5, Action<Sansar.Script.EventData>,System.Boolean,Sansar.Script.IEventSubscription> func, ARG1 arg1, ARG2 arg2, ARG3 arg3, ARG4 arg4, ARG5 arg5, Action run)

Type Parameters

ARG1

The type of the argument to func.

ARG2

The type of the argument to func.

ARG3

The type of the argument to func.

ARG4

The type of the argument to func.

ARG5

The type of the argument to func.

Parameters

func

The event-generating API to wait for.

arg1

An argument to func.

arg2

An argument to func.

arg3

An argument to func.

arg4

An argument to func.

arg5

An argument to func.

run

An Action to run after subscribing the the event, but before waiting for the event to occurr.

Returns

An EventData that can be case to type corresponding to the event type of func.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitForLock Method

WaitFor and take a lock on Token

Syntax

protected void WaitForLock (object Token)

See Also

Parameters

Token

The object controlling the lock. Recommended to be a private object member.

Exceptions

TypeReason

Thrown if Token is null.

Remarks

Example

C# Example

            private object BalanceLock = new Object();
            int Balance = 100;
            bool Spend(int value)
            {
                WaitForLock(BalanceLock);
                bool success = false;
                if (Balance > value)
                {
                    Balance -= value;
                    success = true;
                }
                ReleaseLock(BalanceLock);
                // Note that any early exit between WaitForLock and ReleaseLock fail to release the lock, creating a deadlock the next time this method is called.
                // For this reason it is highly recommended to instead do: using (Lock(BalanceLock))
                return success;
            }

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


WaitForSignal Method

Wait the current coroutine until at least 1 signal is sent to it through the ICoroutine interface.

Syntax

protected int WaitForSignal ()

Returns

The number of signals received while waiting.

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0


Yield Method

Yield to let other coroutines or events run.

Syntax

[Sansar.Script.NonReflective] public void Yield ()

Remarks

Requirements

Namespace: Sansar.Script Assembly: Sansar.Script (in Sansar.Script.dll) Assembly Versions: 1.0.0.0

Last updated