public void Populate(Scene scene) { SceneObjectPart part = scene.GetSceneObjectPart(Key); if (part == null) // Avatar, maybe? { ScenePresence presence = scene.GetScenePresence(Key); if (presence == null) return; Name = presence.Firstname + " " + presence.Lastname; Owner = Key; Position = new LSL_Types.Vector3( presence.AbsolutePosition.X, presence.AbsolutePosition.Y, presence.AbsolutePosition.Z); Rotation = new LSL_Types.Quaternion( presence.Rotation.X, presence.Rotation.Y, presence.Rotation.Z, presence.Rotation.W); Velocity = new LSL_Types.Vector3( presence.Velocity.X, presence.Velocity.Y, presence.Velocity.Z); Type = 0x01; // Avatar if (presence.Velocity != Vector3.Zero) Type |= 0x02; // Active Group = presence.ControllingClient.ActiveGroupId; return; } part=part.ParentGroup.RootPart; // We detect objects only LinkNum = 0; // Not relevant Group = part.GroupID; Name = part.Name; Owner = part.OwnerID; if (part.Velocity == Vector3.Zero) Type = 0x04; // Passive else Type = 0x02; // Passive foreach (SceneObjectPart p in part.ParentGroup.ChildrenList) { if (p.Inventory.ContainsScripts()) { Type |= 0x08; // Scripted break; } } Position = new LSL_Types.Vector3(part.AbsolutePosition.X, part.AbsolutePosition.Y, part.AbsolutePosition.Z); Quaternion wr = part.ParentGroup.GroupRotation; Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W); Velocity = new LSL_Types.Vector3(part.Velocity.X, part.Velocity.Y, part.Velocity.Z); }
public DetectParams() { Key = UUID.Zero; OffsetPos = new LSL_Types.Vector3(); LinkNum = 0; Group = UUID.Zero; Name = String.Empty; Owner = UUID.Zero; Position = new LSL_Types.Vector3(); Rotation = new LSL_Types.Quaternion(); Type = 0; Velocity = new LSL_Types.Vector3(); initializeSurfaceTouch(); }
public void SetStoreVars(Dictionary<string, object> vars) { if (!m_useStateSaves) return; m_lastStateSaveValues = vars; m_stateSaveRequired = false; //If something is setting the vars, we don't need to do a state save, as this came from a state save Type t = GetType (); FieldInfo[] fields = t.GetFields (BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly); foreach (FieldInfo field in fields) { if (vars.ContainsKey (field.Name)) { object var = vars[field.Name]; if (field.FieldType == typeof (LSL_Types.list)) { string val = var.ToString (); int end; LSL_Types.list v = ParseValueToList (val, 0, out end); field.SetValue (this, v); } else if (field.FieldType == typeof (LSL_Types.LSLInteger)) { int val = int.Parse (var.ToString ()); field.SetValue (this, new LSL_Types.LSLInteger (val)); } else if (field.FieldType == typeof (LSL_Types.LSLString)) { string val = var.ToString (); field.SetValue (this, new LSL_Types.LSLString (val)); } else if (field.FieldType == typeof (LSL_Types.LSLFloat)) { float val = float.Parse (var.ToString ()); field.SetValue (this, new LSL_Types.LSLFloat (val)); } else if (field.FieldType == typeof (Int32)) { Int32 val = Int32.Parse (var.ToString ()); field.SetValue (this, val); } else if (field.FieldType == typeof (Double)) { Double val = Double.Parse (var.ToString ()); field.SetValue (this, val); } else if (field.FieldType == typeof (Single)) { Single val = Single.Parse (var.ToString ()); field.SetValue (this, val); } else if (field.FieldType == typeof (String)) { String val = var.ToString (); field.SetValue (this, val); } else if (field.FieldType == typeof (Byte)) { Byte val = Byte.Parse (var.ToString ()); field.SetValue (this, val); } else if (field.FieldType == typeof (short)) { short val = short.Parse (var.ToString ()); field.SetValue (this, val); } else if (field.FieldType == typeof (LSL_Types.Quaternion)) { LSL_Types.Quaternion val = new LSL_Types.Quaternion (var.ToString ()); field.SetValue (this, val); } else if (field.FieldType == typeof (LSL_Types.Vector3)) { LSL_Types.Vector3 val = new LSL_Types.Vector3 (var.ToString ()); field.SetValue (this, val); } } } fields = null; t = null; }
// This can be done in two places including the constructor // so be carefull what gets added here private void initializeSurfaceTouch() { touchST = new LSL_Types.Vector3(-1.0, -1.0, 0.0); touchNormal = new LSL_Types.Vector3(); touchBinormal = new LSL_Types.Vector3(); touchPos = new LSL_Types.Vector3(); touchUV = new LSL_Types.Vector3(-1.0, -1.0, 0.0); touchFace = -1; }
private void Load() { Position = prim.OSSL.llGetPos(); }
public void SetStoreVars(Dictionary<string, object> vars) { foreach (KeyValuePair<string, object> var in vars) { if (m_Fields.ContainsKey(var.Key)) { try { if (m_Fields[var.Key].FieldType == typeof(LSL_Types.list)) { string val = var.Value.ToString(); int end; LSL_Types.list v = ParseValueToList(val,0,out end); m_Fields[var.Key].SetValue(this, v); } else if (m_Fields[var.Key].FieldType == typeof(LSL_Types.LSLInteger)) { int val = int.Parse(var.Value.ToString()); m_Fields[var.Key].SetValue(this, new LSL_Types.LSLInteger(val)); } else if (m_Fields[var.Key].FieldType == typeof(LSL_Types.LSLString)) { string val = var.Value.ToString(); m_Fields[var.Key].SetValue(this, new LSL_Types.LSLString(val)); } else if (m_Fields[var.Key].FieldType == typeof(LSL_Types.LSLFloat)) { float val = float.Parse(var.Value.ToString()); m_Fields[var.Key].SetValue(this, new LSL_Types.LSLFloat(val)); } else if (m_Fields[var.Key].FieldType == typeof(Int32)) { Int32 val = Int32.Parse(var.Value.ToString()); m_Fields[var.Key].SetValue(this, val); } else if (m_Fields[var.Key].FieldType == typeof(Double)) { Double val = Double.Parse(var.Value.ToString()); m_Fields[var.Key].SetValue(this, val); } else if (m_Fields[var.Key].FieldType == typeof(Single)) { Single val = Single.Parse(var.Value.ToString()); m_Fields[var.Key].SetValue(this, val); } else if (m_Fields[var.Key].FieldType == typeof(String)) { String val = var.Value.ToString(); m_Fields[var.Key].SetValue(this, val); } else if (m_Fields[var.Key].FieldType == typeof(Byte)) { Byte val = Byte.Parse(var.Value.ToString()); m_Fields[var.Key].SetValue(this, val); } else if (m_Fields[var.Key].FieldType == typeof(short)) { short val = short.Parse(var.Value.ToString()); m_Fields[var.Key].SetValue(this, val); } else if (m_Fields[var.Key].FieldType == typeof(LSL_Types.Quaternion)) { LSL_Types.Quaternion val = new LSL_Types.Quaternion(var.Value.ToString()); m_Fields[var.Key].SetValue(this, val); } else if (m_Fields[var.Key].FieldType == typeof(LSL_Types.Vector3)) { LSL_Types.Vector3 val = new LSL_Types.Vector3(var.Value.ToString()); m_Fields[var.Key].SetValue(this, val); } } catch (Exception) { } } } }
public bool PostObjectEvent(UUID primID, string name, Object[] p) { Object[] lsl_p = new Object[p.Length]; for (int i = 0; i < p.Length ; i++) { if (p[i] is int) lsl_p[i] = new LSL_Types.LSLInteger((int)p[i]); else if (p[i] is UUID) lsl_p[i] = new LSL_Types.LSLString(UUID.Parse(p[i].ToString()).ToString()); else if (p[i] is string) lsl_p[i] = new LSL_Types.LSLString((string)p[i]); else if (p[i] is Vector3) lsl_p[i] = new LSL_Types.Vector3(((Vector3)p[i]).X, ((Vector3)p[i]).Y, ((Vector3)p[i]).Z); else if (p[i] is Quaternion) lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W); else if (p[i] is float) lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]); else lsl_p[i] = p[i]; } return AddToObjectQueue(primID, name, new DetectParams[0], -1, lsl_p); }
public bool PostScriptEvent(UUID itemID, UUID primID, string name, Object[] p) { Object[] lsl_p = new Object[p.Length]; for (int i = 0; i < p.Length ; i++) { if (p[i] is int) lsl_p[i] = new LSL_Types.LSLInteger((int)p[i]); else if (p[i] is UUID) lsl_p[i] = new LSL_Types.LSLString(UUID.Parse(p[i].ToString()).ToString()); else if (p[i] is string) lsl_p[i] = new LSL_Types.LSLString((string)p[i]); else if (p[i] is Vector3) lsl_p[i] = new LSL_Types.Vector3(((Vector3)p[i]).X, ((Vector3)p[i]).Y, ((Vector3)p[i]).Z); else if (p[i] is Quaternion) lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W); else if (p[i] is float) lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]); else lsl_p[i] = p[i]; } return PostScriptEvent(itemID, primID, new EventParams(name, lsl_p, new DetectParams[0]), EventPriority.FirstStart); }
public void Populate(IScene scene) { ISceneChildEntity part = scene.GetSceneObjectPart (Key); Vector3 tmp; if (part == null) // Avatar, maybe? { IScenePresence presence = scene.GetScenePresence(Key); if (presence == null) return; Name = presence.Name; Owner = Key; tmp = presence.AbsolutePosition; Position = new LSL_Types.Vector3( tmp.X, tmp.Y, tmp.Z); Quaternion rtmp = presence.Rotation; Rotation = new LSL_Types.Quaternion( rtmp.X, rtmp.Y, rtmp.Z, rtmp.W); tmp = presence.Velocity; Velocity = new LSL_Types.Vector3( tmp.X, tmp.Y, tmp.Z); Type = 0x01; // Avatar if (presence.Velocity != Vector3.Zero) Type |= 0x02; // Active Group = presence.ControllingClient.ActiveGroupId; return; } part=part.ParentEntity.RootChild; // We detect objects only LinkNum = 0; // Not relevant Group = part.GroupID; Name = part.Name; Owner = part.OwnerID; if (part.Velocity == Vector3.Zero) Type = 0x04; // Passive else Type = 0x02; // Passive foreach (ISceneChildEntity p in part.ParentEntity.ChildrenEntities ()) { if (p.Inventory.ContainsScripts()) { Type |= 0x08; // Scripted break; } } tmp = part.AbsolutePosition; Position = new LSL_Types.Vector3(tmp.X, tmp.Y, tmp.Z); Quaternion wr = part.ParentEntity.GroupRotation; Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W); tmp = part.Velocity; Velocity = new LSL_Types.Vector3(tmp.X, tmp.Y, tmp.Z); }
public void SetVars(Dictionary<string, object> vars) { foreach (KeyValuePair<string, object> var in vars) { if (m_Fields.ContainsKey(var.Key)) { try { if (m_Fields[var.Key].FieldType == typeof(LSL_Types.list)) { LSL_Types.list v = (LSL_Types.list)m_Fields[var.Key].GetValue(this); Object[] data = (new LSL_Types.list(var.Value.ToString())).Data; v.Data = new Object[data.Length]; Array.Copy(data, 0, v.Data, 0, data.Length); m_Fields[var.Key].SetValue(this, v); } else if (m_Fields[var.Key].FieldType == typeof(LSL_Types.LSLInteger)) { int val = int.Parse(var.Value.ToString()); m_Fields[var.Key].SetValue(this, new LSL_Types.LSLInteger(val)); } else if (m_Fields[var.Key].FieldType == typeof(LSL_Types.LSLString)) { string val = var.Value.ToString(); m_Fields[var.Key].SetValue(this, new LSL_Types.LSLString(val)); } else if (m_Fields[var.Key].FieldType == typeof(LSL_Types.LSLFloat)) { float val = float.Parse(var.Value.ToString()); m_Fields[var.Key].SetValue(this, new LSL_Types.LSLFloat(val)); } else if (m_Fields[var.Key].FieldType == typeof(Int32)) { Int32 val = Int32.Parse(var.Value.ToString()); m_Fields[var.Key].SetValue(this, val); } else if (m_Fields[var.Key].FieldType == typeof(Double)) { Double val = Double.Parse(var.Value.ToString()); m_Fields[var.Key].SetValue(this, val); } else if (m_Fields[var.Key].FieldType == typeof(Single)) { Single val = Single.Parse(var.Value.ToString()); m_Fields[var.Key].SetValue(this, val); } else if (m_Fields[var.Key].FieldType == typeof(String)) { String val = var.Value.ToString(); m_Fields[var.Key].SetValue(this, val); } else if (m_Fields[var.Key].FieldType == typeof(Byte)) { Byte val = Byte.Parse(var.Value.ToString()); m_Fields[var.Key].SetValue(this, val); } else if (m_Fields[var.Key].FieldType == typeof(short)) { short val = short.Parse(var.Value.ToString()); m_Fields[var.Key].SetValue(this, val); } else if (m_Fields[var.Key].FieldType == typeof(LSL_Types.Quaternion)) { LSL_Types.Quaternion val = new LSL_Types.Quaternion(var.Value.ToString()); m_Fields[var.Key].SetValue(this, val); } else if (m_Fields[var.Key].FieldType == typeof(LSL_Types.Vector3)) { LSL_Types.Vector3 val = new LSL_Types.Vector3(var.Value.ToString()); m_Fields[var.Key].SetValue(this, val); } } catch (Exception) { } } } }
public void SetStoreVars(Dictionary<string, object> vars) { m_lastStateSaveValues = vars; m_stateSaveRequired = false; //If something is setting the vars, we don't need to do a state save, as this came from a state save foreach (KeyValuePair<string, object> var in vars) { if (m_Fields.ContainsKey (var.Key)) { try { if (m_Fields[var.Key].FieldType == typeof (LSL_Types.list)) { string val = var.Value.ToString (); int end; LSL_Types.list v = ParseValueToList (val, 0, out end); m_Fields[var.Key].SetValue (this, v); } else if (m_Fields[var.Key].FieldType == typeof (LSL_Types.LSLInteger)) { int val = int.Parse (var.Value.ToString ()); m_Fields[var.Key].SetValue (this, new LSL_Types.LSLInteger (val)); } else if (m_Fields[var.Key].FieldType == typeof (LSL_Types.LSLString)) { string val = var.Value.ToString (); m_Fields[var.Key].SetValue (this, new LSL_Types.LSLString (val)); } else if (m_Fields[var.Key].FieldType == typeof (LSL_Types.LSLFloat)) { float val = float.Parse (var.Value.ToString ()); m_Fields[var.Key].SetValue (this, new LSL_Types.LSLFloat (val)); } else if (m_Fields[var.Key].FieldType == typeof (Int32)) { Int32 val = Int32.Parse (var.Value.ToString ()); m_Fields[var.Key].SetValue (this, val); } else if (m_Fields[var.Key].FieldType == typeof (Double)) { Double val = Double.Parse (var.Value.ToString ()); m_Fields[var.Key].SetValue (this, val); } else if (m_Fields[var.Key].FieldType == typeof (Single)) { Single val = Single.Parse (var.Value.ToString ()); m_Fields[var.Key].SetValue (this, val); } else if (m_Fields[var.Key].FieldType == typeof (String)) { String val = var.Value.ToString (); m_Fields[var.Key].SetValue (this, val); } else if (m_Fields[var.Key].FieldType == typeof (Byte)) { Byte val = Byte.Parse (var.Value.ToString ()); m_Fields[var.Key].SetValue (this, val); } else if (m_Fields[var.Key].FieldType == typeof (short)) { short val = short.Parse (var.Value.ToString ()); m_Fields[var.Key].SetValue (this, val); } else if (m_Fields[var.Key].FieldType == typeof (LSL_Types.Quaternion)) { LSL_Types.Quaternion val = new LSL_Types.Quaternion (var.Value.ToString ()); m_Fields[var.Key].SetValue (this, val); } else if (m_Fields[var.Key].FieldType == typeof (LSL_Types.Vector3)) { LSL_Types.Vector3 val = new LSL_Types.Vector3 (var.Value.ToString ()); m_Fields[var.Key].SetValue (this, val); } } catch (Exception) { } } } }