Exemple #1
0
        public void Search(string query, bool exact, Action <List <GizmoAvatarSearchResult> > callback)
        {
            DatabaseService.Search(new SearchRequest {
                Query = query, Type = SearchType.SIMS
            }, exact)
            .ContinueWith(x =>
            {
                GameThread.InUpdate(() =>
                {
                    object[] ids = x.Result.Items.Select(y => (object)y.EntityId).ToArray();
                    var results  = x.Result.Items.Select(q =>
                    {
                        return(new GizmoAvatarSearchResult()
                        {
                            Result = q
                        });
                    }).ToList();

                    if (ids.Length > 0)
                    {
                        var avatars = DataService.GetMany <Avatar>(ids).Result;
                        foreach (var item in avatars)
                        {
                            results.First(f => f.Result.EntityId == item.Avatar_Id).Avatar = item;
                        }
                    }

                    callback(results);
                });
            });
        }
        public void Search(string query, SearchType type, bool exact)
        {
            DatabaseService.Search(new SearchRequest {
                Query = query, Type = type
            }, exact)
            .ContinueWith(x =>
            {
                object[] ids = x.Result.Items.Select(y => (object)y.EntityId).ToArray();
                if (type == SearchType.SIMS)
                {
                    var results = x.Result.Items.Select(q =>
                    {
                        return(new GizmoAvatarSearchResult()
                        {
                            Result = q
                        });
                    }).ToList();

                    if (ids.Length > 0)
                    {
                        var avatars = DataService.GetMany <Avatar>(ids).Result;
                        foreach (var item in avatars)
                        {
                            results.First(f => f.Result.EntityId == item.Avatar_Id).Avatar = item;
                        }
                    }

                    View.SetResults(results);
                }
                else if (type == SearchType.LOTS)
                {
                    var results = x.Result.Items.Select(q =>
                    {
                        return(new GizmoLotSearchResult()
                        {
                            Result = q
                        });
                    }).ToList();

                    if (ids.Length > 0)
                    {
                        var lots = DataService.GetMany <Lot>(ids).Result;
                        foreach (var item in lots)
                        {
                            results.First(f => f.Result.EntityId == item.Id).Lot = item;
                        }
                    }

                    View.SetResults(results);
                }
            });
        }
Exemple #3
0
        void RefreshCity(BindingChange[] changes)
        {
            if (CurrentCity.Value != null)
            {
                var mapData = LotTileEntry.GenFromCity(CurrentCity.Value);

                //We know if lots are online, we can update the data service
                DataService.GetMany <Lot>(mapData.Select(x => (object)(uint)x.packed_pos).ToArray()).ContinueWith(x =>
                {
                    if (!x.IsCompleted)
                    {
                        return;
                    }

                    foreach (var lot in x.Result)
                    {
                        var mapItem = mapData.FirstOrDefault(y => y.packed_pos == lot.Id);
                        if (mapItem != null)
                        {
                            lot.Lot_IsOnline = (mapItem.flags & LotTileFlags.Online) == LotTileFlags.Online;
                        }
                    }
                });

                GameThread.NextUpdate((state) => View.populateCityLookup(mapData));
            }
        }
        private void RefreshCity(BindingChange[] changes)
        {
            if (CurrentCity.Value != null)
            {
                var mapData   = LotTileEntry.GenFromCity(CurrentCity.Value);
                var neighJSON = CurrentCity.Value.City_NeighJSON;

                //We know if lots are online, we can update the data service
                DataService.GetMany <Lot>(mapData.Select(x => (object)(uint)x.packed_pos).ToArray()).ContinueWith(x =>
                {
                    if (!x.IsCompleted)
                    {
                        return;
                    }

                    foreach (var lot in x.Result)
                    {
                        var mapItem = mapData.FirstOrDefault(y => y.packed_pos == lot.Id);
                        if (mapItem != null)
                        {
                            lot.Lot_IsOnline = (mapItem.flags & LotTileFlags.Online) == LotTileFlags.Online;
                        }
                    }
                });

                GameThread.NextUpdate((state) => {
                    View.populateCityLookup(mapData);
                    if (neighJSON != LastLotJSON)
                    {
                        try
                        {
                            var neigh = JsonConvert.DeserializeObject <List <Rendering.City.Model.CityNeighbourhood> >(neighJSON);
                            Rendering.City.Model.CityNeighbourhood.Init(neigh);
                            View.NeighGeom.Data = neigh;
                            View.NeighGeom.Generate(GameFacade.GraphicsDevice);
                        } catch
                        {
                        }

                        LastLotJSON = neighJSON;
                    }
                });
            }
        }