diff options
author | Talun | 2012-07-03 11:10:09 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-07-06 22:37:19 +0100 |
commit | 1b1f841c6aaf2453b3aca0eade84855ae658e655 (patch) | |
tree | 895b5f5bec7f0ae737e74017809e8762c05518b2 /OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | |
parent | Pull prim crossing/teleport checks up into Scene.IncomingCreateObject() from ... (diff) | |
download | opensim-SC-1b1f841c6aaf2453b3aca0eade84855ae658e655.zip opensim-SC-1b1f841c6aaf2453b3aca0eade84855ae658e655.tar.gz opensim-SC-1b1f841c6aaf2453b3aca0eade84855ae658e655.tar.bz2 opensim-SC-1b1f841c6aaf2453b3aca0eade84855ae658e655.tar.xz |
Mantis 6063 osNpcTouch.
Allow NPCS to touch obects.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index b3e1069..43a09ec 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | |||
@@ -104,6 +104,45 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
104 | OnMoneyTransferRequest(m_uuid, target, amount, 1, "Payment"); | 104 | OnMoneyTransferRequest(m_uuid, target, amount, 1, "Payment"); |
105 | } | 105 | } |
106 | 106 | ||
107 | public bool Touch(UUID target) | ||
108 | { | ||
109 | SceneObjectPart part = m_scene.GetSceneObjectPart(target); | ||
110 | if (part == null) | ||
111 | return false; | ||
112 | bool objectTouchable = hasTouchEvents(part); // Only touch an object that is scripted to respond | ||
113 | if (!objectTouchable && !part.IsRoot) | ||
114 | objectTouchable = hasTouchEvents(part.ParentGroup.RootPart); | ||
115 | if (!objectTouchable) | ||
116 | return false; | ||
117 | // Set up the surface args as if the touch is from a client that does not support this | ||
118 | SurfaceTouchEventArgs surfaceArgs = new SurfaceTouchEventArgs(); | ||
119 | surfaceArgs.FaceIndex = -1; // TOUCH_INVALID_FACE | ||
120 | surfaceArgs.Binormal = Vector3.Zero; // TOUCH_INVALID_VECTOR | ||
121 | surfaceArgs.Normal = Vector3.Zero; // TOUCH_INVALID_VECTOR | ||
122 | surfaceArgs.STCoord = new Vector3(-1.0f, -1.0f, 0.0f); // TOUCH_INVALID_TEXCOORD | ||
123 | surfaceArgs.UVCoord = surfaceArgs.STCoord; // TOUCH_INVALID_TEXCOORD | ||
124 | List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>(); | ||
125 | touchArgs.Add(surfaceArgs); | ||
126 | Vector3 offset = part.OffsetPosition * -1.0f; | ||
127 | if (OnGrabObject == null) | ||
128 | return false; | ||
129 | OnGrabObject(part.LocalId, offset, this, touchArgs); | ||
130 | if (OnGrabUpdate != null) | ||
131 | OnGrabUpdate(part.UUID, offset, part.ParentGroup.RootPart.GroupPosition, this, touchArgs); | ||
132 | if (OnDeGrabObject != null) | ||
133 | OnDeGrabObject(part.LocalId, this, touchArgs); | ||
134 | return true; | ||
135 | } | ||
136 | |||
137 | private bool hasTouchEvents(SceneObjectPart part) | ||
138 | { | ||
139 | if ((part.ScriptEvents & scriptEvents.touch) != 0 || | ||
140 | (part.ScriptEvents & scriptEvents.touch_start) != 0 || | ||
141 | (part.ScriptEvents & scriptEvents.touch_end) != 0) | ||
142 | return true; | ||
143 | return false; | ||
144 | } | ||
145 | |||
107 | public void InstantMessage(UUID target, string message) | 146 | public void InstantMessage(UUID target, string message) |
108 | { | 147 | { |
109 | OnInstantMessage(this, new GridInstantMessage(m_scene, | 148 | OnInstantMessage(this, new GridInstantMessage(m_scene, |