public override void UpdateListenedFriends()
 {
     Collider[] cols = Physics.OverlapSphere(GameObject.transform.position, ListenMessageRadius, FriendMask);
     foreach (Collider col in cols)
     {
         if (col.gameObject == GameObject)
         {
             continue;
         }
         SharedProps sp = col.GetComponent <SharedProps>();
         if (sp && sp.memory != null)
         {
             if (Vector3.Distance(GameObject.transform.position, sp.transform.position) < ListenMessageRadius && sp.GetComponent <Health>() && sp.GetComponent <Health>().health > 0)
             {
                 // Listen
                 sp.memory.onMessageSendToListeners -= OnMessageReceived;
                 sp.memory.onMessageSendToListeners += OnMessageReceived;
                 if (!Friends.Contains(sp.memory))
                 {
                     Friends.Add(sp.memory);
                 }
             }
             else
             {
                 // Don't Listen
                 if (Friends.Contains(sp.memory))
                 {
                     Friends.Find(x => x == sp.memory).onMessageSendToListeners -= OnMessageReceived;
                     Friends.Remove(sp.memory);
                 }
                 sp.memory.onMessageSendToListeners -= OnMessageReceived;
             }
         }
     }
 }
Esempio n. 2
0
 private bool IsFriend(string friendName)
 {
     lock (friendsLock)
     {
         return(Friends.Contains(friendName.ToLower()));
     }
 }
Esempio n. 3
0
 public void RemoveFriend(Mobile target)
 {
     if (Friends.Contains(target))
     {
         Friends.Remove(target);
         FriendSystem.RemoveFriend(target, m_Mobile);
     }
 }
        private void SaveFriend(object friendObject)
        {
            FriendViewModel friend = friendObject as FriendViewModel;

            if (friend != null && friend.IsValid && !Friends.Contains(friend))
            {
                Friends.Add(friend);
            }
            Back();
        }
Esempio n. 5
0
 public bool AddFriend(Mobile target)
 {
     if (!Friends.Contains(target) && target != m_Mobile)
     {
         Friends.Add(target);
         return(true);
     }
     else
     {
         return(false);
     }
 }
Esempio n. 6
0
        public void AddFriend(User friend)
        {
            if (!Friends.Contains(friend))
            {
                Friends.Add(friend);
            }

            if (!friend.Friends.Contains(this))
            {
                friend.Friends.Add(this);
            }
        }
Esempio n. 7
0
        private void XmppOnOnRosterItem(object sender, RosterItem item)
        {
            //Friends.Add(item.);
            switch (item.Subscription)
            {
            case SubscriptionType.none:
                if (item.Jid.Server == "conference." + Host)
                {
                    Chatting.GetRoom(new NewUser(item.Jid), true);
                }
                break;

            case SubscriptionType.to:
                if (item.Jid.User == Me.User.User)
                {
                    break;
                }
                if (Friends.Count(x => x.User.User == item.Jid.User) == 0)
                {
                    Friends.Add(new NewUser(item.Jid));
                }
                break;

            case SubscriptionType.from:
                if (item.Jid.User == Me.User.User)
                {
                    break;
                }
                if (Friends.Count(x => x.User.User == item.Jid.User) == 0)
                {
                    Friends.Add(new NewUser(item.Jid));
                }
                break;

            case SubscriptionType.both:
                if (item.Jid.User == Me.User.User)
                {
                    break;
                }
                if (Friends.Count(x => x.User.User == item.Jid.User) == 0)
                {
                    Friends.Add(new NewUser(item.Jid));
                }
                break;

            case SubscriptionType.remove:
                if (Friends.Contains(new NewUser(item.Jid)))
                {
                    Friends.Remove(new NewUser(item.Jid));
                }
                break;
            }
        }
Esempio n. 8
0
 public void RemoveFriend(FriendModel user, [CanBeNull] Action <FriendModel> onSuccess = null, [CanBeNull] Action <Error> onError = null)
 {
     if (!Friends.Contains(user))
     {
         RaiseOnError($"Can not remove friend with this nickname = {user.Nickname}. This user is not in the friend list.", onError);
     }
     else
     {
         SdkFriendsLogic.Instance.RemoveFriend(user, u =>
         {
             RemoveUserFromMemory(user);
             onSuccess?.Invoke(u);
         }, onError);
     }
 }
Esempio n. 9
0
        /// <summary>
        /// The accept friendship.
        /// </summary>
        /// <param name="user">
        /// The user.
        /// </param>
        public void AcceptFriendship(Jid user)
        {
            if (Friends.Contains(new User(user)))
            {
                this.Friends.Add(new User(user));
            }
            this.xmpp.PresenceManager.ApproveSubscriptionRequest(user);
            this.xmpp.PresenceManager.Subscribe(user);
            this.xmpp.SendMyPresence();
            if (this.OnDataReceived != null)
            {
                this.OnDataReceived.Invoke(this, DataRecType.FriendList, this.Friends);
            }

            // Xmpp.RequestRoster();
        }
Esempio n. 10
0
 public void AddFriend(FriendModel user, [CanBeNull] Action <FriendModel> onSuccess = null, [CanBeNull] Action <Error> onError = null)
 {
     if (Friends.Contains(user) || Blocked.Contains(user) || Pending.Contains(user) || Requested.Contains(user))
     {
         RaiseOnError($"Can not add friend with this nickname = {user.Nickname}. This friend is not in the 'initial' state.", onError);
     }
     else
     {
         SdkFriendsLogic.Instance.SendFriendshipInvite(user, u =>
         {
             RemoveUserFromMemory(user);
             UpdateRequestedUsers(onError: onError);
             onSuccess?.Invoke(u);
         }, onError);
     }
 }
        private void SaveFriend(object friendObject)
        {
            var item = ((FriendViewModel)friendObject);

            //проверка на наличие объекта
            if (item.IsValid())
            {
                if (Friends.Contains(item))
                {
                    Friends.Remove(item);
                }

                //добавление в коллекцию объекта
                Friends.Add(item);
            }

            //вызов Назад
            Back();
        }
Esempio n. 12
0
        static void OnFriendsList(SteamFriends.FriendsListCallback obj)
        {
            //LoadFriends();

            List <SteamID> newFriends = new List <SteamID>();

            foreach (SteamFriends.FriendsListCallback.Friend friend in obj.FriendList)
            {
                switch (friend.SteamID.AccountType)
                {
                // case EAccountType.Clan:
                //     if (friend.Relationship == EFriendRelationship.RequestRecipient)
                //    break;

                default:
                    CreateFriendsListIfNecessary();

                    if (friend.Relationship == EFriendRelationship.None)
                    {
                        steamFriends.RemoveFriend(friend.SteamID);
                    }
                    else if (friend.Relationship == EFriendRelationship.RequestRecipient)
                    {
                        if (!Friends.Contains(friend.SteamID))
                        {
                            Friends.Add(friend.SteamID);
                            newFriends.Add(friend.SteamID);
                        }
                    }
                    else if (friend.Relationship == EFriendRelationship.RequestInitiator)
                    {
                        if (!Friends.Contains(friend.SteamID))
                        {
                            Friends.Add(friend.SteamID);
                            newFriends.Add(friend.SteamID);
                        }
                    }
                    break;
                }
            }
            Console.WriteLine("[" + Program.BOTNAME + "] Recorded steam friends : {0}", steamFriends.GetFriendCount());
        }
Esempio n. 13
0
 private void RemoveUserFromMemory(FriendModel user)
 {
     if (Friends.Contains(user))
     {
         Friends.Remove(user);
         UserFriendsUpdatedEvent?.Invoke();
     }
     if (Pending.Contains(user))
     {
         Pending.Remove(user);
         PendingUsersUpdatedEvent?.Invoke();
     }
     if (Requested.Contains(user))
     {
         Requested.Remove(user);
         RequestedUsersUpdatedEvent?.Invoke();
     }
     if (Blocked.Contains(user))
     {
         Blocked.Remove(user);
         BlockedUsersUpdatedEvent?.Invoke();
     }
 }
Esempio n. 14
0
 public bool IsFriendsWith(string _friend)
 {
     return(Friends.Contains(_friend));
 }
Esempio n. 15
0
        public void Start()
        {
            _callbackHandlerCancellationTokenSource = new CancellationTokenSource();
            Task.Run(() =>
            {
                while (!_callbackHandlerCancellationTokenSource.IsCancellationRequested)
                {
                    var callback = _steamClient.WaitForCallback(true, TimeSpan.FromMilliseconds(50));
                    if (callback == null)
                    {
                        continue;
                    }

                    callback.Handle <SteamClient.ConnectedCallback>(cb =>
                    {
                        if (_connectTaskCompletionSource != null && !_connectTaskCompletionSource.Task.IsCompleted)
                        {
                            _connectTaskCompletionSource.TrySetResult(cb);
                        }

                        // If the connection doesn't disconnect in 3 seconds, reset the retry count.
                        _retryCountResetCancellationTokenSource = new CancellationTokenSource();
                        Task.Delay(3000, _retryCountResetCancellationTokenSource.Token).ContinueWith(task =>
                        {
                            if (!task.IsCanceled)
                            {
                                _retryCount = 0;
                            }
                        });
                    });

                    callback.Handle <SteamClient.DisconnectedCallback>(cb =>
                    {
                        if (_disconnectTaskCompletionSource != null && !_disconnectTaskCompletionSource.Task.IsCompleted)
                        {
                            _disconnectTaskCompletionSource.TrySetResult(cb);
                        }
                        else if (ReconnectOnDisconnected)
                        {
                            TryReconnect();
                        }
                    });

                    callback.Handle <SteamUser.LoggedOnCallback>(cb =>
                    {
                        if (_loginTaskCompletionSource != null && !_loginTaskCompletionSource.Task.IsCompleted)
                        {
                            _loginTaskCompletionSource.TrySetResult(cb);
                        }
                    });

                    //callback.Handle<SteamUser.LoggedOffCallback>(cb =>
                    //{
                    //    if (_logoutTaskCompletionSource != null && !_logoutTaskCompletionSource.Task.IsCompleted)
                    //        _logoutTaskCompletionSource.TrySetResult(cb);
                    //});

                    callback.Handle <SteamUser.UpdateMachineAuthCallback>(async cb =>
                    {
                        if (_applicationSettingsService.Settings.SentryHashStore == null)
                        {
                            _applicationSettingsService.Settings.SentryHashStore = new Dictionary <string, byte[]>();
                        }

                        var sentryHash = CryptoHelper.SHAHash(cb.Data);
                        _applicationSettingsService.Settings.SentryHashStore[_lastLoginDetails.Username] = sentryHash;
                        await _applicationSettingsService.SaveAsync();

                        _steamUser.SendMachineAuthResponse(new SteamUser.MachineAuthDetails
                        {
                            BytesWritten    = cb.BytesToWrite,
                            FileName        = cb.FileName,
                            FileSize        = cb.Data.Length,
                            JobID           = cb.JobID,
                            LastError       = 0,
                            Offset          = cb.Offset,
                            OneTimePassword = cb.OneTimePassword,
                            Result          = EResult.OK,
                            SentryFileHash  = sentryHash
                        });
                    });

                    callback.Handle <SteamFriends.PersonaStateCallback>(cb =>
                    {
                        if (cb.FriendID == _steamUser.SteamID)
                        {
                            if (_setPersonaStateTaskCompletionSource != null &&
                                !_setPersonaStateTaskCompletionSource.Task.IsCompleted)
                            {
                                _setPersonaStateTaskCompletionSource.TrySetResult(cb);
                            }

                            return;
                        }
                        var query   = from f in Friends where f.SteamId.Equals(cb.FriendID) select f;
                        var friends = query as Friend[] ?? query.ToArray();

                        if (!friends.Any())
                        {
                            return;
                        }

                        var friend = friends.First();
                        friend.OnStateChanged();
                    });

                    callback.Handle <SteamClient.CMListCallback>(async cb =>
                    {
                        if (_applicationSettingsService.Settings.PreferedCmServers == null)
                        {
                            _applicationSettingsService.Settings.PreferedCmServers = new List <string>();
                        }
                        _applicationSettingsService.Settings.PreferedCmServers.Clear();
                        _applicationSettingsService.Settings.PreferedCmServers.AddRange(
                            (from sv in cb.Servers select sv.ToString()).Take(8));
                        await _applicationSettingsService.SaveAsync();
                    });

                    callback.Handle <SteamUser.AccountInfoCallback>(cb =>
                    {
                        if (_setPersonaNameTaskCompletionSource != null &&
                            !_setPersonaNameTaskCompletionSource.Task.IsCompleted)
                        {
                            _setPersonaNameTaskCompletionSource.TrySetResult(cb);
                        }
                        Messenger.Default.Send(new PersonaNameChangedMessage());
                    });

                    callback.Handle <SteamFriends.FriendsListCallback>(cb =>
                    {
                        DispatcherHelper.CheckBeginInvokeOnUI(() =>
                        {
                            if (!cb.Incremental)
                            {
                                Friends.Clear();
                            }

                            foreach (var friend in from friendRaw in cb.FriendList
                                     where friendRaw.SteamID.IsIndividualAccount
                                     select new Friend(friendRaw.SteamID, _steamFriends))
                            {
                                if (Friends.Contains(friend))
                                {
                                    if (friend.Relationship == EFriendRelationship.None)
                                    {
                                        Friends.Remove(friend);
                                    }
                                }
                                else
                                {
                                    Friends.Add(friend);
                                }
                            }
                        });
                    });

                    callback.Handle <SteamFriends.FriendAddedCallback>(cb =>
                    {
                        if (_addFriendTaskCompletionSource != null && !_addFriendTaskCompletionSource.Task.IsCompleted)
                        {
                            _addFriendTaskCompletionSource.TrySetResult(cb);
                        }
                    });
                }
            }, _callbackHandlerCancellationTokenSource.Token);
        }
Esempio n. 16
0
 private bool AlreadyHasFriend(Account account)
 {
     return(Friends.Contains(account));
 }
Esempio n. 17
0
 public bool IsFriendWith(User user)
 {
     return(Friends.Contains(user));
 }
Esempio n. 18
0
        private void XmppOnOnPresence(object sender, Presence pres)
        {
            //if (pres.From.User != "lobby") Debugger.Break();
            if (pres.From.User == Xmpp.MyJID.User)
            {
                if (pres.Type == PresenceType.subscribe)
                {
                    Xmpp.PresenceManager.ApproveSubscriptionRequest(pres.From);
                }
                else
                {
                    myPresence      = pres;
                    myPresence.Type = PresenceType.available;
                    if (pres.Show != ShowType.NONE)
                    {
                        myPresence.Show = pres.Show;
                    }
                    Xmpp.Status = myPresence.Status ?? Xmpp.Status;
                    if (OnDataRecieved != null)
                    {
                        OnDataRecieved.Invoke(this, DataRecType.MyInfo, pres);
                    }
                }
                return;
            }
            switch (pres.Type)
            {
            case PresenceType.available:
                if (pres.From.Server == "conference." + Host)
                {
                    var rm = Chatting.GetRoom(new NewUser(pres.From), true);
                    rm.AddUser(new NewUser(pres.MucUser.Item.Jid), false);
                }
                break;

            case PresenceType.unavailable:
            {
                if (pres.From.Server == "conference." + Host)
                {
                    if (pres.MucUser.Item.Jid == null)
                    {
                        break;
                    }
                    if (pres.MucUser.Item.Jid.Bare == Me.User.Bare)
                    {
                        break;
                    }
                    var rm = Chatting.GetRoom(new NewUser(pres.From), true);
                    rm.UserLeft(new NewUser(pres.MucUser.Item.Jid));
                }
                break;
            }

            case PresenceType.subscribe:
                if (!Friends.Contains(new NewUser(pres.From.Bare)))
                {
                    Notifications.Add(new FriendRequestNotification(pres.From.Bare, this, _noteId));
                    _noteId++;
                    if (OnFriendRequest != null)
                    {
                        OnFriendRequest.Invoke(this, pres.From.Bare);
                    }
                }
                else
                {
                    AcceptFriendship(pres.From.Bare);
                }
                break;

            case PresenceType.subscribed:
                break;

            case PresenceType.unsubscribe:
                break;

            case PresenceType.unsubscribed:
                break;

            case PresenceType.error:
                break;

            case PresenceType.probe:
                break;
            }
            for (int i = 0; i < Friends.Count; i++)
            {
                if (Friends[i].User.User == pres.From.User)
                {
                    Friends[i].CustomStatus = pres.Status ?? "";
                    Friends[i].SetStatus(pres);
                    break;
                }
            }
            XmppOnOnRosterEnd(this);
        }
Esempio n. 19
0
        public override void OnDoubleClick(Mobile from)
        {
            if (IsDeadPet)
            {
                return;
            }

            if (from.IsBodyMod && !from.Body.IsHuman)
            {
                if (Core.AOS)                   // You cannot ride a mount in your current form.
                {
                    PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1062061, from.NetState);
                }
                else
                {
                    from.SendLocalizedMessage(1061628);                       // You can't do that while polymorphed.
                }
                return;
            }

            if (!CheckMountAllowed(from, true))
            {
                return;
            }


            if (from.Female ? !AllowFemaleRider : !AllowMaleRider)
            {
                OnDisallowedRider(from);
                return;
            }

            if (!DesignContext.Check(from))
            {
                return;
            }

            if (from.HasTrade)
            {
                from.SendLocalizedMessage(1042317, "", 0x41);                   // You may not ride at this time
                return;
            }

            if (from.InRange(this, 5) && from.InLOS(this))
            {
                var canAccess = (from.AccessLevel >= AccessLevel.GameMaster) ||
                                (Controlled && (ControlMaster == from || (Friends != null && Friends.Contains(from)))) ||
                                (Summoned && SummonMaster == from);

                if (canAccess)
                {
                    if (from.Mounted)
                    {
                        from.Mount.Rider = null;
                    }

                    //if ( this.Poisoned )
                    //	PrivateOverheadMessage( MessageType.Regular, 0x3B2, 1049692, from.NetState ); // This mount is too ill to ride.
                    //else
                    if (this is Horse || this is Mustang)
                    {
                        Effects.PlaySound(this, Map, 168);
                    }
                    else if (this is Zostrich)
                    {
                        Effects.PlaySound(this, Map, 629);
                    }
                    else if (this is Orn || this is Oclock)
                    {
                        Effects.PlaySound(this, Map, 624);
                    }
                    else if (this is Llama)
                    {
                        Effects.PlaySound(this, Map, 184);
                    }

                    Rider = from;
                }

                /*else if ( !Controlled && !Summoned )
                 * {
                 *  // That mount does not look broken! You would have to tame it to ride it.
                 *  //PrivateOverheadMessage( MessageType.Regular, 0x3B2, 501263, from.NetState );
                 * }*/
                else
                {
                    // This isn't your mount; it refuses to let you ride.
                    from.SendAsciiMessage("You dont own that mount.");
                    //PrivateOverheadMessage( MessageType.Regular, 0x3B2, 501264, from.NetState );
                }
            }
            else
            {
                from.SendLocalizedMessage(500206);                   // That is too far away to ride.
            }
        }