public BehaviourTreeBranchBuilder(BehaviorTreeIDEnum behaviourTreeType, string path, BehaviourInjectionOrder injectionOrder)
 {
     this.BehaviourTreeType = behaviourTreeType;
     this.Path           = path;
     this.PathNodeNames  = this.Path.Split('.');
     this.InjectionOrder = injectionOrder;
 }
Exemple #2
0
 public static void Postfix(BehaviorTree __instance, AbstractActor ___unit, BehaviorTreeIDEnum ___behaviorTreeIDEnum)
 {
     if (___behaviorTreeIDEnum != BehaviorTreeIDEnum.DoNothingTree)
     {
         Main.LogDebug($"[BehaviourTreeInitRootNodePatch Postfix] Patching InitRootNode for unit '{___unit.DisplayName}' with behaviour tree id '{___behaviorTreeIDEnum}'");
         Init(__instance, ___unit, ___behaviorTreeIDEnum);
     }
 }
Exemple #3
0
 public void AddCustomBehaviourBranch(BehaviorTreeIDEnum behaviourTreeType, string path, BehaviourTreeBranchBuilder customBranch)
 {
     if (!injectionBranchRoots.ContainsKey(behaviourTreeType))
     {
         injectionBranchRoots.Add(behaviourTreeType, new List <BehaviourTreeBranchBuilder>());
     }
     injectionBranchRoots[behaviourTreeType].Add(customBranch);
 }
 public static void Postfix(BehaviorTree __instance, AbstractActor ___unit, BehaviorTreeIDEnum ___behaviorTreeIDEnum)
 {
     if (MissionControl.Instance.CurrentContract != null && MissionControl.Instance.AllowMissionControl() && ___behaviorTreeIDEnum != BehaviorTreeIDEnum.DoNothingTree)
     {
         Main.LogDebug($"[BehaviourTreeInitRootNodePatch Postfix] Patching InitRootNode for unit '{___unit.DisplayName}' with behaviour tree id '{___behaviorTreeIDEnum}'");
         Init(__instance, ___unit, ___behaviorTreeIDEnum);
     }
 }
Exemple #5
0
        public static void Init(BehaviorTree behaviourTree, AbstractActor unit, BehaviorTreeIDEnum behaviourTreeType)
        {
            AiManager aiManager = AiManager.Instance;

            if (!(unit is Turret))
            {
                aiManager.LoadCustomBehaviourSequences(behaviourTree, behaviourTreeType, unit);
            }
        }
Exemple #6
0
        protected override BehaviorTreeResults Tick()
        {
            int currentRound = tree.battleTechGame.Combat.TurnDirector.CurrentRound;
            int currentPhase = tree.battleTechGame.Combat.TurnDirector.CurrentPhase;
            int actionCount  = (AiUtils.IsOnFirstAction(unit)) ? 1 : 2;

            BehaviorTreeIDEnum behaviorTreeType = (BehaviorTreeIDEnum)AccessTools.Field(typeof(BehaviorTree), "behaviorTreeIDEnum").GetValue(this.tree);

            Main.LogDebug($"[AI] [Round '{currentRound}' Phase '{currentPhase}' Unit Action '{actionCount}'] ['{unit.team.Name}' unit '{unit.DisplayName}' AI type '{behaviorTreeType}'] {this.logMessage}");
            return(new BehaviorTreeResults(requestedState));
        }
Exemple #7
0
 public void LoadCustomBehaviourSequences(BehaviorTree behaviourTree, BehaviorTreeIDEnum behaviourTreeType, AbstractActor unit)
 {
     if (injectionBranchRoots.ContainsKey(behaviourTreeType))
     {
         List <BehaviourTreeBranchBuilder> customBehaviourBranches = injectionBranchRoots[behaviourTreeType];
         foreach (BehaviourTreeBranchBuilder customBehaviourBranch in customBehaviourBranches)
         {
             NodeSearchResult nodeSearchResults = FindNode(behaviourTree, customBehaviourBranch);
             if (nodeSearchResults != null)
             {
                 AddCustomBehaviourVariableScopes(unit);
                 customBehaviourBranch.Build(behaviourTree, nodeSearchResults.ParentNode, nodeSearchResults.NodeIndex, nodeSearchResults.Node, unit);
             }
         }
     }
 }
 public static BehaviorTree MakeBehaviorTree(GameInstance game, AbstractActor unit, BehaviorTreeIDEnum treeID)
 {
     return(new BehaviorTree(unit, game, treeID));
 }
 public FollowLanceBranchBuilder(BehaviorTreeIDEnum behaviourTreeType, string path, BehaviourInjectionOrder injectionOrder) : base(behaviourTreeType, path, injectionOrder)
 {
     Main.LogDebug("[FollowLanceBranchBuilder] Created CustomBehaviourTreeBranch");
 }