those events are per script not per part
parent
c9137912c9
commit
ca48bf4117
|
@ -365,6 +365,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
|
|||
}
|
||||
else if (c.SenderUUID != UUID.Zero)
|
||||
{
|
||||
if(c.SenderObject == null)
|
||||
return;
|
||||
fromID = c.SenderUUID;
|
||||
ownerID = ((SceneObjectPart)c.SenderObject).OwnerID;
|
||||
}
|
||||
|
|
|
@ -569,7 +569,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// </summary>
|
||||
public event ScriptMovingEndEvent OnScriptMovingEndEvent;
|
||||
|
||||
public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos);
|
||||
public delegate void ScriptAtTargetEvent(UUID scriptID, uint handle, Vector3 targetpos, Vector3 atpos);
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when an object has arrived within a tolerance distance
|
||||
|
@ -583,7 +583,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// </remarks>
|
||||
public event ScriptAtTargetEvent OnScriptAtTargetEvent;
|
||||
|
||||
public delegate void ScriptNotAtTargetEvent(uint localID);
|
||||
public delegate void ScriptNotAtTargetEvent(UUID scriptID);
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when an object has a motion target but has not arrived
|
||||
|
@ -597,7 +597,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// </remarks>
|
||||
public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent;
|
||||
|
||||
public delegate void ScriptAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion atrot);
|
||||
public delegate void ScriptAtRotTargetEvent(UUID scriptID, uint handle, Quaternion targetrot, Quaternion atrot);
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when an object has arrived within a tolerance rotation
|
||||
|
@ -611,7 +611,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// </remarks>
|
||||
public event ScriptAtRotTargetEvent OnScriptAtRotTargetEvent;
|
||||
|
||||
public delegate void ScriptNotAtRotTargetEvent(uint localID);
|
||||
public delegate void ScriptNotAtRotTargetEvent(UUID scriptID);
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when an object has a rotation target but has not arrived
|
||||
|
@ -2325,7 +2325,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
public void TriggerAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 currentpos)
|
||||
public void TriggerAtTargetEvent(UUID scriptID, uint handle, Vector3 targetpos, Vector3 currentpos)
|
||||
{
|
||||
ScriptAtTargetEvent handlerScriptAtTargetEvent = OnScriptAtTargetEvent;
|
||||
if (handlerScriptAtTargetEvent != null)
|
||||
|
@ -2334,7 +2334,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
try
|
||||
{
|
||||
d(localID, handle, targetpos, currentpos);
|
||||
d(scriptID, handle, targetpos, currentpos);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -2346,7 +2346,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
public void TriggerNotAtTargetEvent(uint localID)
|
||||
public void TriggerNotAtTargetEvent(UUID scriptID)
|
||||
{
|
||||
ScriptNotAtTargetEvent handlerScriptNotAtTargetEvent = OnScriptNotAtTargetEvent;
|
||||
if (handlerScriptNotAtTargetEvent != null)
|
||||
|
@ -2355,7 +2355,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
try
|
||||
{
|
||||
d(localID);
|
||||
d(scriptID);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -2367,7 +2367,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
public void TriggerAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion currentrot)
|
||||
public void TriggerAtRotTargetEvent(UUID scriptID, uint handle, Quaternion targetrot, Quaternion currentrot)
|
||||
{
|
||||
ScriptAtRotTargetEvent handlerScriptAtRotTargetEvent = OnScriptAtRotTargetEvent;
|
||||
if (handlerScriptAtRotTargetEvent != null)
|
||||
|
@ -2376,7 +2376,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
try
|
||||
{
|
||||
d(localID, handle, targetrot, currentrot);
|
||||
d(scriptID, handle, targetrot, currentrot);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -2388,7 +2388,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
public void TriggerNotAtRotTargetEvent(uint localID)
|
||||
public void TriggerNotAtRotTargetEvent(UUID scriptID)
|
||||
{
|
||||
ScriptNotAtRotTargetEvent handlerScriptNotAtRotTargetEvent = OnScriptNotAtRotTargetEvent;
|
||||
if (handlerScriptNotAtRotTargetEvent != null)
|
||||
|
@ -2397,7 +2397,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
try
|
||||
{
|
||||
d(localID);
|
||||
d(scriptID);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
|
@ -88,7 +88,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
public Vector3 targetPos;
|
||||
public float tolerance;
|
||||
public int handle;
|
||||
public uint partLocalID;
|
||||
public UUID scriptID;
|
||||
}
|
||||
|
||||
public struct scriptRotTarget
|
||||
|
@ -96,7 +96,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
public Quaternion targetRot;
|
||||
public float tolerance;
|
||||
public int handle;
|
||||
public uint partLocalID;
|
||||
public UUID scriptID;
|
||||
}
|
||||
|
||||
public delegate void PrimCountTaintedDelegate();
|
||||
|
@ -4802,12 +4802,12 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
return 0;
|
||||
}
|
||||
|
||||
public int registerRotTargetWaypoint(uint partLocalID, Quaternion target, float tolerance)
|
||||
public int registerRotTargetWaypoint(UUID scriptID, Quaternion target, float tolerance)
|
||||
{
|
||||
scriptRotTarget waypoint = new scriptRotTarget();
|
||||
waypoint.targetRot = target;
|
||||
waypoint.tolerance = tolerance;
|
||||
waypoint.partLocalID = partLocalID;
|
||||
waypoint.scriptID = scriptID;
|
||||
int handle = m_scene.AllocateIntId();
|
||||
waypoint.handle = handle;
|
||||
lock (m_rotTargets)
|
||||
|
@ -4830,15 +4830,14 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
public int registerTargetWaypoint(uint partLocalID, Vector3 target, float tolerance)
|
||||
public int registerTargetWaypoint(UUID scriptID, Vector3 target, float tolerance)
|
||||
{
|
||||
|
||||
int handle = m_scene.AllocateIntId();
|
||||
|
||||
scriptPosTarget waypoint = new scriptPosTarget();
|
||||
waypoint.targetPos = target;
|
||||
waypoint.tolerance = tolerance * tolerance;
|
||||
waypoint.partLocalID = partLocalID;
|
||||
waypoint.scriptID = scriptID;
|
||||
waypoint.handle = handle;
|
||||
|
||||
lock (m_targets)
|
||||
|
@ -4861,12 +4860,46 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
public void RemoveScriptTargets(UUID scriptID)
|
||||
{
|
||||
List<int> toremove = new List<int>();
|
||||
lock (m_targets)
|
||||
{
|
||||
foreach (KeyValuePair<int, scriptPosTarget> kvp in m_targets)
|
||||
{
|
||||
if (kvp.Value.scriptID == scriptID)
|
||||
toremove.Add(kvp.Key);
|
||||
}
|
||||
if (toremove.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < toremove.Count; ++i)
|
||||
m_targets.Remove(toremove[i]);
|
||||
toremove.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
lock (m_rotTargets)
|
||||
{
|
||||
foreach (KeyValuePair<int, scriptRotTarget> kvp in m_rotTargets)
|
||||
{
|
||||
if (kvp.Value.scriptID == scriptID)
|
||||
toremove.Add(kvp.Key);
|
||||
}
|
||||
if (toremove.Count > 0)
|
||||
{
|
||||
for (int i = 0; i < toremove.Count; ++i)
|
||||
m_targets.Remove(toremove[i]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void checkAtTargets()
|
||||
{
|
||||
int targetsCount = m_targets.Count;
|
||||
if (targetsCount > 0 && (m_scriptListens_atTarget || m_scriptListens_notAtTarget))
|
||||
{
|
||||
List<scriptPosTarget> atTargets = new List<scriptPosTarget>(targetsCount);
|
||||
List<scriptPosTarget> atTargets = new List<scriptPosTarget>();
|
||||
List<scriptPosTarget> notatTargets = new List<scriptPosTarget>(targetsCount);
|
||||
Vector3 pos = m_rootPart.GroupPosition;
|
||||
lock (m_targets)
|
||||
|
@ -4886,21 +4919,26 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
bool hasnot = notatTargets.Count > 0;
|
||||
HashSet<UUID> excludes = new HashSet<UUID>();
|
||||
if (atTargets.Count > 0)
|
||||
{
|
||||
for (int target = 0; target < atTargets.Count; ++target)
|
||||
{
|
||||
scriptPosTarget att = atTargets[target];
|
||||
m_scene.EventManager.TriggerAtTargetEvent(
|
||||
att.partLocalID, (uint)att.handle, att.targetPos, pos);
|
||||
m_scene.EventManager.TriggerAtTargetEvent(att.scriptID, (uint)att.handle, att.targetPos, pos);
|
||||
if(hasnot)
|
||||
excludes.Add(att.scriptID);
|
||||
}
|
||||
}
|
||||
|
||||
if (notatTargets.Count > 0)
|
||||
if (hasnot)
|
||||
{
|
||||
for (int target = 0; target < notatTargets.Count; ++target)
|
||||
{
|
||||
m_scene.EventManager.TriggerNotAtTargetEvent(notatTargets[target].partLocalID);
|
||||
UUID id = notatTargets[target].scriptID;
|
||||
if(!excludes.Contains(id))
|
||||
m_scene.EventManager.TriggerNotAtTargetEvent(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4933,13 +4971,17 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
bool hasnot = notatRotTargets.Count > 0;
|
||||
HashSet<UUID> excludes = new HashSet<UUID>();
|
||||
|
||||
if (atRotTargets.Count > 0)
|
||||
{
|
||||
for (int target = 0; target < atRotTargets.Count; ++target)
|
||||
{
|
||||
scriptRotTarget att = atRotTargets[target];
|
||||
m_scene.EventManager.TriggerAtRotTargetEvent(
|
||||
att.partLocalID, (uint)att.handle, att.targetRot, rot);
|
||||
m_scene.EventManager.TriggerAtRotTargetEvent(att.scriptID, (uint)att.handle, att.targetRot, rot);
|
||||
if(hasnot)
|
||||
excludes.Add(att.scriptID);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4947,7 +4989,9 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
for (int target = 0; target < notatRotTargets.Count; ++target)
|
||||
{
|
||||
m_scene.EventManager.TriggerNotAtRotTargetEvent(notatRotTargets[target].partLocalID);
|
||||
UUID id = notatRotTargets[target].scriptID;
|
||||
if(!excludes.Contains(id))
|
||||
m_scene.EventManager.TriggerNotAtRotTargetEvent(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3013,8 +3013,11 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
lock (m_scriptEvents)
|
||||
{
|
||||
if (m_scriptEvents.ContainsKey(scriptid))
|
||||
if (m_scriptEvents.TryGetValue(scriptid, out scriptEvents ev))
|
||||
{
|
||||
if (((ev & (scriptEvents.at_target | scriptEvents.at_rot_target)) != 0) && ParentGroup != null)
|
||||
ParentGroup.RemoveScriptTargets(scriptid);
|
||||
|
||||
m_scriptEvents.Remove(scriptid);
|
||||
aggregateScriptEvents();
|
||||
}
|
||||
|
@ -3996,12 +3999,16 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
// m_log.DebugFormat(
|
||||
// "[SCENE OBJECT PART]: Set script events for script with id {0} on {1}/{2} to {3} in {4}",
|
||||
// scriptid, Name, ParentGroup.Name, events, ParentGroup.Scene.Name);
|
||||
|
||||
// scriptEvents oldparts;
|
||||
lock (m_scriptEvents)
|
||||
{
|
||||
if (m_scriptEvents.ContainsKey(scriptid) && m_scriptEvents[scriptid] == (scriptEvents) events)
|
||||
if (m_scriptEvents.TryGetValue(scriptid, out scriptEvents ev))
|
||||
{
|
||||
if (((ev & (scriptEvents.at_target | scriptEvents.at_rot_target)) != 0) && ParentGroup != null)
|
||||
ParentGroup.RemoveScriptTargets(scriptid);
|
||||
if (ev == (scriptEvents)events)
|
||||
return;
|
||||
}
|
||||
m_scriptEvents[scriptid] = (scriptEvents) events;
|
||||
}
|
||||
aggregateScriptEvents();
|
||||
|
|
|
@ -3035,7 +3035,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
public LSL_Integer llTarget(LSL_Vector position, double range)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
return m_host.ParentGroup.registerTargetWaypoint(m_host.LocalId, position, (float)range);
|
||||
return m_host.ParentGroup.registerTargetWaypoint(m_item.ItemID, position, (float)range);
|
||||
}
|
||||
|
||||
public void llTargetRemove(int number)
|
||||
|
@ -3047,7 +3047,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
public LSL_Integer llRotTarget(LSL_Rotation rot, double error)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
return m_host.ParentGroup.registerRotTargetWaypoint(m_host.LocalId, rot, (float)error);
|
||||
return m_host.ParentGroup.registerRotTargetWaypoint(m_item.ItemID, rot, (float)error);
|
||||
}
|
||||
|
||||
public void llRotTargetRemove(int number)
|
||||
|
|
|
@ -380,10 +380,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
new DetectParams[0]));
|
||||
}
|
||||
|
||||
public void at_target(uint localID, uint handle, Vector3 targetpos,
|
||||
public void at_target(UUID itemID, uint handle, Vector3 targetpos,
|
||||
Vector3 atpos)
|
||||
{
|
||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
||||
myScriptEngine.PostScriptEvent(itemID, new EventParams(
|
||||
"at_target", new object[] {
|
||||
new LSL_Types.LSLInteger(handle),
|
||||
new LSL_Types.Vector3(targetpos),
|
||||
|
@ -391,17 +391,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
new DetectParams[0]));
|
||||
}
|
||||
|
||||
public void not_at_target(uint localID)
|
||||
public void not_at_target(UUID itemID)
|
||||
{
|
||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
||||
myScriptEngine.PostScriptEvent(itemID, new EventParams(
|
||||
"not_at_target",new object[0],
|
||||
new DetectParams[0]));
|
||||
}
|
||||
|
||||
public void at_rot_target(uint localID, uint handle, Quaternion targetrot,
|
||||
public void at_rot_target(UUID itemID, uint handle, Quaternion targetrot,
|
||||
Quaternion atrot)
|
||||
{
|
||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
||||
myScriptEngine.PostScriptEvent(itemID, new EventParams(
|
||||
"at_rot_target", new object[] {
|
||||
new LSL_Types.LSLInteger(handle),
|
||||
new LSL_Types.Quaternion(targetrot),
|
||||
|
@ -409,9 +409,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
new DetectParams[0]));
|
||||
}
|
||||
|
||||
public void not_at_rot_target(uint localID)
|
||||
public void not_at_rot_target(UUID itemID)
|
||||
{
|
||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
||||
myScriptEngine.PostScriptEvent(itemID, new EventParams(
|
||||
"not_at_rot_target",new object[0],
|
||||
new DetectParams[0]));
|
||||
}
|
||||
|
|
|
@ -309,10 +309,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
|||
zeroDetectParams));
|
||||
}
|
||||
|
||||
public void at_target(uint localID, uint handle, Vector3 targetpos,
|
||||
Vector3 atpos)
|
||||
public void at_target(UUID scriptID, uint handle, Vector3 targetpos, Vector3 atpos)
|
||||
{
|
||||
this.PostObjectEvent(localID, new EventParams(
|
||||
PostScriptEvent(scriptID, new EventParams(
|
||||
"at_target", new object[] {
|
||||
(int)handle,
|
||||
new LSL_Vector(targetpos.X,targetpos.Y,targetpos.Z),
|
||||
|
@ -320,32 +319,28 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
|||
zeroDetectParams));
|
||||
}
|
||||
|
||||
public void not_at_target(uint localID)
|
||||
public void not_at_target(UUID scriptID)
|
||||
{
|
||||
this.PostObjectEvent(localID, new EventParams(
|
||||
PostScriptEvent(scriptID, new EventParams(
|
||||
"not_at_target", zeroObjectArray,
|
||||
zeroDetectParams));
|
||||
}
|
||||
|
||||
public void at_rot_target(uint localID, uint handle, OpenMetaverse.Quaternion targetrot, OpenMetaverse.Quaternion atrot)
|
||||
public void at_rot_target(UUID scriptID, uint handle, OpenMetaverse.Quaternion targetrot, OpenMetaverse.Quaternion atrot)
|
||||
{
|
||||
this.PostObjectEvent(
|
||||
localID,
|
||||
new EventParams(
|
||||
PostScriptEvent(scriptID, new EventParams(
|
||||
"at_rot_target",
|
||||
new object[] {
|
||||
new LSL_Integer(handle),
|
||||
new LSL_Rotation(targetrot.X, targetrot.Y, targetrot.Z, targetrot.W),
|
||||
new LSL_Rotation(atrot.X, atrot.Y, atrot.Z, atrot.W)
|
||||
},
|
||||
zeroDetectParams
|
||||
)
|
||||
);
|
||||
zeroDetectParams));
|
||||
}
|
||||
|
||||
public void not_at_rot_target(uint localID)
|
||||
public void not_at_rot_target(UUID scriptID)
|
||||
{
|
||||
this.PostObjectEvent(localID, new EventParams(
|
||||
PostScriptEvent(scriptID, new EventParams(
|
||||
"not_at_rot_target", zeroObjectArray,
|
||||
zeroDetectParams));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue