Пример #1
0
        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);
            }
        }
Пример #2
0
 void Grid_CoarseLocationUpdate(object sender, CoarseLocationUpdateEventArgs e)
 {
     try
     {
         UpdateRadar(e);
     }
     catch { }
 }
Пример #3
0
 private void Grid_OnCoarseLocationUpdate(object sender, CoarseLocationUpdateEventArgs e)
 {
     try
     {
         //UpdateMiniMap(sim);
         BeginInvoke((MethodInvoker) delegate { UpdateMiniMap(e.Simulator); });
     }
     catch {; }
 }
Пример #4
0
        public override void Grid_OnCoarseLocationUpdate(object sender, CoarseLocationUpdateEventArgs e)
        {
            Simulator sim            = e.Simulator;
            var       newEntries     = e.NewEntries;
            var       removedEntries = e.RemovedEntries;

            if (newEntries.Count == 0 && removedEntries.Count == 0)
            {
                return;
            }
            foreach (UUID uuid in newEntries)
            {
                SimObject A = CreateSimAvatar(uuid, this, sim);
                Vector3   pos;
                if (sim.AvatarPositions.TryGetValue(uuid, out pos))
                {
                    A.UpdatePosition(sim.Handle, pos);
                }
            }
            foreach (UUID uuid in removedEntries)
            {
                DeclareAvatar(uuid);
            }
            if (!MaintainAvatarMetaData)
            {
                return;
            }
            //for (int i = 0; i < coarse.Location.Length; i++)
            //{
            //    if (i == coarse.Index.$bot)
            //    {
            //        simulator.positionIndexYou = i;
            //    }
            //    else if (i == coarse.Index.Prey)
            //    {
            //        simulator.positionIndexPrey = i;
            //    }
            //    simulator.avatarPositions.Add(new Vector3(coarse.Location[i].X, coarse.Location[i].Y,
            //        coarse.Location[i].Z * 4));
            //}

            //OnEvent("On-Coarse-Location-Update", paramNamesOnCoarseLocationUpdate, paramTypesOnCoarseLocationUpdate, sim, newEntries , removedEntries);
        }
Пример #5
0
 void Grid_CoarseLocationUpdate(object sender, CoarseLocationUpdateEventArgs e)
 {
     UpdateMiniMap(e.Simulator);
 }
Пример #6
0
 void Grid_CoarseLocationUpdate(object sender, CoarseLocationUpdateEventArgs e)
 {
     UpdateMiniMap(e.Simulator);
 }
Пример #7
0
 void Grid_CoarseLocationUpdate(object sender, CoarseLocationUpdateEventArgs e)
 {
     UpdateCoarseInfo(e.Simulator, e.NewEntries, e.RemovedEntries);
 }
Пример #8
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 height 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(av => av.ID == key);

                        // CoarseLocationUpdate gives us height of 0 when actual height is
                        // between 1024-4096m on OpenSim grids. 1020 on SL
                        bool unknownAltitude = instance.Netcom.LoginOptions.Grid.Platform == "SecondLife" ? pos.Z == 1020f : pos.Z == 0f;
                        if (unknownAltitude)
                        {
                            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 (unknownAltitude)
                        {
                            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, Helpers.LogLevel.Error, client);
                }
            finally
            {
                lvwObjects.EndUpdate();
            }
        }
Пример #9
0
        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);
            }
        }