Implement cmGetAvatarList(). This returns a strided list of all avatars in the region, including their UUID, position and name. The radar is often the most taxing scripts on a sim, this function can help radars reduce their impact by 66% by eliminating the need for sensors.

avinationmerge
Thomas Grimshaw 2010-04-07 23:53:08 +02:00
parent e80e04c5fd
commit d834a2c3da
3 changed files with 87 additions and 60 deletions

View File

@ -85,6 +85,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
} }
/// <summary>
/// Like osGetAgents but returns enough info for a radar
/// </summary>
/// <returns>Strided list of the UUID, position and name of each avatar in the region</returns>
public LSL_List cmGetAvatarList()
{
LSL_List result = new LSL_List();
foreach (ScenePresence avatar in World.GetAvatars())
{
if (avatar.UUID != m_host.OwnerID)
{
if (avatar.IsChildAgent == false)
{
result.Add(avatar.UUID);
result.Add(avatar.PhysicsActor.Position);
result.Add(avatar.Name);
}
}
}
return result;
}
/// <summary> /// <summary>
/// Get the current Windlight scene /// Get the current Windlight scene
/// </summary> /// </summary>
@ -229,10 +251,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return values; return values;
} }
private RegionMeta7WindlightData getWindlightProfileFromRules(LSL_List rules) private RegionMeta7WindlightData getWindlightProfileFromRules(LSL_List rules)
{ {
RegionMeta7WindlightData wl = (RegionMeta7WindlightData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone(); RegionMeta7WindlightData wl = (RegionMeta7WindlightData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone();
LSL_List values = new LSL_List(); LSL_List values = new LSL_List();
@ -244,9 +266,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Types.Vector3 iV; LSL_Types.Vector3 iV;
switch (rule) switch (rule)
{ {
case (int)ScriptBaseClass.WL_SUN_MOON_POSITION: case (int)ScriptBaseClass.WL_SUN_MOON_POSITION:
idx++; idx++;
wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx); wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx);
break; break;
case (int)ScriptBaseClass.WL_AMBIENT: case (int)ScriptBaseClass.WL_AMBIENT:
idx++; idx++;
@ -419,58 +441,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
CMShoutError("Careminster functions are not enabled."); CMShoutError("Careminster functions are not enabled.");
return 0; return 0;
} }
if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200) if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
{ {
CMShoutError("cmSetWindlightScene can only be used by estate managers or owners."); CMShoutError("cmSetWindlightScene can only be used by estate managers or owners.");
return 0; return 0;
} }
int success = 0; int success = 0;
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
if (Meta7WindlightModule.EnableWindlight) if (Meta7WindlightModule.EnableWindlight)
{ {
RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules); RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules);
m_host.ParentGroup.Scene.StoreWindlightProfile(wl); m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
success = 1; success = 1;
} }
else else
{ {
CMShoutError("Windlight module is disabled"); CMShoutError("Windlight module is disabled");
return 0; return 0;
}
return success;
}
/// <summary>
/// Set the current Windlight scene to a target avatar
/// </summary>
/// <param name="rules"></param>
/// <returns>success: true or false</returns>
public int cmSetWindlightSceneTargeted(LSL_List rules, LSL_Key target)
{
if (!m_CMFunctionsEnabled)
{
CMShoutError("Careminster functions are not enabled.");
return 0;
}
if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
{
CMShoutError("cmSetWindlightSceneTargeted can only be used by estate managers or owners.");
return 0;
}
int success = 0;
m_host.AddScriptLPS(1);
if (Meta7WindlightModule.EnableWindlight)
{
RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules);
World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string));
success = 1;
}
else
{
CMShoutError("Windlight module is disabled");
return 0;
} }
return success; return success;
}
/// <summary>
/// Set the current Windlight scene to a target avatar
/// </summary>
/// <param name="rules"></param>
/// <returns>success: true or false</returns>
public int cmSetWindlightSceneTargeted(LSL_List rules, LSL_Key target)
{
if (!m_CMFunctionsEnabled)
{
CMShoutError("Careminster functions are not enabled.");
return 0;
}
if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
{
CMShoutError("cmSetWindlightSceneTargeted can only be used by estate managers or owners.");
return 0;
}
int success = 0;
m_host.AddScriptLPS(1);
if (Meta7WindlightModule.EnableWindlight)
{
RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules);
World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string));
success = 1;
}
else
{
CMShoutError("Windlight module is disabled");
return 0;
}
return success;
} }
} }

View File

@ -15,7 +15,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
{ {
// Windlight Functions // Windlight Functions
LSL_List cmGetWindlightScene(LSL_List rules); LSL_List cmGetWindlightScene(LSL_List rules);
int cmSetWindlightScene(LSL_List rules); int cmSetWindlightScene(LSL_List rules);
int cmSetWindlightSceneTargeted(LSL_List rules, key target); int cmSetWindlightSceneTargeted(LSL_List rules, key target);
LSL_List cmGetAvatarList();
} }
} }

View File

@ -66,11 +66,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public int cmSetWindlightScene(LSL_List rules) public int cmSetWindlightScene(LSL_List rules)
{ {
return m_CM_Functions.cmSetWindlightScene(rules); return m_CM_Functions.cmSetWindlightScene(rules);
} }
public int cmSetWindlightSceneTargeted(LSL_List rules, key target) public int cmSetWindlightSceneTargeted(LSL_List rules, key target)
{ {
return m_CM_Functions.cmSetWindlightSceneTargeted(rules, target); return m_CM_Functions.cmSetWindlightSceneTargeted(rules, target);
}
public LSL_List cmGetAvatarList()
{
return m_CM_Functions.cmGetAvatarList();
} }
} }
} }