This is not always true, but mostly headers contain what the name says:
Player.h = Player class
Pet.h = Pet class
And should be used like tommy said, when necessary.
If you want to use the player class, but not the functions etc that it holds,
you can do that by declaring the class like this before using it:
If you code and see something missing like Pet, its pretty easy to guess that its probably Pet.h or something similar by name.
// now we can create a variable to Player without including the file :D
VS is able to suggest you stuff when you write the start like : #include "Pe
Headers give you access to the declared and defined things in them and other headers the headers include in themselves.
In your example you may need to include:
World.h for sWorld since singletons are classes and you need their method declarations to use their methods
ScriptMgr.h for PlayerScript since PlayerScript is a class that is defined there.
Player.h for Player class and its method usage
A few useful files you could check out: Common.h has most of the map, set, vector and Defines.h has types like uint32 etc defined. However Common.h also includes Defines.h, so just add Common.h.
Sometimes you may only need Player.h for example, since it could include World.h and ScriptMgr.h.
You might want to play it safe sometimes incase for example the headers for Player.h change and your code will then be erroring due to missing includes.
Your build might be going fine since you are using the precompiled header.
Precompiled header is a header file that has a lot of header code in it, which is included everywhere.
Having it compiled will speed up the compiling process of files that use those included files.
As a side effect you may not need to include everything you actually use in your script.
If you check TC commits, you should see often commits that say something like "Fixed build without precompiled header".
Those commits include files that should be included, but are not, and they are not noticed missing unless you build for example without the precompiled header files.
It is probably a good idea to know a bit about what files you actually need if you make some internal files, however for scripts its mostly needed just to include the ScriptPCH.h, which contains most common script and other headers and as the name says, is a pch so the precompiled header is used if set so in Cmake.
Correct me if I am wrong. I have not studied or referenced a textbook myself.