2 using System.Collections.Generic;
5 using Microsoft.Xna.Framework;
11 public readonly List<BallastFloraBranch>
TargetBranches =
new List<BallastFloraBranch>();
14 private bool isFinished;
23 public override void Enter() { }
27 protected override void Grow()
31 if (!Behavior.IgnoredTargets.ContainsKey(
Target))
33 Behavior.IgnoredTargets.Add(
Target, 10);
49 private void GrowTowardsTarget()
51 bool succeeded =
false;
53 List<BallastFloraBranch> newList =
new List<BallastFloraBranch>(
TargetBranches);
56 if (branch.FailedGrowthAttempts > 8 || branch.
DisconnectedFromRoot || !branch.CanGrowMore()) {
continue; }
61 if (branch.IsSideBlocked(side)) {
continue; }
63 succeeded |= Behavior.TryGrowBranch(branch, side, out List<BallastFloraBranch> newBranches);
66 foreach (BallastFloraBranch newBranch
in newBranches)
69 worldRect.Location = Behavior.GetWorldPosition().ToPoint() + worldRect.Location;
70 if (Behavior.BranchContainsTarget(newBranch,
Target))
72 Behavior.ClaimTarget(
Target, newBranch);
81 if (!Behavior.IgnoredTargets.ContainsKey(
Target))
83 Behavior.IgnoredTargets.Add(
Target, 1);
90 private TileSide GetClosestSide(VineTile tile, Vector2 targetPos)
92 var (distX, distY) = tile.Position + Behavior.GetWorldPosition() - targetPos;
93 int absDistX = (int) Math.Abs(distX), absDistY = (int) Math.Abs(distY);
95 return absDistX > absDistY ? distX > 0 ? TileSide.Left : TileSide.Right : distY > 0 ? TileSide.Bottom : TileSide.Top;
bool DisconnectedFromRoot
GrowToTargetState(BallastFloraBehavior behavior, BallastFloraBranch starter, Item target)
readonly List< BallastFloraBranch > TargetBranches
override ExitState GetState()