public BehaverBridge(Behaver _behaverFront, BridgeHelperFactoryBridge _helperFactory) { helperFactory = _helperFactory; behaverFront = _behaverFront; matchAttributeCallback = (newAttributeGBlockPtr) => { try { var gBlock = NativeGrammarBlockUtils.GBlockPtrToGBlock(newAttributeGBlockPtr); var bf = this.behaverFront; return((int)behaverFront.MatchAttribue(gBlock)); } catch (System.Exception e) { Debug.LogError(e); return((int)AttributeMatchResult.NEUTRAL); } }; setBehaviorCallback = (behaviorExpression, listener) => { try { var gBlock = NativeGrammarBlockUtils.GBlockPtrToGBlock(behaviorExpression); behaverFront.ReadyBehavior(GrammarBlockUtils.GBlockToBExpression(gBlock), new NativeBehaviorRequestListener(listener, helperFactory)); Debug.Log("READY Set Behaver Front behavior: " + gBlock.cluster.blocks[1].unit.word); } catch (Exception e) { Debug.LogError(e); } }; checkBehaviorCallback = (behaviorExpression, listener) => { try { var gBlock = NativeGrammarBlockUtils.GBlockPtrToGBlock(behaviorExpression); behaverFront.ReadyCheckBehavior(GrammarBlockUtils.GBlockToBExpression(gBlock), new NativeBehaviorCheckRequestListener(listener, helperFactory)); Debug.Log("READY Check Behaver Front behavior: " + gBlock.cluster.blocks[1].unit.word); } catch (Exception e) { Debug.LogError(e); } }; }
public BehaverFactoryBridge(ImmediateGiver <Behaver, GrammarBlock> _behaverGiver, BridgeHelperFactoryBridge _helperFactory) { behaverGiver = _behaverGiver; behaverFrontFactoryCallback = (factoryAgent, baseAttributeGBlock) => { try { var picked = behaverGiver.PickBestElement(NativeGrammarBlockUtils.GBlockPtrToGBlock(baseAttributeGBlock)); if (picked != null) { behavers.Add(new BehaverBridge(picked, _helperFactory)); ReadyBehaver(factoryAgent, behavers.Last().matchAttributeCallback, behavers.Last().setBehaviorCallback, behavers.Last().checkBehaviorCallback); } } catch (System.Exception e) { Debug.LogError(e); } }; nativeFactoryPtr = _helperFactory.NewBehaverFactory(behaverFrontFactoryCallback); }
private extern static System.IntPtr NewBehaverFactory(System.IntPtr BridgeHelperFactoryBridgePtr, TwoPtrCallback behaverFrontFactoryCallback);
public System.IntPtr NewBehaverFactory(TwoPtrCallback behaverFactoryCallback) { return(NewBehaverFactory(implPtr, behaverFactoryCallback)); }
private extern static void ReadyBehaver( System.IntPtr agent, SinglePtrReturnIntCallback onAddAttributeCallback, TwoPtrCallback setBehaviorCallback, TwoPtrCallback checkBehaviorCallback );