private static void debugAI(Transform transform) { #if UNITY_EDITOR var motor = transform.GetComponent <CharacterMotor>(); if (motor == null || !motor.IsAlive) { return; } var ai = transform.GetComponent <AIController>(); if (ai == null) { return; } var position = transform.position + Vector3.up * 2; var offset = -8; DebugText.Draw(ai.State.ToString(), position, 0, offset); offset += 16; DebugText.Draw(ai.StateReason.ToString(), position, 0, offset); offset += 16; if (ai.IsAlerted) { if (ai.Situation.WouldLikeToRetreat) { DebugText.Draw("Would like to retreat", position, 0, offset, Color.yellow); offset += 16; } if (motor.Target != null) { var actor = motor.Target.GetComponent <Actor>(); if (actor != null && actor.Side == ai.Actor.Side) { DebugText.Draw("Is aiming at a friend", position, 0, offset, Color.red); offset += 16; } } if (ai.Situation.IsAllowedToBeAggressive) { DebugText.Draw("Is aggressive", position, 0, offset, Color.green); offset += 16; } if (ai.IsAiming) { DebugText.Draw("Is aiming", position, 0, offset, Color.cyan); offset += 16; } if (ai.Situation.Threat != null) { if (ai.Situation.CanSeeTheThreat) { Debug.DrawLine(ai.Situation.CurrentPosition, ai.Situation.ThreatGroundPosition, Color.green); } else { Debug.DrawLine(ai.Situation.CurrentPosition, ai.Situation.ThreatGroundPosition, Color.red); } } else { Debug.DrawLine(ai.Situation.CurrentPosition, ai.Situation.ThreatGroundPosition, Color.red); } } if (AIUtil.IsMovingState(ai.State)) { Debug.DrawLine(ai.Situation.CurrentPosition, ai.Situation.TargetPosition, Color.blue); } #endif }