private void DecodeAndEnqueue(string payload) { ProfilingEvents.OnMessageDecodeStart?.Invoke("Misc"); string sceneId; string message; string messageTag; PB_SendSceneMessage sendSceneMessage; if (!MessageDecoder.DecodePayloadChunk(payload, out sceneId, out message, out messageTag, out sendSceneMessage)) { return; } QueuedSceneMessage_Scene queuedMessage; if (sceneMessagesPool.Count > 0) { queuedMessage = sceneMessagesPool.Dequeue(); } else { queuedMessage = new QueuedSceneMessage_Scene(); } MessageDecoder.DecodeSceneMessage(sceneId, message, messageTag, sendSceneMessage, ref queuedMessage); EnqueueSceneMessage(queuedMessage); ProfilingEvents.OnMessageDecodeEnds?.Invoke("Misc"); }
public void EnqueueSceneMessage(QueuedSceneMessage_Scene message) { bool isGlobalScene = WorldStateUtils.IsGlobalScene(message.sceneId); Environment.i.messaging.manager.AddControllerIfNotExists(this, message.sceneId); Environment.i.messaging.manager.Enqueue(isGlobalScene, message); }
public void EnqueueSceneMessage(QueuedSceneMessage_Scene message) { Environment.i.world.state.TryGetScene(message.sceneId, out ParcelScene scene); Environment.i.messaging.manager.AddControllerIfNotExists(this, message.sceneId); Environment.i.messaging.manager.Enqueue(scene is GlobalScene, message); }
public bool ProcessMessage(QueuedSceneMessage_Scene msgObject, out CustomYieldInstruction yieldInstruction) { string sceneId = msgObject.sceneId; string method = msgObject.method; yieldInstruction = null; IParcelScene scene; bool res = false; IWorldState worldState = Environment.i.world.state; DebugConfig debugConfig = DataStore.i.debugConfig; if (worldState.loadedScenes.TryGetValue(sceneId, out scene)) { #if UNITY_EDITOR if (debugConfig.soloScene && scene is GlobalScene && debugConfig.ignoreGlobalScenes) { return(false); } #endif if (!scene.GetSceneTransform().gameObject.activeInHierarchy) { return(true); } #if UNITY_EDITOR OnMessageProcessInfoStart?.Invoke(sceneId, method); #endif ProfilingEvents.OnMessageProcessStart?.Invoke(method); ProcessMessage(scene as ParcelScene, method, msgObject.payload, out yieldInstruction); ProfilingEvents.OnMessageProcessEnds?.Invoke(method); #if UNITY_EDITOR OnMessageProcessInfoEnds?.Invoke(sceneId, method); #endif res = true; } else { res = false; } sceneMessagesPool.Enqueue(msgObject); return(res); }
public static void DecodeSceneMessage(string sceneId, string method, string tag, PB_SendSceneMessage sendSceneMessage, ref QueuedSceneMessage_Scene queuedMessage) { queuedMessage.type = QueuedSceneMessage.Type.SCENE_MESSAGE; queuedMessage.sceneId = sceneId; queuedMessage.method = method; queuedMessage.tag = tag; switch (method) { case MessagingTypes.INIT_DONE: queuedMessage.payload = new Protocol.SceneReady(); break; case MessagingTypes.QUERY: QueryMessage query = new QueryMessage(); DecodeQueryMessage(sendSceneMessage.Query.QueryId, sendSceneMessage.Query.Payload, ref query); queuedMessage.payload = query; break; case MessagingTypes.ENTITY_CREATE: queuedMessage.payload = Protocol.CreateEntity.FromPB(sendSceneMessage.CreateEntity); break; case MessagingTypes.ENTITY_DESTROY: queuedMessage.payload = Protocol.RemoveEntity.FromPB(sendSceneMessage.RemoveEntity); break; case MessagingTypes.ENTITY_REPARENT: queuedMessage.payload = Protocol.SetEntityParent.FromPB(sendSceneMessage.SetEntityParent); break; case MessagingTypes.SHARED_COMPONENT_CREATE: queuedMessage.payload = Protocol.SharedComponentCreate.FromPB(sendSceneMessage.ComponentCreated); break; case MessagingTypes.SHARED_COMPONENT_ATTACH: queuedMessage.payload = Protocol.SharedComponentAttach.FromPB(sendSceneMessage.AttachEntityComponent); break; case MessagingTypes.SHARED_COMPONENT_UPDATE: queuedMessage.payload = Protocol.SharedComponentUpdate.FromPB(sendSceneMessage.ComponentUpdated); break; case MessagingTypes.SHARED_COMPONENT_DISPOSE: queuedMessage.payload = Protocol.SharedComponentDispose.FromPB(sendSceneMessage.ComponentDisposed); break; case MessagingTypes.ENTITY_COMPONENT_CREATE_OR_UPDATE: queuedMessage.payload = Protocol.EntityComponentCreateOrUpdate.FromPB(sendSceneMessage.UpdateEntityComponent); break; case MessagingTypes.ENTITY_COMPONENT_DESTROY: queuedMessage.payload = Protocol.EntityComponentDestroy.FromPB(sendSceneMessage.ComponentRemoved); break; case MessagingTypes.OPEN_NFT_DIALOG: queuedMessage.payload = Protocol.OpenNftDialog.FromPB(sendSceneMessage.OpenNFTDialog); break; case MessagingTypes.OPEN_EXTERNAL_URL: queuedMessage.payload = Protocol.OpenExternalUrl.FromPB(sendSceneMessage.OpenExternalUrl); break; } }
public void Enqueue(bool isUiBus, QueuedSceneMessage_Scene queuedMessage) { messagingControllers[queuedMessage.sceneId].Enqueue(isUiBus, queuedMessage, out MessagingBusType busId); }
public bool ProcessMessage(QueuedSceneMessage_Scene msgObject, out CustomYieldInstruction yieldInstruction) { yieldInstruction = null; return(true); }
public void Enqueue(bool isUiBus, QueuedSceneMessage_Scene queuedMessage, out MessagingBusType busType) { busType = MessagingBusType.NONE; QueueMode queueMode = QueueMode.Reliable; // If current scene is the Global Scene, the bus id should be UI if (isUiBus) { busType = MessagingBusType.UI; } else if (currentQueueState == QueueState.Init) { busType = MessagingBusType.INIT; } else { busType = MessagingBusType.SYSTEM; } // Check if the message type is an EntityComponentCreateOrUpdate if (queuedMessage.payload is Protocol.EntityComponentCreateOrUpdate) { // We need to extract the entityId and the classId from the tag. // The tag format is "entityId_classId", i.e: "E1_2". GetEntityIdAndClassIdFromTag(queuedMessage.tag, out int classId); // If it is a transform update, the queue mode is Lossy if (classId == (int)CLASS_ID_COMPONENT.TRANSFORM) { queueMode = QueueMode.Lossy; } } else if (queuedMessage.payload is Protocol.QueryPayload) { busType = MessagingBusType.UI; queueMode = QueueMode.Lossy; } else if (queuedMessage.payload is Protocol.SceneReady) { // When a INIT DONE message is enqueued, the next messages should be // enqueued in SYSTEM message bus, but we don't process them until // scene started has been processed currentQueueState = QueueState.Systems; } switch (busType) { case MessagingBusType.INIT: initBus.Enqueue(queuedMessage, queueMode); break; case MessagingBusType.SYSTEM: systemBus.Enqueue(queuedMessage, queueMode); break; case MessagingBusType.UI: uiBus.Enqueue(queuedMessage, queueMode); break; } }