UQdeco2800 / 2021-studio-7

6 stars 2 forks source link

Force a unique bed to belong the player. #166

Closed Jantoom closed 3 years ago

Jantoom commented 3 years ago

Nothing is changed in the prefabs.

When a room attempts to spawn a GridObject, it'll check if its method name is equal to "createBed". If so, it will stash the world position in the Floor instance for later. If not, it will spawn as usual.

When all prefab entities are spawned, only dynamic entities are left. This includes the player, other NPCs and now the bed (because its functionality is now only known at runtime). spawnBeds( ) handles bed spawning.

When called, a random stored bed position is chosen to be the player's bed position. A player bed is spawned there. All other stored bed positions will spawn a normal bed. The ObjectFactory methods responsible for these beds are createPlayerBed( ) and createNormalBed( ). If you want to do anything to the beds individually, do them here.