示例#1
0
        public void OnPlayerJoined(Player player)
        {
            var apiUser = player?.field_Private_APIUser_0;

            if (apiUser == null)
            {
                return;
            }
            if (APIUser.CurrentUser.id == apiUser.id)
            {
                myObservedLocalPlayerJoin = true;
                myLastLevelLoad           = Environment.TickCount;
            }

            if (!myObservedLocalPlayerJoin || Environment.TickCount - myLastLevelLoad < 5_000)
            {
                return;
            }
            var isFriendsWith = APIUser.IsFriendsWith(apiUser.id);

            if (!isFriendsWith || !JoinNotifierSettings.ShowFriendsAlways())
            {
                if (!JoinNotifierSettings.ShouldNotifyInCurrentInstance())
                {
                    return;
                }
                if (JoinNotifierSettings.ShowFriendsOnly() && !isFriendsWith)
                {
                    return;
                }
            }
            var playerName = apiUser.displayName ?? "!null!";

            if (JoinNotifierSettings.ShouldBlinkIcon(true))
            {
                MelonCoroutines.Start(BlinkIconCoroutine(myJoinImage));
            }
            if (JoinNotifierSettings.ShouldPlaySound(true))
            {
                myJoinSource.Play();
            }
            if (JoinNotifierSettings.ShouldShowNames(true))
            {
                MelonCoroutines.Start(ShowName(myJoinText, myJoinNames, playerName, true, isFriendsWith));
            }
        }
示例#2
0
        public void OnPlayerLeft(Player player)
        {
            var apiUser = player?.field_Private_APIUser_0;

            if (apiUser == null)
            {
                return;
            }
            if (Environment.TickCount - myLastLevelLoad < 5_000)
            {
                return;
            }

            var isFriendsWith = APIUser.IsFriendsWith(apiUser.id);

            if (!isFriendsWith || !JoinNotifierSettings.ShowFriendsAlways())
            {
                if (!JoinNotifierSettings.ShouldNotifyInCurrentInstance())
                {
                    return;
                }
                if (JoinNotifierSettings.ShowFriendsOnly() && !isFriendsWith)
                {
                    return;
                }
            }

            var playerName = apiUser.displayName ?? "!null!";

            if (JoinNotifierSettings.ShouldBlinkIcon(false))
            {
                MelonCoroutines.Start(BlinkIconCoroutine(myLeaveImage));
            }
            if (JoinNotifierSettings.ShouldPlaySound(false))
            {
                myLeaveSource.Play();
            }
            if (JoinNotifierSettings.ShouldShowNames(false))
            {
                MelonCoroutines.Start(ShowName(myLeaveText, myLeaveNames, playerName, false, isFriendsWith));
            }
        }