aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
diff options
context:
space:
mode:
authorAdam Frisby2009-04-09 07:46:05 +0000
committerAdam Frisby2009-04-09 07:46:05 +0000
commit232241ab25ccd9e3184a2eeda0e80f7af15e1641 (patch)
treeb8cc72323eac42b30b9e1b3f6cf77118f159ded7 /OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
parent* Fixed a number of culture-variant bugs in lsl implicit type conversions. (diff)
downloadopensim-SC_OLD-232241ab25ccd9e3184a2eeda0e80f7af15e1641.zip
opensim-SC_OLD-232241ab25ccd9e3184a2eeda0e80f7af15e1641.tar.gz
opensim-SC_OLD-232241ab25ccd9e3184a2eeda0e80f7af15e1641.tar.bz2
opensim-SC_OLD-232241ab25ccd9e3184a2eeda0e80f7af15e1641.tar.xz
* Implements IObject.OnTouch += delegate(IObject sender, TouchEventArgs e)
* This is equivalent to LSL 'touch(int senders)'
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs')
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs51
1 files changed, 51 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
index 48cae2f..4734fa9 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
@@ -59,6 +59,57 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
59 return null; 59 return null;
60 } 60 }
61 61
62 #region OnTouch
63
64 private event OnTouchDelegate _OnTouch;
65 private bool _OnTouchActive = false;
66
67 public event OnTouchDelegate OnTouch
68 {
69 add
70 {
71 if(!_OnTouchActive)
72 {
73 _OnTouchActive = true;
74 m_rootScene.EventManager.OnObjectGrab += EventManager_OnObjectGrab;
75 }
76
77 _OnTouch += value;
78 }
79 remove
80 {
81 _OnTouch -= value;
82
83 if (_OnTouch == null)
84 {
85 _OnTouchActive = false;
86 m_rootScene.EventManager.OnObjectGrab -= EventManager_OnObjectGrab;
87 }
88 }
89 }
90
91 void EventManager_OnObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
92 {
93 if (_OnTouchActive && m_localID == localID)
94 {
95 TouchEventArgs e = new TouchEventArgs();
96 e.Avatar = new SPAvatar(m_rootScene, remoteClient.AgentId);
97 e.TouchBiNormal = surfaceArgs.Binormal;
98 e.TouchMaterialIndex = surfaceArgs.FaceIndex;
99 e.TouchNormal = surfaceArgs.Normal;
100 e.TouchPosition = surfaceArgs.Position;
101 e.TouchST = new Vector2(surfaceArgs.STCoord.X, surfaceArgs.STCoord.Y);
102 e.TouchUV = new Vector2(surfaceArgs.UVCoord.X, surfaceArgs.UVCoord.Y);
103
104 IObject sender = this;
105
106 if (_OnTouch != null)
107 _OnTouch(sender, e);
108 }
109 }
110
111 #endregion
112
62 public bool Exists 113 public bool Exists
63 { 114 {
64 get { return GetSOP() != null; } 115 get { return GetSOP() != null; }