private void SensorSweep(SensorInfo ts) { if (ts.host == null) { return; } List<SensedEntity> sensedEntities = new List<SensedEntity>(); // Is the sensor type is AGENT and not SCRIPTED then include agents if ((ts.type & (AGENT | AGENT_BY_USERNAME | NPC | OS_NPC)) != 0 && (ts.type & SCRIPTED) == 0) { sensedEntities.AddRange(doAgentSensor(ts)); } // If SCRIPTED or PASSIVE or ACTIVE check objects if ((ts.type & SCRIPTED) != 0 || (ts.type & PASSIVE) != 0 || (ts.type & ACTIVE) != 0) { sensedEntities.AddRange(doObjectSensor(ts)); } lock (SenseLock) { if (sensedEntities.Count == 0) { // send a "no_sensor" // Add it to queue m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, new EventParams("no_sensor", new Object[0], new DetectParams[0])); } else { // Sort the list to get everything ordered by distance sensedEntities.Sort(); int count = sensedEntities.Count; int idx; List<DetectParams> detected = new List<DetectParams>(); for (idx = 0; idx < count; idx++) { try { DetectParams detect = new DetectParams(); detect.Key = sensedEntities[idx].itemID; detect.Populate(m_CmdManager.m_ScriptEngine.World); detected.Add(detect); } catch (Exception) { // Ignore errors, the object has been deleted or the avatar has gone and // there was a problem in detect.Populate so nothing added to the list } if (detected.Count == maximumToReturn) break; } if (detected.Count == 0) { // To get here with zero in the list there must have been some sort of problem // like the object being deleted or the avatar leaving to have caused some // difficulty during the Populate above so fire a no_sensor event m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, new EventParams("no_sensor", new Object[0], new DetectParams[0])); } else { m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, new EventParams("sensor", new Object[] {new LSL_Types.LSLInteger(detected.Count) }, detected.ToArray())); } } } }
public void land_collision_end(uint localID, ColliderArgs col) { List<DetectParams> det = new List<DetectParams>(); foreach (DetectedObject detobj in col.Colliders) { DetectParams d = new DetectParams(); d.Position = detobj.posVector; d.Populate(myScriptEngine.World); det.Add(d); myScriptEngine.PostObjectEvent(localID, new EventParams( "land_collision_end", new Object[] { new LSL_Types.Vector3(d.Position) }, det.ToArray())); } }
private void SensorSweep(SenseRepeatClass ts) { if (ts.host == null) { return; } List<SensedEntity> sensedEntities = new List<SensedEntity>(); // Is the sensor type is AGENT and not SCRIPTED then include agents if ((ts.type & AGENT) != 0 && (ts.type & SCRIPTED) == 0) { sensedEntities.AddRange(doAgentSensor(ts)); } // If SCRIPTED or PASSIVE or ACTIVE check objects if ((ts.type & SCRIPTED) != 0 || (ts.type & PASSIVE) != 0 || (ts.type & ACTIVE) != 0) { sensedEntities.AddRange(doObjectSensor(ts)); } lock (SenseLock) { List<DetectParams> detected = new List<DetectParams>(); if (sensedEntities.Count == 0) { if (ts.host is ScenePresence) { //If it is a scenePresence, then it is a bot that is being used for scanning. // We need to set the bot parameter in the detectParams so that iwDetectedBot works properly // so we have to have at least one detectParam object DetectParams detect = new DetectParams(); detect.BotID = ((ScenePresence)ts.host).UUID; detected.Add(detect); } // send a "no_sensor" // Add it to queue m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, new EventParams("no_sensor", new Object[0], detected.ToArray())); } else { // Sort the list to get everything ordered by distance sensedEntities.Sort(); int count = sensedEntities.Count; int idx; for (idx = 0; idx < count; idx++) { try { DetectParams detect = new DetectParams(); detect.Key = sensedEntities[idx].itemID; if (ts.host is ScenePresence) { //If it is a scenePresence, then it is a bot that is being used for scanning. // We need to set the bot parameter in the detectParams so that iwDetectedBot works properly detect.BotID = ((ScenePresence)ts.host).UUID; if (detect.BotID == detect.Key) continue;//Don't allow the ScenePresence that is scanning to detect itself } detect.Populate(m_CmdManager.m_ScriptEngine.World); detected.Add(detect); } catch (Exception) { // Ignore errors, the object has been deleted or the avatar has gone and // there was a problem in detect.Populate so nothing added to the list } if (detected.Count == maximumToReturn) break; } if (detected.Count == 0) { if (ts.host is ScenePresence) { //If it is a scenePresence, then it is a bot that is being used for scanning. // We need to set the bot parameter in the detectParams so that iwDetectedBot works properly // so we have to have at least one detectParam object DetectParams detect = new DetectParams(); detect.BotID = ((ScenePresence)ts.host).UUID; detected.Add(detect); } // To get here with zero in the list there must have been some sort of problem // like the object being deleted or the avatar leaving to have caused some // difficulty during the Populate above so fire a no_sensor event m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, new EventParams("no_sensor", new Object[0], detected.ToArray())); } else { m_CmdManager.m_ScriptEngine.PostScriptEvent(ts.itemID, new EventParams("sensor", new Object[] {detected.Count}, detected.ToArray())); } } } }
public void collision_end(uint localID, ColliderArgs col) { // Add to queue for all scripts in ObjectID object List<DetectParams> det = new List<DetectParams>(); foreach (DetectedObject detobj in col.Colliders) { DetectParams d = new DetectParams(); d.Key =detobj.keyUUID; d.Populate(myScriptEngine.World); det.Add(d); } if (det.Count > 0) myScriptEngine.PostObjectEvent(localID, new EventParams( "collision_end", new Object[] { new LSL_Types.LSLInteger(det.Count) }, det.ToArray())); }