private void SetCourseLocationDelegate(ScenePresence presence) { presence.SetSendCourseLocationMethod(SendCourseLocationUpdates); }
private void NewPresence(ScenePresence presence) { if (presence.IsChildAgent) { byte[] throttleData; try { throttleData = presence.ControllingClient.GetThrottlesPacked(1); } catch (NotImplementedException) { return; } if (throttleData == null) return; if (throttleData.Length == 0) return; if (throttleData.Length != 28) return; byte[] adjData; int pos = 0; if (!BitConverter.IsLittleEndian) { byte[] newData = new byte[7 * 4]; Buffer.BlockCopy(throttleData, 0, newData, 0, 7 * 4); for (int i = 0; i < 7; i++) Array.Reverse(newData, i * 4, 4); adjData = newData; } else { adjData = throttleData; } // 0.125f converts from bits to bytes int resend = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; int land = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; int wind = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; int cloud = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; int task = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4; int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); // State is a subcategory of task that we allocate a percentage to //int total = resend + land + wind + cloud + task + texture + asset; byte[] data = new byte[7 * 4]; int ii = 0; Buffer.BlockCopy(Utils.FloatToBytes(resend), 0, data, ii, 4); ii += 4; Buffer.BlockCopy(Utils.FloatToBytes(land * 50), 0, data, ii, 4); ii += 4; Buffer.BlockCopy(Utils.FloatToBytes(wind), 0, data, ii, 4); ii += 4; Buffer.BlockCopy(Utils.FloatToBytes(cloud), 0, data, ii, 4); ii += 4; Buffer.BlockCopy(Utils.FloatToBytes(task), 0, data, ii, 4); ii += 4; Buffer.BlockCopy(Utils.FloatToBytes(texture), 0, data, ii, 4); ii += 4; Buffer.BlockCopy(Utils.FloatToBytes(asset), 0, data, ii, 4); try { presence.ControllingClient.SetChildAgentThrottle(data); } catch (NotImplementedException) { return; } presence.SetSendCourseLocationMethod(SendCourseLocationUpdates); } }