diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 159eaf1..0ba64f2 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | |||
@@ -1457,6 +1457,84 @@ namespace OpenSim.Region.Environment.Scenes | |||
1457 | 1457 | ||
1458 | #endregion | 1458 | #endregion |
1459 | 1459 | ||
1460 | #region Sound | ||
1461 | public void PreloadSound(string sound) | ||
1462 | { | ||
1463 | LLUUID ownerID = OwnerID; | ||
1464 | LLUUID objectID = UUID; | ||
1465 | LLUUID soundID = LLUUID.Zero; | ||
1466 | |||
1467 | if (!LLUUID.TryParse(sound, out soundID)) | ||
1468 | { | ||
1469 | //Trys to fetch sound id from prim's inventory. | ||
1470 | //Prim's inventory doesn't support non script items yet | ||
1471 | SceneObjectPart op = this; | ||
1472 | foreach (KeyValuePair<LLUUID, TaskInventoryItem> item in op.TaskInventory) | ||
1473 | { | ||
1474 | if (item.Value.Name == sound) | ||
1475 | { | ||
1476 | soundID = item.Value.ItemID; | ||
1477 | break; | ||
1478 | } | ||
1479 | } | ||
1480 | } | ||
1481 | |||
1482 | List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars(); | ||
1483 | foreach (ScenePresence p in avatarts) | ||
1484 | { | ||
1485 | // TODO: some filtering by distance of avatar | ||
1486 | |||
1487 | p.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); | ||
1488 | } | ||
1489 | } | ||
1490 | |||
1491 | public void SendSound(string sound, double volume, bool triggered) | ||
1492 | { | ||
1493 | if (volume > 1) | ||
1494 | volume = 1; | ||
1495 | if (volume < 0) | ||
1496 | volume = 0; | ||
1497 | |||
1498 | LLUUID ownerID = OwnerID; | ||
1499 | LLUUID objectID = UUID; | ||
1500 | LLUUID parentID = GetRootPartUUID(); | ||
1501 | LLUUID soundID = LLUUID.Zero; | ||
1502 | LLVector3 position = AbsolutePosition; // region local | ||
1503 | ulong regionHandle = m_parentGroup.Scene.RegionInfo.RegionHandle; | ||
1504 | |||
1505 | byte flags = 0; | ||
1506 | |||
1507 | if (!LLUUID.TryParse(sound, out soundID)) | ||
1508 | { | ||
1509 | // search sound file from inventory | ||
1510 | SceneObjectPart op = this; | ||
1511 | foreach (KeyValuePair<LLUUID, TaskInventoryItem> item in op.TaskInventory) | ||
1512 | { | ||
1513 | if (item.Value.Name == sound) | ||
1514 | { | ||
1515 | soundID = item.Value.ItemID; | ||
1516 | break; | ||
1517 | } | ||
1518 | } | ||
1519 | } | ||
1520 | |||
1521 | List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars(); | ||
1522 | foreach (ScenePresence p in avatarts) | ||
1523 | { | ||
1524 | // TODO: some filtering by distance of avatar | ||
1525 | if (triggered) | ||
1526 | { | ||
1527 | p.ControllingClient.SendTriggeredSound(soundID, ownerID, objectID, parentID, regionHandle, position, (float)volume); | ||
1528 | } | ||
1529 | else | ||
1530 | { | ||
1531 | p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)volume, flags); | ||
1532 | } | ||
1533 | } | ||
1534 | } | ||
1535 | |||
1536 | #endregion | ||
1537 | |||
1460 | #region Resizing/Scale | 1538 | #region Resizing/Scale |
1461 | 1539 | ||
1462 | /// <summary> | 1540 | /// <summary> |