コード例 #1
0
        //
        // ApiWorld
        //

        public void OnWorld(ApiWorld world)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new MethodInvoker(() =>
                {
                    OnWorld(world);
                }));
            }
            else
            {
                m_WorldNames[world.id] = world.name;
                if (m_GPS.Remove(world.id))
                {
                    foreach (var pair in m_Friends)
                    {
                        var user = pair.Value;
                        var L    = LocationInfo.Parse(user.location);
                        if (L != null &&
                            L.WorldId.Equals(world.id))
                        {
                            var locationInfo = $"{world.name} {L.InstanceInfo}";
                            user.locationInfo = locationInfo;
                            if (!string.IsNullOrEmpty(user.pastLocation))
                            {
                                VRSEX.SetActivity(new ActivityInfo
                                {
                                    Type  = ActivityType.PlayerGPS,
                                    Text  = DateTime.Now.ToString("HH:mm") + " " + user.displayName + " is " + locationInfo,
                                    Group = GetFriendsGroupIndex(user.id)
                                });
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
 public void OnFriends(List <ApiUser> users)
 {
     if (InvokeRequired)
     {
         BeginInvoke(new MethodInvoker(() =>
         {
             OnFriends(users);
         }));
     }
     else
     {
         foreach (var user in users)
         {
             if (m_Friends.TryGetValue(user.id, out ApiUser _user))
             {
                 user.pastLocation = _user.location;
             }
             m_Friends[user.id] = user;
             var          notify       = true;
             var          locationInfo = user.location;
             LocationInfo L            = LocationInfo.Parse(user.location);
             if (L != null)
             {
                 if (m_WorldNames.TryGetValue(L.WorldId, out string worldName))
                 {
                     locationInfo = $"{worldName} {L.InstanceInfo}";
                 }
                 else
                 {
                     notify = false;
                     if (m_GPS.Add(L.WorldId))
                     {
                         ApiWorld.Fetch(L.WorldId);
                     }
                 }
             }
             user.locationInfo = locationInfo;
             if (!string.IsNullOrEmpty(user.pastLocation) &&
                 !string.Equals(user.pastLocation, user.location))
             {
                 if ("offline".Equals(user.location, StringComparison.OrdinalIgnoreCase))
                 {
                     VRSEX.SetActivity(new ActivityInfo
                     {
                         Type  = ActivityType.PlayerLogout,
                         Text  = DateTime.Now.ToString("HH:mm") + " " + user.displayName + " has logged out",
                         Group = GetFriendsGroupIndex(user.id)
                     });
                 }
                 else
                 {
                     if ("offline".Equals(user.pastLocation, StringComparison.OrdinalIgnoreCase))
                     {
                         VRSEX.SetActivity(new ActivityInfo
                         {
                             Type  = ActivityType.PlayerLogin,
                             Text  = DateTime.Now.ToString("HH:mm") + " " + user.displayName + " has logged in",
                             Group = GetFriendsGroupIndex(user.id)
                         });
                         if ("private".Equals(user.location, StringComparison.OrdinalIgnoreCase))
                         {
                             continue;
                         }
                     }
                     if (notify)
                     {
                         VRSEX.SetActivity(new ActivityInfo
                         {
                             Type  = ActivityType.PlayerGPS,
                             Text  = DateTime.Now.ToString("HH:mm") + " " + user.displayName + " is " + locationInfo,
                             Group = GetFriendsGroupIndex(user.id)
                         });
                     }
                 }
             }
         }
     }
 }