Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI] Merge patch-atomic-adding-to-the-ai-brain-12-28-2024-1735425371 into dev #3646

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/mmextensions/mmextensions/Ai/AiAllyBrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class AiAllyBrain : AIBrain
private AIDecisionDetectTargetRadius2D detectPlayerDecision;
private AIDecisionDetectTargetRadius2D detectEnemyDecision;
private AIDecisionDistanceToTarget distanceToTargetDecision;
private AIDecisionDistanceToTarget distanceToTargetFarDecision;
private AIDecisionTargetIsAlive targetIsAliveDecision;
private AIDecisionTimeInState timeInStateDecision;
private CharacterHandleWeapon handleWeapon;
Expand Down Expand Up @@ -86,12 +87,16 @@ protected override void Awake()

protected virtual void SetupDecisionsAndActions()
{
detectPlayerDecision = CreateDetectTarget2DDecision(PLAYER_LAYER_INT, 20f);
detectPlayerDecision = CreateDetectTarget2DDecision(PLAYER_LAYER_INT, 100f, false);
detectEnemyDecision = CreateDetectTarget2DDecision(ENEMY_LAYER_INT, 20f);
distanceToTargetDecision = CreateDistanceToTarget2DDecision(
2f,
AIDecisionDistanceToTarget.ComparisonModes.LowerThan
);
distanceToTargetFarDecision = CreateDistanceToTarget2DDecision(
4f,
AIDecisionDistanceToTarget.ComparisonModes.LowerThan
);
targetIsAliveDecision = CreateTargetIsAliveDecision();
timeInStateDecision = CreateTimeInStateDecision(2f, 2f);
}
Expand Down Expand Up @@ -137,7 +142,8 @@ private AIState CreateFollowPlayerState()

followState.Transitions = new AITransitionsList
{
new AITransition() { Decision = detectEnemyDecision, TrueState = "ChaseEnemy" }
new AITransition() { Decision = detectEnemyDecision, TrueState = "ChaseEnemy" },
new AITransition() { Decision = distanceToTargetFarDecision, TrueState = "Idle" }
};

return followState;
Expand Down Expand Up @@ -184,12 +190,14 @@ private AIState CreateAttackState()

private AIDecisionDetectTargetRadius2D CreateDetectTarget2DDecision(
int targetLayerInt,
float radius
float radius,
bool obstacleDetection = true
)
{
AIDecisionDetectTargetRadius2D detectTargetDecision =
gameObject.AddComponent<AIDecisionDetectTargetRadius2D>();
detectTargetDecision.TargetLayer = 1 << targetLayerInt;
detectTargetDecision.ObstacleDetection = obstacleDetection;
detectTargetDecision.Radius = radius;

return detectTargetDecision;
Expand Down
Loading