+ (define initial-tasks
+ (list (bootstrap-message hive (actor-id gm) 'init-world
+ #:game-spec game-spec)))
+ (define agenda
+ (make-agenda #:pre-unwind-handler print-error-and-continue
+ #:queue (list->q initial-tasks)))
+
+ (set! %live-gm gm)
+ (set! %live-hive hive)
+ (receive (post-run-hook gameobj-injector)
+ (make-special-injector agenda hive (actor-id gm))
+ ;; Set up injector for live hacking
+ (set! inject! gameobj-injector)
+
+ ;; Set up REPL sever
+ (cond
+ ;; If repl-server is an integer, we'll use that as the port
+ ((integer? repl-server)
+ (spawn-and-queue-repl-server! agenda repl-server))
+ (repl-server
+ (spawn-and-queue-repl-server! agenda)))
+
+ (start-agenda agenda
+ #:post-run-hook post-run-hook)))
+
+
+(define (inject-special! queue hive gm-id game-spec special-symbol)
+ (define gameobj-spec
+ (or (find
+ (lambda (entry) (eq? (car entry) special-symbol))
+ game-spec)
+ (throw 'no-such-symbol "Can't find such a symbol in the game-spec"
+ #:symbol special-symbol)))
+ (define task
+ (bootstrap-message hive gm-id 'inject-special!
+ #:special-symbol special-symbol
+ #:gameobj-spec gameobj-spec))
+ (enq! queue task)
+ 'done)
+
+(define (queue-injected-tasks-on-agenda! agenda inject-queue)
+ "Inject tasks from the inject-queue onto the agenda queue."
+ (while (not (q-empty? inject-queue))
+ (enq! (agenda-queue agenda) (q-pop! inject-queue))))
+
+(define* (make-special-injector agenda hive gm-id)
+ "Make a post-run-hook and gameobj injector for quick live hacking."
+ (define inject-queue (make-q))
+ (values
+ (lambda (agenda)
+ (queue-injected-tasks-on-agenda! agenda inject-queue))
+ (lambda (game-spec special-symbol)
+ (inject-special! inject-queue hive gm-id
+ game-spec special-symbol))))