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);
}
/// <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>
/// Get the current Windlight scene
/// </summary>
@ -229,10 +251,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return values;
}
}
private RegionMeta7WindlightData getWindlightProfileFromRules(LSL_List rules)
{
{
RegionMeta7WindlightData wl = (RegionMeta7WindlightData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone();
LSL_List values = new LSL_List();
@ -244,9 +266,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Types.Vector3 iV;
switch (rule)
{
case (int)ScriptBaseClass.WL_SUN_MOON_POSITION:
idx++;
wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx);
case (int)ScriptBaseClass.WL_SUN_MOON_POSITION:
idx++;
wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx);
break;
case (int)ScriptBaseClass.WL_AMBIENT:
idx++;
@ -419,58 +441,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
CMShoutError("Careminster functions are not enabled.");
return 0;
}
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.");
return 0;
}
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.");
return 0;
}
int success = 0;
m_host.AddScriptLPS(1);
if (Meta7WindlightModule.EnableWindlight)
{
RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules);
m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
success = 1;
}
else
{
CMShoutError("Windlight module is disabled");
return 0;
m_host.AddScriptLPS(1);
if (Meta7WindlightModule.EnableWindlight)
{
RegionMeta7WindlightData wl = getWindlightProfileFromRules(rules);
m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
success = 1;
}
else
{
CMShoutError("Windlight module is disabled");
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;
}
/// <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
LSL_List cmGetWindlightScene(LSL_List rules);
int cmSetWindlightScene(LSL_List rules);
int cmSetWindlightScene(LSL_List rules);
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)
{
return m_CM_Functions.cmSetWindlightScene(rules);
}
public int cmSetWindlightSceneTargeted(LSL_List rules, key target)
{
return m_CM_Functions.cmSetWindlightSceneTargeted(rules, target);
}
public int cmSetWindlightSceneTargeted(LSL_List rules, key target)
{
return m_CM_Functions.cmSetWindlightSceneTargeted(rules, target);
}
public LSL_List cmGetAvatarList()
{
return m_CM_Functions.cmGetAvatarList();
}
}
}