 ;; Render Methods
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(defn- render-left-pane [state]
+(defn- render-left-pane! [state]
   (let [arena-frame (get-in state [:frame :frame/arena])]
     (arena/arena arena-frame canvas-id)
     [:div {:class-name "left-pane"}

  [:div {:class-name "right-pane"}
   [:textarea 
    {:id "editor"
     :onChange #(on-code-change %)
     :value (or (get-player-code state) "")}]
   [:button {:onClick #(on-step-click % state)}
    "Step"]])

(defn- render! [initialized? state templates wombats]
  (when (and (not initialized?) templates wombats)
    (initialize-simulator templates wombats))

  [:div {:class-name "simulator-panel"}
   [render-left-pane state]
   [render-right-pane state]])

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

        sim-templates (re-frame/subscribe [:simulator/templates])
        wombats (re-frame/subscribe [:my-wombats])]
    (reagent/create-class
     {:component-will-mount #(component-will-mount!)
      :props-name "simulator-panel"
      :reagent-render #(render! @sim-initialized? @sim-state @sim-templates @wombats)})))
