snozbot / fungus

An easy to use Unity 3D library for creating illustrated Interactive Fiction games and more.
MIT License
1.63k stars 290 forks source link

Add optional parameters to StartExecute in Block #906

Closed MrMMatricks closed 3 years ago

MrMMatricks commented 3 years ago

Description

This is used to control a Flowchart from the outside. Including jumping to a specific CommandIndex or getting a callback. This was possible before by directly starting a Couroutine wrapping Execute with the parameters but then you have to maintain the Coroutine yourself.

What is the current behavior?

There are no parameters on the StartExecute Method in Block.cs. So we can't start a block from the Outside and jump to a specific CommandIndex or get a callback when the block is done. Issue Number: #904

What is the new behavior?

Added optional Parameters to StartExecute so that we can jump directly to a specific CommandIndex and get a Callback when the block execution is done.

Important Notes

breadnone commented 3 years ago

You can simply pass the index number through Continue method without making new ones
Continue(CommandIndex += yourIntHere);

MrMMatricks commented 3 years ago

That's nice to know! But does not help in this case. I am not in a Command or EventHandler. I am trying to start a Block from "the Outside"

stevehalliwell commented 3 years ago

By adding default params to StartExecution we break the interface users of Fungus may rely on (inher or bind from UnityEvent etc.)

Execute itself is public so it can be called directly those params are desired by your code. If calling as block.StartCoroutine(block.Execute(0, null)); is undesirable then I'd prefer adding an overload or new function perhaps StartExecutionExt that takes the params.