private WorldSpeechBubble getSpeechBubble(long sessionId)
        {
            WorldSpeechBubble worldSpeechBubble = null;

            if (activeSpeechBubbles.ContainsKey(sessionId))
            {
                worldSpeechBubble = activeSpeechBubbles[sessionId];
            }
            else
            {
                GameObject gameObject = worldSpeechBubblePool.Spawn();
                if (gameObject != null)
                {
                    worldSpeechBubble = gameObject.GetComponent <WorldSpeechBubble>();
                    if (worldSpeechBubble == null)
                    {
                        throw new InvalidOperationException("WorldChatController.getSpeechBubble: Did not get speech bubble from pool");
                    }
                    gameObject.transform.SetParent(base.transform, worldPositionStays: false);
                    gameObject.transform.localRotation = Quaternion.identity;
                    worldSpeechBubble.OnCompleteEvent += onSpeechBubbleComplete;
                    activeSpeechBubbles.Add(sessionId, worldSpeechBubble);
                }
            }
            return(worldSpeechBubble);
        }
        private void showChatMessage(long sessionId, string message, int sizzleclipID, bool isAwaitingModeration = false, bool isLocalChatPhrase = false)
        {
            bool flag = dataEntityCollection.IsLocalPlayer(sessionId);

            if (!string.IsNullOrEmpty(message))
            {
                WorldSpeechBubble speechBubble = getSpeechBubble(sessionId);
                if (isAwaitingModeration)
                {
                    if (isLocalChatPhrase)
                    {
                        speechBubble.ShowChatPhraseMessage(sessionId, message);
                    }
                    else
                    {
                        speechBubble.ShowAwaitingModerationMessage(sessionId, message);
                    }
                }
                else if (!isLocalChatPhrase || !flag)
                {
                    speechBubble.ShowChatMessage(sessionId, message);
                }
            }
            if (sizzleclipID > 0 && (isAwaitingModeration || !flag))
            {
                Transform avatar = getAvatar(sessionId);
                if (avatar != null && LocomotionUtils.CanPlaySizzle(avatar.gameObject))
                {
                    Animator component = avatar.GetComponent <Animator>();
                    component.SetInteger(AnimationHashes.Params.Emote, sizzleclipID);
                    component.SetTrigger(AnimationHashes.Params.PlayEmote);
                }
            }
        }
        public WorldSpeechBubble GetActiveSpeechBubble(long sessionID)
        {
            WorldSpeechBubble value = null;

            activeSpeechBubbles.TryGetValue(sessionID, out value);
            return(value);
        }
        private void showActiveTyping(long sessionId)
        {
            WorldSpeechBubble speechBubble = getSpeechBubble(sessionId);

            if (speechBubble != null)
            {
                speechBubble.SetChatActive(sessionId);
            }
        }
 private bool onPlayerLeaveRoom(WorldServiceEvents.PlayerLeaveRoomEvent evt)
 {
     if (isSpeechBubbleActive(evt.SessionId))
     {
         WorldSpeechBubble worldSpeechBubble = activeSpeechBubbles[evt.SessionId];
         worldSpeechBubblePool.Unspawn(worldSpeechBubble.gameObject);
         worldSpeechBubble.OnCompleteEvent -= onSpeechBubbleComplete;
         activeSpeechBubbles.Remove(evt.SessionId);
     }
     return(false);
 }
 private bool onChatActivityCancelReceived(ChatServiceEvents.ChatActivityCancelReceived evt)
 {
     if (isSpeechBubbleActive(evt.SessionId))
     {
         WorldSpeechBubble speechBubble = getSpeechBubble(evt.SessionId);
         if (speechBubble != null)
         {
             speechBubble.SetChatInactive();
         }
     }
     return(false);
 }
 private bool onChatMessageBlockedReceived(ChatServiceEvents.ChatMessageBlockedReceived evt)
 {
     if (isSpeechBubbleActive(base.localSessionId))
     {
         WorldSpeechBubble speechBubble = getSpeechBubble(base.localSessionId);
         if (speechBubble != null)
         {
             speechBubble.SetChatBlocked(base.localSessionId);
         }
     }
     return(false);
 }
 private bool onSendChatActivityCancel(ChatServiceEvents.SendChatActivityCancel evt)
 {
     if (isSpeechBubbleActive(base.localSessionId))
     {
         WorldSpeechBubble speechBubble = getSpeechBubble(base.localSessionId);
         if (speechBubble != null)
         {
             speechBubble.SetChatInactive();
         }
     }
     return(false);
 }
 private void onSpeechBubbleComplete(WorldSpeechBubble speechBubble)
 {
     worldSpeechBubblePool.Unspawn(speechBubble.gameObject);
     speechBubble.OnCompleteEvent -= onSpeechBubbleComplete;
     activeSpeechBubbles.Remove(speechBubble.SessionId);
 }
        private void setSpeechBubbleScale(WorldSpeechBubble bubble, Transform avatarTransform)
        {
            float magnitude = (avatarTransform.position - cameraTransform.position).magnitude;

            bubble.transform.GetChild(0).transform.localScale = DEFAULT_BUBBLE_SCALE * (1f - (magnitude - DefaultDistance) * ScaleFactor);
        }