Skip to content

Commit ff6ac71

Browse files
committed
Cleaning RX code
1 parent b123f35 commit ff6ac71

File tree

5 files changed

+9
-13
lines changed

5 files changed

+9
-13
lines changed

Assets/Scripts/AI/BehaviorManager.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ public void Reinitialize()
6161
{
6262
//TODO: Change to runner extension (?)
6363
Runner = BehaviorTreeFile.LoadFromJSON(this);
64-
65-
6664
if(spliceNewIntoTree) SpliceIntoRunner();
6765
initialized = true;
6866
}
@@ -108,7 +106,6 @@ public bool SpliceIntoRunner()
108106
Runner.AddChild(newBehavior);
109107
}
110108
}
111-
112109
return true;
113110
}
114111
else return false;

Assets/Scripts/AI/Components/ParallelRunner.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ namespace Assets.Scripts.AI.Components
1212
[Description("Runs all children at same time. Fails if NumFailures are >0 and children failed reach that number. Succeeds otherwise.")]
1313
public class ParallelRunner : BehaviorComponent
1414
{
15-
1615
/// <summary>
1716
/// Number of times the children return fail before the parallel runner returns in a fail state.
1817
/// 0 means ignore number of failures.

Assets/Scripts/AI/Components/Sequencer.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@ public override IEnumerator Tick(WaitForSeconds delayStart = null)
2424
.Subscribe();
2525

2626
yield return delayStart;
27-
CurrentState = (BehaviorState.Running);
27+
CurrentState = BehaviorState.Running;
2828
foreach (BehaviorTreeElement behavior in Children)
2929
{
3030
if (CurrentState != BehaviorState.Running) yield break;
31-
3231
yield return behavior.Tick().ToObservable()
33-
.Do(_ =>
32+
.Do(_ =>
3433
{
3534
if (behavior.CurrentState == BehaviorState.Fail)
3635
{

Assets/Scripts/AI/Nodes/BehaviorNode.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ namespace Assets.Scripts.AI.Nodes
77
public abstract class BehaviorNode : BehaviorTreeElement
88
{
99
public BehaviorNode(string name, int depth, int id) : base(name, depth, id)
10-
{
11-
}
10+
{}
1211

1312
public override IEnumerator Tick(WaitForSeconds delayStart = null)
1413
{

Assets/Scripts/AI/Nodes/MoveEnemyIfCloseToPlayer.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,16 @@ public class MoveEnemyIfCloseToPlayer : BehaviorNode
2121
/// This can be very inefficient and typically is not needed. Default is 10.
2222
/// </summary>
2323
[SerializeField]
24-
[Description("Frames between updating player list in the scene. At 0 this ticks every frame which is typically not needed and is very inefficient.")]
24+
[Description("Frames between updating player list in the scene. " +
25+
"At 0 this ticks every frame which is typically not needed and is very inefficient.")]
2526
public int UpdatePlayersTickInterval = 20;
2627

2728
/// <summary>
2829
/// Number of ticks between updating current position. Default is 5.
2930
/// </summary>
3031
[SerializeField]
31-
[Description("Frames between updating current position in the scene. At 0 this ticks every frame which is typically not needed and can be inefficient.")]
32+
[Description("Frames between updating current position in the scene. " +
33+
"At 0 this ticks every frame which is typically not needed and can be inefficient.")]
3234
public int UpdateSelfPositionTickInterval = 5;
3335

3436
public MoveEnemyIfCloseToPlayer(string name, int depth, int id) : base(name, depth, id)
@@ -59,14 +61,14 @@ public override IEnumerator Tick(WaitForSeconds delayStart = null)
5961
CurrentState = (BehaviorState.Running);
6062
float step = (MoveSpeed / directionOfTravel.magnitude) * Time.fixedDeltaTime;
6163
float t = 0;
62-
while (t <= 1.0f)
64+
while(t <= 1.0f)
6365
{
6466
t += step; // Goes from 0 to 1, incrementing by step each time
6567
myPos.position = Vector3.Lerp(currentPosition, targetPosition, t); // Move objectToMove closer to b
6668
yield return new WaitForFixedUpdate(); // Leave the routine and return here in the next frame
6769
}
6870
}
69-
CurrentState = (BehaviorState.Success);
71+
CurrentState = BehaviorState.Success;
7072
yield return null;
7173
}
7274

0 commit comments

Comments
 (0)