Exemple #1
0
        /// <summary>Raises the CoarseLocationUpdate event</summary>
        /// <param name="e">A CoarseLocationUpdateEventArgs object containing the
        /// data sent by simulator</param>
        protected virtual void OnCoarseLocationUpdate(CoarseLocationUpdateEventArgs e)
        {
            EventHandler <CoarseLocationUpdateEventArgs> handler = m_CoarseLocationUpdate;

            if (handler != null)
            {
                handler(this, e);
            }
        }
 /// <summary>Raises the CoarseLocationUpdate event</summary>
 /// <param name="e">A CoarseLocationUpdateEventArgs object containing the
 /// data sent by simulator</param>
 protected virtual void OnCoarseLocationUpdate(CoarseLocationUpdateEventArgs e)
 {
     EventHandler<CoarseLocationUpdateEventArgs> handler = m_CoarseLocationUpdate;
     if (handler != null)
         handler(this, e);
 }
Exemple #3
0
        void UpdateRadar(CoarseLocationUpdateEventArgs e)
        {
            if (client.Network.CurrentSim == null /*|| client.Network.CurrentSim.Handle != sim.Handle*/)
            {
                return;
            }

            if (InvokeRequired)
            {
                if (!instance.MonoRuntime || IsHandleCreated)
                    BeginInvoke(new MethodInvoker(() => UpdateRadar(e)));
                return;
            }

            // later on we can set this with something from the GUI
            const double MAX_DISTANCE = 362.0; // one sim a corner to corner distance
            lock (agentSimHandle)
                try
                {
                    lvwObjects.BeginUpdate();
                    Vector3d mypos = e.Simulator.AvatarPositions.ContainsKey(client.Self.AgentID)
                                        ? StateManager.ToVector3D(e.Simulator.Handle, e.Simulator.AvatarPositions[client.Self.AgentID])
                                        : client.Self.GlobalPosition;

                    // CoarseLocationUpdate gives us hight of 0 when actual height is
                    // between 1024-4096m.
                    if (mypos.Z < 0.1)
                    {
                        mypos.Z = client.Self.GlobalPosition.Z;
                    }

                    List<UUID> existing = new List<UUID>();
                    List<UUID> removed = new List<UUID>(e.RemovedEntries);

                    e.Simulator.AvatarPositions.ForEach(delegate(KeyValuePair<UUID, Vector3> avi)
                    {
                        existing.Add(avi.Key);
                        if (!lvwObjects.Items.ContainsKey(avi.Key.ToString()))
                        {
                            string name = instance.Names.Get(avi.Key);
                            ListViewItem item = lvwObjects.Items.Add(avi.Key.ToString(), name, string.Empty);
                            if (avi.Key == client.Self.AgentID)
                            {
                                // Stops our name saying "Loading..."
                                item.Text = instance.Names.Get(avi.Key, client.Self.Name);
                                item.Font = new Font(item.Font, FontStyle.Bold);
                            }
                            item.Tag = avi.Key;
                            agentSimHandle[avi.Key] = e.Simulator.Handle;
                        }
                    });

                    foreach (ListViewItem item in lvwObjects.Items)
                    {
                        if (item == null) continue;
                        UUID key = (UUID)item.Tag;

                        if (agentSimHandle[key] != e.Simulator.Handle)
                        {
                            // not for this sim
                            continue;
                        }

                        if (key == client.Self.AgentID)
                        {
                            if (instance.Names.Mode != NameMode.Standard)
                                item.Text = instance.Names.Get(key);
                            continue;
                        }

                        //the AvatarPostions is checked once more because it changes wildly on its own
                        //even though the !existing should have been adequate
                        Vector3 pos;
                        if (!existing.Contains(key) || !e.Simulator.AvatarPositions.TryGetValue(key, out pos))
                        {
                            // not here anymore
                            removed.Add(key);
                            continue;
                        }

                        Avatar foundAvi = e.Simulator.ObjectsAvatars.Find((Avatar av) => { return av.ID == key; });

                        // CoarseLocationUpdate gives us hight of 0 when actual height is
                        // between 1024-4096m on OpenSim grids. 1020 on SL
                        bool unkownAltitude = instance.Netcom.LoginOptions.Grid.Platform == "SecondLife" ? pos.Z == 1020f : pos.Z == 0f;
                        if (unkownAltitude)
                        {
                            if (foundAvi != null)
                            {
                                if (foundAvi.ParentID == 0)
                                {
                                    pos.Z = foundAvi.Position.Z;
                                }
                                else
                                {
                                    if (e.Simulator.ObjectsPrimitives.ContainsKey(foundAvi.ParentID))
                                    {
                                        pos.Z = e.Simulator.ObjectsPrimitives[foundAvi.ParentID].Position.Z;
                                    }
                                }
                            }
                        }

                        int d = (int)Vector3d.Distance(StateManager.ToVector3D(e.Simulator.Handle, pos), mypos);

                        if (e.Simulator != client.Network.CurrentSim && d > MAX_DISTANCE)
                        {
                            removed.Add(key);
                            continue;
                        }

                        if (unkownAltitude)
                        {
                            item.Text = instance.Names.Get(key) + " (?m)";
                        }
                        else
                        {
                            item.Text = instance.Names.Get(key) + " (" + d + "m)";
                        }

                        if (foundAvi != null)
                        {
                            item.Text += "*";
                        }
                    }

                    foreach (UUID key in removed)
                    {
                        lvwObjects.Items.RemoveByKey(key.ToString());
                        agentSimHandle.Remove(key);
                    }

                    lvwObjects.Sort();
                }
                catch (Exception ex)
                {
                    Logger.Log("Grid_OnCoarseLocationUpdate: " + ex, OpenMetaverse.Helpers.LogLevel.Error, client);
                }
                finally
                {
                    lvwObjects.EndUpdate();
                }
        }
Exemple #4
0
 private void Grid_OnCoarseLocationUpdate(object sender, CoarseLocationUpdateEventArgs e)
 {
     try
     {
         //UpdateMiniMap(sim);
         BeginInvoke((MethodInvoker)delegate { UpdateMiniMap(e.Simulator); });
     }
     catch { ; }
 }
Exemple #5
0
 void Grid_CoarseLocationUpdate(object sender, CoarseLocationUpdateEventArgs e)
 {
     UpdateCoarseInfo(e.Simulator, e.NewEntries, e.RemovedEntries);
 }
Exemple #6
0
 void Grid_CoarseLocationUpdate(object sender, CoarseLocationUpdateEventArgs e)
 {
     try
     {
         UpdateRadar(e);
     }
     catch { }
 }
        public void OnLocationUpdate(object sender, CoarseLocationUpdateEventArgs e)
        {
            var evt = new ChannelMemberChangeEventArgs();
            Dictionary<UUID, ChannelMembership> nearbyAvatars;

            if (e.Simulator.Name != client.Network.CurrentSim.Name) return;

            if(!nearby.TryGetValue(e.Simulator.Name, out nearbyAvatars))
            {
                nearbyAvatars = new Dictionary<UUID, ChannelMembership>();
                nearby.Add(e.Simulator.Name, nearbyAvatars);
            }

            foreach(var i in e.NewEntries)
            {
                if (i == client.Self.AgentID) { continue; }

                var detail = new ChannelMemberChangeEventArgs.ChangeDetails();
                detail.Subject = mapper.MapUser(i);
                detail.IsOperator = false;
                detail.WasOperator = false;
                detail.NewPosition = CategorisePosition(i, e);
                detail.OldPosition = PositionCategory.Distant;
                evt.NewMembers.Add(detail);

                var membership = new ChannelMembership();
                membership.Subject = detail.Subject;
                membership.IsOperator = false;
                membership.Position = CategorisePosition(i, e);
                if (nearbyAvatars.ContainsKey(i))
                {
                    nearbyAvatars[i] = membership;
                }
                else
                {
                    nearbyAvatars.Add(i, membership);
                }
            }

            foreach(var i in e.RemovedEntries)
            {
                if (i == client.Self.AgentID) { continue; }

                var detail = new ChannelMemberChangeEventArgs.ChangeDetails();
                if (nearbyAvatars.ContainsKey(i))
                {
                    detail.Subject = nearbyAvatars[i].Subject;
                    detail.IsOperator = false;
                    detail.WasOperator = false;
                    detail.NewPosition = PositionCategory.Distant;
                    detail.OldPosition = nearbyAvatars[i].Position;
                    evt.RemovedMembers.Add(detail);

                    nearbyAvatars.Remove(i);
                }
            }

            foreach(var i in nearbyAvatars)
            {
                if (i.Key == client.Self.AgentID) { continue; }

                var newpos = CategorisePosition(i.Key, e);
                if (i.Value.Position != newpos)
                {
                    var detail = new ChannelMemberChangeEventArgs.ChangeDetails();
                    detail.Subject = nearbyAvatars[i.Key].Subject;
                    detail.IsOperator = false;
                    detail.WasOperator = false;
                    detail.NewPosition = newpos;
                    detail.OldPosition = nearbyAvatars[i.Key].Position;
                    evt.ChangedMembers.Add(detail);
                    nearbyAvatars[i.Key].Position = newpos;
                }
            }

            if (!evt.HasChanges) { return; }

            lock (syncRoot)
            {
                if (state != ChannelState.Connected)
                {
                    state = ChannelState.Connected;
                    joinTask.SetResult(true);
                }
            }

            if(this.MembersChanged != null)
            {
                MembersChanged(this, evt);
            }
        }
        private PositionCategory CategorisePosition(UUID i, CoarseLocationUpdateEventArgs e)
        {
            var mypos = client.Self.SimPosition;
            Vector3 otherpos;
            if(!e.Simulator.AvatarPositions.TryGetValue(i, out otherpos))
            {
                return PositionCategory.SameRegionGroup;
            }
            var distance = Vector3.Distance(mypos, otherpos);

            if(distance <= WHISPERDISTANCE)
            {
                return PositionCategory.Whisper;
            }
            else if (distance <= TALKDISTANCE)
            {
                return PositionCategory.Talk;
            }
            else if (distance <= SHOUTDISTANCE)
            {
                return PositionCategory.Shout;
            }
            else
            {
                return PositionCategory.SameRegionGroup;
            }
        }
 void Grid_CoarseLocationUpdate(object sender, CoarseLocationUpdateEventArgs e)
 {
     Gtk.Application.Invoke(delegate
     {
         drawavs();
     });
 }
Exemple #10
0
 public virtual void Grid_OnCoarseLocationUpdate(object sender, CoarseLocationUpdateEventArgs e) { OnEvent("On-Coarse-Location-Update", paramNamesOnCoarseLocationUpdate, paramTypesOnCoarseLocationUpdate, e); }
Exemple #11
0
        // Seperate thread
        private void Grid_OnCoarseLocationUpdate(object sender, CoarseLocationUpdateEventArgs e)
        {
            if (e.Simulator != client.Network.CurrentSim) return;

            CurrentSIM = e.Simulator;

            if (InvokeRequired)
            {

                BeginInvoke(new MethodInvoker(delegate()
                {
                    try
                    {
                        Grid_OnCoarseLocationUpdate(sender, e);
                    }
                    catch { ; }
                }));

                return;
            }

            List<UUID> tremove = new List<UUID>();
            tremove = e.RemovedEntries;

            foreach (UUID id in tremove)
            {
                foreach (ListViewItem litem in lvwRadar.Items)
                {
                    if (litem.Tag.ToString() == id.ToString())
                    {
                        lvwRadar.BeginUpdate();
                        lvwRadar.Items.RemoveAt(lvwRadar.Items.IndexOf(litem));
                        lvwRadar.EndUpdate();
                    }
                }

                lock (instance.avnames)
                {
                    instance.avnames.Remove(id);
                }

                if (instance.State.IsFollowing)
                {
                    if (id == instance.State.FollowID)
                    {
                        instance.State.Follow(string.Empty, UUID.Zero);
                        tbtnFollow.ToolTipText = "Follow";
                    }
                }
            }

            e.Simulator.AvatarPositions.ForEach(delegate(KeyValuePair<UUID, Vector3> favpos)
                    {
                        if (!instance.avnames.ContainsKey(favpos.Key))
                        {
                            client.Avatars.RequestAvatarName(favpos.Key);
                        }
                    });

            try
            {
                BeginInvoke((MethodInvoker)delegate { UpdateMiniMap(e.Simulator); });
                BeginInvoke((MethodInvoker)delegate { GetCompass(); });
            }
            catch { ; }
        }
        void Grid_CoarseLocationUpdate(object sender, CoarseLocationUpdateEventArgs e)
        {
            Gtk.Application.Invoke(delegate
            {
                lock(av_tree)
                {
                    foreach (UUID id in e.RemovedEntries)
                    {
                        if(av_tree.ContainsKey(id))
                        {
                            Gtk.TreeIter iter = av_tree[id];
                            store.Remove(ref iter);
                            av_tree.Remove(id);
                        }
                    }
                }

                calcdistance();
            });
        }
 static void Grid_CoarseLocationUpdate(object sender, CoarseLocationUpdateEventArgs e)
 {
     Think();
 }