Alright, I ACTUALLY figured out how Foxy works this time.
Foxy has a timer for how long she has to wait to take a movement opportunity. If Foxy fails a movement opportunity due to ai level being too low, the timer is reset to 15 seconds. If she passes that check but the player's camera is up, the timer is reset to 25-48 seconds (random). If she passes both of those, she will either advance or leave pirate cove. If she just advances, the timer is reset to 15 seconds.
If she escapes, she'll wait 15 seconds (or until you open the hall cam) to start running down the hall. If you opened the hall cam, she will take 2 seconds to get to your room. Otherwise, she'll take 1.2 seconds.
When she gets to your door, she'll knock 3 times, draining a total of 3, 6, 9, or 12 power (depending on how many times she's visited). If your door is open at any point during the knocking, she will enter your room. You can time when to open your door by imagining a 4th knock in rhythm with the others and opening your door AFTER that imaginary 4th knock.
Then, she gets sent all the way back to the start with a 25-48 second timer.
As for stunlocking Foxy, it's impossible without keeping the camera up at all times. This means that a strategy to deal with foxy relies on probabilities derived from observing Foxy's current state and necessitates risk.