diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine/XEngine.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 211 |
1 files changed, 209 insertions, 2 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 1b49baa..ae13516 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -388,7 +388,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
388 | part.UUID, itemID, assetID, assembly, | 388 | part.UUID, itemID, assetID, assembly, |
389 | m_AppDomains[appDomain], | 389 | m_AppDomains[appDomain], |
390 | part.ParentGroup.RootPart.Name, | 390 | part.ParentGroup.RootPart.Name, |
391 | item.Name); | 391 | item.Name, XScriptInstance.StateSource.NewRez); |
392 | 392 | ||
393 | m_log.DebugFormat("[XEngine] Loaded script {0}.{1}", | 393 | m_log.DebugFormat("[XEngine] Loaded script {0}.{1}", |
394 | part.ParentGroup.RootPart.Name, item.Name); | 394 | part.ParentGroup.RootPart.Name, item.Name); |
@@ -673,9 +673,97 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
673 | 673 | ||
674 | public class XDetectParams | 674 | public class XDetectParams |
675 | { | 675 | { |
676 | public XDetectParams() | ||
677 | { | ||
678 | Key = LLUUID.Zero; | ||
679 | OffsetPos = new LSL_Types.Vector3(); | ||
680 | LinkNum = 0; | ||
681 | Group = LLUUID.Zero; | ||
682 | Name = String.Empty; | ||
683 | Owner = LLUUID.Zero; | ||
684 | Position = new LSL_Types.Vector3(); | ||
685 | Rotation = new LSL_Types.Quaternion(); | ||
686 | Type = 0; | ||
687 | Velocity = new LSL_Types.Vector3(); | ||
688 | } | ||
689 | |||
676 | public LLUUID Key; | 690 | public LLUUID Key; |
677 | public LSL_Types.Vector3 OffsetPos; | 691 | public LSL_Types.Vector3 OffsetPos; |
678 | public int LinkNum; | 692 | public int LinkNum; |
693 | public LLUUID Group; | ||
694 | public string Name; | ||
695 | public LLUUID Owner; | ||
696 | public LSL_Types.Vector3 Position; | ||
697 | public LSL_Types.Quaternion Rotation; | ||
698 | public int Type; | ||
699 | public LSL_Types.Vector3 Velocity; | ||
700 | |||
701 | public void Populate(Scene scene) | ||
702 | { | ||
703 | SceneObjectPart part = scene.GetSceneObjectPart(Key); | ||
704 | if(part == null) // Avatar, maybe? | ||
705 | { | ||
706 | ScenePresence presence = scene.GetScenePresence(Key); | ||
707 | if(presence == null) | ||
708 | return; | ||
709 | |||
710 | Name = presence.Firstname + " " + presence.Lastname; | ||
711 | Owner = Key; | ||
712 | Position = new LSL_Types.Vector3( | ||
713 | presence.AbsolutePosition.X, | ||
714 | presence.AbsolutePosition.X, | ||
715 | presence.AbsolutePosition.Z); | ||
716 | Rotation = new LSL_Types.Quaternion( | ||
717 | presence.Rotation.x, | ||
718 | presence.Rotation.y, | ||
719 | presence.Rotation.z, | ||
720 | presence.Rotation.w); | ||
721 | Velocity = new LSL_Types.Vector3( | ||
722 | presence.Velocity.X, | ||
723 | presence.Velocity.X, | ||
724 | presence.Velocity.Z); | ||
725 | |||
726 | Type = 0x01; // Avatar | ||
727 | if(presence.Velocity != LLVector3.Zero) | ||
728 | Type |= 0x02; // Active | ||
729 | |||
730 | Group = presence.ControllingClient.ActiveGroupId; | ||
731 | |||
732 | return; | ||
733 | } | ||
734 | |||
735 | part=part.ParentGroup.RootPart; // We detect objects only | ||
736 | |||
737 | LinkNum = 0; // Not relevant | ||
738 | |||
739 | Group = part.GroupID; | ||
740 | Name = part.Name; | ||
741 | Owner = part.OwnerID; | ||
742 | if(part.Velocity == LLVector3.Zero) | ||
743 | Type = 0x04; // Passive | ||
744 | else | ||
745 | Type = 0x02; // Passive | ||
746 | |||
747 | foreach (SceneObjectPart p in part.ParentGroup.Children.Values) | ||
748 | { | ||
749 | if(part.ContainsScripts()) | ||
750 | { | ||
751 | Type |= 0x08; // Scripted | ||
752 | break; | ||
753 | } | ||
754 | } | ||
755 | |||
756 | Position = new LSL_Types.Vector3(part.AbsolutePosition.X, | ||
757 | part.AbsolutePosition.Y, | ||
758 | part.AbsolutePosition.Z); | ||
759 | |||
760 | LLQuaternion wr = part.GetWorldRotation(); | ||
761 | Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W); | ||
762 | |||
763 | Velocity = new LSL_Types.Vector3(part.Velocity.X, | ||
764 | part.Velocity.Y, | ||
765 | part.Velocity.Z); | ||
766 | } | ||
679 | } | 767 | } |
680 | 768 | ||
681 | public class XEventParams | 769 | public class XEventParams |
@@ -715,6 +803,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
715 | private string m_ScriptName; | 803 | private string m_ScriptName; |
716 | private string m_Assembly; | 804 | private string m_Assembly; |
717 | 805 | ||
806 | public enum StateSource | ||
807 | { | ||
808 | NewRez = 0, | ||
809 | PrimCrossing = 1, | ||
810 | AttachmentCrossing = 2 | ||
811 | } | ||
812 | |||
718 | // Script state | 813 | // Script state |
719 | private string m_State="default"; | 814 | private string m_State="default"; |
720 | 815 | ||
@@ -786,7 +881,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
786 | 881 | ||
787 | public XScriptInstance(XEngine engine, uint localID, LLUUID objectID, | 882 | public XScriptInstance(XEngine engine, uint localID, LLUUID objectID, |
788 | LLUUID itemID, LLUUID assetID, string assembly, AppDomain dom, | 883 | LLUUID itemID, LLUUID assetID, string assembly, AppDomain dom, |
789 | string primName, string scriptName) | 884 | string primName, string scriptName, StateSource stateSource) |
790 | { | 885 | { |
791 | m_Engine = engine; | 886 | m_Engine = engine; |
792 | 887 | ||
@@ -874,6 +969,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
874 | m_RunEvents = false; | 969 | m_RunEvents = false; |
875 | Start(); | 970 | Start(); |
876 | } | 971 | } |
972 | |||
973 | // we get new rez events on sim restart, too | ||
974 | // but if there is state, then we fire the change | ||
975 | // event | ||
976 | if(stateSource == StateSource.NewRez) | ||
977 | PostEvent(new XEventParams("changed", | ||
978 | new Object[] {256}, new XDetectParams[0])); | ||
877 | } | 979 | } |
878 | } | 980 | } |
879 | else | 981 | else |
@@ -1286,6 +1388,47 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1286 | XmlAttribute pos = xmldoc.CreateAttribute("", "pos", ""); | 1388 | XmlAttribute pos = xmldoc.CreateAttribute("", "pos", ""); |
1287 | pos.Value = det.OffsetPos.ToString(); | 1389 | pos.Value = det.OffsetPos.ToString(); |
1288 | objectElem.Attributes.Append(pos); | 1390 | objectElem.Attributes.Append(pos); |
1391 | |||
1392 | XmlAttribute d_linkNum = xmldoc.CreateAttribute("", | ||
1393 | "linkNum", ""); | ||
1394 | d_linkNum.Value = det.LinkNum.ToString(); | ||
1395 | objectElem.Attributes.Append(d_linkNum); | ||
1396 | |||
1397 | XmlAttribute d_group = xmldoc.CreateAttribute("", | ||
1398 | "group", ""); | ||
1399 | d_group.Value = det.Group.ToString(); | ||
1400 | objectElem.Attributes.Append(d_group); | ||
1401 | |||
1402 | XmlAttribute d_name = xmldoc.CreateAttribute("", | ||
1403 | "name", ""); | ||
1404 | d_name.Value = det.Name.ToString(); | ||
1405 | objectElem.Attributes.Append(d_name); | ||
1406 | |||
1407 | XmlAttribute d_owner = xmldoc.CreateAttribute("", | ||
1408 | "owner", ""); | ||
1409 | d_owner.Value = det.Owner.ToString(); | ||
1410 | objectElem.Attributes.Append(d_owner); | ||
1411 | |||
1412 | XmlAttribute d_position = xmldoc.CreateAttribute("", | ||
1413 | "position", ""); | ||
1414 | d_position.Value = det.Position.ToString(); | ||
1415 | objectElem.Attributes.Append(d_position); | ||
1416 | |||
1417 | XmlAttribute d_rotation = xmldoc.CreateAttribute("", | ||
1418 | "rotation", ""); | ||
1419 | d_rotation.Value = det.Rotation.ToString(); | ||
1420 | objectElem.Attributes.Append(d_rotation); | ||
1421 | |||
1422 | XmlAttribute d_type = xmldoc.CreateAttribute("", | ||
1423 | "type", ""); | ||
1424 | d_type.Value = det.Type.ToString(); | ||
1425 | objectElem.Attributes.Append(d_type); | ||
1426 | |||
1427 | XmlAttribute d_velocity = xmldoc.CreateAttribute("", | ||
1428 | "velocity", ""); | ||
1429 | d_velocity.Value = det.Velocity.ToString(); | ||
1430 | objectElem.Attributes.Append(d_velocity); | ||
1431 | |||
1289 | objectElem.AppendChild( | 1432 | objectElem.AppendChild( |
1290 | xmldoc.CreateTextNode(det.Key.ToString())); | 1433 | xmldoc.CreateTextNode(det.Key.ToString())); |
1291 | 1434 | ||
@@ -1385,6 +1528,62 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1385 | "pos").Value; | 1528 | "pos").Value; |
1386 | LSL_Types.Vector3 v = | 1529 | LSL_Types.Vector3 v = |
1387 | new LSL_Types.Vector3(vect); | 1530 | new LSL_Types.Vector3(vect); |
1531 | |||
1532 | int d_linkNum=0; | ||
1533 | LLUUID d_group = LLUUID.Zero; | ||
1534 | string d_name = String.Empty; | ||
1535 | LLUUID d_owner = LLUUID.Zero; | ||
1536 | LSL_Types.Vector3 d_position = | ||
1537 | new LSL_Types.Vector3(); | ||
1538 | LSL_Types.Quaternion d_rotation = | ||
1539 | new LSL_Types.Quaternion(); | ||
1540 | int d_type = 0; | ||
1541 | LSL_Types.Vector3 d_velocity = | ||
1542 | new LSL_Types.Vector3(); | ||
1543 | |||
1544 | try | ||
1545 | { | ||
1546 | string tmp; | ||
1547 | |||
1548 | tmp = det.Attributes.GetNamedItem( | ||
1549 | "linkNum").Value; | ||
1550 | int.TryParse(tmp, out d_linkNum); | ||
1551 | |||
1552 | tmp = det.Attributes.GetNamedItem( | ||
1553 | "group").Value; | ||
1554 | LLUUID.TryParse(tmp, out d_group); | ||
1555 | |||
1556 | d_name = det.Attributes.GetNamedItem( | ||
1557 | "name").Value; | ||
1558 | |||
1559 | tmp = det.Attributes.GetNamedItem( | ||
1560 | "owner").Value; | ||
1561 | LLUUID.TryParse(tmp, out d_owner); | ||
1562 | |||
1563 | tmp = det.Attributes.GetNamedItem( | ||
1564 | "position").Value; | ||
1565 | d_position = | ||
1566 | new LSL_Types.Vector3(tmp); | ||
1567 | |||
1568 | tmp = det.Attributes.GetNamedItem( | ||
1569 | "rotation").Value; | ||
1570 | d_rotation = | ||
1571 | new LSL_Types.Quaternion(tmp); | ||
1572 | |||
1573 | tmp = det.Attributes.GetNamedItem( | ||
1574 | "type").Value; | ||
1575 | int.TryParse(tmp, out d_type); | ||
1576 | |||
1577 | tmp = det.Attributes.GetNamedItem( | ||
1578 | "velocity").Value; | ||
1579 | d_velocity = | ||
1580 | new LSL_Types.Vector3(tmp); | ||
1581 | |||
1582 | } | ||
1583 | catch (Exception) // Old version XML | ||
1584 | { | ||
1585 | } | ||
1586 | |||
1388 | LLUUID uuid = new LLUUID(); | 1587 | LLUUID uuid = new LLUUID(); |
1389 | LLUUID.TryParse(det.InnerText, | 1588 | LLUUID.TryParse(det.InnerText, |
1390 | out uuid); | 1589 | out uuid); |
@@ -1392,6 +1591,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1392 | XDetectParams d = new XDetectParams(); | 1591 | XDetectParams d = new XDetectParams(); |
1393 | d.Key = uuid; | 1592 | d.Key = uuid; |
1394 | d.OffsetPos = v; | 1593 | d.OffsetPos = v; |
1594 | d.LinkNum = d_linkNum; | ||
1595 | d.Group = d_group; | ||
1596 | d.Name = d_name; | ||
1597 | d.Owner = d_owner; | ||
1598 | d.Position = d_position; | ||
1599 | d.Rotation = d_rotation; | ||
1600 | d.Type = d_type; | ||
1601 | d.Velocity = d_velocity; | ||
1395 | 1602 | ||
1396 | detected.Add(d); | 1603 | detected.Add(d); |
1397 | } | 1604 | } |