Advertisement
Guest User

Example Plan

a guest
Apr 28th, 2025
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.92 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using Unity.Entities.UniversalDelegates;
  5. using System;
  6. public class PlanFlank : PseudoPlannerBasePlan
  7. {
  8.     int prevhealth;
  9.     int waypointIndex = 0;
  10.     Vector3[] waypoints;
  11.     public override void Enter()
  12.     {
  13.         var path = planner.TargetManager.FlankPath();
  14.         if (path == null)
  15.         {
  16.             planner.SwitchPlan(new PlanInvestigate());
  17.             return;
  18.         }
  19.         Debug.Log(planner.gameObject.name + " is flanking!");
  20.         waypoints = path;
  21.         waypoints[2] = planner.TargetManager.Target.position;
  22.        
  23.         States = new List<BotBaseState>()
  24.         {
  25.                new BotWalkTowards(),
  26.                new BotWalkTowards(),
  27.                new BotWalkTowardsTarget(),
  28.         };
  29.         AdvanceConditions = new List<List<Func<bool>>>()
  30.         {
  31.              new ()
  32.              {
  33.                 () => planner.flags.CloserThan(waypoints[0], 0.5f)
  34.              },
  35.              new ()
  36.              {
  37.                 () => planner.flags.CloserThan(waypoints[1], 0.5f)
  38.              },
  39.              new (),
  40.         };
  41.         base.Enter();
  42.         prevhealth = planner.flags.hitboxManager.Health;
  43.         planner.botMotor.WalkPoint = waypoints[waypointIndex];
  44.     }
  45.     public override void Run()
  46.     {
  47.         base.Run();
  48.         AutoEvaluateFiringMode();
  49.     }
  50.     public override void MonitorAdvance()
  51.     {
  52.         if (ConditionsSuccesful(0))
  53.         {
  54.             waypointIndex += 1;
  55.             planner.botMotor.WalkPoint = waypoints[waypointIndex];
  56.         }
  57.         base.MonitorAdvance();
  58.     }
  59.    
  60.     public override void Exit()
  61.     {
  62.     }
  63.    
  64.     public override void MonitorBreak()
  65.     {
  66.         if (index == 2 && planner.flags.CloserThan(planner.TargetManager.Target, 10f))
  67.         {
  68.             planner.SwitchPlan(new PlanCombat());
  69.         }
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement