YieldInstruction
Namespace:
namespace Lenga\Engine\Core;
class YieldInstruction
Methods
resumePhase
public function resumePhase()
keepWaiting
public function keepWaiting()
Example
use Lenga\Engine\Core\Behaviour;
use Lenga\Engine\Core\YieldInstruction;
use Lenga\Engine\Core\WaitForSeconds;
class CustomYieldExample extends Behaviour
{
public function start(): void
{
$this->startCoroutine($this->myCoroutine());
}
private function myCoroutine(): \Generator
{
// YieldInstruction is the base class for all yield instructions
// You typically use concrete subclasses like:
// Wait for a fixed time
yield new WaitForSeconds(1.0);
Debug::log('After waiting 1 second');
// You can also create custom yield instructions by extending YieldInstruction
}
}