Skip to content

What is the Scene Manager

kytooooo edited this page Apr 23, 2020 · 5 revisions

As a game framework, it would have a scene & room management in the backend which provides scene & room services to the frontend.

Normally, the backend creates room base on the scene, one scene could have many rooms, the room’s feature and the rule would follow the scene.

enum ESceneType
{
  SCENE_NORMAL = 0;
  SCENE_SINGLE_CLONE = 1;
  SCENE_MULTI_CLONE = 2;
}
  • SCENE_NORMAL

This kind of scene is a public scene, it has only one room in the game world as the default room. Everyone can enter and leave the default room, all players can see each other if they entered this scene(default room).

  • SCENE_SINGLE_CLONE

This kind of scene is a private scene, the backend creates room base on this scene by player requirement. The player only can see himself, NPC belong to this room and the items created by this player. The backend will destroy the room if the player left the room.

  • SCENE_MULTI_CLONE

This kind of scene is like a group scene, the backend creates room base on the scene by player’s requirement, after that, the player who did the require will work as the owner of the room. Other players could enter and leave this room, the player can see each other if in the same room. Normally, the backend will destroy the room when all players left the room.

Scene management

Swapping between two scenes:

Below the chart shows the flow about how to swap from scene 1 (group 4) to scene 2 (group 6):

NFObjects in the scene are divided into 3 parts: Self Player(Self), Other Players(OP), Other Objects(OO). Clients will receive NFObjects data in 3 steps:

  • Receive NFObject Id: ObjectEnterEvent, ObjectLeaveEvent
  • Receive NFOBject Properties: PropertyEnterEvent
  • Receive NFOBject Records: RecordEnterEvent

Below steps shows the data flow swapping from the scene 1 (group 4) to the scene 2 (group 6):

  1. Stage 1 - Self leaves group 4 to group 0 (scene 1, group 4 -> scene 1, group 0)
  • Tell OP : Self id leaves.

  • Tell Self : OP id leaves.

  • Tell Self : OO id leaves.

  1. Stage 2 - Self enter scene 2 (scene 1, group 0 -> scene 2, group 0)
  • Tell Self : Property [SceneID] changed.
  1. Stage 3 - Self enter group 6 from group 0 (scene 2, group 0 -> scene 2, group 6)
  • Tell OP : Self id enters.

  • Tell Self : OP id enters.

  • Tell Self : OO id enters.

  • Tell Self : OP properties enter.

  • Tell Self : OP records enter.

  • Tell OP : Self properties enter.

  • Tell OP : Self records enter.