Add docblock and hook for actions to setupViewpoint

This commit is contained in:
Austen McDonald
2016-07-31 22:06:07 +00:00
parent a4dd6a4a25
commit be2e296419
+14
View File
@@ -203,6 +203,12 @@ class Game
$nextViewpoint->save();
}
/**
* Returns a viewpoint made from a Scene $s and the current user, complete
* with actions built from the scene's children and those modified/added by
* the hook 'h/lotgd/core/actions-for/[scene-template]'.
* @param Scene $s
*/
private function setupViewpoint(Scene $s): CharacterViewpoint
{
$v = new CharacterViewpoint([
@@ -211,6 +217,14 @@ class Game
$v->changeFromScene($s);
$ag = new ActionGroup('lotgd/core/default', '', 'A');
$as = array_map(function ($c) { return new Action($c->getId()); }, $s->getChildren());
$context = [
'viewpoint' => $v,
'actions' => $as
];
$this->getEventManager()->publish('h/lotgd/core/actions-for/' . $s->getTemplate(), $context);
$as = $context['actions'];
$ag->setActions($as);
return $v;