Attempt

Methods

Subscribe

PUT Subscribe(Event newEvent)

Invoking this method will subscribe the parameter passed to the list of subscribers for this Attempt; these subscribers get invoked when it succeeds.

Path Parameters

Name
Type
Description

NewEvent

object

Method we are trying to subscribe to this Attempt. Has to be of type Event.

private void OnShoot(){
    
}

private void Start(){
    PlayerEvents.Instance.Shoot.Subscribe(OnShoot);
}

Add Trier

PUT AddTrier(TryDelegate trier)

Invoking this method will allow you to add a trier to the attempt; triers are functions of type bool that decide whether this attempt succeeds or not.

Path Parameters

Name
Type
Description

Trier

object

Function that will be added as a trier for the attempt. Can be any function that returns a boolean.

private bool OnTry_Jump(){
    return false;
}

PlayerEvents.Jump.AddTrier(OnTry_Jump);

Methods

Try

POST Try()

Invoking this method will try to invoke the listeners on the Attempt, but it will only do it if the trier allows for it.

PlayerEvents.Jump.Try();

Debug

OPTIONS Debug(bool debugAttempts = false, string name = "Debug")

Logs the names of the methods subscribed to this Attempt, and the Triers added.

Path Parameters

Name
Type
Description

Name

string

Simple name that you can give this debug, making it easier to not confuse it when debugging other things.

DebugAttempts

boolean

​Determines whether you want to debug the triers of this attempt, or only the listeners.

PlayerEvents.Jump.Debug(false, false);

Last updated

Was this helpful?