diff options
author | SignpostMarv | 2012-09-01 02:44:11 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-09-04 00:03:44 +0100 |
commit | ff867b59cf59fdab19413cd46f3dd04058fbf3c7 (patch) | |
tree | 36d6ac570be77c61245be64a8403fc296be76d3f /OpenSim/Region/ScriptEngine/Shared/Api/Implementation | |
parent | refactoring the grunt work of MessageObject into a private method with a UUID... (diff) | |
download | opensim-SC_OLD-ff867b59cf59fdab19413cd46f3dd04058fbf3c7.zip opensim-SC_OLD-ff867b59cf59fdab19413cd46f3dd04058fbf3c7.tar.gz opensim-SC_OLD-ff867b59cf59fdab19413cd46f3dd04058fbf3c7.tar.bz2 opensim-SC_OLD-ff867b59cf59fdab19413cd46f3dd04058fbf3c7.tar.xz |
Implementing functing to send messages directly to attachments
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 82114b3..8e80b4c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -3354,6 +3354,137 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3354 | return resp; | 3354 | return resp; |
3355 | } | 3355 | } |
3356 | 3356 | ||
3357 | public void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int options) | ||
3358 | { | ||
3359 | CheckThreatLevel(ThreatLevel.Moderate, "osMessageAttachments"); | ||
3360 | m_host.AddScriptLPS(1); | ||
3361 | |||
3362 | UUID targetUUID; | ||
3363 | ScenePresence target; | ||
3364 | |||
3365 | if (attachmentPoints.Length >= 1 && UUID.TryParse(avatar.ToString(), out targetUUID) && World.TryGetScenePresence(targetUUID, out target)) | ||
3366 | { | ||
3367 | List<int> aps = new List<int>(); | ||
3368 | foreach (object point in attachmentPoints.Data) | ||
3369 | { | ||
3370 | int ipoint; | ||
3371 | if (int.TryParse(point.ToString(), out ipoint)) | ||
3372 | { | ||
3373 | aps.Add(ipoint); | ||
3374 | } | ||
3375 | } | ||
3376 | |||
3377 | List<SceneObjectGroup> attachments = new List<SceneObjectGroup>(); | ||
3378 | |||
3379 | bool msgAll = aps.Contains(ScriptBaseClass.OS_ATTACH_MSG_ALL); | ||
3380 | bool invertPoints = (options & ScriptBaseClass.OS_ATTACH_MSG_INVERT_POINTS) != 0; | ||
3381 | |||
3382 | if (msgAll && invertPoints) | ||
3383 | { | ||
3384 | return; | ||
3385 | } | ||
3386 | else if (msgAll || invertPoints) | ||
3387 | { | ||
3388 | attachments = target.GetAttachments(); | ||
3389 | } | ||
3390 | else | ||
3391 | { | ||
3392 | foreach (int point in aps) | ||
3393 | { | ||
3394 | if (point > 0) | ||
3395 | { | ||
3396 | attachments.AddRange(target.GetAttachments((uint)point)); | ||
3397 | } | ||
3398 | } | ||
3399 | } | ||
3400 | |||
3401 | // if we have no attachments at this point, exit now | ||
3402 | if (attachments.Count == 0) | ||
3403 | { | ||
3404 | return; | ||
3405 | } | ||
3406 | |||
3407 | List<SceneObjectGroup> ignoreThese = new List<SceneObjectGroup>(); | ||
3408 | |||
3409 | if (invertPoints) | ||
3410 | { | ||
3411 | foreach (SceneObjectGroup attachment in attachments) | ||
3412 | { | ||
3413 | if (aps.Contains((int)attachment.AttachmentPoint)) | ||
3414 | { | ||
3415 | ignoreThese.Add(attachment); | ||
3416 | } | ||
3417 | } | ||
3418 | } | ||
3419 | |||
3420 | foreach (SceneObjectGroup attachment in ignoreThese) | ||
3421 | { | ||
3422 | attachments.Remove(attachment); | ||
3423 | } | ||
3424 | ignoreThese.Clear(); | ||
3425 | |||
3426 | // if inverting removed all attachments to check, exit now | ||
3427 | if (attachments.Count < 1) | ||
3428 | { | ||
3429 | return; | ||
3430 | } | ||
3431 | |||
3432 | if ((options & ScriptBaseClass.OS_ATTACH_MSG_OBJECT_CREATOR) != 0) | ||
3433 | { | ||
3434 | foreach (SceneObjectGroup attachment in attachments) | ||
3435 | { | ||
3436 | if (attachment.RootPart.CreatorID != m_host.CreatorID) | ||
3437 | { | ||
3438 | ignoreThese.Add(attachment); | ||
3439 | } | ||
3440 | } | ||
3441 | |||
3442 | foreach (SceneObjectGroup attachment in ignoreThese) | ||
3443 | { | ||
3444 | attachments.Remove(attachment); | ||
3445 | } | ||
3446 | ignoreThese.Clear(); | ||
3447 | |||
3448 | // if filtering by same object creator removed all | ||
3449 | // attachments to check, exit now | ||
3450 | if (attachments.Count == 0) | ||
3451 | { | ||
3452 | return; | ||
3453 | } | ||
3454 | } | ||
3455 | |||
3456 | if ((options & ScriptBaseClass.OS_ATTACH_MSG_SCRIPT_CREATOR) != 0) | ||
3457 | { | ||
3458 | foreach (SceneObjectGroup attachment in attachments) | ||
3459 | { | ||
3460 | if (attachment.RootPart.CreatorID != m_item.CreatorID) | ||
3461 | { | ||
3462 | ignoreThese.Add(attachment); | ||
3463 | } | ||
3464 | } | ||
3465 | |||
3466 | foreach (SceneObjectGroup attachment in ignoreThese) | ||
3467 | { | ||
3468 | attachments.Remove(attachment); | ||
3469 | } | ||
3470 | ignoreThese.Clear(); | ||
3471 | |||
3472 | // if filtering by object creator must match originating | ||
3473 | // script creator removed all attachments to check, | ||
3474 | // exit now | ||
3475 | if (attachments.Count == 0) | ||
3476 | { | ||
3477 | return; | ||
3478 | } | ||
3479 | } | ||
3480 | |||
3481 | foreach (SceneObjectGroup attachment in attachments) | ||
3482 | { | ||
3483 | MessageObject(attachment.RootPart.UUID, message); | ||
3484 | } | ||
3485 | } | ||
3486 | } | ||
3487 | |||
3357 | #endregion | 3488 | #endregion |
3358 | 3489 | ||
3359 | /// <summary> | 3490 | /// <summary> |