The faction system is well integrated into the game and multifaction makes good use of it. Most of the work needs to be done in places where vanilla expects only one (player) faction.
Basically, RimWorld keeps a global variable Faction.OfPlayer
storing the single player faction.
Multiplayer creates additional player factions and then changes the value of this variable when necessary.
The value of OfPlayer
then depends on the context in which code is executing (you could say it's a form of dynamic scoping).
This "faction context" is set, for example, to the a colonist's faction when it begins executing its logic and then restored. In code:
void Pawn.Tick() {