private Packet InImprovedTerseObjectUpdateHandler(Packet packet, IPEndPoint sim) { string simIP = sim.ToString(); // If the sim doesn't exist, add it if (!SharedInfo.Aux_Simulators.ContainsKey(simIP)) { SharedInfo.Aux_Simulators.Add(simIP, new PubComb.Aux_Simulator(simIP)); } ImprovedTerseObjectUpdatePacket update = (ImprovedTerseObjectUpdatePacket)packet; foreach (ImprovedTerseObjectUpdatePacket.ObjectDataBlock block in update.ObjectData) { // Is it an avatar? if (block.Data[5] != 0) { uint localid = Utils.BytesToUInt(block.Data, 0); PubComb.Aux_Avatar avatar = SharedInfo.Aux_Simulators[simIP].AvatarByLocalID(localid); if (avatar != null) { // update position avatar.Position = new Vector3(block.Data, 22); SharedInfo.Aux_Simulators[simIP].Avatars[avatar.UUID].Position = avatar.Position; if (avatar.UUID == frame.AgentID) { SharedInfo.AvPosition = avatar.Position; } form.UpdateAvatar(avatar); } } } return(packet); }
public void UpdateAvatar1(PubComb.Aux_Avatar avatar) { lock (dataGridView1.Rows) { int t = dataGridView1.Rows.Count; for (int i = 0; i < t; i++) { if ((string)dataGridView1.Rows[i].Cells["UUID"].Value == avatar.UUID.ToString()) { dataGridView1.Rows[i].Cells["Position"].Value = avatar.Position.ToString(); return; } } } }
private Packet InKillObjectHandler(Packet packet, IPEndPoint sim) { string simIP = sim.ToString(); if (SharedInfo.Aux_Simulators.ContainsKey(simIP)) { KillObjectPacket KillObject = (KillObjectPacket)packet; List <UUID> ToBeRemoved = new List <UUID>(); foreach (KillObjectPacket.ObjectDataBlock block in KillObject.ObjectData) { PubComb.Aux_Avatar avatar = SharedInfo.Aux_Simulators[simIP].AvatarByLocalID(block.ID); if (avatar != null) { form.RemoveAvatar(avatar); ToBeRemoved.Add(avatar.UUID); } } foreach (UUID uuid in ToBeRemoved) { SharedInfo.Aux_Simulators[simIP].Avatars.Remove(uuid); } } return(packet); }
public void UpdateAvatar(PubComb.Aux_Avatar avatar) { this.dataGridView1.Invoke(new UpdatevatarCallback(this.UpdateAvatar1), new object[] { avatar }); }
public void RemoveAvatar(PubComb.Aux_Avatar avatar) { this.dataGridView1.Invoke(new RemAvatarCallback(this.RemoveAvatar1), new object[] { avatar }); }
public void AddAvatar1(PubComb.Aux_Avatar avatar) { dataGridView1.Rows.Add(new string[] { avatar.Name, avatar.UUID.ToString(), avatar.sim_IP.ToString(), avatar.LocalID.ToString(), avatar.Position.ToString() }); }
private Packet InObjectUpdateHandler(Packet packet, IPEndPoint sim) { string simIP = sim.ToString(); ObjectUpdatePacket ObjectUpdate = (ObjectUpdatePacket)packet; foreach (ObjectUpdatePacket.ObjectDataBlock block in ObjectUpdate.ObjectData) { if (block.PCode == 0x2f) // Avatars only { // If this simulator doesn't exist, create it if (!SharedInfo.Aux_Simulators.ContainsKey(simIP)) { SharedInfo.Aux_Simulators.Add(simIP, new PubComb.Aux_Simulator(simIP)); } Vector3 position = new Vector3(); #region decode position switch (block.ObjectData.Length) { case 76: position = new Vector3(block.ObjectData, 16); break; case 60: position = new Vector3(block.ObjectData, 0); break; case 32: // The data is an array of unsigned shorts position = new Vector3( Utils.UInt16ToFloat(block.ObjectData, 0, -0.5f * 256.0f, 1.5f * 256.0f), Utils.UInt16ToFloat(block.ObjectData, 2, -0.5f * 256.0f, 1.5f * 256.0f), Utils.UInt16ToFloat(block.ObjectData, 4, -256.0f, 3.0f * 256.0f)); break; case 16: // The data is an array of single bytes (8-bit numbers) position = new Vector3( Utils.ByteToFloat(block.ObjectData, 0, -256.0f, 256.0f), Utils.ByteToFloat(block.ObjectData, 1, -256.0f, 256.0f), Utils.ByteToFloat(block.ObjectData, 2, -256.0f, 256.0f)); break; default: plugin.SayToUser("Couldn't decode position, the data was " + block.ObjectData.Length.ToString() + " bytes long."); break; } #endregion string FirstName = null; string LastName = null; #region decode name if (block.NameValue != null) { string[] namevalues = Utils.BytesToString(block.NameValue).Split("\r\n".ToCharArray()); foreach (string line in namevalues) { NameValue namevalue = new NameValue(line); if (namevalue.Value != null) { if (namevalue.Name == "FirstName") { FirstName = Convert.ToString(namevalue.Value); } else if (namevalue.Name == "LastName") { LastName = Convert.ToString(namevalue.Value); } } } } string name = ""; if (FirstName != null) name += FirstName; else name += "(Waiting)"; name += " "; if (LastName != null) name += LastName; else name += "(Waiting)"; #endregion PubComb.Aux_Avatar avatar = new PubComb.Aux_Avatar(block.FullID, simIP, block.ID, name, position); if (!SharedInfo.Aux_Simulators[simIP].Avatars.ContainsKey(block.FullID)) { // Add avatar to simulator SharedInfo.Aux_Simulators[simIP].Avatars.Add(block.FullID, avatar); form.AddAvatar(avatar); } else { // Just update the avatar's position SharedInfo.Aux_Simulators[simIP].Avatars[block.FullID].Position = position; form.UpdateAvatar(avatar); } if (avatar.UUID == frame.AgentID) { SharedInfo.AgentName = name; SharedInfo.AvPosition = position; } } } return packet; }
private Packet InObjectUpdateHandler(Packet packet, IPEndPoint sim) { string simIP = sim.ToString(); ObjectUpdatePacket ObjectUpdate = (ObjectUpdatePacket)packet; foreach (ObjectUpdatePacket.ObjectDataBlock block in ObjectUpdate.ObjectData) { if (block.PCode == 0x2f) // Avatars only { // If this simulator doesn't exist, create it if (!SharedInfo.Aux_Simulators.ContainsKey(simIP)) { SharedInfo.Aux_Simulators.Add(simIP, new PubComb.Aux_Simulator(simIP)); } Vector3 position = new Vector3(); #region decode position switch (block.ObjectData.Length) { case 76: position = new Vector3(block.ObjectData, 16); break; case 60: position = new Vector3(block.ObjectData, 0); break; case 32: // The data is an array of unsigned shorts position = new Vector3( Utils.UInt16ToFloat(block.ObjectData, 0, -0.5f * 256.0f, 1.5f * 256.0f), Utils.UInt16ToFloat(block.ObjectData, 2, -0.5f * 256.0f, 1.5f * 256.0f), Utils.UInt16ToFloat(block.ObjectData, 4, -256.0f, 3.0f * 256.0f)); break; case 16: // The data is an array of single bytes (8-bit numbers) position = new Vector3( Utils.ByteToFloat(block.ObjectData, 0, -256.0f, 256.0f), Utils.ByteToFloat(block.ObjectData, 1, -256.0f, 256.0f), Utils.ByteToFloat(block.ObjectData, 2, -256.0f, 256.0f)); break; default: plugin.SayToUser("Couldn't decode position, the data was " + block.ObjectData.Length.ToString() + " bytes long."); break; } #endregion string FirstName = null; string LastName = null; #region decode name if (block.NameValue != null) { string[] namevalues = Utils.BytesToString(block.NameValue).Split("\r\n".ToCharArray()); foreach (string line in namevalues) { NameValue namevalue = new NameValue(line); if (namevalue.Value != null) { if (namevalue.Name == "FirstName") { FirstName = Convert.ToString(namevalue.Value); } else if (namevalue.Name == "LastName") { LastName = Convert.ToString(namevalue.Value); } } } } string name = ""; if (FirstName != null) { name += FirstName; } else { name += "(Waiting)"; } name += " "; if (LastName != null) { name += LastName; } else { name += "(Waiting)"; } #endregion PubComb.Aux_Avatar avatar = new PubComb.Aux_Avatar(block.FullID, simIP, block.ID, name, position); if (!SharedInfo.Aux_Simulators[simIP].Avatars.ContainsKey(block.FullID)) { // Add avatar to simulator SharedInfo.Aux_Simulators[simIP].Avatars.Add(block.FullID, avatar); form.AddAvatar(avatar); } else { // Just update the avatar's position SharedInfo.Aux_Simulators[simIP].Avatars[block.FullID].Position = position; form.UpdateAvatar(avatar); } if (avatar.UUID == frame.AgentID) { SharedInfo.AgentName = name; SharedInfo.AvPosition = position; } } } return(packet); }