// Notify first, so that handler has a chance to get a
// reference from the ObjectTracker to the object being killed
for (int i = 0; i < kill.ObjectData.length; i++)
{
onKillObject.raiseEvent(new KillObjectEventArgs(simulator, kill.ObjectData[i].ID));
}
synchronized (simulator.ObjectsPrimitives.getDictionary())
{
List<Long> removeAvatars = new ArrayList<Long>();
List<Long> removePrims = new ArrayList<Long>();
if (Client.settings.OBJECT_TRACKING)
{
long localID;
for (int i = 0; i < kill.ObjectData.length; i++)
{
localID = kill.ObjectData[i].ID;
if (simulator.ObjectsPrimitives.getDictionary().containsKey(localID))
removePrims.add(localID);
for (Entry<Long, Primitive> prim : simulator.ObjectsPrimitives.getDictionary().entrySet())
{
if (prim.getValue().ParentID == localID)
{
onKillObject.raiseEvent(new KillObjectEventArgs(simulator, prim.getKey()));
removePrims.add(prim.getKey());
}
}
}
}
if (Client.settings.AVATAR_TRACKING)
{
synchronized (simulator.ObjectsAvatars.getDictionary())
{
long localID;
for (int i = 0; i < kill.ObjectData.length; i++)
{
localID = kill.ObjectData[i].ID;
if (simulator.ObjectsAvatars.getDictionary().containsKey(localID))
removeAvatars.add(localID);
List<Long> rootPrims = new ArrayList<Long>();
for (Entry<Long, Primitive> prim : simulator.ObjectsPrimitives.getDictionary().entrySet())
{
if (prim.getValue().ParentID == localID)
{
onKillObject.raiseEvent(new KillObjectEventArgs(simulator, prim.getKey()));
removePrims.add(prim.getKey());
rootPrims.add(prim.getKey());
}
}
for (Entry<Long, Primitive> prim : simulator.ObjectsPrimitives.getDictionary().entrySet())
{
if (rootPrims.contains(prim.getValue().ParentID))
{
onKillObject.raiseEvent(new KillObjectEventArgs(simulator, prim.getKey()));
removePrims.add(prim.getKey());
}
}
}