There's one thing in the Desing Flyweight Pattern that's making me really confused. Briefly, the standard says that to save memory in a situation where you use several similar objects, you use a factory that returns references to the same object in a flyweights pool instead of instantiating thousands of different objects.
I also saw that to generate data independence between each object, it is necessary to understand two concepts in this pattern: extrinsic and intrinsic data, which I also did not understand very well.
If using this pattern I am using references to the same object, will not have problems when changing the state of only one object and end up changing the state of all? For example: I have developed a game in which, using this pattern, I have the object port that is shared between all the "ports" of the game; the player controls a character that can open or close doors. If all doors in the game are referencing a same object, the game will not have the bug of when the character opens a door, inexplicably all the doors in the same scenario open?
I saw that this problem could be solved with the concept of extrinsic and intrinsic data, but in all the examples I read, I did not understand how this is implemented. How, really, is a state of state independence implemented between various flyweights?