Exemple #1
0
        public bool AskForFloatAnswer(GrammarBlock question, AnswerListener <float> listener)
        {
            var lisBridge = new FloatAnswerListenerBridge(listener);

            floatAnswerListeners.Add(lisBridge);
            return(AskForNumericAnswer(helperFactory.implPtr, implPtr, helperFactory.GBlockToGBlockPtr(question), lisBridge.callback));
        }
Exemple #2
0
		AttributeMatchResult AttributeMatcher.MatchAttribue(GrammarBlock attribute) {
			lastMatchedCardAttribute = attribute;
			if (attribute.unit.word == "button" || attribute.unit.word == "title" || attribute.unit.word == "text") {
				return AttributeMatchResult.POSITIVE;
			}
			return AttributeMatchResult.NEUTRAL;
		}
Exemple #3
0
 void BehaverEquipper.EquipBehaverByAttribute(GrammarBlock attribute, BehaverEquipListener listener)
 {
     foreach (var equipper in equippers)
     {
         equipper.EquipBehaverByAttribute(attribute, listener);
     }
 }
Exemple #4
0
        float TimeExpresssionToFloatSec(GrammarBlock timeExpression)
        {
            var vis = new TimeCountVisitor();

            GrammarBlockUtils.VisitGrammarBlock(timeExpression, vis);
            return(vis.result);
        }
Exemple #5
0
 GBlockConvertResult GBlockConverter.ConvertGBlock(GrammarBlock sourceGBlock, GBlockConvertListener listener)
 {
     if (sourceGBlock.cluster != null)
     {
         var newClusterGB = new StdMutableClusterGBlock();
         foreach (var subGB in sourceGBlock.cluster.blocks)
         {
             var convertedSub = listener.subBlockConverter.ConvertGBlock(subGB, listener).result;
             if (convertedSub != null)
             {
                 newClusterGB.subBlocks.Add(convertedSub);
             }
         }
         GBlockConvertUtility.ApplyModAndMeta(newClusterGB, sourceGBlock, listener);
         return(new GBlockConvertResult(true, newClusterGB));
     }
     else if (sourceGBlock.unit != null)
     {
         var newGUnit = new StdMutableGUnit {
             word = sourceGBlock.unit.word
         };
         GBlockConvertUtility.ApplyModAndMeta(newGUnit, sourceGBlock, listener);
         return(new GBlockConvertResult(true, newGUnit));
     }
     return(default(GBlockConvertResult));
 }
Exemple #6
0
 void AssetImplementCustomizer <ImplType> .EditAssetRequestFromGBlock(GrammarBlock gBlock, AssetRequestUnit assetReqUnit)
 {
     assetReqUnit.assettype = assetType;
     if (gBlock.unit.word == null)
     {
         assetReqUnit.attributes.Add(gBlock.unit.word);
     }
 }
Exemple #7
0
 AttributeMatchResult AttributeMatcher.MatchAttribue(GrammarBlock attribute)
 {
     if (GrammarBlockUtils.IsUnit(attribute, "system"))
     {
         return(AttributeMatchResult.POSITIVE);
     }
     return(AttributeMatchResult.NEUTRAL);
 }
Exemple #8
0
 //public Taker dependencyBehavers;
 AttributeMatchResult AttributeMatcher.MatchAttribue(GrammarBlock attribute)
 {
     if (actualBehaver != null)
     {
         return(actualBehaver.MatchAttribue(attribute));
     }
     return(GrammarBlockUtils.IsUnit(attribute, baseGUnit.word) ? AttributeMatchResult.POSITIVE : AttributeMatchResult.NEUTRAL);
 }
Exemple #9
0
 void Taker <GrammarBlock> .Take(GrammarBlock item)
 {
     GrammarBlockUtils.ForEach(item, "Unreadable", (gBlock) => {
         string result = fileName + " : ";
         GrammarBlockUtils.ForEachUnits((gBlock), (gUnit) => result += " " + gUnit.word);
         parent.parent.OnUnreadableFound.Invoke(result);
     });
     parent.parent.bAnalyzer.bAnlys.AnalyzeBehavior(item, this);
 }
Exemple #10
0
        AssetType AssetImplementer <AssetType> .PickImplementedAsset(GrammarBlock gBlock)
        {
            var found = customizer.implementedAssets.Find((elem) => customizer.MatchAsset(elem, gBlock));

            if (found != null)
            {
                return(customizer.ExtractAsset <AssetType>(found));
            }
            return(default(AssetType));
        }
Exemple #11
0
 void BehaverEquipper.EquipBehaverByAttribute(GrammarBlock attribute, BehaverEquipListener listener)
 {
     if (behaverPrefab != null)
     {
         if (behaverPrefab.behaver.MatchAttribue(attribute) == AttributeMatchResult.POSITIVE)
         {
             listener.OnEquipSubBehaver(behaverPrefab);
         }
     }
 }
        ContentType AssetMediator.GetImplementedAsset <ContentType>(GrammarBlock gBlock)
        {
            var implementer = implementerGetter.assetImplGetter.GetAssetImplementer <ContentType>(gBlock);

            if (implementer != null)
            {
                return(implementer.PickImplementedAsset(gBlock));
            }
            return(default(ContentType));
        }
Exemple #13
0
 public void SetPronounSolution(GrammarBlock sourceGBlock, GBlockConvertListener listener)
 {
     GrammarBlockUtils.DeepSeek(sourceGBlock, StdMetaInfos.nominalBlock.word, (gBlock) => {
         //acutual noun found
         if (!GrammarBlockUtils.HasMetaInfo(gBlock, StdMetaInfos.pronoun.word))
         {
             pronouc.dict["they"] = listener.subBlockConverter.ConvertGBlock(gBlock, listener).result;
         }
     }, true);
 }
Exemple #14
0
 AttributeMatchResult AttributeMatcher.MatchAttribue(GrammarBlock attribute)
 {
     if (attribute.unit != null)
     {
         return(FindDef(attribute.unit.word) != null ? AttributeMatchResult.POSITIVE : AttributeMatchResult.NEGATIVE);
     }
     else
     {
     }
     return(AttributeMatchResult.NEGATIVE);
 }
Exemple #15
0
 GBlockConvertResult GBlockConverter.ConvertGBlock(GrammarBlock sourceGBlock, GBlockConvertListener listener)
 {
     if (sourceGBlock.unit == null)
     {
         return(default(GBlockConvertResult));
     }
     if (sourceGBlock.unit.word.Equals(filteringString, System.StringComparison.CurrentCultureIgnoreCase))
     {
         return(new GBlockConvertResult(true, null));
     }
     return(default(GBlockConvertResult));
 }
Exemple #16
0
 AttributeMatchResult AttributeMatcher.MatchAttribue(GrammarBlock attribute)
 {
     if (baseBehaver != null)
     {
         return(baseBehaver.behaver.MatchAttribue(attribute));
     }
     if (attribute.unit != null)
     {
         return(nameOnCreate == attribute.unit.word ? AttributeMatchResult.POSITIVE : AttributeMatchResult.NEGATIVE);
     }
     return(AttributeMatchResult.NEGATIVE);
 }
Exemple #17
0
 GBlockConvertResult GBlockConverter.ConvertGBlock(GrammarBlock sourceGBlock, GBlockConvertListener listener)
 {
     foreach (var converter in converters)
     {
         var converted = converter.ConvertGBlock(sourceGBlock, listener);
         if (converted.didConvert)
         {
             return(converted);
         }
     }
     return(default(GBlockConvertResult));
 }
Exemple #18
0
 void Giver <IEnumerable <BehaverAgent>, GrammarBlock> .Give(GrammarBlock key, Taker <IEnumerable <BehaverAgent> > colletor)
 {
     if (GrammarBlockUtils.IsUnit(key, nameOnCreate))
     {
         var inst = Utilities.ConsistentInstantiate(seekingAgentPrefab);
         inst.behaverAttribute = seekingAgentPrefab.behaverAttribute;
         inst.gameObject.SetActive(true);
         colletor.Take(new List <BehaverAgent> {
             inst.behaverAgent
         });
     }
 }
Exemple #19
0
            void AvatarPhysicalizeInterface.Search(GrammarBlock attribute, Taker <IEnumerable <BehaverAgent> > asyncTaker)
            {
                var pickedAgents = new List <BehaverAgent>();

                foreach (var agent in agents)
                {
                    if (agent.MatchAttribue(attribute) == AttributeMatchResult.POSITIVE)
                    {
                        pickedAgents.Add(agent);
                    }
                }
                asyncTaker.Take(pickedAgents);
            }
                void Taker <GrammarBlock> .Take(GrammarBlock item)
                {
                    GrammarBlockUtils.ForEach(item, "Unreadable", (gBlock) => {
                        string result = "";
                        GrammarBlockUtils.ForEachUnits((gBlock), (gUnit) => result += " " + gUnit.word);
                        parent.parent.OnUnreadableFound.Invoke(result);
                    });
                    parent.parent.OnSucceedEvent.Invoke(new AnalysisResult {
                        gBlock = item, name = fileName, sourceText = sourceText
                    });

                    parent.parent.bAnalyzer.bAnlys.AnalyzeBehavior(item, this);
                }
Exemple #21
0
        AttributeMatchResult AttributeMatcher.MatchAttribue(GrammarBlock attribute)
        {
            var checker = new MultiMatchingGBlockVisitor {
                candidates = candidates
            };

            GrammarBlockUtils.VisitGrammarBlock(attribute, checker);
            if (checker.hasOne && !checker.hasUnmatch)
            {
                return(AttributeMatchResult.POSITIVE);
            }
            return(AttributeMatchResult.NEGATIVE);
        }
Exemple #22
0
		void Giver<IEnumerable<BehaverAgent>, GrammarBlock>.Give(GrammarBlock key, Taker<IEnumerable<BehaverAgent>> colletor) {
			if (GrammarBlockUtils.IsUnit(key, "button")) {
				GrammarBlockUtils.ForEachUnits(
					key.modifier,
					(unit) => {
						MonoBBehaverAgent newButton;
						nameToButtonDict[unit.word] = newButton = GameObject.Instantiate(textButtonPrefab);
						newButton.GetComponent<TextViewer>().SetText(unit.word);
						newButton.GetComponent<BehaverAgent>().TryFittingSpace(new Vector3(0.4f, 1f, 1));
						colletor.Take(new List<BehaverAgent> { newButton.behaverAgent });
					}
				);
			}
		}
 ClusterBehaverEventListener GetCluster(GrammarBlock grammarBlock)
 {
     if (grammarBlock.unit != null)
     {
         eventListenerDict.TryGetValue(grammarBlock.unit.word, out var cluster);
         if (cluster == null)
         {
             cluster = new ClusterBehaverEventListener();
             eventListenerDict.Add(grammarBlock.unit.word, cluster);
         }
         return(cluster);
     }
     return(null);
 }
        void AssetMediator.SeekAsset <ContentType>(GrammarBlock gBlock, Taker <ContentType> collLis)
        {
            var implementer = implementerGetter.assetImplGetter.GetAssetImplementer <ContentType>(gBlock);

            if (implementer != null)
            {
                implementer.SeekAsset(gBlock, new PrvtSeekLis <ContentType> {
                    collLis = collLis, parent = this
                });
                return;
            }
            //stub: should seek asset tool
            else
            {
                collLis.None();
            }
        }
Exemple #25
0
 GBlockConvertResult GBlockConverter.ConvertGBlock(GrammarBlock sourceGBlock, GBlockConvertListener listener)
 {
     if (sourceGBlock.unit == null)
     {
         return(default(GBlockConvertResult));
     }
     if (number.TryGetValue(sourceGBlock.unit.word, out var value))
     {
         if (value == null)
         {
             return(new GBlockConvertResult(true, null));
         }
         //doubt : using sub block converter?
         var newMGBlock = listener.subBlockConverter.ConvertGBlock(value, listener);
         GBlockConvertUtility.ApplyModAndMeta(newMGBlock.result, sourceGBlock, listener);
         return(new GBlockConvertResult(true, newMGBlock.result));
     }
     return(default(GBlockConvertResult));
 }
Exemple #26
0
 void BehaviorAnalyzer.AnalyzeBehavior(GrammarBlock behaviorExpressionByGBlock, Taker <BehaviorTriggerSet> listener)
 {
     //ensure behaver
     {
         var metaDepVis = new MetaInfoDependentGrammarBlockVisitor {
             doDeepSeek = true, doDeepSeekModifier = true
         };
         metaDepVis.metaToVis[StdMetaInfos.nominalBlock.word] = new EnsureBehaver {
             behaverGiver = stdGiver
         };
         GrammarBlockUtils.VisitGrammarBlock(behaviorExpressionByGBlock, metaDepVis);
     }
     //cereate behavior trigger
     {
         var rootTrigger    = new StdCompositeBehaviorTrigger();
         var namedCBTrigger = new Dictionary <string, CompositeBehaviorTrigger>();
         var processor      = new SentenceBlockRecursiveProcessor {
             subSentenceBehaviorTaker = rootTrigger, behaverSetCheck = bSetCheck, namedCBTriggers = namedCBTrigger, support = new StdBehaviorReadySupport {
                 assetMediator = assetMediator.assetMed
             }
         };
         processor.GrammarBlockCommon(behaviorExpressionByGBlock);
         if (rootTrigger.bTriggers.Count > 0 || namedCBTrigger.Count > 0)
         {
             List <NameAndBTrigger> namedTriggers = null;
             if (namedCBTrigger.Count > 0)
             {
                 namedTriggers = new List <NameAndBTrigger>();
                 foreach (var pair in namedCBTrigger)
                 {
                     namedTriggers.Add(new NameAndBTrigger {
                         name = pair.Key, bTrigger = pair.Value
                     });
                 }
             }
             var result = new BehaviorTriggerSet {
                 rootTrigger = rootTrigger.bTriggers.Count > 0 ? rootTrigger : null, namedTriggers = namedTriggers
             };
             listener.Take(result);
         }
     }
 }
Exemple #27
0
        void AssetImplementer <AssetType> .SeekAsset(GrammarBlock gBlock, AssetSeekSupportListener <AssetType> listener)
        {
            var found = (this as AssetImplementer <AssetType>).PickImplementedAsset(gBlock);

            if (found != null)
            {
                listener.collectorOnImplement.Take(found);
                return;
            }
            var newAssetReqUnit = new AssetRequestUnit {
            };

            customizer.EditAssetRequestFromGBlock(gBlock, newAssetReqUnit);
            listener.auInterfaceGiver.Give(
                newAssetReqUnit,
                new PrvtinterfaceColl {
                externalTaker = listener.collectorOnImplement, customizer = customizer
            }
                );
        }
Exemple #28
0
        GBlockConvertResult GBlockConverter.ConvertGBlock(GrammarBlock sourceGBlock, GBlockConvertListener listener)
        {
            if (!GrammarBlockUtils.IsUnit(sourceGBlock, "each"))
            {
                return(default(GBlockConvertResult));
            }
            if (!GrammarBlockUtils.IsUnit(sourceGBlock.modifier, "turn"))
            {
                return(default(GBlockConvertResult));
            }
            var newSubject = listener.subBlockConverter.ConvertGBlock(sourceGBlock.modifier, listener).result;
            var newVerb    = new StdMutableGUnit {
                word = "begin"
            };

            (newVerb as MutableGrammarBlock).AddMetaInfo(StdMetaInfos.verbalBlock);
            MutableClusterGrammarBlock newSV = new StdMutableClusterGBlock();

            newSV.AddBlock(newSubject);
            newSV.AddBlock(newVerb);
            newSV.AddMetaInfo(StdMetaInfos.conditionSV);
            return(new GBlockConvertResult(true, newSV));
        }
Exemple #29
0
 GBlockConvertResult GBlockConverter.ConvertGBlock(GrammarBlock sourceGBlock, GBlockConvertListener listener)
 {
     if (!GrammarBlockUtils.HasMetaInfo(sourceGBlock, StdMetaInfos.pronoun.word))
     {
         return(default(GBlockConvertResult));
     }
     if (dict.TryGetValue(sourceGBlock.unit.word, out var value))
     {
         var clusterGBC = new ClusterGBlockConverter {
             converters = new List <GBlockConverter> {
                 new GBlockConverter_GUnitFilter {
                     filteringString = StdMetaInfos.pronoun.word
                 },
                 listener.metaConverter
             }
         };
         GBlockConvertUtility.ApplyModAndMeta(value, sourceGBlock, listener, clusterGBC);
         return(new GBlockConvertResult {
             didConvert = true, result = value
         });
     }
     return(default(GBlockConvertResult));
 }
Exemple #30
0
 public static void ApplyModAndMeta(
     MutableGrammarBlock newBlock,
     GrammarBlock sourceBlock,
     GBlockConvertListener listener,
     GBlockConverter metaConv = null,
     GBlockConverter modConv  = null
     )
 {
     if (sourceBlock.metaInfo != null)
     {
         var metaLis = new MixedGBlockConvertListener {
             _subBlockConverter = listener.metaConverter,
             _metaConverter     = PassThroughGBlockConverter.instance,
             _modConverter      = PassThroughGBlockConverter.instance
         };
         var result = listener.metaConverter.ConvertGBlock(sourceBlock.metaInfo, metaLis);
         if (result.result != null)
         {
             newBlock.AddMetaInfo(result.result);
         }
     }
     if (sourceBlock.modifier != null)
     {
         var modLis = new MixedGBlockConvertListener {
             _subBlockConverter = listener.modConverter,
             _metaConverter     = listener.metaConverter,
             _modConverter      = listener.modConverter,
             _baseLisetner      = listener
         };
         var result = listener.modConverter.ConvertGBlock(sourceBlock.modifier, modLis);
         if (result.result != null)
         {
             newBlock.AddModifier(result.result);
         }
     }
     listener.AdditionalEdit(newBlock);
 }