Optional Actions do not implement the IAction interface as the other ones and as a result you cannot code an Optional Action as the rest.
However, they enable the use of multiple active Lessons at the same time and decision-making. Below there is an explanation of those two functionalities.
Multiple active Actions¶
Imagine a Total Knee Arthroplasty scenario were we have the main tasks on the knee but at the same time there are some available Actions on your surgical table to assemble an instrument. Those Actions will wait there to be completed, but they will not affect the main path. Those are called Optional Action.
In the image above you see two active Actions: 1) The removal of jar using the pliers and 2) The insertion of jar (bottom)
You can see a tutorial on how to implement Optional Actions here.
Scenegraph manipulation (decision-making)¶
Another functionality of Optional Actions is related with the real-time manipulation (Action addition and deletion) of scenegraph and decision-making. In the same Total Knee Arthroplasty scenario we can have the main Action for the knee and an Optional Action for the tibia active at the same time. If the user decides to perform the tibia Action instead we can write a bit of code in its Perform to change the main scenegraph by adding lets say a Lesson that has all the Actions for the tibia. This Lesson will spawn inside the main scenegraph as the other main Actions.
n the image above you see two active Actions: 1) The insertion of Sponza (left) and 2) the insertion of Knossos (right). The normal path is the Knossos. However, if the user decides to insert the Sponza instead, the scenegraph will replace the Knossos Lesson with the Sponza Lesson.
You can see a tutorial on how to implement the decision-making functionality with Optional Actions here.