├── BehaviourTree ├── Editor.meta ├── Decorator.meta ├── Builder │ ├── Decorator.meta │ ├── Composite │ │ ├── SelectorGraphNode.cs.meta │ │ ├── ActiveSelectorGraphNode.cs.meta │ │ ├── CompositeGraphNode.cs.meta │ │ ├── SequencerGraphNode.cs.meta │ │ ├── SelectorGraphNode.cs │ │ ├── SequencerGraphNode.cs │ │ ├── ActiveSelectorGraphNode.cs │ │ └── CompositeGraphNode.cs │ ├── Decorator │ │ ├── InverterGraphNode.cs.meta │ │ ├── DecoratorGraphNode.cs.meta │ │ ├── ResultReplacerGraphNode.cs.meta │ │ ├── InverterGraphNode.cs │ │ ├── ResultReplacerGraphNode.cs │ │ └── DecoratorGraphNode.cs │ ├── Base │ │ ├── BehaviourTreeSubGraphNode.cs.meta │ │ ├── BehaviourTreeGraphConnection.cs │ │ ├── BehaviourTreeGraph.cs.meta │ │ ├── BehaviourTreeGraphNode.cs.meta │ │ ├── BehaviourTreeGraphConnection.cs.meta │ │ ├── BehaviourTreeSubGraphNode.cs │ │ ├── BehaviourTreeGraph.cs │ │ └── BehaviourTreeGraphNode.cs │ ├── Leaf │ │ ├── LeafGraphNode.cs │ │ └── LeafGraphNode.cs.meta │ ├── Base.meta │ ├── Leaf.meta │ └── Composite.meta ├── Base │ ├── BehaviourTreeState.cs.meta │ ├── BehaviourTreeEnumerator.cs.meta │ ├── BehaviourTree.cs.meta │ ├── BehaviourTreeNode.cs.meta │ ├── BehaviourTreeNodeState.cs.meta │ ├── BehaviourTreeState.cs │ ├── BehaviourTree.cs │ ├── BehaviourTreeEnumerator.cs │ ├── BehaviourTreeNode.cs │ └── BehaviourTreeNodeState.cs ├── Composite │ ├── ActiveSelector.cs.meta │ ├── Selector.cs.meta │ ├── Sequencer.cs.meta │ ├── CompositeNode.cs.meta │ ├── ActiveSelector.cs │ ├── Selector.cs │ ├── Sequencer.cs │ └── CompositeNode.cs ├── Decorator │ ├── DecoratorNode.cs.meta │ ├── InverterNode.cs.meta │ ├── ResultReplacerNode.cs.meta │ ├── DecoratorNode.cs │ ├── InverterNode.cs │ └── ResultReplacerNode.cs ├── Editor │ ├── BehaviourTreeGraphEditor.cs.meta │ ├── BehaviourTreeGraphNodeEditor.cs.meta │ ├── BehaviourTreeSubGraphNodeEditor.cs.meta │ ├── BehaviourTreeSubGraphNodeEditor.cs │ ├── BehaviourTreeGraphEditor.cs │ └── BehaviourTreeGraphNodeEditor.cs ├── Leaf │ ├── LeafNode.cs │ └── LeafNode.cs.meta ├── Base.meta ├── Leaf.meta ├── Builder.meta └── Composite.meta ├── FiniteStateMachine.meta ├── .gitmodules ├── FiniteStateMachine ├── Base.meta ├── Builder.meta ├── Editor.meta ├── Builder │ ├── Base.meta │ ├── Transition.meta │ ├── Base │ │ ├── FiniteStateMachineGraph.cs.meta │ │ ├── FiniteStateMachineGraphNode.cs.meta │ │ ├── FiniteStateMachineConnection.cs.meta │ │ ├── FiniteStateMachineStateGraphNode.cs.meta │ │ ├── FiniteStateMachineSubGraphNode.cs.meta │ │ ├── FiniteStateMachineTransitionGraphNode.cs.meta │ │ ├── FiniteStateMachineGraphNode.cs │ │ ├── FiniteStateMachineConnection.cs │ │ ├── FiniteStateMachineTransitionGraphNode.cs │ │ ├── FiniteStateMachineGraph.cs │ │ ├── FiniteStateMachineSubGraphNode.cs │ │ └── FiniteStateMachineStateGraphNode.cs │ └── Transition │ │ ├── AlwaysTransitionGraphNode.cs.meta │ │ └── AlwaysTransitionGraphNode.cs ├── Base │ ├── FiniteStateMachine.cs.meta │ ├── FiniteStateMachineState.cs.meta │ ├── FiniteStateMachineRuntimeState.cs.meta │ ├── FiniteStateMachineTransition.cs.meta │ ├── FiniteStateMachineTransition.cs │ ├── FiniteStateMachineRuntimeState.cs │ ├── FiniteStateMachineState.cs │ └── FiniteStateMachine.cs └── Editor │ ├── FiniteStateMachineGraphEditor.cs.meta │ ├── FiniteStateMachineGraphNodeEditor.cs.meta │ ├── FiniteStateMachineStateGraphNodeEditor.cs.meta │ ├── FiniteStateMachineSubGraphNodeEditor.cs.meta │ ├── FiniteStateMachineGraphNodeEditor.cs │ ├── FiniteStateMachineGraphEditor.cs │ ├── FiniteStateMachineStateGraphNodeEditor.cs │ └── FiniteStateMachineSubGraphNodeEditor.cs ├── Samples~ ├── Gatherer │ ├── Code │ │ ├── BT.meta │ │ ├── Common.meta │ │ ├── BT │ │ │ ├── Behaviours.meta │ │ │ ├── LeafNodes.meta │ │ │ ├── LeafNodes │ │ │ │ ├── RestGraphNode.cs.meta │ │ │ │ ├── GoHomeGraphNode.cs.meta │ │ │ │ ├── CheckNeedsRestGraphNode.cs.meta │ │ │ │ ├── DropResourceGraphNode.cs.meta │ │ │ │ ├── FindResourceGraphNode.cs.meta │ │ │ │ ├── MoveToTargetGraphNode.cs.meta │ │ │ │ ├── PickResourceGraphNode.cs.meta │ │ │ │ ├── CheckAlarmRaisedGraphNode.cs.meta │ │ │ │ ├── ConsumeResourceGraphNode.cs.meta │ │ │ │ ├── GoHomeGraphNode.cs │ │ │ │ ├── CheckAlarmRaisedGraphNode.cs │ │ │ │ ├── CheckNeedsRestGraphNode.cs │ │ │ │ ├── DropResourceGraphNode.cs │ │ │ │ ├── PickResourceGraphNode.cs │ │ │ │ ├── ConsumeResourceGraphNode.cs │ │ │ │ ├── RestGraphNode.cs │ │ │ │ ├── MoveToTargetGraphNode.cs │ │ │ │ └── FindResourceGraphNode.cs │ │ │ └── Behaviours │ │ │ │ ├── GathererBTDebugger.cs.meta │ │ │ │ ├── GatherersBTManager.cs.meta │ │ │ │ ├── GathererBTDebugger.cs │ │ │ │ ├── GatherersBTManager.cs │ │ │ │ ├── GathererBTRunner.cs.meta │ │ │ │ └── GathererBTRunner.cs │ │ ├── FSM │ │ │ ├── States.meta │ │ │ ├── Transitions.meta │ │ │ ├── States │ │ │ │ ├── GoHomeStateGraphNode.cs.meta │ │ │ │ ├── RestStateGraphNode.cs.meta │ │ │ │ ├── WaitStateGraphNode.cs.meta │ │ │ │ ├── ConsumeResourceStateGraphNode.cs.meta │ │ │ │ ├── DropResourceStateGraphNode.cs.meta │ │ │ │ ├── FindResourceStateGraphNode.cs.meta │ │ │ │ ├── MoveToTargetStateGraphNode.cs.meta │ │ │ │ ├── PickResourceStateGraphNode.cs.meta │ │ │ │ ├── WaitStateGraphNode.cs │ │ │ │ ├── GoHomeStateGraphNode.cs │ │ │ │ ├── MoveToTargetStateGraphNode.cs │ │ │ │ ├── ConsumeResourceStateGraphNode.cs │ │ │ │ ├── PickResourceStateGraphNode.cs │ │ │ │ ├── RestStateGraphNode.cs │ │ │ │ ├── DropResourceStateGraphNode.cs │ │ │ │ └── FindResourceStateGraphNode.cs │ │ │ ├── Behaviours │ │ │ │ ├── GathererFSMDebugger.cs.meta │ │ │ │ ├── GathererFSMRunner.cs.meta │ │ │ │ ├── GatherersFSMManager.cs.meta │ │ │ │ ├── GatherersFSMManager.cs │ │ │ │ ├── GathererFSMDebugger.cs │ │ │ │ └── GathererFSMRunner.cs │ │ │ ├── Transitions │ │ │ │ ├── NeedsRestTransitionGraphNode.cs.meta │ │ │ │ ├── AlarmIsRaisedTransitionGraphNode.cs.meta │ │ │ │ ├── FoundResourceTransitionGraphNode.cs.meta │ │ │ │ ├── ResourcePickedTransitionGraphNode.cs.meta │ │ │ │ ├── TargetReachedTransitionGraphNode.cs.meta │ │ │ │ ├── ResourceUnavailableTransitionGraphNode.cs.meta │ │ │ │ ├── HasRestedTransitionGraphNode.cs.meta │ │ │ │ ├── FoundResourceTransitionGraphNode.cs │ │ │ │ ├── HasRestedTransitionGraphNode.cs │ │ │ │ ├── NeedsRestTransitionGraphNode.cs │ │ │ │ ├── ResourcePickedTransitionGraphNode.cs │ │ │ │ ├── TargetReachedTransitionGraphNode.cs │ │ │ │ ├── ResourceUnavailableTransitionGraphNode.cs │ │ │ │ └── AlarmIsRaisedTransitionGraphNode.cs │ │ │ └── Behaviours.meta │ │ ├── Common │ │ │ ├── Behaviours │ │ │ │ ├── Home.cs.meta │ │ │ │ ├── BehaviourDebugger.cs.meta │ │ │ │ ├── GatherersManager.cs.meta │ │ │ │ ├── SampleController.cs.meta │ │ │ │ ├── Home.cs │ │ │ │ ├── Resource.cs.meta │ │ │ │ ├── BehaviourDebugger.cs │ │ │ │ ├── Resource.cs │ │ │ │ ├── SampleController.cs │ │ │ │ └── GatherersManager.cs │ │ │ ├── Blackboard │ │ │ │ ├── WorldState.cs.meta │ │ │ │ ├── WorldState.cs │ │ │ │ ├── Gatherer.cs.meta │ │ │ │ └── Gatherer.cs │ │ │ ├── Interfaces │ │ │ │ ├── IBehaviourManager.cs.meta │ │ │ │ └── IBehaviourManager.cs │ │ │ ├── Behaviours.meta │ │ │ ├── Blackboard.meta │ │ │ └── Interfaces.meta │ │ └── FSM.meta │ ├── Code.meta │ ├── Content │ │ ├── Common │ │ │ ├── Home.prefab.meta │ │ │ ├── Resource.prefab.meta │ │ │ ├── Home.mat.meta │ │ │ ├── Gatherer.mat.meta │ │ │ ├── Resource.mat.meta │ │ │ ├── Home.mat │ │ │ ├── Resource.mat │ │ │ ├── Gatherer.mat │ │ │ ├── Home.prefab │ │ │ └── Resource.prefab │ │ ├── BT.meta │ │ ├── FSM.meta │ │ ├── Common.meta │ │ ├── BT │ │ │ ├── Sample01.meta │ │ │ ├── Sample01 │ │ │ │ ├── GathererBT-01.prefab.meta │ │ │ │ ├── GathererBT-01.asset.meta │ │ │ │ └── GathererBT-01.prefab │ │ │ ├── Sample02.meta │ │ │ ├── Sample02 │ │ │ │ ├── GathererBT-02.prefab.meta │ │ │ │ ├── GathererBT-02.asset.meta │ │ │ │ ├── GathererBT-Rest.asset.meta │ │ │ │ ├── GathererBT-Gathering.asset.meta │ │ │ │ ├── GathererBT-02.prefab │ │ │ │ └── GathererBT-02.asset │ │ │ ├── Sample03.meta │ │ │ ├── Sample03 │ │ │ │ ├── GathererBT-03.prefab.meta │ │ │ │ ├── GathererBT-03.asset.meta │ │ │ │ └── GathererBT-03.prefab │ │ │ ├── Sample04.meta │ │ │ └── Sample04 │ │ │ │ ├── GathererBT-03.prefab.meta │ │ │ │ ├── GathererBT-04.asset.meta │ │ │ │ ├── GathererBT-04-Hide.asset.meta │ │ │ │ ├── GathererBT-04-Work.asset.meta │ │ │ │ └── GathererBT-03.prefab │ │ └── FSM │ │ │ ├── Sample 01.meta │ │ │ ├── Sample 01 │ │ │ ├── GathererFSM-01.prefab.meta │ │ │ ├── GathererFSM.asset.meta │ │ │ ├── Gatherer-FSM-01.asset.meta │ │ │ └── GathererFSM-01.prefab │ │ │ ├── Sample 02.meta │ │ │ ├── Sample 02 │ │ │ ├── GathererFSM-02.prefab.meta │ │ │ ├── GathererFetch.asset.meta │ │ │ ├── GathererRest.asset.meta │ │ │ ├── GathererStore.asset.meta │ │ │ ├── Gatherer-FSM-02.asset.meta │ │ │ └── GathererFSM-02.prefab │ │ │ ├── Sample 03.meta │ │ │ ├── Sample 03 │ │ │ ├── GathererFSM-03.prefab.meta │ │ │ └── GathererFSM-03.prefab │ │ │ ├── Sample 04.meta │ │ │ └── Sample 04 │ │ │ ├── GathererFSM-03.prefab.meta │ │ │ ├── Gatherer-FSM-04-Hide.asset.meta │ │ │ ├── Gatherer-FSM-04.asset.meta │ │ │ └── GathererFSM-03.prefab │ ├── Scenes.meta │ ├── Content.meta │ └── Scenes │ │ ├── BT.meta │ │ ├── BT │ │ ├── Gatherer-BT-01.unity.meta │ │ ├── Gatherer-BT-02.unity.meta │ │ ├── Gatherer-BT-03.unity.meta │ │ └── Gatherer-BT-04.unity.meta │ │ ├── FSM.meta │ │ └── FSM │ │ ├── Gatherer-FSM-01.unity.meta │ │ ├── Gatherer-FSM-02.unity.meta │ │ ├── Gatherer-FSM-03.unity.meta │ │ └── Gatherer-FSM-04.unity.meta └── Gatherer.meta ├── Interfaces ├── IAIBehaviourDebugger.cs.meta ├── IAIBehaviourBuilder.cs ├── IAIBehaviour.cs ├── IAIBehaviourDebugger.cs ├── IAIBehaviour.cs.meta └── IAIBehaviourBuilder.cs.meta ├── License.md.meta ├── README.md.meta ├── package.json.meta ├── Planilo.asmdef.meta ├── BehaviourTree.meta ├── Interfaces.meta ├── Submodules.meta ├── Submodules └── xNode.meta ├── Planilo.asmdef ├── package.json ├── License.md └── README.md /BehaviourTree/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 23f10a60f37b47b4aa4a0b15d16b6262 3 | timeCreated: 1598021827 -------------------------------------------------------------------------------- /FiniteStateMachine.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2752ac942d074a808c60ab3fa02a26a3 3 | timeCreated: 1598285816 -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "Submodules/xNode"] 2 | path = Submodules/xNode 3 | url = https://github.com/jlreymendez/xNode 4 | -------------------------------------------------------------------------------- /BehaviourTree/Decorator.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1062cffa68e04d719a4e1d07c26726db 3 | timeCreated: 1597947459 -------------------------------------------------------------------------------- /FiniteStateMachine/Base.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d24b1a71ff5042c1b3d46f6bd8818eb7 3 | timeCreated: 1598285816 -------------------------------------------------------------------------------- /FiniteStateMachine/Builder.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a93d1136348c4e55a2310c63f4f4e0db 3 | timeCreated: 1598287596 -------------------------------------------------------------------------------- /FiniteStateMachine/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1e96165401b8460fbbe677de2f3a5ea6 3 | timeCreated: 1598358865 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bd34d992e0634ba1834ff457c53da51e 3 | timeCreated: 1597954406 -------------------------------------------------------------------------------- /BehaviourTree/Builder/Decorator.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 67e9a45ba2f1473688bcfd1fdb992b88 3 | timeCreated: 1597949088 -------------------------------------------------------------------------------- /FiniteStateMachine/Builder/Base.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 13447a4ebe76486eaf010ab4c7b94370 3 | timeCreated: 1598303338 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/Common.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8befd0c44e2342dd9c8f1b3af7e11d1d 3 | timeCreated: 1598625855 -------------------------------------------------------------------------------- /FiniteStateMachine/Builder/Transition.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a534e37d9adb419ab4357e3ee24cf10a 3 | timeCreated: 1598303353 -------------------------------------------------------------------------------- /Interfaces/IAIBehaviourDebugger.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 46dfe5098ac84355a3466e935e4c31a9 3 | timeCreated: 1598021665 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/Behaviours.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 21f6e3ac850e43549910fbbac9c860ef 3 | timeCreated: 1597954348 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/LeafNodes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fa0523d4492349d6919e58eca290e430 3 | timeCreated: 1597964303 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/States.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 74f61da2682b4048bb2fa691520cc54e 3 | timeCreated: 1598364122 -------------------------------------------------------------------------------- /BehaviourTree/Base/BehaviourTreeState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 06579914a4164a8f98b76a19d8520a4c 3 | timeCreated: 1598353389 -------------------------------------------------------------------------------- /BehaviourTree/Composite/ActiveSelector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 94fcea079da7480b940a5fd6694b185b 3 | timeCreated: 1598898910 -------------------------------------------------------------------------------- /BehaviourTree/Decorator/DecoratorNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bcc18f1f1c3642b9a882da28f21c5d01 3 | timeCreated: 1597947467 -------------------------------------------------------------------------------- /BehaviourTree/Decorator/InverterNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f344b2aa9e5f46f48f6713e44cae17a3 3 | timeCreated: 1597948037 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Transitions.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a49a6cdb3364ff88d52b589e6472f75 3 | timeCreated: 1598460742 -------------------------------------------------------------------------------- /BehaviourTree/Base/BehaviourTreeEnumerator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 464389cd451545b8acd644a07bf60186 3 | timeCreated: 1598016134 -------------------------------------------------------------------------------- /BehaviourTree/Decorator/ResultReplacerNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a29822550b8043abac9899ad55545b9d 3 | timeCreated: 1598901099 -------------------------------------------------------------------------------- /FiniteStateMachine/Base/FiniteStateMachine.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 264479c3c5074a53b5c79ddb06c23365 3 | timeCreated: 1598285816 -------------------------------------------------------------------------------- /BehaviourTree/Builder/Composite/SelectorGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c6c0b00122704a0d83cbe9f1b074eb53 3 | timeCreated: 1597947213 -------------------------------------------------------------------------------- /BehaviourTree/Builder/Decorator/InverterGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 119f7effb34a49a3a55716e9f173101a 3 | timeCreated: 1597949105 -------------------------------------------------------------------------------- /BehaviourTree/Editor/BehaviourTreeGraphEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1570f3df354e453aa53e5dd7ec72c87d 3 | timeCreated: 1598024380 -------------------------------------------------------------------------------- /BehaviourTree/Editor/BehaviourTreeGraphNodeEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 82bc11547dde4c37826bec6e31996ca6 3 | timeCreated: 1598021825 -------------------------------------------------------------------------------- /FiniteStateMachine/Base/FiniteStateMachineState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 091eaeb6820e4d07a8b703997363c479 3 | timeCreated: 1598285965 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/LeafNodes/RestGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c5ea3905ccdf4111bbe8d4a09d9b7ce1 3 | timeCreated: 1598042572 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/Common/Behaviours/Home.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9e5615bec2c34559835bd071d3bb48c2 3 | timeCreated: 1598382326 -------------------------------------------------------------------------------- /BehaviourTree/Builder/Base/BehaviourTreeSubGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d4c86fb00794ade9d41dbd82f12ea61 3 | timeCreated: 1598036631 -------------------------------------------------------------------------------- /BehaviourTree/Builder/Decorator/DecoratorGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 86913e94f2204c94b3d8b3883dfac021 3 | timeCreated: 1597949160 -------------------------------------------------------------------------------- /BehaviourTree/Editor/BehaviourTreeSubGraphNodeEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 69c1b0a45bb143af8f5d46df57b93708 3 | timeCreated: 1598468049 -------------------------------------------------------------------------------- /FiniteStateMachine/Base/FiniteStateMachineRuntimeState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 08d6be8b46b44ce0869ca4e95a4b3545 3 | timeCreated: 1598285888 -------------------------------------------------------------------------------- /FiniteStateMachine/Base/FiniteStateMachineTransition.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: afba9a82b6f543e4a3ac0db1daf0ef0f 3 | timeCreated: 1598364529 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/LeafNodes/GoHomeGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a157d042975b448fa94d4bcbb7e5d627 3 | timeCreated: 1598560425 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/Common/Blackboard/WorldState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2264e1910dc340ed9a53117111cde205 3 | timeCreated: 1598625287 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/States/GoHomeStateGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4e601dc71e4749d3acc7a59b2c924ff7 3 | timeCreated: 1598461038 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/States/RestStateGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 69099855ed1b4e2799e865896a2d588f 3 | timeCreated: 1598460894 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/States/WaitStateGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b6af6373287a46bab01b6311c11fd8a9 3 | timeCreated: 1598905433 -------------------------------------------------------------------------------- /BehaviourTree/Builder/Composite/ActiveSelectorGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: feec9caa577841e4a55c8306c36b2af2 3 | timeCreated: 1598899801 -------------------------------------------------------------------------------- /BehaviourTree/Builder/Decorator/ResultReplacerGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d1e670abc9c743348bcd401adaacb0c0 3 | timeCreated: 1598901378 -------------------------------------------------------------------------------- /FiniteStateMachine/Builder/Base/FiniteStateMachineGraph.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cdd908a76ba246eb91d13f28a40a4143 3 | timeCreated: 1598287637 -------------------------------------------------------------------------------- /FiniteStateMachine/Builder/Base/FiniteStateMachineGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db3384b79add4143a1545cd9cecdd099 3 | timeCreated: 1598365914 -------------------------------------------------------------------------------- /FiniteStateMachine/Editor/FiniteStateMachineGraphEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0e0f2ad9085045c6b2c476fb4cf315d3 3 | timeCreated: 1598358912 -------------------------------------------------------------------------------- /FiniteStateMachine/Editor/FiniteStateMachineGraphNodeEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 853921e758314674a0d28255aec17df9 3 | timeCreated: 1598465887 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/Behaviours/GathererBTDebugger.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 027e1eeb965c47308c0eb9a7f463d140 3 | timeCreated: 1598558576 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/Behaviours/GatherersBTManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7a8be2dd4d874ca4884668eab0061623 3 | timeCreated: 1598554820 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/LeafNodes/CheckNeedsRestGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 380edce1ad95493996bb9efd2d361ac8 3 | timeCreated: 1598042098 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/LeafNodes/DropResourceGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5fa672b651f64a19a439ee5dc7e32c39 3 | timeCreated: 1598901560 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/LeafNodes/FindResourceGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 31373fe844ce4ed4b8846208b499f763 3 | timeCreated: 1597954599 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/LeafNodes/MoveToTargetGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6b95438f51c14f18b534180eba3ff087 3 | timeCreated: 1597961310 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/LeafNodes/PickResourceGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5740cfef256c48dbb51b82cc660b8f2c 3 | timeCreated: 1597956249 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/Common/Behaviours/BehaviourDebugger.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8ee27841369646ac9e4fecbdb3024986 3 | timeCreated: 1598641427 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/Common/Behaviours/GatherersManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8a706759fdab4196ae3b50f4571bdcd3 3 | timeCreated: 1598639685 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/Common/Behaviours/SampleController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 87d431af597644b69f7463eee295ca99 3 | timeCreated: 1597952974 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/Common/Interfaces/IBehaviourManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e2327ae99e304c20b13c5c1ca2dd2bab 3 | timeCreated: 1598641481 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Behaviours/GathererFSMDebugger.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 59eb80b7c79f4504a4089aff3faed7b0 3 | timeCreated: 1598641901 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Behaviours/GathererFSMRunner.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 51ac5a52e81843fb838880aaeb330450 3 | timeCreated: 1598355869 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Behaviours/GatherersFSMManager.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d522d97a44344e0fbd8054fa1fa1ca59 3 | timeCreated: 1598639109 -------------------------------------------------------------------------------- /FiniteStateMachine/Builder/Base/FiniteStateMachineConnection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8ed624537b3d4481b6493c852cddfbd6 3 | timeCreated: 1598299718 -------------------------------------------------------------------------------- /FiniteStateMachine/Builder/Base/FiniteStateMachineStateGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 326bc9f3b49049f99bbaaef87fae77fb 3 | timeCreated: 1598303089 -------------------------------------------------------------------------------- /FiniteStateMachine/Builder/Base/FiniteStateMachineSubGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d5c365a7459a4e51b5d70760f51d3422 3 | timeCreated: 1598447710 -------------------------------------------------------------------------------- /FiniteStateMachine/Builder/Transition/AlwaysTransitionGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d6f7728263c24687b8653873d7007634 3 | timeCreated: 1598303388 -------------------------------------------------------------------------------- /FiniteStateMachine/Editor/FiniteStateMachineStateGraphNodeEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c5d230aa803d488c813e3c298e14282f 3 | timeCreated: 1598378335 -------------------------------------------------------------------------------- /FiniteStateMachine/Editor/FiniteStateMachineSubGraphNodeEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8cb84b3c62c846979927cf8bfba30d2f 3 | timeCreated: 1598466473 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/LeafNodes/CheckAlarmRaisedGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 863c2ca275ed4395a81dc8138d815e74 3 | timeCreated: 1598900207 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/LeafNodes/ConsumeResourceGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a88fe74c964a426fb000ff9f4a348534 3 | timeCreated: 1597961104 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/States/ConsumeResourceStateGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7369c90c41f7469ab6178a63d1117fe8 3 | timeCreated: 1598362425 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/States/DropResourceStateGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae5589b5b0464be4b9970d20ac2bd9fc 3 | timeCreated: 1598904925 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/States/FindResourceStateGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2480d82061c942deac16aaf1273f2e7c 3 | timeCreated: 1598358266 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/States/MoveToTargetStateGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 208d0805e7004efb8763b88ab70d028c 3 | timeCreated: 1598360351 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/States/PickResourceStateGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 78a48d9d87324eb3a78f60d0de091eb1 3 | timeCreated: 1598360762 -------------------------------------------------------------------------------- /FiniteStateMachine/Builder/Base/FiniteStateMachineTransitionGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 45094c98a8c048a4bc78bf0bcf2b4e86 3 | timeCreated: 1598299907 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/Common/Behaviours/Home.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace PlaniloSamples.Common 4 | { 5 | public class Home : MonoBehaviour {} 6 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Transitions/NeedsRestTransitionGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4150a0bc66cb4f27ae8a0f58a55e5f64 3 | timeCreated: 1598365038 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Transitions/AlarmIsRaisedTransitionGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e93f9f373dc845a9b4e69d4a91592020 3 | timeCreated: 1598904181 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Transitions/FoundResourceTransitionGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: efb6bf345c7e45f79e63c44baf9fe264 3 | timeCreated: 1598365200 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Transitions/ResourcePickedTransitionGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5a116ab9b5ea43999e6d547dfc91c14b 3 | timeCreated: 1598365399 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Transitions/TargetReachedTransitionGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6d87c294d43b4c53a3d64335776dccd8 3 | timeCreated: 1598364227 -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Transitions/ResourceUnavailableTransitionGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 746ada97dc1e42238e771dd6e1264605 3 | timeCreated: 1598365326 -------------------------------------------------------------------------------- /BehaviourTree/Builder/Base/BehaviourTreeGraphConnection.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo.BT.Builder 2 | { 3 | [System.Serializable] 4 | public class BehaviourTreeGraphConnection { } 5 | } 6 | -------------------------------------------------------------------------------- /BehaviourTree/Builder/Leaf/LeafGraphNode.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo.BT.Builder 2 | { 3 | [NodeTint("#2e6b38")] 4 | public abstract class LeafGraphNode : BehaviourTreeGraphNode { } 5 | } 6 | -------------------------------------------------------------------------------- /Interfaces/IAIBehaviourBuilder.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo 2 | { 3 | public interface IAIBehaviourBuilder 4 | { 5 | IAIBehaviour Build(); 6 | } 7 | } -------------------------------------------------------------------------------- /License.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf0be06b37c4a5446bd29deb63618fb8 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0cdbf1c4baf74bb499e51cd61f6d4ccf 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b7630e4b170faca41bfb49460b11ee6b 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /BehaviourTree/Leaf/LeafNode.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo.BT 2 | { 3 | public abstract class LeafNode : BehaviourTreeNode 4 | { 5 | public LeafNode(int index) : base(index) {} 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Planilo.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a6582943af2a7f2459da73aa3febf111 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /BehaviourTree.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6c022f72e6abf154aa6529773d5a7a39 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Interfaces.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bc9eb3ec6dece9c428e5b0e15a58aed2 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Submodules.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 67411cbb1edbfac43b45d0be5088e675 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /BehaviourTree/Base.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cc3363c304bc33d49b2f8702bb78742e 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /BehaviourTree/Leaf.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0026211ea9a9fe64ab19159069a53fe0 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 37e54c6fd961025428fe1896d8a53d05 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Submodules/xNode.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 132ba438bf2a24f4d97a53b0a3235407 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /BehaviourTree/Builder.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e0e03a877601715448f75641512ed07d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /BehaviourTree/Composite.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a8dae50cc56cb94e8a278b67c4da501 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Code.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 46f65c032d014fd0b5110a7339889720 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/Common/Home.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ec928f6b96f8f74783f92c2888272db 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b96ad9671f30a54f97dfae33b0cd511 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /BehaviourTree/Builder/Base.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f52cb0b6ab1d889428941b9c3d2692c8 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /BehaviourTree/Builder/Leaf.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 450ecae9ca3e13846a1ac61d30aa8277 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 44dce9c8298d9fb44a3412b2da7ff25b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 852140d3db681254ea78568341a4571a 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 90ee2e13a0b11a34499eccefd36de2bb 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/Common/Resource.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d629e753717899a4ea2dcc9d727b03ce 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/FSM.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e67f39b6f6d85c1489134a3f27867e5c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Scenes/BT.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a1aa1ff72c141964f9cac978aaa5e114 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Scenes/BT/Gatherer-BT-01.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 484355d5c0520934e801b43aa7400bf6 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Scenes/BT/Gatherer-BT-02.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 924c59d98e7b34043b4b4e677277171e 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Scenes/BT/Gatherer-BT-03.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 137b5d108a845914a974afac0c8d657d 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Scenes/BT/Gatherer-BT-04.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 880cfaa0f143c5c40b4d9b302251eddc 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Scenes/FSM.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 35b50b1dc4886c745915aa5c10658ac9 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Scenes/FSM/Gatherer-FSM-01.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c83154e996aba6e4a967cc120ff760cc 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Scenes/FSM/Gatherer-FSM-02.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be463a4b4c73ccf4a809ee7cc502d90c 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Scenes/FSM/Gatherer-FSM-03.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 20dc5419b7e55ea46a806d3cce8f94c6 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Scenes/FSM/Gatherer-FSM-04.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aabf809ab01921140bc7ab7e54b17244 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /BehaviourTree/Builder/Composite.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 737c6d89e555e8b4aac1948709a1e22c 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/Common.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0e7037a0eedddfb428d38ca304a4d2cd 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Behaviours.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 521b4dd62498ebd46b3b2392abc4e433 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT/Sample01.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3b8c2911872d19b47a032c0ee9a09b00 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT/Sample01/GathererBT-01.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 473630c0e7a16ea45a73d9b7e5bbb9ea 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT/Sample02.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 32fb748d79a92164c98be6d8dd802b28 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT/Sample02/GathererBT-02.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d326ef9e89def5f41b90954fb7e56080 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT/Sample03.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ee2b7ce3906258746b348c677d4aa183 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT/Sample03/GathererBT-03.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a4ab309244c765f4ca5db3e781fc0e6e 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT/Sample04.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 88829b0001d7de943b9369db382e333b 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT/Sample04/GathererBT-03.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c07a14ebf2e26274e9874613561fa6ab 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/FSM/Sample 01.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4739974843c11e64385a488bd855dc80 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/FSM/Sample 01/GathererFSM-01.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a6a024a172cd6442b30b89ec4f075d7 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/FSM/Sample 02.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4db0a2c1a77c9cd4abca57d215c71455 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/FSM/Sample 02/GathererFSM-02.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3268cda8723819b4b91bce3ab3e98b87 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/FSM/Sample 03.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f49a171f79498ba4b843a6217b9cd0b2 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/FSM/Sample 03/GathererFSM-03.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fbd6dd1761d9cb746816522a21f6fad6 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/FSM/Sample 04.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c1767b63263facc47b415b49785fac94 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/FSM/Sample 04/GathererFSM-03.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 47f42ec6ff39bc34aa36a732fb045c63 3 | PrefabImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/Common/Behaviours.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3227b81ded2245e9b3f4e3b8e0947de6 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/Common/Blackboard.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 24fe962b4c1b4bda9e7c6cc3abe3937d 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/Common/Interfaces.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 32cb490a96862584591e3e32ea4c99f2 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/Common/Home.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 05927f2e62dc77a4494a7bed5d0b8866 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/Common/Gatherer.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d4e355b1fbfd80340832d1c819625f12 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/Common/Resource.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33c0852471331d9449a8296af5dcc9c0 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Interfaces/IAIBehaviour.cs: -------------------------------------------------------------------------------- 1 | using Planilo.BT; 2 | 3 | namespace Planilo 4 | { 5 | public interface IAIBehaviour 6 | { 7 | TState Initialize(ref TAgent agent); 8 | void Run(ref TAgent agent, ref TState state); 9 | } 10 | } -------------------------------------------------------------------------------- /Interfaces/IAIBehaviourDebugger.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo 2 | { 3 | public interface IAIBehaviourDebugger 4 | { 5 | #if UNITY_EDITOR 6 | TState GetState(); 7 | TBehaviour GetBehaviour(); 8 | #endif 9 | } 10 | } -------------------------------------------------------------------------------- /FiniteStateMachine/Base/FiniteStateMachineTransition.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Planilo.FSM 4 | { 5 | public class FiniteStateMachineTransition 6 | { 7 | public Func Condition; 8 | public int TargetState; 9 | } 10 | } -------------------------------------------------------------------------------- /FiniteStateMachine/Builder/Base/FiniteStateMachineGraphNode.cs: -------------------------------------------------------------------------------- 1 | using XNode; 2 | 3 | namespace Planilo.FSM.Builder 4 | { 5 | public abstract class FiniteStateMachineGraphNode : Node 6 | { 7 | public override object GetValue(NodePort port) => null; 8 | } 9 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT/Sample02/GathererBT-02.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c44872229baa7e6458b0078a3c00d37f 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/FSM/Sample 01/GathererFSM.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5dadc9d47e922a2408dfdebeee509f50 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/FSM/Sample 02/GathererFetch.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 738092e4ded8c6c47a13491720b661b2 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/FSM/Sample 02/GathererRest.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c700a57f07dab0843b07f455e13d6c68 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/FSM/Sample 02/GathererStore.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7a4f0fb2d50b55f499b876d5300929be 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT/Sample01/GathererBT-01.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1b3f2ea6723381e4da1d2f1c019dac18 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT/Sample03/GathererBT-03.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b72ad6e615f04fc478667b75c8ec4529 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT/Sample04/GathererBT-04.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 55ee643f2a668e34bb8503fa50ff825f 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT/Sample02/GathererBT-Rest.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8508a9d30c031ab43845b7f4fdacc7e2 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT/Sample04/GathererBT-04-Hide.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6ffe2b1873699d142ada10cadfcea035 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT/Sample04/GathererBT-04-Work.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8d7094a53c00b2749bc0f87cc5ca4b30 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/FSM/Sample 01/Gatherer-FSM-01.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 48bbfe83bac28f34ebe22b97145cc2b6 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/FSM/Sample 02/Gatherer-FSM-02.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 849e2b67845e27143a3cadd0ab4c454e 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/FSM/Sample 04/Gatherer-FSM-04-Hide.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2fcecdcd6a1cbce41964868636fd6a57 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/FSM/Sample 04/Gatherer-FSM-04.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d1b154cc056d51348962c302abea347b 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/Behaviours/GathererBTDebugger.cs: -------------------------------------------------------------------------------- 1 | using Planilo.BT; 2 | using Planilo.BT.Builder; 3 | using PlaniloSamples.Common; 4 | 5 | namespace PlaniloSamples.BT 6 | { 7 | public class GathererBTDebugger : BehaviourDebugger { } 8 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/Behaviours/GatherersBTManager.cs: -------------------------------------------------------------------------------- 1 | using Planilo.BT; 2 | using Planilo.BT.Builder; 3 | using PlaniloSamples.Common; 4 | 5 | namespace PlaniloSamples.BT 6 | { 7 | public class GatherersBTManager : GatherersManager { } 8 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT/Sample02/GathererBT-Gathering.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9bfb238198ae1da40a943ff0f2726144 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 11400000 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /FiniteStateMachine/Builder/Base/FiniteStateMachineConnection.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo.FSM.Builder 2 | { 3 | [System.Serializable] 4 | public struct FiniteStateMachineConnectionToTransition { } 5 | 6 | [System.Serializable] 7 | public struct FiniteStateMachineConnectionToState { } 8 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/Common/Blackboard/WorldState.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace PlaniloSamples.Common 4 | { 5 | public struct WorldState 6 | { 7 | public Vector3 Home; 8 | public Resource[] Resources; 9 | public bool Alarm; 10 | } 11 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/Common/Interfaces/IBehaviourManager.cs: -------------------------------------------------------------------------------- 1 | namespace PlaniloSamples.Common 2 | { 3 | public interface IBehaviourManager 4 | { 5 | TBehaviourGraph BehaviourGraph { get; } 6 | 7 | TBehaviourState GetAgentState(int index); 8 | } 9 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Behaviours/GatherersFSMManager.cs: -------------------------------------------------------------------------------- 1 | using Planilo.FSM; 2 | using Planilo.FSM.Builder; 3 | using PlaniloSamples.Common; 4 | 5 | namespace PlaniloSamples.FSM 6 | { 7 | public class GatherersFSMManager : GatherersManager {} 8 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Behaviours/GathererFSMDebugger.cs: -------------------------------------------------------------------------------- 1 | using Planilo.FSM; 2 | using Planilo.FSM.Builder; 3 | using PlaniloSamples.Common; 4 | 5 | namespace PlaniloSamples.FSM 6 | { 7 | public class GathererFSMDebugger : BehaviourDebugger { } 8 | } -------------------------------------------------------------------------------- /Interfaces/IAIBehaviour.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f1c3386d7926a94b9205f01621148ec 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /BehaviourTree/Leaf/LeafNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4bd8c2a084702bc46a17900df059e04a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Interfaces/IAIBehaviourBuilder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce2dde0722302f54893f429df4dd1381 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /BehaviourTree/Base/BehaviourTree.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ed4ef1c7ca8b1b9499727d97824ea979 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /BehaviourTree/Base/BehaviourTreeNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ed661402bf26e884297ea39a1549bb56 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /BehaviourTree/Composite/Selector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 596b5901dd73ba24a80bf00d2d7d679a 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /BehaviourTree/Composite/Sequencer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3c774cf6087a6f345a39248ac49f1076 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /BehaviourTree/Base/BehaviourTreeNodeState.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c27662892fd0e7409c858e11519194b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /BehaviourTree/Base/BehaviourTreeState.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo.BT 2 | { 3 | public struct BehaviourTreeState 4 | { 5 | public BehaviourTreeNodeState[] NodeStates; 6 | 7 | public BehaviourTreeState(int size) 8 | { 9 | NodeStates = new BehaviourTreeNodeState[size]; 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /BehaviourTree/Builder/Leaf/LeafGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0447fb26f3311e148bbc9a8fadd07f19 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /BehaviourTree/Composite/CompositeNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a48c7243474fd945bf8bd5c6b518834 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /BehaviourTree/Builder/Base/BehaviourTreeGraph.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1180afa5dc987974da2f70507dec4e21 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /BehaviourTree/Builder/Base/BehaviourTreeGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 343969b3f6168744ea69d33fa7218c01 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /BehaviourTree/Builder/Composite/CompositeGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5acfda80b53d1a7489ee4eff926af855 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /BehaviourTree/Builder/Composite/SequencerGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 439a5b47165d47044a37321987f517d0 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/Common/Behaviours/Resource.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 30ebf5c271474270873684a51acbc282 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/Common/Blackboard/Gatherer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a8cf483067447aaaaaf34aa7b4cb96c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /BehaviourTree/Builder/Base/BehaviourTreeGraphConnection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1f7d32e8016e9a14d9c316f25477f41b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/Behaviours/GathererBTRunner.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b1b24e150d6d5874c9741ff78369f4ce 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Transitions/HasRestedTransitionGraphNode.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c056fe3e0de3b3e46a99d981231f2928 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Planilo.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Planilo", 3 | "references": ["XNode","XNodeEditor"], 4 | "optionalUnityReferences": [], 5 | "includePlatforms": [], 6 | "excludePlatforms": [], 7 | "allowUnsafeCode": false, 8 | "overrideReferences": false, 9 | "precompiledReferences": [], 10 | "autoReferenced": true, 11 | "defineConstraints": [], 12 | "versionDefines": [] 13 | } 14 | -------------------------------------------------------------------------------- /FiniteStateMachine/Base/FiniteStateMachineRuntimeState.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo.FSM 2 | { 3 | public struct FiniteStateMachineRuntimeState 4 | { 5 | public int CurrentState; 6 | public int LastState; 7 | 8 | public static FiniteStateMachineRuntimeState EntryState => new FiniteStateMachineRuntimeState 9 | { 10 | CurrentState = 0, 11 | LastState = -1 12 | }; 13 | } 14 | } -------------------------------------------------------------------------------- /BehaviourTree/Builder/Decorator/InverterGraphNode.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo.BT.Builder 2 | { 3 | [CreateNodeMenu("Planilo/BT/Decorator/Inverter")] 4 | public class InverterGraphNode : DecoratorGraphNode 5 | { 6 | #region Protected 7 | protected override DecoratorNode BuildNode(BehaviourTreeNode child, int index) 8 | { 9 | return new InverterNode(child, index); 10 | } 11 | #endregion 12 | } 13 | } -------------------------------------------------------------------------------- /BehaviourTree/Builder/Composite/SelectorGraphNode.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo.BT.Builder 2 | { 3 | [CreateNodeMenu("Planilo/BT/Composite/Selector")] 4 | public class SelectorGraphNode : CompositeGraphNode 5 | { 6 | #region Protected 7 | protected override CompositeNode BuildNode(BehaviourTreeNode[] children, int index) 8 | { 9 | return new Selector(children, index); 10 | } 11 | #endregion 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /BehaviourTree/Builder/Composite/SequencerGraphNode.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo.BT.Builder 2 | { 3 | [CreateNodeMenu("Planilo/BT/Composite/Sequencer")] 4 | public class SequencerGraphNode : CompositeGraphNode 5 | { 6 | #region Protected 7 | protected override CompositeNode BuildNode(BehaviourTreeNode[] children, int index) 8 | { 9 | return new Sequencer(children, index); 10 | } 11 | #endregion 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /BehaviourTree/Builder/Composite/ActiveSelectorGraphNode.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo.BT.Builder 2 | { 3 | [CreateNodeMenu("Planilo/BT/Composite/ActiveSelector")] 4 | public class ActiveSelectorGraphNode : CompositeGraphNode 5 | { 6 | #region Protected 7 | protected override CompositeNode BuildNode(BehaviourTreeNode[] children, int index) 8 | { 9 | return new ActiveSelector(children, index); 10 | } 11 | #endregion 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /FiniteStateMachine/Base/FiniteStateMachineState.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo.FSM 2 | { 3 | public abstract class FiniteStateMachineState 4 | { 5 | #region Public 6 | public virtual void OnEnter(ref T agent) {} 7 | 8 | public abstract void OnTick(ref T agent); 9 | 10 | public virtual void OnExit(ref T agent) {} 11 | #endregion 12 | 13 | #region Internal 14 | internal FiniteStateMachineTransition[] Transitions { get; set; } 15 | #endregion 16 | } 17 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/Common/Blackboard/Gatherer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace PlaniloSamples.Common 4 | { 5 | public struct Gatherer 6 | { 7 | public int Id; 8 | public Transform Transform; 9 | public Resource Resource; 10 | public Vector3 Target; 11 | public float Reach; 12 | public float Speed; 13 | 14 | public float LastRest; 15 | public float WorkTime; 16 | public float RestTime; 17 | 18 | public WorldState World; 19 | } 20 | } -------------------------------------------------------------------------------- /BehaviourTree/Composite/ActiveSelector.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo.BT 2 | { 3 | public class ActiveSelector : Selector 4 | { 5 | public ActiveSelector(BehaviourTreeNode[] children, int index) : base(children, index) {} 6 | 7 | public override BehaviourTreeResult Update(ref T agent, BehaviourTreeNodeState[] states) 8 | { 9 | states[nodeIndex].Enumerator.Reset(); 10 | states[nodeIndex].Enumerator.MoveNext(); 11 | return base.Update(ref agent, states); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.github.jlreymendez.planilo", 3 | "displayName": "Planilo", 4 | "description": "A set of Unity Editor tools for designing AI Graphs like Behavior Trees and Finite State Machines", 5 | "version": "0.2.0-preview.1", 6 | "keywords": 7 | [ 8 | "unity", 9 | "ai" 10 | ], 11 | "unity": "2019.1", 12 | "samples": 13 | [ 14 | { 15 | "displayName": "Gatherer", 16 | "description": "A set of gatherer AI samples using Behaviour Trees and Finite State Machines.", 17 | "path": "Samples~/Gatherer" 18 | } 19 | ] 20 | } 21 | -------------------------------------------------------------------------------- /FiniteStateMachine/Builder/Transition/AlwaysTransitionGraphNode.cs: -------------------------------------------------------------------------------- 1 | using XNode; 2 | 3 | namespace Planilo.FSM.Builder 4 | { 5 | [CreateNodeMenu("Planilo/FSM/Transitions/Always")] 6 | public class AlwaysTransitionGraphNode : FiniteStateMachineTransitionGraphNode 7 | { 8 | public override FiniteStateMachineTransition Build(int targetIndex) 9 | { 10 | return new FiniteStateMachineTransition() 11 | { 12 | Condition = (T agent) => true, 13 | TargetState = targetIndex 14 | }; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /FiniteStateMachine/Editor/FiniteStateMachineGraphNodeEditor.cs: -------------------------------------------------------------------------------- 1 | using Planilo.FSM.Builder; 2 | using UnityEditor; 3 | using UnityEngine; 4 | using XNodeEditor; 5 | 6 | namespace Planilo.FSM.Editor 7 | { 8 | [CustomNodeEditor(typeof(FiniteStateMachineTransitionGraphNode))] 9 | public class FiniteStateMachineGraphNodeEditor : NodeEditor 10 | { 11 | public override void OnHeaderGUI() 12 | { 13 | var name = target.name.Replace("Transition Graph", ""); 14 | GUILayout.Label(name, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30)); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /BehaviourTree/Editor/BehaviourTreeSubGraphNodeEditor.cs: -------------------------------------------------------------------------------- 1 | using Planilo.BT.Builder; 2 | using UnityEditor; 3 | using UnityEngine; 4 | using XNodeEditor; 5 | 6 | namespace Planilo.BT.Editor 7 | { 8 | [CustomNodeEditor(typeof(BehaviourTreeSubGraphNode))] 9 | public class BehaviourTreeSubGraphNodeEditor : BehaviourTreeGraphNodeEditor 10 | { 11 | public override void OnHeaderGUI() 12 | { 13 | var name = target.name.Replace("Behaviour Tree Sub Graph", "Sub Tree"); 14 | GUILayout.Label(name, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30)); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/States/WaitStateGraphNode.cs: -------------------------------------------------------------------------------- 1 | using Planilo.FSM; 2 | using Planilo.FSM.Builder; 3 | using PlaniloSamples.Common; 4 | 5 | namespace PlaniloSamples.FSM 6 | { 7 | public class WaitState : FiniteStateMachineState 8 | { 9 | public override void OnTick(ref Gatherer agent) {} 10 | } 11 | 12 | [CreateNodeMenu("PlaniloSamples/FSM/States/Wait")] 13 | public class WaitStateGraphNode : FiniteStateMachineStateGraphNode 14 | { 15 | protected override FiniteStateMachineState ProtectedBuild() 16 | { 17 | return new WaitState() as FiniteStateMachineState; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /BehaviourTree/Decorator/DecoratorNode.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo.BT 2 | { 3 | public abstract class DecoratorNode : BehaviourTreeNode 4 | { 5 | #region Constructor 6 | public DecoratorNode(BehaviourTreeNode child, int index) : base(index) 7 | { 8 | this.child = child; 9 | } 10 | #endregion 11 | 12 | #region Protected 13 | protected BehaviourTreeResult UpdateChild(ref T agent, BehaviourTreeNodeState[] states) 14 | { 15 | return child.Update(ref agent, states); 16 | } 17 | #endregion 18 | 19 | #region Private 20 | BehaviourTreeNode child; 21 | #endregion 22 | } 23 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/States/GoHomeStateGraphNode.cs: -------------------------------------------------------------------------------- 1 | using Planilo.FSM; 2 | using Planilo.FSM.Builder; 3 | using PlaniloSamples.Common; 4 | 5 | namespace PlaniloSamples.FSM 6 | { 7 | public class GoHomeState : MoveToTargetState 8 | { 9 | public override void OnEnter(ref Gatherer agent) 10 | { 11 | agent.Target = agent.World.Home; 12 | } 13 | } 14 | 15 | [CreateNodeMenu("PlaniloSamples/FSM/States/GoHome")] 16 | public class GoHomeStateGraphNode : FiniteStateMachineStateGraphNode 17 | { 18 | protected override FiniteStateMachineState ProtectedBuild() 19 | { 20 | return new GoHomeState() as FiniteStateMachineState; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /BehaviourTree/Composite/Selector.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo.BT 2 | { 3 | public class Selector : CompositeNode 4 | { 5 | #region Public 6 | public Selector(BehaviourTreeNode[] children, int index) : base(children, index) {} 7 | 8 | public override BehaviourTreeResult Update(ref T agent, BehaviourTreeNodeState[] states) 9 | { 10 | ref var state = ref states[nodeIndex]; 11 | while (Current(state) != null) 12 | { 13 | state.Result = Current(state).Run(ref agent, states); 14 | if (!state.IsFailure) { break; } 15 | NextChild(ref state); 16 | } 17 | 18 | return state.Result; 19 | } 20 | #endregion 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /BehaviourTree/Composite/Sequencer.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo.BT 2 | { 3 | public class Sequencer : CompositeNode 4 | { 5 | #region Public 6 | public Sequencer(BehaviourTreeNode[] children, int index) : base(children, index) {} 7 | 8 | public override BehaviourTreeResult Update(ref T agent, BehaviourTreeNodeState[] states) 9 | { 10 | ref var state = ref states[nodeIndex]; 11 | while (Current(state) != null) 12 | { 13 | state.Result = Current(state).Run(ref agent, states); 14 | if (!state.IsSuccess) { break; } 15 | NextChild(ref state); 16 | } 17 | 18 | return state.Result; 19 | } 20 | #endregion 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/Common/Behaviours/BehaviourDebugger.cs: -------------------------------------------------------------------------------- 1 | using Planilo; 2 | using UnityEngine; 3 | 4 | namespace PlaniloSamples.Common 5 | { 6 | public class BehaviourDebugger : MonoBehaviour, IAIBehaviourDebugger 7 | { 8 | #if UNITY_EDITOR 9 | public IBehaviourManager Manager { private get; set; } 10 | public int Index { private get; set; } 11 | 12 | public TBehaviourState GetState() 13 | { 14 | return Manager.GetAgentState(Index); 15 | } 16 | 17 | public TBehaviourGraph GetBehaviour() 18 | { 19 | return Manager.BehaviourGraph; 20 | } 21 | #endif 22 | 23 | } 24 | } -------------------------------------------------------------------------------- /FiniteStateMachine/Builder/Base/FiniteStateMachineTransitionGraphNode.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using XNode; 3 | 4 | namespace Planilo.FSM.Builder 5 | { 6 | [NodeTint("#6b532e")] 7 | public abstract class FiniteStateMachineTransitionGraphNode : FiniteStateMachineGraphNode 8 | { 9 | public abstract FiniteStateMachineTransition Build(int targetIndex); 10 | 11 | public FiniteStateMachineStateGraphNode GetTransitionState() 12 | { 13 | var port = GetOutputPort("target"); 14 | return (FiniteStateMachineStateGraphNode) port?.Connection?.node; 15 | } 16 | 17 | [SerializeField, Input] FiniteStateMachineConnectionToTransition source; 18 | [SerializeField, Output] FiniteStateMachineConnectionToState target; 19 | } 20 | } -------------------------------------------------------------------------------- /BehaviourTree/Base/BehaviourTree.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo.BT 2 | { 3 | public class BehaviourTree : IAIBehaviour 4 | { 5 | #region Public 6 | public BehaviourTree(BehaviourTreeNode root, int size) 7 | { 8 | this.root = root; 9 | this.size = size; 10 | } 11 | 12 | public BehaviourTreeState Initialize(ref T agent) 13 | { 14 | return new BehaviourTreeState(size); 15 | } 16 | 17 | public void Run(ref T agent, ref BehaviourTreeState state) 18 | { 19 | root.Run(ref agent, state.NodeStates); 20 | } 21 | #endregion 22 | 23 | #region Private 24 | BehaviourTreeNode root; 25 | int size; 26 | #endregion 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /BehaviourTree/Base/BehaviourTreeEnumerator.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | 4 | namespace Planilo.BT 5 | { 6 | public struct BehaviourTreeEnumerator : IEnumerator 7 | { 8 | int count; 9 | int index; 10 | 11 | public BehaviourTreeEnumerator(int count) 12 | { 13 | this.count = count; 14 | this.index = -1; 15 | } 16 | 17 | public bool MoveNext() 18 | { 19 | index++; 20 | return index < count; 21 | } 22 | 23 | public void Reset() 24 | { 25 | index = -1; 26 | } 27 | 28 | public int Current => index; 29 | 30 | object IEnumerator.Current => Current; 31 | 32 | public void Dispose() { } 33 | } 34 | } -------------------------------------------------------------------------------- /BehaviourTree/Builder/Decorator/ResultReplacerGraphNode.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo.BT.Builder 2 | { 3 | [CreateNodeMenu("Planilo/BT/Decorator/ResultReplacer")] 4 | public class ResultReplacerGraphNode : DecoratorGraphNode 5 | { 6 | #region Public 7 | 8 | public BehaviourTreeResult FromSuccess = BehaviourTreeResult.Success; 9 | public BehaviourTreeResult FromFailure = BehaviourTreeResult.Failure; 10 | public BehaviourTreeResult FromRunning = BehaviourTreeResult.Running; 11 | #endregion 12 | 13 | #region Protected 14 | protected override DecoratorNode BuildNode(BehaviourTreeNode child, int index) 15 | { 16 | return new ResultReplacerNode(child, index, FromSuccess, FromFailure, FromRunning); 17 | } 18 | #endregion 19 | } 20 | } -------------------------------------------------------------------------------- /BehaviourTree/Builder/Base/BehaviourTreeSubGraphNode.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Planilo.BT.Builder 4 | { 5 | [CreateNodeMenu("Planilo/BT/Subtree")] 6 | [NodeTint("#2e6b57")] 7 | public class BehaviourTreeSubGraphNode : BehaviourTreeGraphNode 8 | { 9 | #region Public 10 | public override int Size => subGraph.Root.Size; 11 | #endregion 12 | 13 | #region Protected 14 | protected override BehaviourTreeNode ProtectedBuild(ref int index) 15 | { 16 | #if UNITY_EDITOR 17 | subGraph.Root.BuildingGraph = BuildingGraph; 18 | #endif 19 | 20 | index--; 21 | return subGraph.Root.Build(ref index); 22 | } 23 | #endregion 24 | 25 | #region Private 26 | [SerializeField] BehaviourTreeGraph subGraph = default; 27 | #endregion 28 | } 29 | } -------------------------------------------------------------------------------- /BehaviourTree/Decorator/InverterNode.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo.BT 2 | { 3 | public class InverterNode : DecoratorNode 4 | { 5 | #region Constructor 6 | public InverterNode(BehaviourTreeNode child, int index) : base(child, index) { } 7 | #endregion 8 | 9 | #region Public 10 | public override BehaviourTreeResult Update(ref T agent, BehaviourTreeNodeState[] states) 11 | { 12 | ref var state = ref states[nodeIndex]; 13 | state.Result = UpdateChild(ref agent, states); 14 | 15 | if (state.IsFailure) 16 | { 17 | state.Result = BehaviourTreeResult.Success; 18 | } 19 | else if (state.IsSuccess) 20 | { 21 | state.Result = BehaviourTreeResult.Failure; 22 | } 23 | 24 | return state.Result; 25 | } 26 | #endregion 27 | } 28 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/States/MoveToTargetStateGraphNode.cs: -------------------------------------------------------------------------------- 1 | using Planilo.FSM; 2 | using Planilo.FSM.Builder; 3 | using PlaniloSamples.Common; 4 | using UnityEngine; 5 | 6 | namespace PlaniloSamples.FSM 7 | { 8 | public class MoveToTargetState : FiniteStateMachineState 9 | { 10 | public override void OnTick(ref Gatherer agent) 11 | { 12 | var direction = Vector3.Normalize(agent.Target - agent.Transform.position); 13 | agent.Transform.position += direction * (Time.deltaTime * agent.Speed); 14 | } 15 | } 16 | 17 | [CreateNodeMenu("PlaniloSamples/FSM/States/MoveToTarget")] 18 | public class MoveToTargetStateGraphNode : FiniteStateMachineStateGraphNode 19 | { 20 | protected override FiniteStateMachineState ProtectedBuild() 21 | { 22 | return new MoveToTargetState() as FiniteStateMachineState; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/States/ConsumeResourceStateGraphNode.cs: -------------------------------------------------------------------------------- 1 | using Planilo.FSM; 2 | using Planilo.FSM.Builder; 3 | using PlaniloSamples.Common; 4 | using UnityEngine; 5 | 6 | namespace PlaniloSamples.FSM 7 | { 8 | public class ConsumeResourceState : FiniteStateMachineState 9 | { 10 | public override void OnTick(ref Gatherer agent) 11 | { 12 | if (agent.Resource != null) 13 | { 14 | agent.Resource.Consume(); 15 | agent.Resource = null; 16 | } 17 | } 18 | } 19 | 20 | [CreateNodeMenu("PlaniloSamples/FSM/States/ConsumeResource")] 21 | public class ConsumeResourceStateGraphNode : FiniteStateMachineStateGraphNode 22 | { 23 | protected override FiniteStateMachineState ProtectedBuild() 24 | { 25 | return new ConsumeResourceState() as FiniteStateMachineState; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/States/PickResourceStateGraphNode.cs: -------------------------------------------------------------------------------- 1 | using Planilo.FSM; 2 | using Planilo.FSM.Builder; 3 | using PlaniloSamples.Common; 4 | using UnityEngine; 5 | 6 | namespace PlaniloSamples.FSM 7 | { 8 | public class PickResourceState : FiniteStateMachineState 9 | { 10 | public override void OnTick(ref Gatherer agent) 11 | { 12 | if (Vector3.Distance(agent.Transform.position, agent.Resource.transform.position) <= agent.Reach) 13 | { 14 | agent.Resource.Pick(); 15 | } 16 | } 17 | } 18 | 19 | [CreateNodeMenu("PlaniloSamples/FSM/States/PickResource")] 20 | public class PickResourceStateGraphNode : FiniteStateMachineStateGraphNode 21 | { 22 | protected override FiniteStateMachineState ProtectedBuild() 23 | { 24 | return new PickResourceState() as FiniteStateMachineState; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/States/RestStateGraphNode.cs: -------------------------------------------------------------------------------- 1 | using Planilo.FSM; 2 | using Planilo.FSM.Builder; 3 | using PlaniloSamples.Common; 4 | using UnityEngine; 5 | 6 | namespace PlaniloSamples.FSM 7 | { 8 | public class RestState : FiniteStateMachineState 9 | { 10 | public override void OnEnter(ref Gatherer agent) 11 | { 12 | agent.LastRest = Time.time; 13 | } 14 | 15 | public override void OnTick(ref Gatherer agent) {} 16 | 17 | public override void OnExit(ref Gatherer agent) 18 | { 19 | agent.LastRest = Time.time; 20 | } 21 | } 22 | 23 | [CreateNodeMenu("PlaniloSamples/FSM/States/Rest")] 24 | public class RestStateGraphNode : FiniteStateMachineStateGraphNode 25 | { 26 | protected override FiniteStateMachineState ProtectedBuild() 27 | { 28 | return new RestState() as FiniteStateMachineState; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /BehaviourTree/Editor/BehaviourTreeGraphEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Planilo.BT.Builder; 3 | using UnityEditor; 4 | using XNodeEditor; 5 | 6 | namespace Planilo.BT.Editor 7 | { 8 | [CustomNodeGraphEditor(typeof(BehaviourTreeGraph))] 9 | public class BehaviourTreeGraphEditor : NodeGraphEditor 10 | { 11 | public override string GetNodeMenuName(Type type) 12 | { 13 | if (typeof(BehaviourTreeGraphNode).IsAssignableFrom(type) == false) return null; 14 | return base.GetNodeMenuName(type).Replace("BT/", ""); 15 | } 16 | 17 | public override void OnGUI() 18 | { 19 | if (Selection.activeGameObject == null) return; 20 | var runner = Selection.activeGameObject.GetComponent>(); 21 | if (runner != null) 22 | { 23 | NodeEditorWindow.current.Repaint(); 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/LeafNodes/GoHomeGraphNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Planilo.BT; 3 | using Planilo.BT.Builder; 4 | using PlaniloSamples.Common; 5 | using UnityEngine; 6 | using XNode; 7 | 8 | namespace PlaniloSamples.BT 9 | { 10 | public class GoHomeNode : MoveToTargetNode 11 | { 12 | public GoHomeNode(int index) : base(index) {} 13 | 14 | public override void Initialize(ref Gatherer agent, BehaviourTreeNodeState[] states) 15 | { 16 | agent.Target = agent.World.Home; 17 | } 18 | } 19 | 20 | [Node.CreateNodeMenuAttribute("PlaniloSamples/Gatherer/GoHome")] 21 | public class GoHomeGraphNode : LeafGraphNode 22 | { 23 | #region Protected 24 | protected override Type AllowedType => typeof(Gatherer); 25 | 26 | protected override BehaviourTreeNode ProtectedBuild(ref int index) 27 | { 28 | return new GoHomeNode(index) as BehaviourTreeNode; 29 | } 30 | #endregion 31 | } 32 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Transitions/FoundResourceTransitionGraphNode.cs: -------------------------------------------------------------------------------- 1 | using Planilo.FSM; 2 | using Planilo.FSM.Builder; 3 | using PlaniloSamples.Common; 4 | using UnityEngine; 5 | 6 | namespace PlaniloSamples.FSM 7 | { 8 | public static class FoundResourceTransition 9 | { 10 | public static bool Condition(Gatherer agent) 11 | { 12 | return agent.Resource != null; 13 | } 14 | } 15 | 16 | [CreateNodeMenu("PlaniloSamples/FSM/Transitions/FoundResource")] 17 | public class FoundResourceTransitionGraphNode : FiniteStateMachineTransitionGraphNode 18 | { 19 | public override FiniteStateMachineTransition Build(int targetIndex) 20 | { 21 | var transition = new FiniteStateMachineTransition 22 | { 23 | Condition = FoundResourceTransition.Condition, 24 | TargetState = targetIndex 25 | }; 26 | return transition as FiniteStateMachineTransition; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Transitions/HasRestedTransitionGraphNode.cs: -------------------------------------------------------------------------------- 1 | using Planilo.FSM; 2 | using Planilo.FSM.Builder; 3 | using PlaniloSamples.Common; 4 | using UnityEngine; 5 | 6 | namespace PlaniloSamples.FSM 7 | { 8 | public static class HasRestedTransition 9 | { 10 | public static bool Condition(Gatherer agent) 11 | { 12 | return Time.time - agent.LastRest >= agent.RestTime; 13 | } 14 | } 15 | 16 | [CreateNodeMenu("PlaniloSamples/FSM/Transitions/HasRested")] 17 | public class HasRestedTransitionGraphNode : FiniteStateMachineTransitionGraphNode 18 | { 19 | public override FiniteStateMachineTransition Build(int targetIndex) 20 | { 21 | var transition = new FiniteStateMachineTransition 22 | { 23 | Condition = HasRestedTransition.Condition, 24 | TargetState = targetIndex 25 | }; 26 | return transition as FiniteStateMachineTransition; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Transitions/NeedsRestTransitionGraphNode.cs: -------------------------------------------------------------------------------- 1 | using Planilo.FSM; 2 | using Planilo.FSM.Builder; 3 | using PlaniloSamples.Common; 4 | using UnityEngine; 5 | 6 | namespace PlaniloSamples.FSM 7 | { 8 | public static class NeedsRestTransition 9 | { 10 | public static bool Condition(Gatherer agent) 11 | { 12 | return Time.time - agent.LastRest >= agent.WorkTime; 13 | } 14 | } 15 | 16 | [CreateNodeMenu("PlaniloSamples/FSM/Transitions/NeedsRest")] 17 | public class NeedsRestTransitionGraphNode : FiniteStateMachineTransitionGraphNode 18 | { 19 | public override FiniteStateMachineTransition Build(int targetIndex) 20 | { 21 | var transition = new FiniteStateMachineTransition 22 | { 23 | Condition = NeedsRestTransition.Condition, 24 | TargetState = targetIndex 25 | }; 26 | return transition as FiniteStateMachineTransition; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Transitions/ResourcePickedTransitionGraphNode.cs: -------------------------------------------------------------------------------- 1 | using Planilo.FSM; 2 | using Planilo.FSM.Builder; 3 | using PlaniloSamples.Common; 4 | using UnityEngine; 5 | 6 | namespace PlaniloSamples.FSM 7 | { 8 | public static class ResourcePickedTransition 9 | { 10 | public static bool Condition(Gatherer agent) 11 | { 12 | return agent.Resource != null && agent.Resource.CarrierId == agent.Id; 13 | } 14 | } 15 | 16 | [CreateNodeMenu("PlaniloSamples/FSM/Transitions/ResourcePicked")] 17 | public class ResourcePickedTransitionGraphNode : FiniteStateMachineTransitionGraphNode 18 | { 19 | public override FiniteStateMachineTransition Build(int targetIndex) 20 | { 21 | var transition = new FiniteStateMachineTransition 22 | { 23 | Condition = ResourcePickedTransition.Condition, 24 | TargetState = targetIndex 25 | }; 26 | return transition as FiniteStateMachineTransition; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Transitions/TargetReachedTransitionGraphNode.cs: -------------------------------------------------------------------------------- 1 | using Planilo.FSM; 2 | using Planilo.FSM.Builder; 3 | using PlaniloSamples.Common; 4 | using UnityEngine; 5 | 6 | namespace PlaniloSamples.FSM 7 | { 8 | public static class TargetReachedTransition 9 | { 10 | public static bool Condition(Gatherer agent) 11 | { 12 | return Vector3.Distance(agent.Target, agent.Transform.position) <= agent.Reach; 13 | } 14 | } 15 | 16 | [CreateNodeMenu("PlaniloSamples/FSM/Transitions/TargetReached")] 17 | public class TargetReachedTransitionGraphNode : FiniteStateMachineTransitionGraphNode 18 | { 19 | public override FiniteStateMachineTransition Build(int targetIndex) 20 | { 21 | var transition = new FiniteStateMachineTransition 22 | { 23 | Condition = TargetReachedTransition.Condition, 24 | TargetState = targetIndex 25 | }; 26 | return transition as FiniteStateMachineTransition; 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/States/DropResourceStateGraphNode.cs: -------------------------------------------------------------------------------- 1 | using Planilo.FSM; 2 | using Planilo.FSM.Builder; 3 | using PlaniloSamples.Common; 4 | 5 | namespace PlaniloSamples.FSM 6 | { 7 | public class DropResourceState : FiniteStateMachineState 8 | { 9 | public override void OnEnter(ref Gatherer agent) 10 | { 11 | if (agent.Resource != null && agent.Resource.CarrierId == agent.Id) 12 | { 13 | agent.Resource.Drop(agent.Transform.position); 14 | agent.Resource.CarrierId = 0; 15 | agent.Resource = null; 16 | } 17 | } 18 | 19 | public override void OnTick(ref Gatherer agent) { } 20 | } 21 | 22 | [CreateNodeMenu("PlaniloSamples/FSM/States/DropResource")] 23 | public class DropResourceStateGraphNode : FiniteStateMachineStateGraphNode 24 | { 25 | protected override FiniteStateMachineState ProtectedBuild() 26 | { 27 | return new DropResourceState() as FiniteStateMachineState; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/LeafNodes/CheckAlarmRaisedGraphNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Planilo.BT; 3 | using Planilo.BT.Builder; 4 | using PlaniloSamples.Common; 5 | using XNode; 6 | 7 | namespace PlaniloSamples.BT 8 | { 9 | public class CheckAlarmRaisedNode : LeafNode 10 | { 11 | public CheckAlarmRaisedNode(int index) : base(index) {} 12 | 13 | public override BehaviourTreeResult Update(ref Gatherer agent, BehaviourTreeNodeState[] states) 14 | { 15 | return agent.World.Alarm ? BehaviourTreeResult.Success : BehaviourTreeResult.Failure; 16 | } 17 | } 18 | 19 | [Node.CreateNodeMenuAttribute("PlaniloSamples/Gatherer/CheckAlarmRaised")] 20 | public class CheckAlarmRaisedGraphNode : LeafGraphNode 21 | { 22 | #region Protected 23 | protected override Type AllowedType => typeof(Gatherer); 24 | 25 | protected override BehaviourTreeNode ProtectedBuild(ref int index) 26 | { 27 | return new CheckAlarmRaisedNode(index) as BehaviourTreeNode; 28 | } 29 | #endregion 30 | } 31 | } -------------------------------------------------------------------------------- /License.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 jlreymendez 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /FiniteStateMachine/Editor/FiniteStateMachineGraphEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Planilo.FSM.Builder; 3 | using UnityEditor; 4 | using XNodeEditor; 5 | 6 | namespace Planilo.FSM.Editor 7 | { 8 | [CustomNodeGraphEditor(typeof(FiniteStateMachineGraph))] 9 | public class FiniteStateMachineGraphEditor : NodeGraphEditor 10 | { 11 | public override string GetNodeMenuName(Type type) 12 | { 13 | if (typeof(FiniteStateMachineStateGraphNode).IsAssignableFrom(type) == false && 14 | typeof(FiniteStateMachineTransitionGraphNode).IsAssignableFrom(type) == false) 15 | { 16 | return null; 17 | } 18 | return base.GetNodeMenuName(type).Replace("FSM/", ""); 19 | } 20 | 21 | public override void OnGUI() 22 | { 23 | if (Selection.activeGameObject == null) return; 24 | var runner = Selection.activeGameObject.GetComponent>(); 25 | if (runner != null) 26 | { 27 | NodeEditorWindow.current.Repaint(); 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/LeafNodes/CheckNeedsRestGraphNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Planilo.BT; 3 | using Planilo.BT.Builder; 4 | using PlaniloSamples.Common; 5 | using UnityEngine; 6 | using XNode; 7 | 8 | namespace PlaniloSamples.BT 9 | { 10 | public class CheckNeedsRestNode : LeafNode 11 | { 12 | public CheckNeedsRestNode(int index) : base(index) {} 13 | 14 | public override BehaviourTreeResult Update(ref Gatherer agent, BehaviourTreeNodeState[] states) 15 | { 16 | if (Time.time - agent.LastRest >= agent.WorkTime) 17 | { 18 | return BehaviourTreeResult.Success; 19 | } 20 | 21 | return BehaviourTreeResult.Failure; 22 | } 23 | } 24 | 25 | [Node.CreateNodeMenuAttribute("PlaniloSamples/Gatherer/CheckNeedsRest")] 26 | public class CheckNeedsRestGraphNode : LeafGraphNode 27 | { 28 | #region Protected 29 | protected override Type AllowedType => typeof(Gatherer); 30 | 31 | protected override BehaviourTreeNode ProtectedBuild(ref int index) 32 | { 33 | return new CheckNeedsRestNode(index) as BehaviourTreeNode; 34 | } 35 | #endregion 36 | } 37 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/Common/Behaviours/Resource.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace PlaniloSamples.Common 5 | { 6 | public class Resource : MonoBehaviour 7 | { 8 | public int CarrierId { get; set; } 9 | public event Action OnPicked; 10 | public event Action OnConsumed; 11 | bool picked; 12 | bool consumed; 13 | 14 | public bool Pick() 15 | { 16 | if (picked) return false; 17 | 18 | picked = true; 19 | gameObject.SetActive(false); 20 | OnPicked?.Invoke(this); 21 | return true; 22 | } 23 | 24 | public void Drop(Vector3 position) 25 | { 26 | if (picked == false) return; 27 | 28 | transform.position = position; 29 | gameObject.SetActive(true); 30 | } 31 | 32 | public void Consume() 33 | { 34 | if (consumed) return; 35 | 36 | consumed = true; 37 | OnConsumed?.Invoke(this); 38 | } 39 | 40 | void OnEnable() 41 | { 42 | picked = false; 43 | consumed = false; 44 | CarrierId = 0; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Transitions/ResourceUnavailableTransitionGraphNode.cs: -------------------------------------------------------------------------------- 1 | using Planilo.FSM; 2 | using Planilo.FSM.Builder; 3 | using PlaniloSamples.Common; 4 | using UnityEngine; 5 | 6 | namespace PlaniloSamples.FSM 7 | { 8 | public static class ResourceUnavailableTransition 9 | { 10 | public static bool Condition(Gatherer agent) 11 | { 12 | return agent.Resource == null || 13 | Vector3.Distance(agent.Transform.position, agent.Target) > agent.Reach || 14 | (agent.Resource.CarrierId != 0 && agent.Resource.CarrierId != agent.Id); 15 | } 16 | } 17 | 18 | [CreateNodeMenu("PlaniloSamples/FSM/Transitions/ResourceUnavailable")] 19 | public class ResourceUnavailableTransitionGraphNode : FiniteStateMachineTransitionGraphNode 20 | { 21 | public override FiniteStateMachineTransition Build(int targetIndex) 22 | { 23 | var transition = new FiniteStateMachineTransition 24 | { 25 | Condition = ResourceUnavailableTransition.Condition, 26 | TargetState = targetIndex 27 | }; 28 | return transition as FiniteStateMachineTransition; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/LeafNodes/DropResourceGraphNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Planilo.BT; 3 | using Planilo.BT.Builder; 4 | using PlaniloSamples.Common; 5 | 6 | namespace PlaniloSamples.BT 7 | { 8 | public class DropResourceNode : LeafNode 9 | { 10 | public DropResourceNode(int index) : base(index) { } 11 | 12 | public override BehaviourTreeResult Update(ref Gatherer agent, BehaviourTreeNodeState[] states) 13 | { 14 | if (agent.Resource != null && agent.Resource.CarrierId == agent.Id) 15 | { 16 | agent.Resource.Drop(agent.Transform.position); 17 | agent.Resource.CarrierId = 0; 18 | agent.Resource = null; 19 | } 20 | 21 | return BehaviourTreeResult.Success; 22 | } 23 | } 24 | 25 | [CreateNodeMenuAttribute("PlaniloSamples/Gatherer/DropResource")] 26 | public class DropResourceGraphNode : LeafGraphNode 27 | { 28 | #region Protected 29 | protected override Type AllowedType => typeof(Gatherer); 30 | 31 | protected override BehaviourTreeNode ProtectedBuild(ref int index) 32 | { 33 | return new DropResourceNode(index) as BehaviourTreeNode; 34 | } 35 | #endregion 36 | } 37 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Transitions/AlarmIsRaisedTransitionGraphNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Planilo.FSM; 3 | using Planilo.FSM.Builder; 4 | using PlaniloSamples.Common; 5 | 6 | namespace PlaniloSamples.FSM 7 | { 8 | public static class AlarmIsRaisedTransition 9 | { 10 | public static bool Condition(Gatherer agent) 11 | { 12 | return agent.World.Alarm; 13 | } 14 | 15 | public static bool InversedCondition(Gatherer agent) 16 | { 17 | return agent.World.Alarm == false; 18 | } 19 | } 20 | 21 | [CreateNodeMenu("PlaniloSamples/FSM/Transitions/AlarmIsRaised")] 22 | public class AlarmIsRaisedTransitionGraphNode : FiniteStateMachineTransitionGraphNode 23 | { 24 | public bool Inversed; 25 | 26 | public override FiniteStateMachineTransition Build(int targetIndex) 27 | { 28 | var transition = new FiniteStateMachineTransition 29 | { 30 | Condition = Inversed ? 31 | (Func)AlarmIsRaisedTransition.InversedCondition : AlarmIsRaisedTransition.Condition, 32 | TargetState = targetIndex 33 | }; 34 | return transition as FiniteStateMachineTransition; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /BehaviourTree/Composite/CompositeNode.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo.BT 2 | { 3 | public abstract class CompositeNode : BehaviourTreeNode 4 | { 5 | #region Constructor 6 | public CompositeNode(BehaviourTreeNode[] children, int index) : base(index) 7 | { 8 | this.children = children; 9 | } 10 | #endregion 11 | 12 | #region Public 13 | public override void Initialize(ref T agent, BehaviourTreeNodeState[] states) 14 | { 15 | ref var nodeState = ref states[nodeIndex]; 16 | nodeState.Enumerator = new BehaviourTreeEnumerator(children.Length); 17 | nodeState.Result = BehaviourTreeResult.Success; 18 | NextChild(ref nodeState); 19 | } 20 | #endregion 21 | 22 | #region Protected 23 | protected BehaviourTreeNode Current(BehaviourTreeNodeState nodeState) 24 | { 25 | return nodeState.Enumerator.Current < children.Length ? children[nodeState.Enumerator.Current] : null; 26 | } 27 | 28 | protected void NextChild(ref BehaviourTreeNodeState nodeState) 29 | { 30 | nodeState.Enumerator.MoveNext(); 31 | } 32 | #endregion 33 | 34 | #region Private 35 | BehaviourTreeNode[] children; 36 | #endregion 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /BehaviourTree/Decorator/ResultReplacerNode.cs: -------------------------------------------------------------------------------- 1 | namespace Planilo.BT 2 | { 3 | public class ResultReplacerNode : DecoratorNode 4 | { 5 | readonly BehaviourTreeResult fromSuccess; 6 | readonly BehaviourTreeResult fromFailure; 7 | readonly BehaviourTreeResult fromRunning; 8 | 9 | public ResultReplacerNode(BehaviourTreeNode child, int index, BehaviourTreeResult fromSuccess, BehaviourTreeResult fromFailure, BehaviourTreeResult fromRunning) : base(child, index) 10 | { 11 | this.fromSuccess = fromSuccess; 12 | this.fromFailure = fromFailure; 13 | this.fromRunning = fromRunning; 14 | } 15 | 16 | public override BehaviourTreeResult Update(ref T agent, BehaviourTreeNodeState[] states) 17 | { 18 | ref var state = ref states[nodeIndex]; 19 | state.Result = UpdateChild(ref agent, states); 20 | 21 | if (state.IsSuccess) 22 | { 23 | state.Result = fromSuccess; 24 | } 25 | else if (state.IsFailure) 26 | { 27 | state.Result = fromFailure; 28 | } 29 | else if (state.IsRunning) 30 | { 31 | state.Result = fromRunning; 32 | } 33 | 34 | return state.Result; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/LeafNodes/PickResourceGraphNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Planilo.BT; 3 | using Planilo.BT.Builder; 4 | using PlaniloSamples.Common; 5 | using UnityEngine; 6 | using XNode; 7 | 8 | namespace PlaniloSamples.BT 9 | { 10 | public class PickResourceNode : LeafNode 11 | { 12 | public PickResourceNode(int index) : base(index) {} 13 | 14 | public override BehaviourTreeResult Update(ref Gatherer agent, BehaviourTreeNodeState[] states) 15 | { 16 | if (!agent.Resource) return BehaviourTreeResult.Failure; 17 | 18 | var distance = Vector3.Distance(agent.Transform.position, agent.Resource.transform.position); 19 | if (distance > agent.Reach || agent.Resource.Pick() == false) return BehaviourTreeResult.Failure; 20 | 21 | return BehaviourTreeResult.Success; 22 | } 23 | } 24 | 25 | [Node.CreateNodeMenuAttribute("PlaniloSamples/Gatherer/PickResource")] 26 | public class PickResourceGraphNode : LeafGraphNode 27 | { 28 | #region Protected 29 | protected override Type AllowedType => typeof(Gatherer); 30 | 31 | protected override BehaviourTreeNode ProtectedBuild(ref int index) 32 | { 33 | return new PickResourceNode(index) as BehaviourTreeNode; 34 | } 35 | #endregion 36 | } 37 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/LeafNodes/ConsumeResourceGraphNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Planilo.BT; 3 | using Planilo.BT.Builder; 4 | using PlaniloSamples.Common; 5 | using UnityEngine; 6 | using XNode; 7 | 8 | namespace PlaniloSamples.BT 9 | { 10 | public class ConsumeResourceNode : LeafNode 11 | { 12 | public ConsumeResourceNode(int index) : base(index) {} 13 | 14 | public override BehaviourTreeResult Update(ref Gatherer agent, BehaviourTreeNodeState[] states) 15 | { 16 | if (agent.Resource == null) return BehaviourTreeResult.Failure; 17 | 18 | var distance = Vector3.Distance(agent.Transform.position, agent.World.Home); 19 | if (distance > agent.Reach) return BehaviourTreeResult.Failure; 20 | 21 | agent.Resource.Consume(); 22 | agent.Resource = null; 23 | 24 | return BehaviourTreeResult.Success; 25 | } 26 | } 27 | 28 | [Node.CreateNodeMenuAttribute("PlaniloSamples/Gatherer/ConsumeResource")] 29 | public class ConsumeResourceGraphNode : LeafGraphNode 30 | { 31 | #region Protected 32 | protected override Type AllowedType => typeof(Gatherer); 33 | 34 | protected override BehaviourTreeNode ProtectedBuild(ref int index) 35 | { 36 | return new ConsumeResourceNode(index) as BehaviourTreeNode; 37 | } 38 | #endregion 39 | } 40 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/LeafNodes/RestGraphNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Planilo.BT; 3 | using Planilo.BT.Builder; 4 | using PlaniloSamples.Common; 5 | using UnityEngine; 6 | using XNode; 7 | 8 | namespace PlaniloSamples.BT 9 | { 10 | public class RestNode : LeafNode 11 | { 12 | public RestNode(int index) : base(index) {} 13 | 14 | public override void Initialize(ref Gatherer agent, BehaviourTreeNodeState[] states) 15 | { 16 | agent.LastRest = Time.time; 17 | } 18 | 19 | public override BehaviourTreeResult Update(ref Gatherer agent, BehaviourTreeNodeState[] states) 20 | { 21 | return Time.time - agent.LastRest > agent.RestTime ? BehaviourTreeResult.Success : BehaviourTreeResult.Running; 22 | } 23 | 24 | public override void Finalize(ref Gatherer agent, BehaviourTreeNodeState[] states) 25 | { 26 | agent.LastRest = Time.time; 27 | } 28 | } 29 | 30 | [Node.CreateNodeMenuAttribute("PlaniloSamples/Gatherer/Rest")] 31 | public class RestGraphNode : LeafGraphNode 32 | { 33 | #region Protected 34 | protected override Type AllowedType => typeof(Gatherer); 35 | 36 | protected override BehaviourTreeNode ProtectedBuild(ref int index) 37 | { 38 | return new RestNode(index) as BehaviourTreeNode; 39 | } 40 | #endregion 41 | } 42 | } -------------------------------------------------------------------------------- /BehaviourTree/Base/BehaviourTreeNode.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Planilo.BT 4 | { 5 | public abstract class BehaviourTreeNode 6 | { 7 | #region Constructor 8 | public BehaviourTreeNode(int nodeIndex) 9 | { 10 | this.nodeIndex = nodeIndex; 11 | } 12 | #endregion 13 | 14 | #region Public 15 | public BehaviourTreeResult Run(ref T agent, BehaviourTreeNodeState[] states) 16 | { 17 | ref var state = ref states[nodeIndex]; 18 | state.LastUpdateTime = Time.time; 19 | if (state.IsRunning == false) { Initialize(ref agent, states); } 20 | state.Result = Update(ref agent, states); 21 | if (state.IsRunning == false) { Finalize(ref agent, states); } 22 | return state.Result; 23 | } 24 | 25 | public virtual void Initialize(ref T agent, BehaviourTreeNodeState[] states) {} 26 | 27 | public abstract BehaviourTreeResult Update(ref T agent, BehaviourTreeNodeState[] states); 28 | 29 | public virtual void Finalize(ref T agent, BehaviourTreeNodeState[] states) {} 30 | #endregion 31 | 32 | #region Protected 33 | protected int nodeIndex; 34 | #endregion 35 | 36 | #region Operators 37 | public static implicit operator bool(BehaviourTreeNode node) 38 | { 39 | return node != null; 40 | } 41 | #endregion 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/LeafNodes/MoveToTargetGraphNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Planilo.BT; 3 | using Planilo.BT.Builder; 4 | using PlaniloSamples.Common; 5 | using UnityEngine; 6 | using XNode; 7 | 8 | namespace PlaniloSamples.BT 9 | { 10 | public class MoveToTargetNode : LeafNode 11 | { 12 | public MoveToTargetNode(int index) : base(index) {} 13 | 14 | public override BehaviourTreeResult Update(ref Gatherer agent, BehaviourTreeNodeState[] states) 15 | { 16 | var position = agent.Transform.position; 17 | var distance = Vector3.Distance(position, agent.Target); 18 | if (distance <= agent.Reach) 19 | { 20 | return BehaviourTreeResult.Success; 21 | } 22 | 23 | var direction = Vector3.Normalize(agent.Target - position); 24 | agent.Transform.position += direction * (Time.deltaTime * agent.Speed); 25 | return BehaviourTreeResult.Running; 26 | } 27 | } 28 | 29 | [Node.CreateNodeMenuAttribute("PlaniloSamples/Gatherer/MoveToTarget")] 30 | public class MoveToTargetGraphNode : LeafGraphNode 31 | { 32 | #region Protected 33 | protected override Type AllowedType => typeof(Gatherer); 34 | 35 | protected override BehaviourTreeNode ProtectedBuild(ref int index) 36 | { 37 | return new MoveToTargetNode(index) as BehaviourTreeNode; 38 | } 39 | #endregion 40 | } 41 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/States/FindResourceStateGraphNode.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using Planilo.FSM; 3 | using Planilo.FSM.Builder; 4 | using PlaniloSamples.Common; 5 | using UnityEngine; 6 | 7 | namespace PlaniloSamples.FSM 8 | { 9 | public class FindResourceState : FiniteStateMachineState 10 | { 11 | public override void OnTick(ref Gatherer agent) 12 | { 13 | agent.Resource = null; 14 | 15 | var minDistance = float.MaxValue; 16 | foreach (var resource in agent.World.Resources) 17 | { 18 | var distance = Vector3.Distance(agent.Transform.position, resource.transform.position); 19 | if (resource.CarrierId == 0 && distance < minDistance) 20 | { 21 | minDistance = distance; 22 | agent.Resource = resource; 23 | agent.Target = resource.transform.position; 24 | } 25 | } 26 | 27 | if (agent.Resource != null) 28 | { 29 | agent.Resource.CarrierId = agent.Id; 30 | } 31 | } 32 | } 33 | 34 | [CreateNodeMenu("PlaniloSamples/FSM/States/FindResource")] 35 | public class FindResourceStateGraphNode : FiniteStateMachineStateGraphNode 36 | { 37 | protected override FiniteStateMachineState ProtectedBuild() 38 | { 39 | return new FindResourceState() as FiniteStateMachineState; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /BehaviourTree/Base/BehaviourTreeNodeState.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using UnityEngine; 3 | 4 | namespace Planilo.BT 5 | { 6 | public struct BehaviourTreeNodeState 7 | { 8 | #region Static 9 | public static BehaviourTreeNodeState Success 10 | { 11 | get => new BehaviourTreeNodeState(BehaviourTreeResult.Success); 12 | } 13 | 14 | public static BehaviourTreeNodeState Failure 15 | { 16 | get => new BehaviourTreeNodeState(BehaviourTreeResult.Failure); 17 | } 18 | 19 | public static BehaviourTreeNodeState Running 20 | { 21 | get => new BehaviourTreeNodeState(BehaviourTreeResult.Running); 22 | } 23 | #endregion 24 | 25 | #region Constructor 26 | public BehaviourTreeNodeState(BehaviourTreeResult result) 27 | { 28 | Result = result; 29 | LastUpdateTime = Time.time; 30 | Enumerator = default; 31 | } 32 | #endregion 33 | 34 | #region Public 35 | public bool IsSuccess { get => Result == BehaviourTreeResult.Success; } 36 | public bool IsFailure { get => Result == BehaviourTreeResult.Failure; } 37 | public bool IsRunning { get => Result == BehaviourTreeResult.Running; } 38 | 39 | public BehaviourTreeResult Result; 40 | public BehaviourTreeEnumerator Enumerator; 41 | public float LastUpdateTime; 42 | #endregion 43 | } 44 | 45 | public enum BehaviourTreeResult 46 | { 47 | Success, 48 | Failure, 49 | Running 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /FiniteStateMachine/Base/FiniteStateMachine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Planilo.FSM 4 | { 5 | public class FiniteStateMachine : IAIBehaviour 6 | { 7 | #region Public 8 | public FiniteStateMachine(FiniteStateMachineState[] states) 9 | { 10 | this.states = states; 11 | } 12 | 13 | public FiniteStateMachineRuntimeState Initialize(ref T agent) 14 | { 15 | return FiniteStateMachineRuntimeState.EntryState; 16 | } 17 | 18 | public void Run(ref T agent, ref FiniteStateMachineRuntimeState state) 19 | { 20 | var currentState = states[state.CurrentState]; 21 | if (state.CurrentState != state.LastState) 22 | { 23 | currentState.OnEnter(ref agent); 24 | state.LastState = state.CurrentState; 25 | } 26 | 27 | currentState.OnTick(ref agent); 28 | 29 | for (var i = 0; i < currentState.Transitions.Length; i++) 30 | { 31 | if (currentState.Transitions[i].Condition(agent)) 32 | { 33 | state.CurrentState = currentState.Transitions[i].TargetState; 34 | break; 35 | } 36 | } 37 | 38 | if (state.CurrentState != state.LastState) 39 | { 40 | currentState.OnExit(ref agent); 41 | } 42 | } 43 | #endregion 44 | 45 | #region Private 46 | FiniteStateMachineState[] states; 47 | #endregion 48 | } 49 | } -------------------------------------------------------------------------------- /BehaviourTree/Builder/Decorator/DecoratorGraphNode.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Planilo.BT.Builder 4 | { 5 | [NodeTint("#6b2e53")] 6 | public abstract class DecoratorGraphNode : BehaviourTreeGraphNode 7 | { 8 | #region Public 9 | public override int Size 10 | { 11 | get 12 | { 13 | var port = GetOutputPort(string.Format(ChildPortNameFormat)); 14 | var connectedNode = port.Connection.node as BehaviourTreeGraphNode; 15 | return connectedNode == null ? 1 : connectedNode.Size + 1; 16 | } 17 | } 18 | #endregion 19 | 20 | #region Protected 21 | protected override BehaviourTreeNode ProtectedBuild(ref int index) 22 | { 23 | var nodeIndex = index; 24 | var builtChild = BuildChild(ref index); 25 | return BuildNode(builtChild, nodeIndex); 26 | } 27 | 28 | protected BehaviourTreeNode BuildChild(ref int index) 29 | { 30 | var port = GetOutputPort(string.Format(ChildPortNameFormat)); 31 | var connectedNode = port.Connection.node as BehaviourTreeGraphNode; 32 | 33 | return connectedNode != null ? connectedNode.Build(ref index) : null; 34 | } 35 | 36 | protected abstract DecoratorNode BuildNode(BehaviourTreeNode child, int nodeIndex); 37 | #endregion 38 | 39 | #region Private 40 | [SerializeField, Output(dynamicPortList = false)] BehaviourTreeGraphConnection child; 41 | const string ChildPortNameFormat = "child"; 42 | #endregion 43 | } 44 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/LeafNodes/FindResourceGraphNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Planilo.BT; 3 | using Planilo.BT.Builder; 4 | using PlaniloSamples.Common; 5 | using UnityEngine; 6 | using XNode; 7 | 8 | namespace PlaniloSamples.BT 9 | { 10 | public class FindResourceNode : LeafNode 11 | { 12 | public FindResourceNode(int index) : base(index) {} 13 | 14 | public override BehaviourTreeResult Update(ref Gatherer agent, BehaviourTreeNodeState[] states) 15 | { 16 | agent.Resource = null; 17 | 18 | var minDistance = float.MaxValue; 19 | foreach (var resource in agent.World.Resources) 20 | { 21 | var distance = Vector3.Distance(agent.Transform.position, resource.transform.position); 22 | if (resource.CarrierId == 0 && distance < minDistance) 23 | { 24 | minDistance = distance; 25 | agent.Resource = resource; 26 | agent.Target = resource.transform.position; 27 | } 28 | } 29 | 30 | if (agent.Resource != null) 31 | { 32 | agent.Resource.CarrierId = agent.Id; 33 | return BehaviourTreeResult.Success; 34 | } 35 | 36 | return BehaviourTreeResult.Failure; 37 | } 38 | } 39 | 40 | [Node.CreateNodeMenuAttribute("PlaniloSamples/Gatherer/FindResource")] 41 | public class FindResourceGraphNode : LeafGraphNode 42 | { 43 | #region Protected 44 | protected override Type AllowedType => typeof(Gatherer); 45 | 46 | protected override BehaviourTreeNode ProtectedBuild(ref int index) 47 | { 48 | return new FindResourceNode(index) as BehaviourTreeNode; 49 | } 50 | #endregion 51 | } 52 | } -------------------------------------------------------------------------------- /BehaviourTree/Editor/BehaviourTreeGraphNodeEditor.cs: -------------------------------------------------------------------------------- 1 | using Planilo.BT.Builder; 2 | using UnityEditor; 3 | using UnityEngine; 4 | using XNodeEditor; 5 | 6 | namespace Planilo.BT.Editor 7 | { 8 | [CustomNodeEditor(typeof(BehaviourTreeGraphNode))] 9 | public class BehaviourTreeGraphNodeEditor : NodeEditor 10 | { 11 | Color rootColor = new Color(0.42f, 0.18f, 0.18f); 12 | Color inactiveColor = new Color(0.5f, 0.5f, 0.5f); 13 | Color runningColor = new Color(0.43f, 0.41f, 0.18f); 14 | 15 | public override void OnHeaderGUI() 16 | { 17 | var name = target.name.Replace(" Graph", ""); 18 | GUILayout.Label(name, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30)); 19 | } 20 | 21 | public override Color GetTint() 22 | { 23 | // Make sure node is connected. 24 | if (Selection.activeGameObject == null || Application.isPlaying == false) return GetEditorTint(); 25 | 26 | // Check if there is an active game object with a runner. 27 | var runner = Selection.activeGameObject.GetComponent>(); 28 | if (runner == null) return GetEditorTint(); 29 | 30 | // Check if it is running. 31 | var behaviourGraph = runner.GetBehaviour(); 32 | var runnerState = runner.GetState(); 33 | var node = target as BehaviourTreeGraphNode; 34 | if (behaviourGraph.TryGetNodeIndex(node.GetInstanceID(), out var nodeIndex)) 35 | { 36 | var state = runnerState.NodeStates[nodeIndex]; 37 | if (state.LastUpdateTime == Time.time) 38 | { 39 | return runningColor; 40 | } 41 | } 42 | 43 | return GetEditorTint(); 44 | } 45 | 46 | Color GetEditorTint() 47 | { 48 | var node = target as BehaviourTreeGraphNode; 49 | var hasParent = node.GetInputPort("parent").Connection != null; 50 | return node.IsRoot ? rootColor : hasParent ? base.GetTint() : base.GetTint() * inactiveColor; 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /BehaviourTree/Builder/Base/BehaviourTreeGraph.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using XNode; 5 | 6 | namespace Planilo.BT.Builder 7 | { 8 | [CreateAssetMenu(menuName = "Planilo/BT/Tree")] 9 | public class BehaviourTreeGraph : NodeGraph, IAIBehaviourBuilder 10 | { 11 | #region Public 12 | public IAIBehaviour Build() 13 | { 14 | #if UNITY_EDITOR 15 | root.BuildingGraph = this; 16 | #endif 17 | var startIndex = -1; 18 | var rootNode = root.Build(ref startIndex); 19 | 20 | return new BehaviourTree(rootNode, root.Size); 21 | } 22 | 23 | public void SetRoot(BehaviourTreeGraphNode node) 24 | { 25 | if (root) { root.IsRoot = false; } 26 | root = node; 27 | root.IsRoot = true; 28 | } 29 | 30 | public override Node AddNode(Type type) 31 | { 32 | // Only allow the right type of nodes. 33 | if (typeof(BehaviourTreeGraphNode).IsAssignableFrom(type) == false) 34 | { 35 | return null; 36 | } 37 | // Set first node as root by default 38 | var node = base.AddNode(type) as BehaviourTreeGraphNode; 39 | if (root == null) 40 | { 41 | SetRoot(node); 42 | } 43 | 44 | return node; 45 | } 46 | 47 | public BehaviourTreeGraphNode Root => root; 48 | #endregion 49 | 50 | #region Private 51 | [SerializeField] BehaviourTreeGraphNode root; 52 | #endregion 53 | 54 | #if UNITY_EDITOR 55 | #region Editor 56 | Dictionary nodeIdToIndexMap = new Dictionary(); 57 | 58 | public void SetNodeIndex(int nodeId, int index) 59 | { 60 | nodeIdToIndexMap[nodeId] = index; 61 | } 62 | 63 | public bool TryGetNodeIndex(int nodeId, out int index) 64 | { 65 | return nodeIdToIndexMap.TryGetValue(nodeId, out index); 66 | } 67 | #endregion 68 | #endif 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/BT/Behaviours/GathererBTRunner.cs: -------------------------------------------------------------------------------- 1 | using Planilo; 2 | using Planilo.BT; 3 | using Planilo.BT.Builder; 4 | using PlaniloSamples.Common; 5 | using UnityEngine; 6 | 7 | namespace PlaniloSamples.BT 8 | { 9 | public class GathererBTRunner : MonoBehaviour, 10 | // note: This is only required for debugging the tree inside the planilo graph tool 11 | IAIBehaviourDebugger 12 | { 13 | [Header("General")] 14 | public BehaviourTreeGraph BehaviourDefinition; 15 | 16 | [Header("Sample 01")] 17 | public float Speed; 18 | public float Reach; 19 | 20 | [Header("Sample 02")] 21 | public float WorkTime; 22 | public float RestTime; 23 | 24 | Gatherer agent = default; 25 | BehaviourTreeState behaviourTreeState = default; 26 | IAIBehaviour behaviourTree = default; 27 | 28 | void Awake() 29 | { 30 | behaviourTree = BehaviourDefinition.Build(); 31 | behaviourTreeState = behaviourTree.Initialize(ref agent); 32 | } 33 | 34 | void Start() 35 | { 36 | agent.Id = GetInstanceID(); 37 | agent.World.Home = FindObjectOfType().transform.position; 38 | agent.Speed = Speed; 39 | agent.Reach = Reach; 40 | agent.Transform = transform; 41 | agent.LastRest = Time.time; 42 | agent.WorkTime = WorkTime; 43 | agent.RestTime = RestTime; 44 | } 45 | 46 | void Update() 47 | { 48 | // Update all agent sensors 49 | agent.World.Resources = FindObjectsOfType(); 50 | // Execute behaviour tree. 51 | behaviourTree.Run(ref agent, ref behaviourTreeState); 52 | } 53 | 54 | #if UNITY_EDITOR 55 | #region Editor 56 | public BehaviourTreeState GetState() 57 | { 58 | return behaviourTreeState; 59 | } 60 | 61 | public BehaviourTreeGraph GetBehaviour() 62 | { 63 | return BehaviourDefinition; 64 | } 65 | #endregion 66 | #endif 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/Common/Home.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: Home 11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 1, g: 1, b: 1, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | m_BuildTextureStacks: [] 79 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/Common/Resource.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: Resource 11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 0.75, g: 0.65, b: 0.25, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | m_BuildTextureStacks: [] 79 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/Common/Gatherer.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: Gatherer 11 | m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 0.8018868, g: 0.23073156, b: 0.23073156, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | m_BuildTextureStacks: [] 79 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/FSM/Behaviours/GathererFSMRunner.cs: -------------------------------------------------------------------------------- 1 | using Planilo; 2 | using Planilo.FSM; 3 | using Planilo.FSM.Builder; 4 | using PlaniloSamples.Common; 5 | using UnityEngine; 6 | 7 | namespace PlaniloSamples.FSM 8 | { 9 | public class GathererFSMRunner : MonoBehaviour, 10 | // Note: this is only required for debugging the agent in the planilo graph tool 11 | IAIBehaviourDebugger 12 | { 13 | [Header("General")] 14 | public FiniteStateMachineGraph BehaviourDefinition; 15 | 16 | [Header("Sample 01")] 17 | public float Speed; 18 | public float Reach; 19 | 20 | [Header("Sample 02")] 21 | public float WorkTime; 22 | public float RestTime; 23 | 24 | Gatherer agent = default; 25 | FiniteStateMachineRuntimeState fsmRuntimeState = default; 26 | IAIBehaviour fsm = default; 27 | 28 | void Awake() 29 | { 30 | // We need to create an FSM based on the graph definition. And initialize the state for the agent. 31 | fsm = BehaviourDefinition.Build(); 32 | fsmRuntimeState = fsm.Initialize(ref agent); 33 | } 34 | 35 | void Start() 36 | { 37 | // Initialize agent on start once all required objects have initialized. 38 | agent.Id = GetInstanceID(); 39 | agent.World.Home = FindObjectOfType().transform.position; 40 | agent.Speed = Speed; 41 | agent.Reach = Reach; 42 | agent.Transform = transform; 43 | agent.LastRest = Time.time; 44 | agent.WorkTime = WorkTime; 45 | agent.RestTime = RestTime; 46 | } 47 | void Update() 48 | { 49 | // Update agent sensors. 50 | agent.World.Resources = FindObjectsOfType(); 51 | // Execute finite state machine. 52 | // Every update we pass by reference the agent and the last state. 53 | fsm.Run(ref agent, ref fsmRuntimeState); 54 | } 55 | 56 | #if UNITY_EDITOR 57 | #region Editor 58 | public FiniteStateMachineRuntimeState GetState() 59 | { 60 | return fsmRuntimeState; 61 | } 62 | 63 | public FiniteStateMachineGraph GetBehaviour() 64 | { 65 | return BehaviourDefinition; 66 | } 67 | #endregion 68 | #endif 69 | } 70 | } -------------------------------------------------------------------------------- /BehaviourTree/Builder/Base/BehaviourTreeGraphNode.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using XNode; 3 | using UnityEngine; 4 | 5 | namespace Planilo.BT.Builder 6 | { 7 | public abstract class BehaviourTreeGraphNode : Node 8 | { 9 | #region Public 10 | public bool IsRoot 11 | { 12 | get => isRoot; 13 | set => isRoot = value; 14 | } 15 | 16 | public BehaviourTreeNode Build(ref int index) 17 | { 18 | if (AllowedType == null || AllowedType.IsAssignableFrom(typeof(T))) 19 | { 20 | #if UNITY_EDITOR 21 | SetNodeIndexInBuildingGraph(index + 1); 22 | #endif 23 | 24 | index++; 25 | return ProtectedBuild(ref index); 26 | } 27 | 28 | return null; 29 | } 30 | 31 | [ContextMenu("Set as root")] 32 | public void SetAsRoot() 33 | { 34 | BehaviourTreeGraph btGraph = graph as BehaviourTreeGraph; 35 | btGraph.SetRoot(this); 36 | 37 | NodePort port = GetInputPort("parent"); 38 | port.Disconnect(port.Connection); 39 | } 40 | 41 | public virtual int Size => 1; 42 | 43 | public override object GetValue(NodePort port) 44 | { 45 | return null; 46 | } 47 | #endregion 48 | 49 | #region Protected 50 | 51 | protected virtual string NiceName => ""; 52 | 53 | protected virtual Type AllowedType => null; 54 | 55 | protected abstract BehaviourTreeNode ProtectedBuild(ref int index); 56 | 57 | protected override void Init() 58 | { 59 | name = string.IsNullOrEmpty(NiceName) ? name : NiceName; 60 | } 61 | #endregion 62 | 63 | #region Private 64 | [SerializeField, HideInInspector] bool isRoot; 65 | [SerializeField, Input] BehaviourTreeGraphConnection parent; 66 | #endregion 67 | 68 | #if UNITY_EDITOR 69 | #region Editor 70 | public BehaviourTreeGraph BuildingGraph { get; set; } 71 | 72 | void SetNodeIndexInBuildingGraph(int index) 73 | { 74 | if (IsRoot == false) 75 | { 76 | var parentNode = GetInputPort("parent").Connection.node as BehaviourTreeGraphNode; 77 | BuildingGraph = parentNode.BuildingGraph; 78 | } 79 | 80 | BuildingGraph.SetNodeIndex(GetInstanceID(), index); 81 | } 82 | #endregion 83 | #endif 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /FiniteStateMachine/Builder/Base/FiniteStateMachineGraph.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using XNode; 5 | 6 | namespace Planilo.FSM.Builder 7 | { 8 | [CreateAssetMenu(menuName = "Planilo/FSM")] 9 | public class FiniteStateMachineGraph : NodeGraph, IAIBehaviourBuilder 10 | { 11 | #region Public 12 | public IAIBehaviour Build() 13 | { 14 | var nextIndex = 0; 15 | var states = new List>(); 16 | var nodeIdToStateIndexMap = new Dictionary(); 17 | entryState.Build(ref nextIndex, states, nodeIdToStateIndexMap); 18 | 19 | #if UNITY_EDITOR 20 | nodeIdToIndexMap = nodeIdToStateIndexMap; 21 | #endif 22 | 23 | return new FiniteStateMachine(states.ToArray()); 24 | } 25 | 26 | public override Node AddNode(Type type) 27 | { 28 | // Only allow the right type of nodes. 29 | if (typeof(FiniteStateMachineStateGraphNode).IsAssignableFrom(type) == false && 30 | typeof(FiniteStateMachineTransitionGraphNode).IsAssignableFrom(type) == false) 31 | { 32 | return null; 33 | } 34 | // Set first node as root by default 35 | var node = base.AddNode(type); 36 | var stateNode = node as FiniteStateMachineStateGraphNode; 37 | if (stateNode != null && entryState == null) 38 | { 39 | SetEntryNode(stateNode); 40 | } 41 | 42 | return node; 43 | } 44 | #endregion 45 | 46 | #region Internal 47 | internal FiniteStateMachineStateGraphNode EntryState => entryState; 48 | 49 | internal void SetEntryNode(FiniteStateMachineStateGraphNode node) 50 | { 51 | if (entryState != null) 52 | { 53 | entryState.IsEntry = false; 54 | } 55 | entryState = node; 56 | entryState.IsEntry = true; 57 | } 58 | #endregion 59 | 60 | #region Private 61 | [SerializeField] FiniteStateMachineStateGraphNode entryState; 62 | #endregion 63 | 64 | #if UNITY_EDITOR 65 | #region Editor 66 | 67 | Dictionary nodeIdToIndexMap = new Dictionary(); 68 | 69 | internal bool TryGetNodeIndex(int nodeId, out int index) 70 | { 71 | return nodeIdToIndexMap.TryGetValue(nodeId, out index); 72 | } 73 | #endregion 74 | #endif 75 | } 76 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/Common/Behaviours/SampleController.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using Random = UnityEngine.Random; 5 | 6 | namespace PlaniloSamples.Common 7 | { 8 | public class SampleController : MonoBehaviour 9 | { 10 | public GameObject homePrefab; 11 | public Resource resourcePrefab; 12 | public GameObject agentPrefab; 13 | 14 | public int agentsCount; 15 | public int maxResourceCount; 16 | public float resourceProductionRate = 0.8f; 17 | 18 | List resources; 19 | List recycledResources; 20 | 21 | void Awake() 22 | { 23 | Instantiate(homePrefab); 24 | SpawnAgents(); 25 | StartCoroutine(SpawnResources()); 26 | } 27 | 28 | void SpawnAgents() 29 | { 30 | for (var i = 0; i < agentsCount; i++) 31 | { 32 | var rotation = Quaternion.Euler(0, 0, Random.Range(0f, 360f)); 33 | var position = new Vector3(Random.Range(0f, 0.3f), 0, 0); 34 | Instantiate(agentPrefab, rotation * position, Quaternion.identity); 35 | } 36 | } 37 | 38 | IEnumerator SpawnResources() 39 | { 40 | recycledResources = new List(); 41 | for (var i = 0; i < maxResourceCount; i++) 42 | { 43 | var resource = Instantiate(resourcePrefab); 44 | resource.OnPicked += Resource_OnPick; 45 | resource.OnConsumed += Resource_OnConsume; 46 | resource.gameObject.SetActive(false); 47 | recycledResources.Add(resource); 48 | } 49 | 50 | while (true) 51 | { 52 | if (recycledResources.Count > 0) 53 | { 54 | var rotation = Quaternion.Euler(0, 0, Random.Range(0f, 360f)); 55 | var position = new Vector3(Random.Range(0.5f, 1f), 0, 0); 56 | var resource = recycledResources[0]; 57 | resource.transform.position = rotation * position; 58 | resource.gameObject.SetActive(true); 59 | recycledResources.RemoveAt(0); 60 | } 61 | yield return new WaitForSeconds(Random.Range(resourceProductionRate * 0.5f, resourceProductionRate)); 62 | } 63 | } 64 | 65 | void Resource_OnPick(Resource resource) 66 | { 67 | } 68 | 69 | void Resource_OnConsume(Resource resource) 70 | { 71 | recycledResources.Add(resource); 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /BehaviourTree/Builder/Composite/CompositeGraphNode.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections.Generic; 3 | 4 | namespace Planilo.BT.Builder 5 | { 6 | [NodeTint("#2e4e6b")] 7 | public abstract class CompositeGraphNode : BehaviourTreeGraphNode 8 | { 9 | #region Public 10 | public override int Size 11 | { 12 | get 13 | { 14 | var size = 0; 15 | for (var i = 0; i < childrenCount; i++) 16 | { 17 | var port = GetOutputPort(string.Format(ChildrenPortNameFormat, i)); 18 | var connectedNode = port.Connection.node as BehaviourTreeGraphNode; 19 | if (connectedNode == null) continue; 20 | size += connectedNode.Size; 21 | } 22 | 23 | return size + 1; 24 | } 25 | } 26 | #endregion 27 | 28 | #region Protected 29 | 30 | protected override void Init() 31 | { 32 | base.Init(); 33 | // Calculate children count. 34 | // note: it appears that xNode doesn't populate the children list on init. 35 | // Which results in children.Count being 0. 36 | childrenCount = 0; 37 | while (true) 38 | { 39 | var port = GetOutputPort(string.Format(ChildrenPortNameFormat, childrenCount)); 40 | if (port == null) break; 41 | childrenCount++; 42 | } 43 | } 44 | 45 | protected override BehaviourTreeNode ProtectedBuild(ref int index) 46 | { 47 | var nodeIndex = index; 48 | var builtChildren = BuildChildren(ref index); 49 | return BuildNode(builtChildren, nodeIndex); 50 | } 51 | 52 | protected BehaviourTreeNode[] BuildChildren(ref int index) 53 | { 54 | var childrenNodes = new BehaviourTreeNode[childrenCount]; 55 | for (var i = 0; i < childrenCount; i++) 56 | { 57 | var port = GetOutputPort(string.Format(ChildrenPortNameFormat, i)); 58 | var connectedNode = port.Connection.node as BehaviourTreeGraphNode; 59 | if (connectedNode != null) 60 | { 61 | childrenNodes[i] = connectedNode.Build(ref index); 62 | } 63 | } 64 | 65 | return childrenNodes; 66 | } 67 | 68 | protected abstract CompositeNode BuildNode(BehaviourTreeNode[] children, int index); 69 | #endregion 70 | 71 | #region Private 72 | [SerializeField, Output(dynamicPortList = true)] List children; 73 | int childrenCount; 74 | 75 | const string ChildrenPortNameFormat = "children {0}"; 76 | #endregion 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /FiniteStateMachine/Editor/FiniteStateMachineStateGraphNodeEditor.cs: -------------------------------------------------------------------------------- 1 | using Planilo.FSM.Builder; 2 | using UnityEditor; 3 | using UnityEngine; 4 | using XNodeEditor; 5 | 6 | namespace Planilo.FSM.Editor 7 | { 8 | [CustomNodeEditor(typeof(FiniteStateMachineStateGraphNode))] 9 | public class FiniteStateMachineStateGraphNodeEditor : NodeEditor 10 | { 11 | Color entryColor = new Color(0.18f, 0.42f, 0.22f); 12 | Color entryExitColor = new Color(0.3f, 0.3f, 0.22f); 13 | Color exitColor = new Color(0.42f, 0.18f, 0.22f); 14 | Color inactiveColor = new Color(0.5f, 0.5f, 0.5f); 15 | Color runningColor = new Color(0.43f, 0.41f, 0.18f); 16 | 17 | public override void OnHeaderGUI() 18 | { 19 | var stateNode = target as FiniteStateMachineStateGraphNode; 20 | var name = stateNode.name.Replace(" State Graph", ""); 21 | name = string.Format("{0}{1}{2}", stateNode.IsEntry ? "→ " : "", name, stateNode.IsExit ? " →" : ""); 22 | GUILayout.Label(name, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30)); 23 | } 24 | 25 | public override Color GetTint() 26 | { 27 | // Make sure node is connected. 28 | if (Selection.activeGameObject == null || Application.isPlaying == false) return GetEditorTint(); 29 | 30 | // Check if there is an active game object with a runner. 31 | var runner = Selection.activeGameObject.GetComponent>(); 32 | if (runner == null) return GetEditorTint(); 33 | 34 | // Check if it is running. 35 | var behaviourGraph = runner.GetBehaviour(); 36 | var runnerState = runner.GetState(); 37 | var node = target as FiniteStateMachineStateGraphNode; 38 | if (behaviourGraph.TryGetNodeIndex(node.GetInstanceID(), out var nodeIndex)) 39 | { 40 | if (runnerState.CurrentState == nodeIndex) 41 | { 42 | return runningColor; 43 | } 44 | } 45 | 46 | return GetEditorTint(); 47 | } 48 | 49 | protected Color GetRunningColor() 50 | { 51 | return runningColor; 52 | } 53 | 54 | protected Color GetEditorTint() 55 | { 56 | var node = target as FiniteStateMachineStateGraphNode; 57 | var isDisconnected = node.GetInputPort("entry").Connection == null; 58 | 59 | if (node.IsEntry && node.IsExit) 60 | { 61 | return entryExitColor; 62 | } 63 | if (node.IsEntry) 64 | { 65 | return entryColor; 66 | } 67 | if (node.IsExit) 68 | { 69 | return exitColor; 70 | } 71 | if (isDisconnected) 72 | { 73 | return base.GetTint() * inactiveColor; 74 | } 75 | 76 | return base.GetTint(); 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![planilo](https://user-images.githubusercontent.com/1077394/91163953-be4d8d80-e6a4-11ea-9f86-127a6374235d.png) 2 | 3 | A set of tools for designing AI in a visual node editor on unity. Use for: 4 | * Behavior Trees. 5 | * Finite State Machines. 6 | * Implement your own AI graphs. 7 | 8 | ## Key features 9 | * A visual editor for Behavior Trees, Finite State Machines and the basis to create other types of AI tools. 10 | * AI graphs implemented as reusable scriptable objects, same instance can be run by multiple GameObjects. 11 | * Share data between the Scene an your Behavior Tree using Blackboard variables. 12 | * Ready implemented examples to use as guidance. 13 | * See highlighted nodes in runtime to understand how your AI graphs are running. 14 | * Modularize your AI graphs and execute them as part of nodes of other AI graphs. 15 | * See more in [documentation](https://github.com/jlreymendez/planilo/wiki) 16 | 17 | ## Road to v0.2.0 18 | As I'm not actively using planilo on any project I have stopped development of planilo for the time being. 19 | I have merged the development branch to master, hoping to encourage people to stop using v0.1.0 which in my opinion has major design flaws. 20 | The only thing that's stopping the release of v0.2.0 is that the samples have bugs coming from either Unity's Assets v2 or xNode. 21 | This was the last thing to convince me that if I ever continue developing this tool I will need to drop xNode to gain control over important parts 22 | of the tool. 23 | 24 | ### What is changing? 25 | * **Separation of concerns.** Using xNode as a serialization and behaviour builder tool only. Making no assumptions of how runtime execution should be. 26 | * Interface blackboards for behaviours instead of dictionaries. 27 | * Behaviour tree overhaul with new composite nodes Active Selector and Active Sequencer. 28 | 29 | ## Things left to investigate 30 | * Jobified versions of the AI behaviour. 31 | * Utility based Behaviour Tree. 32 | 33 | ## v0.1.0 34 | The initial release of planilo had some design flaws which would cause: 35 | * Bugs difficult to track. 36 | * Less control over the flow execution for the user. 37 | * Performance hits due to allocations while using dictionaries for the blackboard variables. 38 | 39 | If you still want to have access to planilo v0.1.0 you can find it in the releases page [v0.1.0](https://github.com/jlreymendez/planilo/releases/tag/untagged-e47bab49a17a75565867) 40 | 41 | ## Installing with Unity Package Manager 42 | *(Requires Unity version 2019.1 or above)* 43 | 44 | To install this project as a [Git dependency](https://docs.unity3d.com/Manual/upm-git.html) using the Unity Package Manager, 45 | add the following line to your project's `manifest.json`: 46 | 47 | ``` 48 | "com.github.jlreymendez.planilo": "https://github.com/jlreymendez/planilo.git" 49 | ``` 50 | NOTE: This will also install the dependencies xNode under the Planilo path. 51 | 52 | You will need to have Git installed and available in your system's PATH. 53 | 54 | ## Acknowledgements: 55 | * [xNode by Siccity](https://github.com/Siccity/xNode) 56 | * [Game-icons.net and Delapouite](https://game-icons.net/1x1/delapouite/choice.html) 57 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/Common/Home.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &8978833225110489825 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 8978833225110489826} 12 | - component: {fileID: 8978833225110489827} 13 | - component: {fileID: 8978833225110489824} 14 | - component: {fileID: 4187142808589720587} 15 | m_Layer: 0 16 | m_Name: Home 17 | m_TagString: Untagged 18 | m_Icon: {fileID: 0} 19 | m_NavMeshLayer: 0 20 | m_StaticEditorFlags: 0 21 | m_IsActive: 1 22 | --- !u!4 &8978833225110489826 23 | Transform: 24 | m_ObjectHideFlags: 0 25 | m_CorrespondingSourceObject: {fileID: 0} 26 | m_PrefabInstance: {fileID: 0} 27 | m_PrefabAsset: {fileID: 0} 28 | m_GameObject: {fileID: 8978833225110489825} 29 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 30 | m_LocalPosition: {x: 0, y: 0, z: 0} 31 | m_LocalScale: {x: 0.2, y: 0.2, z: 0.01} 32 | m_Children: [] 33 | m_Father: {fileID: 0} 34 | m_RootOrder: 0 35 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 36 | --- !u!33 &8978833225110489827 37 | MeshFilter: 38 | m_ObjectHideFlags: 0 39 | m_CorrespondingSourceObject: {fileID: 0} 40 | m_PrefabInstance: {fileID: 0} 41 | m_PrefabAsset: {fileID: 0} 42 | m_GameObject: {fileID: 8978833225110489825} 43 | m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} 44 | --- !u!23 &8978833225110489824 45 | MeshRenderer: 46 | m_ObjectHideFlags: 0 47 | m_CorrespondingSourceObject: {fileID: 0} 48 | m_PrefabInstance: {fileID: 0} 49 | m_PrefabAsset: {fileID: 0} 50 | m_GameObject: {fileID: 8978833225110489825} 51 | m_Enabled: 1 52 | m_CastShadows: 1 53 | m_ReceiveShadows: 1 54 | m_DynamicOccludee: 1 55 | m_MotionVectors: 1 56 | m_LightProbeUsage: 1 57 | m_ReflectionProbeUsage: 1 58 | m_RayTracingMode: 2 59 | m_RayTraceProcedural: 0 60 | m_RenderingLayerMask: 1 61 | m_RendererPriority: 0 62 | m_Materials: 63 | - {fileID: 2100000, guid: 05927f2e62dc77a4494a7bed5d0b8866, type: 2} 64 | m_StaticBatchInfo: 65 | firstSubMesh: 0 66 | subMeshCount: 0 67 | m_StaticBatchRoot: {fileID: 0} 68 | m_ProbeAnchor: {fileID: 0} 69 | m_LightProbeVolumeOverride: {fileID: 0} 70 | m_ScaleInLightmap: 1 71 | m_ReceiveGI: 1 72 | m_PreserveUVs: 0 73 | m_IgnoreNormalsForChartDetection: 0 74 | m_ImportantGI: 0 75 | m_StitchLightmapSeams: 1 76 | m_SelectedEditorRenderState: 3 77 | m_MinimumChartSize: 4 78 | m_AutoUVMaxDistance: 0.5 79 | m_AutoUVMaxAngle: 89 80 | m_LightmapParameters: {fileID: 0} 81 | m_SortingLayerID: 0 82 | m_SortingLayer: 0 83 | m_SortingOrder: 0 84 | m_AdditionalVertexStreams: {fileID: 0} 85 | --- !u!114 &4187142808589720587 86 | MonoBehaviour: 87 | m_ObjectHideFlags: 0 88 | m_CorrespondingSourceObject: {fileID: 0} 89 | m_PrefabInstance: {fileID: 0} 90 | m_PrefabAsset: {fileID: 0} 91 | m_GameObject: {fileID: 8978833225110489825} 92 | m_Enabled: 1 93 | m_EditorHideFlags: 0 94 | m_Script: {fileID: 11500000, guid: 9e5615bec2c34559835bd071d3bb48c2, type: 3} 95 | m_Name: 96 | m_EditorClassIdentifier: 97 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/Common/Resource.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &6113266835351547083 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 6113266835351547095} 12 | - component: {fileID: 6113266835351547080} 13 | - component: {fileID: 6113266835351547081} 14 | - component: {fileID: -261033501117576378} 15 | m_Layer: 0 16 | m_Name: Resource 17 | m_TagString: Untagged 18 | m_Icon: {fileID: 0} 19 | m_NavMeshLayer: 0 20 | m_StaticEditorFlags: 0 21 | m_IsActive: 1 22 | --- !u!4 &6113266835351547095 23 | Transform: 24 | m_ObjectHideFlags: 0 25 | m_CorrespondingSourceObject: {fileID: 0} 26 | m_PrefabInstance: {fileID: 0} 27 | m_PrefabAsset: {fileID: 0} 28 | m_GameObject: {fileID: 6113266835351547083} 29 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 30 | m_LocalPosition: {x: 0, y: 0, z: 0} 31 | m_LocalScale: {x: 0.05, y: 0.05, z: 0.02} 32 | m_Children: [] 33 | m_Father: {fileID: 0} 34 | m_RootOrder: 0 35 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 36 | --- !u!33 &6113266835351547080 37 | MeshFilter: 38 | m_ObjectHideFlags: 0 39 | m_CorrespondingSourceObject: {fileID: 0} 40 | m_PrefabInstance: {fileID: 0} 41 | m_PrefabAsset: {fileID: 0} 42 | m_GameObject: {fileID: 6113266835351547083} 43 | m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} 44 | --- !u!23 &6113266835351547081 45 | MeshRenderer: 46 | m_ObjectHideFlags: 0 47 | m_CorrespondingSourceObject: {fileID: 0} 48 | m_PrefabInstance: {fileID: 0} 49 | m_PrefabAsset: {fileID: 0} 50 | m_GameObject: {fileID: 6113266835351547083} 51 | m_Enabled: 1 52 | m_CastShadows: 1 53 | m_ReceiveShadows: 1 54 | m_DynamicOccludee: 1 55 | m_MotionVectors: 1 56 | m_LightProbeUsage: 1 57 | m_ReflectionProbeUsage: 1 58 | m_RayTracingMode: 2 59 | m_RayTraceProcedural: 0 60 | m_RenderingLayerMask: 1 61 | m_RendererPriority: 0 62 | m_Materials: 63 | - {fileID: 2100000, guid: 33c0852471331d9449a8296af5dcc9c0, type: 2} 64 | m_StaticBatchInfo: 65 | firstSubMesh: 0 66 | subMeshCount: 0 67 | m_StaticBatchRoot: {fileID: 0} 68 | m_ProbeAnchor: {fileID: 0} 69 | m_LightProbeVolumeOverride: {fileID: 0} 70 | m_ScaleInLightmap: 1 71 | m_ReceiveGI: 1 72 | m_PreserveUVs: 0 73 | m_IgnoreNormalsForChartDetection: 0 74 | m_ImportantGI: 0 75 | m_StitchLightmapSeams: 1 76 | m_SelectedEditorRenderState: 3 77 | m_MinimumChartSize: 4 78 | m_AutoUVMaxDistance: 0.5 79 | m_AutoUVMaxAngle: 89 80 | m_LightmapParameters: {fileID: 0} 81 | m_SortingLayerID: 0 82 | m_SortingLayer: 0 83 | m_SortingOrder: 0 84 | m_AdditionalVertexStreams: {fileID: 0} 85 | --- !u!114 &-261033501117576378 86 | MonoBehaviour: 87 | m_ObjectHideFlags: 0 88 | m_CorrespondingSourceObject: {fileID: 0} 89 | m_PrefabInstance: {fileID: 0} 90 | m_PrefabAsset: {fileID: 0} 91 | m_GameObject: {fileID: 6113266835351547083} 92 | m_Enabled: 1 93 | m_EditorHideFlags: 0 94 | m_Script: {fileID: 11500000, guid: 30ebf5c271474270873684a51acbc282, type: 3} 95 | m_Name: 96 | m_EditorClassIdentifier: 97 | -------------------------------------------------------------------------------- /FiniteStateMachine/Builder/Base/FiniteStateMachineSubGraphNode.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | 4 | namespace Planilo.FSM.Builder 5 | { 6 | [CreateNodeMenu("Planilo/FSM/States/SubGraphState")] 7 | [NodeWidth(300)] 8 | public sealed class FiniteStateMachineSubGraphNode : FiniteStateMachineStateGraphNode 9 | { 10 | #region Internal 11 | internal override void Build(ref int nextIndex, List> states, Dictionary idToIndexMap) 12 | { 13 | // Check and register index. 14 | var instanceId = GetInstanceID(); 15 | if (idToIndexMap.ContainsKey(instanceId)) return; 16 | idToIndexMap[instanceId] = nextIndex; 17 | 18 | // Create subgraph. 19 | subGraph.EntryState.Build(ref nextIndex, states, idToIndexMap); 20 | 21 | var exitStates = GetExitStates(states, idToIndexMap, exitType); 22 | 23 | foreach (var exitState in exitStates) 24 | { 25 | // Prepend parent graph transitions to node transition. 26 | var transitions = new List>(BuildTransitions(ref nextIndex, states, idToIndexMap)); 27 | transitions.AddRange(exitState.Transitions); 28 | exitState.Transitions = transitions.ToArray(); 29 | } 30 | } 31 | 32 | internal FiniteStateMachineState[] GetExitStates(List> states, Dictionary idToIndexMap, FiniteStateMachineGraphExitType withExitType) 33 | { 34 | var exitStates = new List>(); 35 | foreach (var node in subGraph.nodes) 36 | { 37 | var stateNode = node as FiniteStateMachineStateGraphNode; 38 | if (stateNode == null) continue; 39 | 40 | if (idToIndexMap.ContainsKey(node.GetInstanceID()) == false) continue; 41 | if (withExitType == FiniteStateMachineGraphExitType.ExitOnly && stateNode.IsExit == false) continue; 42 | 43 | var subGraphNode = stateNode as FiniteStateMachineSubGraphNode; 44 | if (subGraphNode != null) 45 | { 46 | exitStates.AddRange(subGraphNode.GetExitStates(states, idToIndexMap, withExitType)); 47 | } 48 | else 49 | { 50 | var stateIndex = idToIndexMap[node.GetInstanceID()]; 51 | exitStates.Add(states[stateIndex]); 52 | } 53 | } 54 | 55 | return exitStates.ToArray(); 56 | } 57 | 58 | public FiniteStateMachineGraph SubGraph => subGraph; 59 | #endregion 60 | 61 | #region Protected 62 | protected override FiniteStateMachineState ProtectedBuild() => null; 63 | #endregion 64 | 65 | #region Private 66 | [SerializeField] FiniteStateMachineGraph subGraph = default; 67 | [SerializeField] FiniteStateMachineGraphExitType exitType = default; 68 | #endregion 69 | } 70 | 71 | public enum FiniteStateMachineGraphExitType 72 | { 73 | All, 74 | ExitOnly 75 | } 76 | } -------------------------------------------------------------------------------- /FiniteStateMachine/Editor/FiniteStateMachineSubGraphNodeEditor.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Planilo.FSM.Builder; 3 | using UnityEditor; 4 | using UnityEngine; 5 | using XNodeEditor; 6 | 7 | namespace Planilo.FSM.Editor 8 | { 9 | [CustomNodeEditor(typeof(FiniteStateMachineSubGraphNode))] 10 | public class FiniteStateMachineSubGraphNodeEditor : FiniteStateMachineStateGraphNodeEditor 11 | { 12 | public override void OnHeaderGUI() 13 | { 14 | var stateNode = target as FiniteStateMachineSubGraphNode; 15 | var name = target.name.Replace("Finite State Machine Sub Graph", "Sub Graph State"); 16 | name = string.Format("{0}{1}{2}", stateNode.IsEntry ? "→ " : "", name, stateNode.IsExit ? " →" : ""); 17 | GUILayout.Label(name, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30)); 18 | } 19 | 20 | public override Color GetTint() 21 | { 22 | // Make sure node is connected. 23 | if (Selection.activeGameObject == null || Application.isPlaying == false) return GetEditorTint(); 24 | 25 | // Check if there is an active game object with a runner. 26 | var runner = Selection.activeGameObject.GetComponent>(); 27 | if (runner == null) return GetEditorTint(); 28 | 29 | // Check if it is running. 30 | var behaviourGraph = runner.GetBehaviour(); 31 | var runnerState = runner.GetState(); 32 | if (IsSubGraphRunning(target as FiniteStateMachineSubGraphNode, behaviourGraph, runnerState, new List())) 33 | { 34 | return GetRunningColor(); 35 | } 36 | 37 | return GetEditorTint(); 38 | } 39 | 40 | bool IsStateRunning(FiniteStateMachineStateGraphNode stateNode, FiniteStateMachineGraph behaviourGraph, FiniteStateMachineRuntimeState state) 41 | { 42 | if (behaviourGraph.TryGetNodeIndex(stateNode.GetInstanceID(), out var nodeIndex)) 43 | { 44 | if (state.CurrentState == nodeIndex) 45 | { 46 | return true; 47 | } 48 | } 49 | 50 | return false; 51 | } 52 | 53 | bool IsSubGraphRunning(FiniteStateMachineSubGraphNode subGraphNode, FiniteStateMachineGraph behaviourGraph, FiniteStateMachineRuntimeState state, List checkedSubgraphs) 54 | { 55 | checkedSubgraphs.Add(subGraphNode.GetInstanceID()); 56 | var subGraph = subGraphNode.SubGraph; 57 | foreach (var node in subGraph.nodes) 58 | { 59 | var running = false; 60 | // If node is another subgraph execute recursively but prevent infinite cycles. 61 | if (node is FiniteStateMachineSubGraphNode && checkedSubgraphs.Contains(node.GetInstanceID()) == false) 62 | { 63 | running = IsSubGraphRunning(node as FiniteStateMachineSubGraphNode, behaviourGraph, state, checkedSubgraphs); 64 | } 65 | else if (node is FiniteStateMachineStateGraphNode) 66 | { 67 | running = IsStateRunning(node as FiniteStateMachineStateGraphNode, behaviourGraph, state); 68 | } 69 | 70 | if (running) return true; 71 | } 72 | 73 | return false; 74 | } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /FiniteStateMachine/Builder/Base/FiniteStateMachineStateGraphNode.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | using XNode; 4 | 5 | namespace Planilo.FSM.Builder 6 | { 7 | [NodeTint("#2e506b")] 8 | public abstract class FiniteStateMachineStateGraphNode : FiniteStateMachineGraphNode 9 | { 10 | #region Internal 11 | internal bool IsEntry 12 | { 13 | get => isEntry; 14 | set => isEntry = value; 15 | } 16 | 17 | internal bool IsExit => isExit; 18 | 19 | [ContextMenu("Set as entry state")] 20 | internal void SetAsEntry() 21 | { 22 | var fsmGraph = graph as FiniteStateMachineGraph; 23 | fsmGraph.SetEntryNode(this); 24 | } 25 | 26 | [ContextMenu("Toggle exit state")] 27 | internal void SetAsExit() 28 | { 29 | isExit = !isExit; 30 | } 31 | 32 | internal virtual void Build(ref int nextIndex, List> states, Dictionary idToIndexMap) 33 | { 34 | // Register index. 35 | var instanceId = GetInstanceID(); 36 | if (idToIndexMap.ContainsKey(instanceId)) return; 37 | 38 | idToIndexMap[instanceId] = nextIndex; 39 | nextIndex++; 40 | 41 | var state = ProtectedBuild(); 42 | states.Add(state); 43 | state.Transitions = BuildTransitions(ref nextIndex, states, idToIndexMap); 44 | } 45 | #endregion 46 | 47 | #region Protected 48 | protected override void Init() 49 | { 50 | base.Init(); 51 | // Calculate children count. 52 | // note: it appears that xNode doesn't populate the children list on init. 53 | // Which results in children.Count being 0. 54 | transitionsCount = 0; 55 | while (true) 56 | { 57 | var transition = GetTransitionNode(transitionsCount); 58 | if (transition == null) break; 59 | transitionsCount++; 60 | } 61 | } 62 | 63 | protected virtual FiniteStateMachineTransition[] BuildTransitions(ref int nextIndex, List> states, Dictionary idToIndexMap) 64 | { 65 | // Build transitions. 66 | var transitionList = new List>(); 67 | for (var i = 0; i < transitionsCount; i++) 68 | { 69 | var transition = GetTransitionNode(i); 70 | var targetState = transition.GetTransitionState(); 71 | if (targetState == null) continue; 72 | 73 | if (idToIndexMap.TryGetValue(targetState.GetInstanceID(), out var targetIndex) == false) 74 | { 75 | targetIndex = nextIndex; 76 | targetState.Build(ref nextIndex, states, idToIndexMap); 77 | } 78 | 79 | transitionList.Add(transition.Build(targetIndex)); 80 | } 81 | 82 | return transitionList.ToArray(); 83 | } 84 | 85 | protected FiniteStateMachineTransitionGraphNode GetTransitionNode(int index) 86 | { 87 | var port = GetOutputPort(string.Format(TransitionKeyFormat, index)); 88 | return (FiniteStateMachineTransitionGraphNode) port?.Connection?.node; 89 | } 90 | 91 | protected abstract FiniteStateMachineState ProtectedBuild(); 92 | #endregion 93 | 94 | #region Private 95 | [SerializeField, Input] FiniteStateMachineConnectionToState entry; 96 | [SerializeField, Output(dynamicPortList = true)] List transitions; 97 | [HideInInspector, SerializeField] bool isEntry; 98 | [HideInInspector, SerializeField] bool isExit; 99 | int transitionsCount; 100 | 101 | const string TransitionKeyFormat = "transitions {0}"; 102 | #endregion 103 | } 104 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT/Sample03/GathererBT-03.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &1166321500944852649 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 3389551673463484162} 12 | - component: {fileID: 4036792051990113276} 13 | - component: {fileID: 4418647757956906798} 14 | m_Layer: 0 15 | m_Name: Capsule 16 | m_TagString: Untagged 17 | m_Icon: {fileID: 0} 18 | m_NavMeshLayer: 0 19 | m_StaticEditorFlags: 0 20 | m_IsActive: 1 21 | --- !u!4 &3389551673463484162 22 | Transform: 23 | m_ObjectHideFlags: 0 24 | m_CorrespondingSourceObject: {fileID: 0} 25 | m_PrefabInstance: {fileID: 0} 26 | m_PrefabAsset: {fileID: 0} 27 | m_GameObject: {fileID: 1166321500944852649} 28 | m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068} 29 | m_LocalPosition: {x: 0, y: 0, z: 0} 30 | m_LocalScale: {x: 0.05, y: 0.02, z: 0.05} 31 | m_Children: [] 32 | m_Father: {fileID: 7325841998788872598} 33 | m_RootOrder: 0 34 | m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} 35 | --- !u!33 &4036792051990113276 36 | MeshFilter: 37 | m_ObjectHideFlags: 0 38 | m_CorrespondingSourceObject: {fileID: 0} 39 | m_PrefabInstance: {fileID: 0} 40 | m_PrefabAsset: {fileID: 0} 41 | m_GameObject: {fileID: 1166321500944852649} 42 | m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0} 43 | --- !u!23 &4418647757956906798 44 | MeshRenderer: 45 | m_ObjectHideFlags: 0 46 | m_CorrespondingSourceObject: {fileID: 0} 47 | m_PrefabInstance: {fileID: 0} 48 | m_PrefabAsset: {fileID: 0} 49 | m_GameObject: {fileID: 1166321500944852649} 50 | m_Enabled: 1 51 | m_CastShadows: 1 52 | m_ReceiveShadows: 1 53 | m_DynamicOccludee: 1 54 | m_MotionVectors: 1 55 | m_LightProbeUsage: 1 56 | m_ReflectionProbeUsage: 1 57 | m_RayTracingMode: 2 58 | m_RayTraceProcedural: 0 59 | m_RenderingLayerMask: 1 60 | m_RendererPriority: 0 61 | m_Materials: 62 | - {fileID: 2100000, guid: d4e355b1fbfd80340832d1c819625f12, type: 2} 63 | m_StaticBatchInfo: 64 | firstSubMesh: 0 65 | subMeshCount: 0 66 | m_StaticBatchRoot: {fileID: 0} 67 | m_ProbeAnchor: {fileID: 0} 68 | m_LightProbeVolumeOverride: {fileID: 0} 69 | m_ScaleInLightmap: 1 70 | m_ReceiveGI: 1 71 | m_PreserveUVs: 0 72 | m_IgnoreNormalsForChartDetection: 0 73 | m_ImportantGI: 0 74 | m_StitchLightmapSeams: 1 75 | m_SelectedEditorRenderState: 3 76 | m_MinimumChartSize: 4 77 | m_AutoUVMaxDistance: 0.5 78 | m_AutoUVMaxAngle: 89 79 | m_LightmapParameters: {fileID: 0} 80 | m_SortingLayerID: 0 81 | m_SortingLayer: 0 82 | m_SortingOrder: 0 83 | m_AdditionalVertexStreams: {fileID: 0} 84 | --- !u!1 &7325841998788872592 85 | GameObject: 86 | m_ObjectHideFlags: 0 87 | m_CorrespondingSourceObject: {fileID: 0} 88 | m_PrefabInstance: {fileID: 0} 89 | m_PrefabAsset: {fileID: 0} 90 | serializedVersion: 6 91 | m_Component: 92 | - component: {fileID: 7325841998788872598} 93 | - component: {fileID: 633421382752347569} 94 | m_Layer: 0 95 | m_Name: GathererBT-03 96 | m_TagString: Untagged 97 | m_Icon: {fileID: 0} 98 | m_NavMeshLayer: 0 99 | m_StaticEditorFlags: 0 100 | m_IsActive: 1 101 | --- !u!4 &7325841998788872598 102 | Transform: 103 | m_ObjectHideFlags: 0 104 | m_CorrespondingSourceObject: {fileID: 0} 105 | m_PrefabInstance: {fileID: 0} 106 | m_PrefabAsset: {fileID: 0} 107 | m_GameObject: {fileID: 7325841998788872592} 108 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 109 | m_LocalPosition: {x: 0, y: 0, z: 0} 110 | m_LocalScale: {x: 1, y: 1, z: 1} 111 | m_Children: 112 | - {fileID: 3389551673463484162} 113 | m_Father: {fileID: 0} 114 | m_RootOrder: 0 115 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 116 | --- !u!114 &633421382752347569 117 | MonoBehaviour: 118 | m_ObjectHideFlags: 0 119 | m_CorrespondingSourceObject: {fileID: 0} 120 | m_PrefabInstance: {fileID: 0} 121 | m_PrefabAsset: {fileID: 0} 122 | m_GameObject: {fileID: 7325841998788872592} 123 | m_Enabled: 1 124 | m_EditorHideFlags: 0 125 | m_Script: {fileID: 11500000, guid: 027e1eeb965c47308c0eb9a7f463d140, type: 3} 126 | m_Name: 127 | m_EditorClassIdentifier: 128 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT/Sample04/GathererBT-03.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &1166321500944852649 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 3389551673463484162} 12 | - component: {fileID: 4036792051990113276} 13 | - component: {fileID: 4418647757956906798} 14 | m_Layer: 0 15 | m_Name: Capsule 16 | m_TagString: Untagged 17 | m_Icon: {fileID: 0} 18 | m_NavMeshLayer: 0 19 | m_StaticEditorFlags: 0 20 | m_IsActive: 1 21 | --- !u!4 &3389551673463484162 22 | Transform: 23 | m_ObjectHideFlags: 0 24 | m_CorrespondingSourceObject: {fileID: 0} 25 | m_PrefabInstance: {fileID: 0} 26 | m_PrefabAsset: {fileID: 0} 27 | m_GameObject: {fileID: 1166321500944852649} 28 | m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068} 29 | m_LocalPosition: {x: 0, y: 0, z: 0} 30 | m_LocalScale: {x: 0.05, y: 0.02, z: 0.05} 31 | m_Children: [] 32 | m_Father: {fileID: 7325841998788872598} 33 | m_RootOrder: 0 34 | m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} 35 | --- !u!33 &4036792051990113276 36 | MeshFilter: 37 | m_ObjectHideFlags: 0 38 | m_CorrespondingSourceObject: {fileID: 0} 39 | m_PrefabInstance: {fileID: 0} 40 | m_PrefabAsset: {fileID: 0} 41 | m_GameObject: {fileID: 1166321500944852649} 42 | m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0} 43 | --- !u!23 &4418647757956906798 44 | MeshRenderer: 45 | m_ObjectHideFlags: 0 46 | m_CorrespondingSourceObject: {fileID: 0} 47 | m_PrefabInstance: {fileID: 0} 48 | m_PrefabAsset: {fileID: 0} 49 | m_GameObject: {fileID: 1166321500944852649} 50 | m_Enabled: 1 51 | m_CastShadows: 1 52 | m_ReceiveShadows: 1 53 | m_DynamicOccludee: 1 54 | m_MotionVectors: 1 55 | m_LightProbeUsage: 1 56 | m_ReflectionProbeUsage: 1 57 | m_RayTracingMode: 2 58 | m_RayTraceProcedural: 0 59 | m_RenderingLayerMask: 1 60 | m_RendererPriority: 0 61 | m_Materials: 62 | - {fileID: 2100000, guid: d4e355b1fbfd80340832d1c819625f12, type: 2} 63 | m_StaticBatchInfo: 64 | firstSubMesh: 0 65 | subMeshCount: 0 66 | m_StaticBatchRoot: {fileID: 0} 67 | m_ProbeAnchor: {fileID: 0} 68 | m_LightProbeVolumeOverride: {fileID: 0} 69 | m_ScaleInLightmap: 1 70 | m_ReceiveGI: 1 71 | m_PreserveUVs: 0 72 | m_IgnoreNormalsForChartDetection: 0 73 | m_ImportantGI: 0 74 | m_StitchLightmapSeams: 1 75 | m_SelectedEditorRenderState: 3 76 | m_MinimumChartSize: 4 77 | m_AutoUVMaxDistance: 0.5 78 | m_AutoUVMaxAngle: 89 79 | m_LightmapParameters: {fileID: 0} 80 | m_SortingLayerID: 0 81 | m_SortingLayer: 0 82 | m_SortingOrder: 0 83 | m_AdditionalVertexStreams: {fileID: 0} 84 | --- !u!1 &7325841998788872592 85 | GameObject: 86 | m_ObjectHideFlags: 0 87 | m_CorrespondingSourceObject: {fileID: 0} 88 | m_PrefabInstance: {fileID: 0} 89 | m_PrefabAsset: {fileID: 0} 90 | serializedVersion: 6 91 | m_Component: 92 | - component: {fileID: 7325841998788872598} 93 | - component: {fileID: 633421382752347569} 94 | m_Layer: 0 95 | m_Name: GathererBT-03 96 | m_TagString: Untagged 97 | m_Icon: {fileID: 0} 98 | m_NavMeshLayer: 0 99 | m_StaticEditorFlags: 0 100 | m_IsActive: 1 101 | --- !u!4 &7325841998788872598 102 | Transform: 103 | m_ObjectHideFlags: 0 104 | m_CorrespondingSourceObject: {fileID: 0} 105 | m_PrefabInstance: {fileID: 0} 106 | m_PrefabAsset: {fileID: 0} 107 | m_GameObject: {fileID: 7325841998788872592} 108 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 109 | m_LocalPosition: {x: 0, y: 0, z: 0} 110 | m_LocalScale: {x: 1, y: 1, z: 1} 111 | m_Children: 112 | - {fileID: 3389551673463484162} 113 | m_Father: {fileID: 0} 114 | m_RootOrder: 0 115 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 116 | --- !u!114 &633421382752347569 117 | MonoBehaviour: 118 | m_ObjectHideFlags: 0 119 | m_CorrespondingSourceObject: {fileID: 0} 120 | m_PrefabInstance: {fileID: 0} 121 | m_PrefabAsset: {fileID: 0} 122 | m_GameObject: {fileID: 7325841998788872592} 123 | m_Enabled: 1 124 | m_EditorHideFlags: 0 125 | m_Script: {fileID: 11500000, guid: 027e1eeb965c47308c0eb9a7f463d140, type: 3} 126 | m_Name: 127 | m_EditorClassIdentifier: 128 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/FSM/Sample 03/GathererFSM-03.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &1166321500944852649 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 3389551673463484162} 12 | - component: {fileID: 4036792051990113276} 13 | - component: {fileID: 4418647757956906798} 14 | m_Layer: 0 15 | m_Name: Capsule 16 | m_TagString: Untagged 17 | m_Icon: {fileID: 0} 18 | m_NavMeshLayer: 0 19 | m_StaticEditorFlags: 0 20 | m_IsActive: 1 21 | --- !u!4 &3389551673463484162 22 | Transform: 23 | m_ObjectHideFlags: 0 24 | m_CorrespondingSourceObject: {fileID: 0} 25 | m_PrefabInstance: {fileID: 0} 26 | m_PrefabAsset: {fileID: 0} 27 | m_GameObject: {fileID: 1166321500944852649} 28 | m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068} 29 | m_LocalPosition: {x: 0, y: 0, z: 0} 30 | m_LocalScale: {x: 0.05, y: 0.02, z: 0.05} 31 | m_Children: [] 32 | m_Father: {fileID: 7325841998788872598} 33 | m_RootOrder: 0 34 | m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} 35 | --- !u!33 &4036792051990113276 36 | MeshFilter: 37 | m_ObjectHideFlags: 0 38 | m_CorrespondingSourceObject: {fileID: 0} 39 | m_PrefabInstance: {fileID: 0} 40 | m_PrefabAsset: {fileID: 0} 41 | m_GameObject: {fileID: 1166321500944852649} 42 | m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0} 43 | --- !u!23 &4418647757956906798 44 | MeshRenderer: 45 | m_ObjectHideFlags: 0 46 | m_CorrespondingSourceObject: {fileID: 0} 47 | m_PrefabInstance: {fileID: 0} 48 | m_PrefabAsset: {fileID: 0} 49 | m_GameObject: {fileID: 1166321500944852649} 50 | m_Enabled: 1 51 | m_CastShadows: 1 52 | m_ReceiveShadows: 1 53 | m_DynamicOccludee: 1 54 | m_MotionVectors: 1 55 | m_LightProbeUsage: 1 56 | m_ReflectionProbeUsage: 1 57 | m_RayTracingMode: 2 58 | m_RayTraceProcedural: 0 59 | m_RenderingLayerMask: 1 60 | m_RendererPriority: 0 61 | m_Materials: 62 | - {fileID: 2100000, guid: d4e355b1fbfd80340832d1c819625f12, type: 2} 63 | m_StaticBatchInfo: 64 | firstSubMesh: 0 65 | subMeshCount: 0 66 | m_StaticBatchRoot: {fileID: 0} 67 | m_ProbeAnchor: {fileID: 0} 68 | m_LightProbeVolumeOverride: {fileID: 0} 69 | m_ScaleInLightmap: 1 70 | m_ReceiveGI: 1 71 | m_PreserveUVs: 0 72 | m_IgnoreNormalsForChartDetection: 0 73 | m_ImportantGI: 0 74 | m_StitchLightmapSeams: 1 75 | m_SelectedEditorRenderState: 3 76 | m_MinimumChartSize: 4 77 | m_AutoUVMaxDistance: 0.5 78 | m_AutoUVMaxAngle: 89 79 | m_LightmapParameters: {fileID: 0} 80 | m_SortingLayerID: 0 81 | m_SortingLayer: 0 82 | m_SortingOrder: 0 83 | m_AdditionalVertexStreams: {fileID: 0} 84 | --- !u!1 &7325841998788872592 85 | GameObject: 86 | m_ObjectHideFlags: 0 87 | m_CorrespondingSourceObject: {fileID: 0} 88 | m_PrefabInstance: {fileID: 0} 89 | m_PrefabAsset: {fileID: 0} 90 | serializedVersion: 6 91 | m_Component: 92 | - component: {fileID: 7325841998788872598} 93 | - component: {fileID: 6300960816345439604} 94 | m_Layer: 0 95 | m_Name: GathererFSM-03 96 | m_TagString: Untagged 97 | m_Icon: {fileID: 0} 98 | m_NavMeshLayer: 0 99 | m_StaticEditorFlags: 0 100 | m_IsActive: 1 101 | --- !u!4 &7325841998788872598 102 | Transform: 103 | m_ObjectHideFlags: 0 104 | m_CorrespondingSourceObject: {fileID: 0} 105 | m_PrefabInstance: {fileID: 0} 106 | m_PrefabAsset: {fileID: 0} 107 | m_GameObject: {fileID: 7325841998788872592} 108 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 109 | m_LocalPosition: {x: 0, y: 0, z: 0} 110 | m_LocalScale: {x: 1, y: 1, z: 1} 111 | m_Children: 112 | - {fileID: 3389551673463484162} 113 | m_Father: {fileID: 0} 114 | m_RootOrder: 0 115 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 116 | --- !u!114 &6300960816345439604 117 | MonoBehaviour: 118 | m_ObjectHideFlags: 0 119 | m_CorrespondingSourceObject: {fileID: 0} 120 | m_PrefabInstance: {fileID: 0} 121 | m_PrefabAsset: {fileID: 0} 122 | m_GameObject: {fileID: 7325841998788872592} 123 | m_Enabled: 1 124 | m_EditorHideFlags: 0 125 | m_Script: {fileID: 11500000, guid: 59eb80b7c79f4504a4089aff3faed7b0, type: 3} 126 | m_Name: 127 | m_EditorClassIdentifier: 128 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/FSM/Sample 04/GathererFSM-03.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &1166321500944852649 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 3389551673463484162} 12 | - component: {fileID: 4036792051990113276} 13 | - component: {fileID: 4418647757956906798} 14 | m_Layer: 0 15 | m_Name: Capsule 16 | m_TagString: Untagged 17 | m_Icon: {fileID: 0} 18 | m_NavMeshLayer: 0 19 | m_StaticEditorFlags: 0 20 | m_IsActive: 1 21 | --- !u!4 &3389551673463484162 22 | Transform: 23 | m_ObjectHideFlags: 0 24 | m_CorrespondingSourceObject: {fileID: 0} 25 | m_PrefabInstance: {fileID: 0} 26 | m_PrefabAsset: {fileID: 0} 27 | m_GameObject: {fileID: 1166321500944852649} 28 | m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068} 29 | m_LocalPosition: {x: 0, y: 0, z: 0} 30 | m_LocalScale: {x: 0.05, y: 0.02, z: 0.05} 31 | m_Children: [] 32 | m_Father: {fileID: 7325841998788872598} 33 | m_RootOrder: 0 34 | m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} 35 | --- !u!33 &4036792051990113276 36 | MeshFilter: 37 | m_ObjectHideFlags: 0 38 | m_CorrespondingSourceObject: {fileID: 0} 39 | m_PrefabInstance: {fileID: 0} 40 | m_PrefabAsset: {fileID: 0} 41 | m_GameObject: {fileID: 1166321500944852649} 42 | m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0} 43 | --- !u!23 &4418647757956906798 44 | MeshRenderer: 45 | m_ObjectHideFlags: 0 46 | m_CorrespondingSourceObject: {fileID: 0} 47 | m_PrefabInstance: {fileID: 0} 48 | m_PrefabAsset: {fileID: 0} 49 | m_GameObject: {fileID: 1166321500944852649} 50 | m_Enabled: 1 51 | m_CastShadows: 1 52 | m_ReceiveShadows: 1 53 | m_DynamicOccludee: 1 54 | m_MotionVectors: 1 55 | m_LightProbeUsage: 1 56 | m_ReflectionProbeUsage: 1 57 | m_RayTracingMode: 2 58 | m_RayTraceProcedural: 0 59 | m_RenderingLayerMask: 1 60 | m_RendererPriority: 0 61 | m_Materials: 62 | - {fileID: 2100000, guid: d4e355b1fbfd80340832d1c819625f12, type: 2} 63 | m_StaticBatchInfo: 64 | firstSubMesh: 0 65 | subMeshCount: 0 66 | m_StaticBatchRoot: {fileID: 0} 67 | m_ProbeAnchor: {fileID: 0} 68 | m_LightProbeVolumeOverride: {fileID: 0} 69 | m_ScaleInLightmap: 1 70 | m_ReceiveGI: 1 71 | m_PreserveUVs: 0 72 | m_IgnoreNormalsForChartDetection: 0 73 | m_ImportantGI: 0 74 | m_StitchLightmapSeams: 1 75 | m_SelectedEditorRenderState: 3 76 | m_MinimumChartSize: 4 77 | m_AutoUVMaxDistance: 0.5 78 | m_AutoUVMaxAngle: 89 79 | m_LightmapParameters: {fileID: 0} 80 | m_SortingLayerID: 0 81 | m_SortingLayer: 0 82 | m_SortingOrder: 0 83 | m_AdditionalVertexStreams: {fileID: 0} 84 | --- !u!1 &7325841998788872592 85 | GameObject: 86 | m_ObjectHideFlags: 0 87 | m_CorrespondingSourceObject: {fileID: 0} 88 | m_PrefabInstance: {fileID: 0} 89 | m_PrefabAsset: {fileID: 0} 90 | serializedVersion: 6 91 | m_Component: 92 | - component: {fileID: 7325841998788872598} 93 | - component: {fileID: 6300960816345439604} 94 | m_Layer: 0 95 | m_Name: GathererFSM-03 96 | m_TagString: Untagged 97 | m_Icon: {fileID: 0} 98 | m_NavMeshLayer: 0 99 | m_StaticEditorFlags: 0 100 | m_IsActive: 1 101 | --- !u!4 &7325841998788872598 102 | Transform: 103 | m_ObjectHideFlags: 0 104 | m_CorrespondingSourceObject: {fileID: 0} 105 | m_PrefabInstance: {fileID: 0} 106 | m_PrefabAsset: {fileID: 0} 107 | m_GameObject: {fileID: 7325841998788872592} 108 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 109 | m_LocalPosition: {x: 0, y: 0, z: 0} 110 | m_LocalScale: {x: 1, y: 1, z: 1} 111 | m_Children: 112 | - {fileID: 3389551673463484162} 113 | m_Father: {fileID: 0} 114 | m_RootOrder: 0 115 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 116 | --- !u!114 &6300960816345439604 117 | MonoBehaviour: 118 | m_ObjectHideFlags: 0 119 | m_CorrespondingSourceObject: {fileID: 0} 120 | m_PrefabInstance: {fileID: 0} 121 | m_PrefabAsset: {fileID: 0} 122 | m_GameObject: {fileID: 7325841998788872592} 123 | m_Enabled: 1 124 | m_EditorHideFlags: 0 125 | m_Script: {fileID: 11500000, guid: 59eb80b7c79f4504a4089aff3faed7b0, type: 3} 126 | m_Name: 127 | m_EditorClassIdentifier: 128 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT/Sample01/GathererBT-01.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &1166321500944852649 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 3389551673463484162} 12 | - component: {fileID: 4036792051990113276} 13 | - component: {fileID: 4418647757956906798} 14 | m_Layer: 0 15 | m_Name: Capsule 16 | m_TagString: Untagged 17 | m_Icon: {fileID: 0} 18 | m_NavMeshLayer: 0 19 | m_StaticEditorFlags: 0 20 | m_IsActive: 1 21 | --- !u!4 &3389551673463484162 22 | Transform: 23 | m_ObjectHideFlags: 0 24 | m_CorrespondingSourceObject: {fileID: 0} 25 | m_PrefabInstance: {fileID: 0} 26 | m_PrefabAsset: {fileID: 0} 27 | m_GameObject: {fileID: 1166321500944852649} 28 | m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068} 29 | m_LocalPosition: {x: 0, y: 0, z: 0} 30 | m_LocalScale: {x: 0.05, y: 0.02, z: 0.05} 31 | m_Children: [] 32 | m_Father: {fileID: 7325841998788872598} 33 | m_RootOrder: 0 34 | m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} 35 | --- !u!33 &4036792051990113276 36 | MeshFilter: 37 | m_ObjectHideFlags: 0 38 | m_CorrespondingSourceObject: {fileID: 0} 39 | m_PrefabInstance: {fileID: 0} 40 | m_PrefabAsset: {fileID: 0} 41 | m_GameObject: {fileID: 1166321500944852649} 42 | m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0} 43 | --- !u!23 &4418647757956906798 44 | MeshRenderer: 45 | m_ObjectHideFlags: 0 46 | m_CorrespondingSourceObject: {fileID: 0} 47 | m_PrefabInstance: {fileID: 0} 48 | m_PrefabAsset: {fileID: 0} 49 | m_GameObject: {fileID: 1166321500944852649} 50 | m_Enabled: 1 51 | m_CastShadows: 1 52 | m_ReceiveShadows: 1 53 | m_DynamicOccludee: 1 54 | m_MotionVectors: 1 55 | m_LightProbeUsage: 1 56 | m_ReflectionProbeUsage: 1 57 | m_RayTracingMode: 2 58 | m_RayTraceProcedural: 0 59 | m_RenderingLayerMask: 1 60 | m_RendererPriority: 0 61 | m_Materials: 62 | - {fileID: 2100000, guid: d4e355b1fbfd80340832d1c819625f12, type: 2} 63 | m_StaticBatchInfo: 64 | firstSubMesh: 0 65 | subMeshCount: 0 66 | m_StaticBatchRoot: {fileID: 0} 67 | m_ProbeAnchor: {fileID: 0} 68 | m_LightProbeVolumeOverride: {fileID: 0} 69 | m_ScaleInLightmap: 1 70 | m_ReceiveGI: 1 71 | m_PreserveUVs: 0 72 | m_IgnoreNormalsForChartDetection: 0 73 | m_ImportantGI: 0 74 | m_StitchLightmapSeams: 1 75 | m_SelectedEditorRenderState: 3 76 | m_MinimumChartSize: 4 77 | m_AutoUVMaxDistance: 0.5 78 | m_AutoUVMaxAngle: 89 79 | m_LightmapParameters: {fileID: 0} 80 | m_SortingLayerID: 0 81 | m_SortingLayer: 0 82 | m_SortingOrder: 0 83 | m_AdditionalVertexStreams: {fileID: 0} 84 | --- !u!1 &7325841998788872592 85 | GameObject: 86 | m_ObjectHideFlags: 0 87 | m_CorrespondingSourceObject: {fileID: 0} 88 | m_PrefabInstance: {fileID: 0} 89 | m_PrefabAsset: {fileID: 0} 90 | serializedVersion: 6 91 | m_Component: 92 | - component: {fileID: 7325841998788872598} 93 | - component: {fileID: 7325841998788872593} 94 | m_Layer: 0 95 | m_Name: GathererBT-01 96 | m_TagString: Untagged 97 | m_Icon: {fileID: 0} 98 | m_NavMeshLayer: 0 99 | m_StaticEditorFlags: 0 100 | m_IsActive: 1 101 | --- !u!4 &7325841998788872598 102 | Transform: 103 | m_ObjectHideFlags: 0 104 | m_CorrespondingSourceObject: {fileID: 0} 105 | m_PrefabInstance: {fileID: 0} 106 | m_PrefabAsset: {fileID: 0} 107 | m_GameObject: {fileID: 7325841998788872592} 108 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 109 | m_LocalPosition: {x: 0, y: 0, z: 0} 110 | m_LocalScale: {x: 1, y: 1, z: 1} 111 | m_Children: 112 | - {fileID: 3389551673463484162} 113 | m_Father: {fileID: 0} 114 | m_RootOrder: 0 115 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 116 | --- !u!114 &7325841998788872593 117 | MonoBehaviour: 118 | m_ObjectHideFlags: 0 119 | m_CorrespondingSourceObject: {fileID: 0} 120 | m_PrefabInstance: {fileID: 0} 121 | m_PrefabAsset: {fileID: 0} 122 | m_GameObject: {fileID: 7325841998788872592} 123 | m_Enabled: 1 124 | m_EditorHideFlags: 0 125 | m_Script: {fileID: 11500000, guid: b1b24e150d6d5874c9741ff78369f4ce, type: 3} 126 | m_Name: 127 | m_EditorClassIdentifier: 128 | BehaviourDefinition: {fileID: 11400000, guid: 1b3f2ea6723381e4da1d2f1c019dac18, 129 | type: 2} 130 | Speed: 0.5 131 | Reach: 0.05 132 | WorkTime: 0 133 | RestTime: 0 134 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT/Sample02/GathererBT-02.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &1166321500944852649 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 3389551673463484162} 12 | - component: {fileID: 4036792051990113276} 13 | - component: {fileID: 4418647757956906798} 14 | m_Layer: 0 15 | m_Name: Capsule 16 | m_TagString: Untagged 17 | m_Icon: {fileID: 0} 18 | m_NavMeshLayer: 0 19 | m_StaticEditorFlags: 0 20 | m_IsActive: 1 21 | --- !u!4 &3389551673463484162 22 | Transform: 23 | m_ObjectHideFlags: 0 24 | m_CorrespondingSourceObject: {fileID: 0} 25 | m_PrefabInstance: {fileID: 0} 26 | m_PrefabAsset: {fileID: 0} 27 | m_GameObject: {fileID: 1166321500944852649} 28 | m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068} 29 | m_LocalPosition: {x: 0, y: 0, z: 0} 30 | m_LocalScale: {x: 0.05, y: 0.02, z: 0.05} 31 | m_Children: [] 32 | m_Father: {fileID: 7325841998788872598} 33 | m_RootOrder: 0 34 | m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} 35 | --- !u!33 &4036792051990113276 36 | MeshFilter: 37 | m_ObjectHideFlags: 0 38 | m_CorrespondingSourceObject: {fileID: 0} 39 | m_PrefabInstance: {fileID: 0} 40 | m_PrefabAsset: {fileID: 0} 41 | m_GameObject: {fileID: 1166321500944852649} 42 | m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0} 43 | --- !u!23 &4418647757956906798 44 | MeshRenderer: 45 | m_ObjectHideFlags: 0 46 | m_CorrespondingSourceObject: {fileID: 0} 47 | m_PrefabInstance: {fileID: 0} 48 | m_PrefabAsset: {fileID: 0} 49 | m_GameObject: {fileID: 1166321500944852649} 50 | m_Enabled: 1 51 | m_CastShadows: 1 52 | m_ReceiveShadows: 1 53 | m_DynamicOccludee: 1 54 | m_MotionVectors: 1 55 | m_LightProbeUsage: 1 56 | m_ReflectionProbeUsage: 1 57 | m_RayTracingMode: 2 58 | m_RayTraceProcedural: 0 59 | m_RenderingLayerMask: 1 60 | m_RendererPriority: 0 61 | m_Materials: 62 | - {fileID: 2100000, guid: d4e355b1fbfd80340832d1c819625f12, type: 2} 63 | m_StaticBatchInfo: 64 | firstSubMesh: 0 65 | subMeshCount: 0 66 | m_StaticBatchRoot: {fileID: 0} 67 | m_ProbeAnchor: {fileID: 0} 68 | m_LightProbeVolumeOverride: {fileID: 0} 69 | m_ScaleInLightmap: 1 70 | m_ReceiveGI: 1 71 | m_PreserveUVs: 0 72 | m_IgnoreNormalsForChartDetection: 0 73 | m_ImportantGI: 0 74 | m_StitchLightmapSeams: 1 75 | m_SelectedEditorRenderState: 3 76 | m_MinimumChartSize: 4 77 | m_AutoUVMaxDistance: 0.5 78 | m_AutoUVMaxAngle: 89 79 | m_LightmapParameters: {fileID: 0} 80 | m_SortingLayerID: 0 81 | m_SortingLayer: 0 82 | m_SortingOrder: 0 83 | m_AdditionalVertexStreams: {fileID: 0} 84 | --- !u!1 &7325841998788872592 85 | GameObject: 86 | m_ObjectHideFlags: 0 87 | m_CorrespondingSourceObject: {fileID: 0} 88 | m_PrefabInstance: {fileID: 0} 89 | m_PrefabAsset: {fileID: 0} 90 | serializedVersion: 6 91 | m_Component: 92 | - component: {fileID: 7325841998788872598} 93 | - component: {fileID: 7325841998788872593} 94 | m_Layer: 0 95 | m_Name: GathererBT-02 96 | m_TagString: Untagged 97 | m_Icon: {fileID: 0} 98 | m_NavMeshLayer: 0 99 | m_StaticEditorFlags: 0 100 | m_IsActive: 1 101 | --- !u!4 &7325841998788872598 102 | Transform: 103 | m_ObjectHideFlags: 0 104 | m_CorrespondingSourceObject: {fileID: 0} 105 | m_PrefabInstance: {fileID: 0} 106 | m_PrefabAsset: {fileID: 0} 107 | m_GameObject: {fileID: 7325841998788872592} 108 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 109 | m_LocalPosition: {x: 0, y: 0, z: 0} 110 | m_LocalScale: {x: 1, y: 1, z: 1} 111 | m_Children: 112 | - {fileID: 3389551673463484162} 113 | m_Father: {fileID: 0} 114 | m_RootOrder: 0 115 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 116 | --- !u!114 &7325841998788872593 117 | MonoBehaviour: 118 | m_ObjectHideFlags: 0 119 | m_CorrespondingSourceObject: {fileID: 0} 120 | m_PrefabInstance: {fileID: 0} 121 | m_PrefabAsset: {fileID: 0} 122 | m_GameObject: {fileID: 7325841998788872592} 123 | m_Enabled: 1 124 | m_EditorHideFlags: 0 125 | m_Script: {fileID: 11500000, guid: b1b24e150d6d5874c9741ff78369f4ce, type: 3} 126 | m_Name: 127 | m_EditorClassIdentifier: 128 | BehaviourDefinition: {fileID: 11400000, guid: c44872229baa7e6458b0078a3c00d37f, 129 | type: 2} 130 | Speed: 0.5 131 | Reach: 0.05 132 | WorkTime: 24 133 | RestTime: 8 134 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/FSM/Sample 01/GathererFSM-01.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &1166321500944852649 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 3389551673463484162} 12 | - component: {fileID: 4036792051990113276} 13 | - component: {fileID: 4418647757956906798} 14 | m_Layer: 0 15 | m_Name: Capsule 16 | m_TagString: Untagged 17 | m_Icon: {fileID: 0} 18 | m_NavMeshLayer: 0 19 | m_StaticEditorFlags: 0 20 | m_IsActive: 1 21 | --- !u!4 &3389551673463484162 22 | Transform: 23 | m_ObjectHideFlags: 0 24 | m_CorrespondingSourceObject: {fileID: 0} 25 | m_PrefabInstance: {fileID: 0} 26 | m_PrefabAsset: {fileID: 0} 27 | m_GameObject: {fileID: 1166321500944852649} 28 | m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068} 29 | m_LocalPosition: {x: 0, y: 0, z: 0} 30 | m_LocalScale: {x: 0.05, y: 0.02, z: 0.05} 31 | m_Children: [] 32 | m_Father: {fileID: 7325841998788872598} 33 | m_RootOrder: 0 34 | m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} 35 | --- !u!33 &4036792051990113276 36 | MeshFilter: 37 | m_ObjectHideFlags: 0 38 | m_CorrespondingSourceObject: {fileID: 0} 39 | m_PrefabInstance: {fileID: 0} 40 | m_PrefabAsset: {fileID: 0} 41 | m_GameObject: {fileID: 1166321500944852649} 42 | m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0} 43 | --- !u!23 &4418647757956906798 44 | MeshRenderer: 45 | m_ObjectHideFlags: 0 46 | m_CorrespondingSourceObject: {fileID: 0} 47 | m_PrefabInstance: {fileID: 0} 48 | m_PrefabAsset: {fileID: 0} 49 | m_GameObject: {fileID: 1166321500944852649} 50 | m_Enabled: 1 51 | m_CastShadows: 1 52 | m_ReceiveShadows: 1 53 | m_DynamicOccludee: 1 54 | m_MotionVectors: 1 55 | m_LightProbeUsage: 1 56 | m_ReflectionProbeUsage: 1 57 | m_RayTracingMode: 2 58 | m_RayTraceProcedural: 0 59 | m_RenderingLayerMask: 1 60 | m_RendererPriority: 0 61 | m_Materials: 62 | - {fileID: 2100000, guid: d4e355b1fbfd80340832d1c819625f12, type: 2} 63 | m_StaticBatchInfo: 64 | firstSubMesh: 0 65 | subMeshCount: 0 66 | m_StaticBatchRoot: {fileID: 0} 67 | m_ProbeAnchor: {fileID: 0} 68 | m_LightProbeVolumeOverride: {fileID: 0} 69 | m_ScaleInLightmap: 1 70 | m_ReceiveGI: 1 71 | m_PreserveUVs: 0 72 | m_IgnoreNormalsForChartDetection: 0 73 | m_ImportantGI: 0 74 | m_StitchLightmapSeams: 1 75 | m_SelectedEditorRenderState: 3 76 | m_MinimumChartSize: 4 77 | m_AutoUVMaxDistance: 0.5 78 | m_AutoUVMaxAngle: 89 79 | m_LightmapParameters: {fileID: 0} 80 | m_SortingLayerID: 0 81 | m_SortingLayer: 0 82 | m_SortingOrder: 0 83 | m_AdditionalVertexStreams: {fileID: 0} 84 | --- !u!1 &7325841998788872592 85 | GameObject: 86 | m_ObjectHideFlags: 0 87 | m_CorrespondingSourceObject: {fileID: 0} 88 | m_PrefabInstance: {fileID: 0} 89 | m_PrefabAsset: {fileID: 0} 90 | serializedVersion: 6 91 | m_Component: 92 | - component: {fileID: 7325841998788872598} 93 | - component: {fileID: -2571171841456886146} 94 | m_Layer: 0 95 | m_Name: GathererFSM-01 96 | m_TagString: Untagged 97 | m_Icon: {fileID: 0} 98 | m_NavMeshLayer: 0 99 | m_StaticEditorFlags: 0 100 | m_IsActive: 1 101 | --- !u!4 &7325841998788872598 102 | Transform: 103 | m_ObjectHideFlags: 0 104 | m_CorrespondingSourceObject: {fileID: 0} 105 | m_PrefabInstance: {fileID: 0} 106 | m_PrefabAsset: {fileID: 0} 107 | m_GameObject: {fileID: 7325841998788872592} 108 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 109 | m_LocalPosition: {x: 0, y: 0, z: 0} 110 | m_LocalScale: {x: 1, y: 1, z: 1} 111 | m_Children: 112 | - {fileID: 3389551673463484162} 113 | m_Father: {fileID: 0} 114 | m_RootOrder: 0 115 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 116 | --- !u!114 &-2571171841456886146 117 | MonoBehaviour: 118 | m_ObjectHideFlags: 0 119 | m_CorrespondingSourceObject: {fileID: 0} 120 | m_PrefabInstance: {fileID: 0} 121 | m_PrefabAsset: {fileID: 0} 122 | m_GameObject: {fileID: 7325841998788872592} 123 | m_Enabled: 1 124 | m_EditorHideFlags: 0 125 | m_Script: {fileID: 11500000, guid: 51ac5a52e81843fb838880aaeb330450, type: 3} 126 | m_Name: 127 | m_EditorClassIdentifier: 128 | BehaviourDefinition: {fileID: 11400000, guid: 48bbfe83bac28f34ebe22b97145cc2b6, 129 | type: 2} 130 | Speed: 0.5 131 | Reach: 0.05 132 | WorkTime: 24 133 | RestTime: 8 134 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/FSM/Sample 02/GathererFSM-02.prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1 &1166321500944852649 4 | GameObject: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | serializedVersion: 6 10 | m_Component: 11 | - component: {fileID: 3389551673463484162} 12 | - component: {fileID: 4036792051990113276} 13 | - component: {fileID: 4418647757956906798} 14 | m_Layer: 0 15 | m_Name: Capsule 16 | m_TagString: Untagged 17 | m_Icon: {fileID: 0} 18 | m_NavMeshLayer: 0 19 | m_StaticEditorFlags: 0 20 | m_IsActive: 1 21 | --- !u!4 &3389551673463484162 22 | Transform: 23 | m_ObjectHideFlags: 0 24 | m_CorrespondingSourceObject: {fileID: 0} 25 | m_PrefabInstance: {fileID: 0} 26 | m_PrefabAsset: {fileID: 0} 27 | m_GameObject: {fileID: 1166321500944852649} 28 | m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068} 29 | m_LocalPosition: {x: 0, y: 0, z: 0} 30 | m_LocalScale: {x: 0.05, y: 0.02, z: 0.05} 31 | m_Children: [] 32 | m_Father: {fileID: 7325841998788872598} 33 | m_RootOrder: 0 34 | m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} 35 | --- !u!33 &4036792051990113276 36 | MeshFilter: 37 | m_ObjectHideFlags: 0 38 | m_CorrespondingSourceObject: {fileID: 0} 39 | m_PrefabInstance: {fileID: 0} 40 | m_PrefabAsset: {fileID: 0} 41 | m_GameObject: {fileID: 1166321500944852649} 42 | m_Mesh: {fileID: 10208, guid: 0000000000000000e000000000000000, type: 0} 43 | --- !u!23 &4418647757956906798 44 | MeshRenderer: 45 | m_ObjectHideFlags: 0 46 | m_CorrespondingSourceObject: {fileID: 0} 47 | m_PrefabInstance: {fileID: 0} 48 | m_PrefabAsset: {fileID: 0} 49 | m_GameObject: {fileID: 1166321500944852649} 50 | m_Enabled: 1 51 | m_CastShadows: 1 52 | m_ReceiveShadows: 1 53 | m_DynamicOccludee: 1 54 | m_MotionVectors: 1 55 | m_LightProbeUsage: 1 56 | m_ReflectionProbeUsage: 1 57 | m_RayTracingMode: 2 58 | m_RayTraceProcedural: 0 59 | m_RenderingLayerMask: 1 60 | m_RendererPriority: 0 61 | m_Materials: 62 | - {fileID: 2100000, guid: d4e355b1fbfd80340832d1c819625f12, type: 2} 63 | m_StaticBatchInfo: 64 | firstSubMesh: 0 65 | subMeshCount: 0 66 | m_StaticBatchRoot: {fileID: 0} 67 | m_ProbeAnchor: {fileID: 0} 68 | m_LightProbeVolumeOverride: {fileID: 0} 69 | m_ScaleInLightmap: 1 70 | m_ReceiveGI: 1 71 | m_PreserveUVs: 0 72 | m_IgnoreNormalsForChartDetection: 0 73 | m_ImportantGI: 0 74 | m_StitchLightmapSeams: 1 75 | m_SelectedEditorRenderState: 3 76 | m_MinimumChartSize: 4 77 | m_AutoUVMaxDistance: 0.5 78 | m_AutoUVMaxAngle: 89 79 | m_LightmapParameters: {fileID: 0} 80 | m_SortingLayerID: 0 81 | m_SortingLayer: 0 82 | m_SortingOrder: 0 83 | m_AdditionalVertexStreams: {fileID: 0} 84 | --- !u!1 &7325841998788872592 85 | GameObject: 86 | m_ObjectHideFlags: 0 87 | m_CorrespondingSourceObject: {fileID: 0} 88 | m_PrefabInstance: {fileID: 0} 89 | m_PrefabAsset: {fileID: 0} 90 | serializedVersion: 6 91 | m_Component: 92 | - component: {fileID: 7325841998788872598} 93 | - component: {fileID: -2571171841456886146} 94 | m_Layer: 0 95 | m_Name: GathererFSM-02 96 | m_TagString: Untagged 97 | m_Icon: {fileID: 0} 98 | m_NavMeshLayer: 0 99 | m_StaticEditorFlags: 0 100 | m_IsActive: 1 101 | --- !u!4 &7325841998788872598 102 | Transform: 103 | m_ObjectHideFlags: 0 104 | m_CorrespondingSourceObject: {fileID: 0} 105 | m_PrefabInstance: {fileID: 0} 106 | m_PrefabAsset: {fileID: 0} 107 | m_GameObject: {fileID: 7325841998788872592} 108 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 109 | m_LocalPosition: {x: 0, y: 0, z: 0} 110 | m_LocalScale: {x: 1, y: 1, z: 1} 111 | m_Children: 112 | - {fileID: 3389551673463484162} 113 | m_Father: {fileID: 0} 114 | m_RootOrder: 0 115 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 116 | --- !u!114 &-2571171841456886146 117 | MonoBehaviour: 118 | m_ObjectHideFlags: 0 119 | m_CorrespondingSourceObject: {fileID: 0} 120 | m_PrefabInstance: {fileID: 0} 121 | m_PrefabAsset: {fileID: 0} 122 | m_GameObject: {fileID: 7325841998788872592} 123 | m_Enabled: 1 124 | m_EditorHideFlags: 0 125 | m_Script: {fileID: 11500000, guid: 51ac5a52e81843fb838880aaeb330450, type: 3} 126 | m_Name: 127 | m_EditorClassIdentifier: 128 | BehaviourDefinition: {fileID: 11400000, guid: 849e2b67845e27143a3cadd0ab4c454e, 129 | type: 2} 130 | Speed: 0.5 131 | Reach: 0.05 132 | WorkTime: 24 133 | RestTime: 8 134 | -------------------------------------------------------------------------------- /Samples~/Gatherer/Code/Common/Behaviours/GatherersManager.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using Planilo; 4 | using UnityEngine; 5 | 6 | namespace PlaniloSamples.Common 7 | { 8 | public class GatherersManager : MonoBehaviour, IBehaviourManager 9 | where TBehaviourGraph : IAIBehaviourBuilder 10 | { 11 | [SerializeField] GameObject gathererPrefab = default; 12 | [SerializeField] int gatherersCount = default; 13 | [SerializeField] TBehaviourGraph behaviourDefinition = default; 14 | 15 | [Header("Gatherer Stats")] 16 | [SerializeField] float speed = 0.5f; 17 | [SerializeField] float reach = 0.05f; 18 | [SerializeField] float workTime = 24f; 19 | [SerializeField] float restTime = 8f; 20 | 21 | IAIBehaviour behaviourTree; 22 | TBehaviourState[] gathererStates; 23 | Gatherer[] gatherers; 24 | GameObject[] gathererGos; 25 | bool alarm; 26 | 27 | IEnumerator Start() 28 | { 29 | enabled = false; 30 | var homeSpawn = WaitForHomeSpawn(); 31 | yield return homeSpawn; 32 | SpawnGatherers(homeSpawn.Current); 33 | InitializeBehaviours(); 34 | enabled = true; 35 | } 36 | 37 | IEnumerator WaitForHomeSpawn() 38 | { 39 | Home home = null; 40 | while (home == null) 41 | { 42 | home = FindObjectOfType(); 43 | yield return null; 44 | } 45 | 46 | yield return home; 47 | } 48 | 49 | void SpawnGatherers(Home home) 50 | { 51 | gatherers = new Gatherer[gatherersCount]; 52 | var homePosition = home.transform.position; 53 | // Spawn game objects. 54 | for (var i = 0; i < gatherersCount; i++) 55 | { 56 | var rotation = Quaternion.Euler(0, 0, Random.Range(0f, 360f)); 57 | var position = new Vector3(Random.Range(0f, 0.3f), 0, 0); 58 | var go = Instantiate(gathererPrefab, rotation * position, Quaternion.identity); 59 | InitializeGatherer(i, go, homePosition); 60 | } 61 | } 62 | 63 | void InitializeGatherer(int index, GameObject go, Vector3 homePosition) 64 | { 65 | ref var gatherer = ref gatherers[index]; 66 | gatherer.Id = index + 1; 67 | gatherer.World.Home = homePosition; 68 | gatherer.Transform = go.transform; 69 | gatherer.Speed = speed; 70 | gatherer.Reach = reach; 71 | gatherer.LastRest = Time.time; 72 | gatherer.WorkTime = workTime; 73 | gatherer.RestTime = restTime; 74 | 75 | #if UNITY_EDITOR 76 | var debugger = go.GetComponent>(); 77 | if (debugger != null) 78 | { 79 | debugger.Manager = this; 80 | debugger.Index = index; 81 | } 82 | #endif 83 | } 84 | 85 | void InitializeBehaviours() 86 | { 87 | gathererStates = new TBehaviourState[gatherersCount]; 88 | behaviourTree = behaviourDefinition.Build(); 89 | for (var i = 0; i < gatherersCount; i++) 90 | { 91 | gathererStates[i] = behaviourTree.Initialize(ref gatherers[i]); 92 | } 93 | } 94 | 95 | void Update() 96 | { 97 | // Toggle alarm in world state. 98 | if (Input.GetKeyUp(KeyCode.A)) 99 | { 100 | alarm = !alarm; 101 | } 102 | // Find all available resources 103 | var resources = FindObjectsOfType(); 104 | // Run behaviours and update the world state. 105 | for (var i = 0; i < gatherersCount; i++) 106 | { 107 | gatherers[i].World.Alarm = alarm; 108 | gatherers[i].World.Resources = resources; 109 | behaviourTree.Run(ref gatherers[i], ref gathererStates[i]); 110 | } 111 | } 112 | 113 | #if UNITY_EDITOR 114 | public TBehaviourGraph BehaviourGraph => behaviourDefinition; 115 | 116 | public TBehaviourState GetAgentState(int index) 117 | { 118 | return gathererStates.Length > index ? gathererStates[index] : default; 119 | } 120 | #endif 121 | } 122 | } -------------------------------------------------------------------------------- /Samples~/Gatherer/Content/BT/Sample02/GathererBT-02.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &11400000 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 0 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 11500000, guid: 1180afa5dc987974da2f70507dec4e21, type: 3} 13 | m_Name: GathererBT-02 14 | m_EditorClassIdentifier: 15 | nodes: 16 | - {fileID: 5699466600653079777} 17 | - {fileID: 5400389990176100079} 18 | - {fileID: 4472946374452244862} 19 | root: {fileID: 5699466600653079777} 20 | --- !u!114 &4472946374452244862 21 | MonoBehaviour: 22 | m_ObjectHideFlags: 0 23 | m_CorrespondingSourceObject: {fileID: 0} 24 | m_PrefabInstance: {fileID: 0} 25 | m_PrefabAsset: {fileID: 0} 26 | m_GameObject: {fileID: 0} 27 | m_Enabled: 1 28 | m_EditorHideFlags: 0 29 | m_Script: {fileID: 11500000, guid: 0d4c86fb00794ade9d41dbd82f12ea61, type: 3} 30 | m_Name: Behaviour Tree Sub Graph 31 | m_EditorClassIdentifier: 32 | graph: {fileID: 11400000} 33 | position: {x: -8, y: -56} 34 | ports: 35 | keys: 36 | - parent 37 | values: 38 | - _fieldName: parent 39 | _node: {fileID: 4472946374452244862} 40 | _typeQualifiedName: Planilo.BT.Builder.BehaviourTreeGraphConnection, Planilo, 41 | Version=0.0.0.0, Culture=neutral, PublicKeyToken=null 42 | connections: 43 | - fieldName: children 0 44 | node: {fileID: 5699466600653079777} 45 | reroutePoints: [] 46 | _direction: 0 47 | _connectionType: 0 48 | _typeConstraint: 0 49 | _dynamic: 0 50 | isRoot: 0 51 | subGraph: {fileID: 11400000, guid: 8508a9d30c031ab43845b7f4fdacc7e2, type: 2} 52 | --- !u!114 &5400389990176100079 53 | MonoBehaviour: 54 | m_ObjectHideFlags: 0 55 | m_CorrespondingSourceObject: {fileID: 0} 56 | m_PrefabInstance: {fileID: 0} 57 | m_PrefabAsset: {fileID: 0} 58 | m_GameObject: {fileID: 0} 59 | m_Enabled: 1 60 | m_EditorHideFlags: 0 61 | m_Script: {fileID: 11500000, guid: 0d4c86fb00794ade9d41dbd82f12ea61, type: 3} 62 | m_Name: Behaviour Tree Sub Graph 63 | m_EditorClassIdentifier: 64 | graph: {fileID: 11400000} 65 | position: {x: -8, y: 72} 66 | ports: 67 | keys: 68 | - parent 69 | values: 70 | - _fieldName: parent 71 | _node: {fileID: 5400389990176100079} 72 | _typeQualifiedName: Planilo.BT.Builder.BehaviourTreeGraphConnection, Planilo, 73 | Version=0.0.0.0, Culture=neutral, PublicKeyToken=null 74 | connections: 75 | - fieldName: children 1 76 | node: {fileID: 5699466600653079777} 77 | reroutePoints: [] 78 | _direction: 0 79 | _connectionType: 0 80 | _typeConstraint: 0 81 | _dynamic: 0 82 | isRoot: 0 83 | subGraph: {fileID: 11400000, guid: 9bfb238198ae1da40a943ff0f2726144, type: 2} 84 | --- !u!114 &5699466600653079777 85 | MonoBehaviour: 86 | m_ObjectHideFlags: 0 87 | m_CorrespondingSourceObject: {fileID: 0} 88 | m_PrefabInstance: {fileID: 0} 89 | m_PrefabAsset: {fileID: 0} 90 | m_GameObject: {fileID: 0} 91 | m_Enabled: 1 92 | m_EditorHideFlags: 0 93 | m_Script: {fileID: 11500000, guid: c6c0b00122704a0d83cbe9f1b074eb53, type: 3} 94 | m_Name: Selector Graph 95 | m_EditorClassIdentifier: 96 | graph: {fileID: 11400000} 97 | position: {x: -312, y: -24} 98 | ports: 99 | keys: 100 | - children 101 | - parent 102 | - children 0 103 | - children 1 104 | values: 105 | - _fieldName: children 106 | _node: {fileID: 5699466600653079777} 107 | _typeQualifiedName: System.Collections.Generic.List`1[[Planilo.BT.Builder.BehaviourTreeGraphConnection, 108 | Planilo, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, 109 | Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 110 | connections: [] 111 | _direction: 1 112 | _connectionType: 0 113 | _typeConstraint: 0 114 | _dynamic: 0 115 | - _fieldName: parent 116 | _node: {fileID: 5699466600653079777} 117 | _typeQualifiedName: Planilo.BT.Builder.BehaviourTreeGraphConnection, Planilo, 118 | Version=0.0.0.0, Culture=neutral, PublicKeyToken=null 119 | connections: [] 120 | _direction: 0 121 | _connectionType: 0 122 | _typeConstraint: 0 123 | _dynamic: 0 124 | - _fieldName: children 0 125 | _node: {fileID: 5699466600653079777} 126 | _typeQualifiedName: System.Collections.Generic.List`1[[Planilo.BT.Builder.BehaviourTreeGraphConnection, 127 | Planilo, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, 128 | Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 129 | connections: 130 | - fieldName: parent 131 | node: {fileID: 4472946374452244862} 132 | reroutePoints: [] 133 | _direction: 1 134 | _connectionType: 0 135 | _typeConstraint: 0 136 | _dynamic: 1 137 | - _fieldName: children 1 138 | _node: {fileID: 5699466600653079777} 139 | _typeQualifiedName: System.Collections.Generic.List`1[[Planilo.BT.Builder.BehaviourTreeGraphConnection, 140 | Planilo, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]], mscorlib, 141 | Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 142 | connections: 143 | - fieldName: parent 144 | node: {fileID: 5400389990176100079} 145 | reroutePoints: [] 146 | _direction: 1 147 | _connectionType: 0 148 | _typeConstraint: 0 149 | _dynamic: 1 150 | isRoot: 1 151 | children: [] 152 | --------------------------------------------------------------------------------