Skip to content

Commit

Permalink
Rename AEnemyAI2 -> AEnemyAI
Browse files Browse the repository at this point in the history
  • Loading branch information
12joan committed Dec 29, 2024
1 parent c16f55c commit 775d908
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 20 deletions.
24 changes: 12 additions & 12 deletions Assets/src/AEnemyAI2.cs → Assets/src/AEnemyAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using UnityEngine;
using UnityEngine.Events;

public abstract class AEnemyAI2 : MonoBehaviour {
public abstract class AEnemyAI : MonoBehaviour {
protected virtual void WhileActive() { }
protected virtual void OnActivate() { }
protected virtual void OnDeactivate() { }
Expand All @@ -22,9 +22,9 @@ protected virtual AMovementEnemyAI InternalUseMovementAI() {

public bool IsActive = false;

private List<AEnemyAI2> ActiveChildAIs = new();
private List<AEnemyAI> ActiveChildAIs = new();
private EnemyAIHelper _Helper = null;
private AEnemyAI2 Parent = null;
private AEnemyAI Parent = null;

protected EnemyAIHelper Helper {
get {
Expand All @@ -46,9 +46,9 @@ public void UpdateActiveChildAIs() {
if (!IsActive)
return;

List<AEnemyAI2> childAIs = new();
List<AEnemyAI> childAIs = new();

Action<AEnemyAI2> useChild = (child) => {
Action<AEnemyAI> useChild = (child) => {
if (child) {
childAIs.Add(child);
}
Expand All @@ -57,18 +57,18 @@ public void UpdateActiveChildAIs() {
UseChildAIs(useChild);
useChild(InternalUseMovementAI());

foreach (AEnemyAI2 child in ActiveChildAIs.Except(childAIs)) {
foreach (AEnemyAI child in ActiveChildAIs.Except(childAIs)) {
DeactivateChildAI(child);
}

foreach (AEnemyAI2 child in childAIs.Except(ActiveChildAIs)) {
foreach (AEnemyAI child in childAIs.Except(ActiveChildAIs)) {
ActivateChildAI(child);
}

ActiveChildAIs = childAIs;
}

protected void Activate(AEnemyAI2 parent = null) {
protected void Activate(AEnemyAI parent = null) {
IsActive = true;
Parent = parent;
OnActivate();
Expand All @@ -83,23 +83,23 @@ public void Deactivate() {
OnDeactivate();
}

protected virtual void OnChildFinish(AEnemyAI2 child) {
protected virtual void OnChildFinish(AEnemyAI child) {
OnFinish();
}

protected void OnFinish() {
Parent?.OnChildFinish(this);
}

private void ActivateChildAI(AEnemyAI2 child) {
private void ActivateChildAI(AEnemyAI child) {
child.Activate(this);
}

private void DeactivateChildAI(AEnemyAI2 child) {
private void DeactivateChildAI(AEnemyAI child) {
child.Deactivate();
}

protected bool AnyDescendant(Func<AEnemyAI2, bool> condition) {
protected bool AnyDescendant(Func<AEnemyAI, bool> condition) {
if (condition(this))
return true;

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion Assets/src/AGenericEnemyAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
using System.Collections.Generic;
using UnityEngine;

public abstract class AGenericEnemyAI : AEnemyAI2 {
public abstract class AGenericEnemyAI : AEnemyAI {
}
2 changes: 1 addition & 1 deletion Assets/src/AMovementEnemyAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using UnityEngine;

public abstract class AMovementEnemyAI : AEnemyAI2 {
public abstract class AMovementEnemyAI : AEnemyAI {
public virtual float Speed {
get {
throw new System.NotImplementedException("Cannot get Speed on AI that doesn't implmenet it");
Expand Down
2 changes: 1 addition & 1 deletion Assets/src/CycleRandomAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protected override void OnActivate() {
ScheduleChangeAI();
}

protected override void OnChildFinish(AEnemyAI2 child) {
protected override void OnChildFinish(AEnemyAI child) {
ScheduleChangeAI();
}

Expand Down
6 changes: 3 additions & 3 deletions Assets/src/EnemyAIHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ public class EnemyAIHelper {
public GameObject GameObject;
public HitPoints HitPoints;

private AEnemyAI2 AI;
private AEnemyAI AI;
private MovementManager MovementManager;
private NavigateToPoint NavigateToPoint;
private CapsuleCollider2D CapsuleCollider2D;
private OnCollision OnCollisionComponent;
private bool MovementAllowed;
private List<AsyncTimer.EnqueuedEvent> Timers = new();

public EnemyAIHelper(AEnemyAI2 ai, GameObject gameObject, bool movementAllowed) {
public EnemyAIHelper(AEnemyAI ai, GameObject gameObject, bool movementAllowed) {
AI = ai;
GameObject = gameObject;
HitPoints = gameObject.GetComponent<HitPoints>();
Expand Down Expand Up @@ -145,7 +145,7 @@ private void ClearTimers() {
Timers.Clear();
}

// Called by AEnemyAI2
// Called by AEnemyAI
public void Deactivate() {
ClearTimers();
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/src/EnemyHitPointEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class EnemyHitPointEvents : MonoBehaviour {
public HitPoints HitPoints;

public Flash Flash;
public AEnemyAI2 RootAI;
public AEnemyAI RootAI;
public DeathAnimation DeathAnimation;
public Collider2D Collider;

Expand Down
2 changes: 1 addition & 1 deletion Assets/src/ScheduleAttackAI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected override void OnActivate() {
LastAttacked = -Mathf.Infinity;
}

protected override void OnChildFinish(AEnemyAI2 child) {
protected override void OnChildFinish(AEnemyAI child) {
if (child == AttackAI) {
StopAttack();
} else {
Expand Down

0 comments on commit 775d908

Please sign in to comment.