Inject my service locator in all nodes

FlowCanvas Forums Support Inject my service locator in all nodes

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #3794
    exejutable
    Participant

      Hi,

      I’m running tests to integrate FlowCanvas into my project. Since my flows run using my own services, I want to inject my ServiceLocator, and I don’t need GameObjects. My goal is to wrap some logic into nodes.

      To achieve this, I created FlowScriptManager, which has a method called RunFlowScriptController. This method:

      – Creates the controller and attaches the FlowScript.
      – Also creates a Blackboard and assigns the ServiceLocator to it.

      Then I want to access the blackboard in one of the nodes, but none of the blackboards have the ServiceLocator. Eventually, my idea is to extend my BaseNode from FlowNode and handle all the boilerplate for the nodes.

      1 – Can I access the blackboard and obtain ServiceLocator before the graph starts? I want to avoid the use of a static if is possible.
      2 – Exist other possible ways to inject it?
      3 – Does FlowNode have some method to override better than RegisterPorts?
      4 – What is the best class to implement my Node if I need more control over the callbacks besides FlowNode

      Thanks in advance!

      #3795
      Gavalakis
      Keymaster

        Hello there,

        As far as I can see, you are adding the variable to the GameObject component blackboard, but from within the node you access the local Graph blackboard which is a different blackboard 🙂
        To access the GameObject component blackboard from within a node, you can do so with owner.blackboard. This will return the component blackboard attached to the gameobject where the FlowScriptController is (‘owner’ refers to the FlowScriptController here).

        Let me know if that works for you.
        Thanks 🙂

      Viewing 2 posts - 1 through 2 (of 2 total)
      • You must be logged in to reply to this topic.