Decision Tree of Arduplane Flight Stage

Hello Everyone,

I am new at Ardupilot Dev. I have tried to figure out how flight stage set automatically but i havent understood yet. Because there are a lot of things about stage and mode. For example in main section there is a “takeoff.cpp” and “mode_takeoff.cpp.” in main section or there is a landing library in Libraries. Where should i look for decision making about setting flight stage? Is there any decision tree about that?

Thanks.