Annotation of /trunk/ModularRex/RexParts/RexPython/RexScriptInterface.cs
Parent Directory
|
Revision Log
Revision 85 - (view) (download)
| 1 : | mikkopa | 12 | using System; |
| 2 : | using System.Collections.Generic; | ||
| 3 : | using System.Text; | ||
| 4 : | using System.IO; | ||
| 5 : | mikkopa | 14 | using System.Reflection; |
| 6 : | mikkopa | 12 | using OpenSim.Framework; |
| 7 : | using OpenSim.Framework.Communications.Cache; | ||
| 8 : | |||
| 9 : | mikkopa | 63 | using OpenSim.Region.Framework.Scenes; |
| 10 : | using OpenSim.Region.Framework.Scenes.Scripting; | ||
| 11 : | using OpenSim.Region.Framework.Interfaces; | ||
| 12 : | mikkopa | 12 | using OpenSim.Region.ScriptEngine.Shared; |
| 13 : | using OpenSim.Region.ScriptEngine.Interfaces; | ||
| 14 : | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
| 15 : | mikkopa | 14 | using log4net; |
| 16 : | mikkopa | 12 | using OpenMetaverse; |
| 17 : | |||
| 18 : | namespace ModularRex.RexParts.RexPython | ||
| 19 : | { | ||
| 20 : | public class RexScriptInterface : Rex_BuiltIn_Commands | ||
| 21 : | { | ||
| 22 : | private RexScriptEngine myScriptEngine; | ||
| 23 : | mikkopa | 14 | private static readonly ILog m_log = |
| 24 : | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
| 25 : | mikkopa | 49 | private ModrexObjects m_rexObjects; |
| 26 : | mikkopa | 12 | |
| 27 : | public RexScriptInterface(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID, RexScriptEngine vScriptEngine) | ||
| 28 : | { | ||
| 29 : | myScriptEngine = vScriptEngine; | ||
| 30 : | |||
| 31 : | foreach (System.Collections.Generic.KeyValuePair<string, IRegionModule> de in myScriptEngine.World.Modules) | ||
| 32 : | { | ||
| 33 : | if (de.Value is IScriptEngine) | ||
| 34 : | { | ||
| 35 : | if (((IScriptEngine)de.Value).ScriptEngineName == "ScriptEngine.DotNetEngine") | ||
| 36 : | mikkopa | 14 | { |
| 37 : | mikkopa | 12 | m_ScriptEngine = ((IScriptEngine)de.Value); |
| 38 : | mikkopa | 14 | m_log.Info("[REXSCRIPT]: Found DotNetEngine"); |
| 39 : | } | ||
| 40 : | //Console.WriteLine(((IScriptEngine)de.Value).ScriptEngineName); | ||
| 41 : | mikkopa | 12 | } |
| 42 : | } | ||
| 43 : | if (m_ScriptEngine == null) | ||
| 44 : | mikkopa | 43 | { |
| 45 : | m_log.Error("[REXSCRIPT]: Could not find DotNetEngine"); | ||
| 46 : | mikkopa | 12 | throw new Exception("Could not find DotNetEngine"); |
| 47 : | mikkopa | 43 | } |
| 48 : | mikkopa | 12 | //this was causing lots of errors. instead of creating a new instance of .Net script engine, check for an existing one and use that |
| 49 : | //this requires of using .NET scripting engine when using the python engine. | ||
| 50 : | //m_ScriptEngine = new OpenSim.Region.ScriptEngine.DotNetEngine.ScriptEngine(); | ||
| 51 : | //m_ScriptEngine.World = myScriptEngine.World; | ||
| 52 : | mikkopa | 14 | try |
| 53 : | { | ||
| 54 : | base.Initialize(m_ScriptEngine, host, localID, itemID); | ||
| 55 : | } | ||
| 56 : | catch (Exception e) | ||
| 57 : | { | ||
| 58 : | m_log.Error("[REXSCRIPT]: Initializting rex scriptengine failed: " + e.ToString()); | ||
| 59 : | } | ||
| 60 : | mikkopa | 49 | |
| 61 : | mikkopa | 63 | OpenSim.Region.Framework.Interfaces.IRegionModule module = myScriptEngine.World.Modules["RexObjectsModule"]; |
| 62 : | mikkopa | 49 | if (module != null && module is ModrexObjects) |
| 63 : | { | ||
| 64 : | m_rexObjects = (ModrexObjects)module; | ||
| 65 : | } | ||
| 66 : | mikkopa | 12 | } |
| 67 : | |||
| 68 : | private EntityBase GetEntityBase(uint vId) | ||
| 69 : | { | ||
| 70 : | SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(vId); | ||
| 71 : | if (part != null && (EntityBase)(part.ParentGroup) != null) | ||
| 72 : | return (EntityBase)(part.ParentGroup); | ||
| 73 : | else | ||
| 74 : | return null; | ||
| 75 : | } | ||
| 76 : | |||
| 77 : | // Functions exposed to Python! | ||
| 78 : | // ********************************* | ||
| 79 : | public bool SetScriptRunner(string vId) | ||
| 80 : | { | ||
| 81 : | uint id = System.Convert.ToUInt32(vId, 10); | ||
| 82 : | |||
| 83 : | SceneObjectPart tempobj = myScriptEngine.World.GetSceneObjectPart(id); | ||
| 84 : | if (tempobj != null) | ||
| 85 : | { | ||
| 86 : | m_host = tempobj; | ||
| 87 : | m_localID = tempobj.LocalId; | ||
| 88 : | m_itemID = tempobj.UUID; | ||
| 89 : | return true; | ||
| 90 : | } | ||
| 91 : | else | ||
| 92 : | return false; | ||
| 93 : | } | ||
| 94 : | |||
| 95 : | public void CommandToClient(string vPresenceId, string vUnit, string vCommand, string vCmdParams) | ||
| 96 : | { | ||
| 97 : | UUID TempId = new UUID(vPresenceId); | ||
| 98 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 99 : | if (temppre != null) | ||
| 100 : | { | ||
| 101 : | if (temppre.ControllingClient is RexNetwork.RexClientView) | ||
| 102 : | { | ||
| 103 : | RexNetwork.RexClientView client = (RexNetwork.RexClientView)temppre.ControllingClient; | ||
| 104 : | client.SendRexScriptCommand(vUnit, vCommand, vCmdParams); | ||
| 105 : | } | ||
| 106 : | } | ||
| 107 : | } | ||
| 108 : | |||
| 109 : | public bool GetPhysics(string vId) | ||
| 110 : | { | ||
| 111 : | SceneObjectPart tempobj = myScriptEngine.World.GetSceneObjectPart(System.Convert.ToUInt32(vId, 10)); | ||
| 112 : | if (tempobj != null) | ||
| 113 : | return ((tempobj.ObjectFlags & (uint)PrimFlags.Physics) != 0); | ||
| 114 : | else | ||
| 115 : | return false; | ||
| 116 : | } | ||
| 117 : | |||
| 118 : | public void SetPhysics(string vId, bool vbUsePhysics) | ||
| 119 : | { | ||
| 120 : | SceneObjectPart tempobj = myScriptEngine.World.GetSceneObjectPart(System.Convert.ToUInt32(vId, 10)); | ||
| 121 : | if (tempobj != null) | ||
| 122 : | { | ||
| 123 : | if (vbUsePhysics) | ||
| 124 : | tempobj.AddFlag(PrimFlags.Physics); | ||
| 125 : | else | ||
| 126 : | tempobj.RemFlag(PrimFlags.Physics); | ||
| 127 : | |||
| 128 : | tempobj.DoPhysicsPropertyUpdate(vbUsePhysics, false); | ||
| 129 : | tempobj.ScheduleFullUpdate(); | ||
| 130 : | } | ||
| 131 : | else | ||
| 132 : | myScriptEngine.Log.WarnFormat("[PythonScript]: SetPhysics for nonexisting object:" + vId); | ||
| 133 : | } | ||
| 134 : | |||
| 135 : | |||
| 136 : | |||
| 137 : | public void SetMass(string vId, float vMass) | ||
| 138 : | mikkopa | 42 | { |
| 139 : | tuco | 85 | m_log.Warn("[REXSCRIPT]: SetMass not implemented"); |
| 140 : | mikkopa | 42 | //SceneObjectPart tempobj = myScriptEngine.World.GetSceneObjectPart(System.Convert.ToUInt32(vId, 10)); |
| 141 : | //if (tempobj != null) | ||
| 142 : | //{ | ||
| 143 : | // if (tempobj is RexObjects.RexObjectPart) | ||
| 144 : | // { | ||
| 145 : | // RexObjects.RexObjectPart rexObj = (RexObjects.RexObjectPart)tempobj; | ||
| 146 : | // rexObj.SetMass(vMass); | ||
| 147 : | // } | ||
| 148 : | //} | ||
| 149 : | //else | ||
| 150 : | // myScriptEngine.Log.WarnFormat("[PythonScript]: SetMass for nonexisting object:" + vId); | ||
| 151 : | mikkopa | 12 | |
| 152 : | } | ||
| 153 : | |||
| 154 : | public void SetVelocity(string vId, LSL_Types.Vector3 vVelocity) | ||
| 155 : | { | ||
| 156 : | SceneObjectPart tempobj = myScriptEngine.World.GetSceneObjectPart(System.Convert.ToUInt32(vId, 10)); | ||
| 157 : | if (((SceneObjectPart)tempobj) != null) | ||
| 158 : | { | ||
| 159 : | Vector3 tempvel = new Vector3((float)vVelocity.x, (float)vVelocity.y, (float)vVelocity.z); | ||
| 160 : | tempobj.Velocity = tempvel; | ||
| 161 : | } | ||
| 162 : | } | ||
| 163 : | |||
| 164 : | public bool GetUsePrimVolumeCollision(string vId) | ||
| 165 : | { | ||
| 166 : | tuco | 85 | m_log.Warn("[REXSCRIPT]: GetUsePrimVolumeCollision not implemented"); |
| 167 : | return false; | ||
| 168 : | mikkopa | 42 | //SceneObjectPart tempobj = myScriptEngine.World.GetSceneObjectPart(System.Convert.ToUInt32(vId, 10)); |
| 169 : | //if (tempobj != null) | ||
| 170 : | //{ | ||
| 171 : | // if (tempobj is RexObjects.RexObjectPart) | ||
| 172 : | // { | ||
| 173 : | // RexObjects.RexObjectPart rexObj = (RexObjects.RexObjectPart)tempobj; | ||
| 174 : | // return rexObj.GetUsePrimVolumeCollision(); | ||
| 175 : | // } | ||
| 176 : | //} | ||
| 177 : | //return false; | ||
| 178 : | mikkopa | 12 | } |
| 179 : | |||
| 180 : | public void SetUsePrimVolumeCollision(string vId, bool vUseVolumeCollision) | ||
| 181 : | { | ||
| 182 : | tuco | 85 | m_log.Warn("[REXSCRIPT]: SetUsePrimVolumeCollision not implemented"); |
| 183 : | mikkopa | 42 | //SceneObjectPart tempobj = myScriptEngine.World.GetSceneObjectPart(System.Convert.ToUInt32(vId, 10)); |
| 184 : | //if (tempobj != null) | ||
| 185 : | //{ | ||
| 186 : | // if (tempobj is RexObjects.RexObjectPart) | ||
| 187 : | // { | ||
| 188 : | // RexObjects.RexObjectPart rexObj = (RexObjects.RexObjectPart)tempobj; | ||
| 189 : | // rexObj.SetUsePrimVolumeCollision(vUseVolumeCollision); | ||
| 190 : | // } | ||
| 191 : | //} | ||
| 192 : | //else | ||
| 193 : | // myScriptEngine.Log.WarnFormat("[PythonScript]: SetPrimVolumeCollision for nonexisting object:" + vId); | ||
| 194 : | mikkopa | 12 | } |
| 195 : | |||
| 196 : | public int GetPrimLocalIdFromUUID(string vUUID) | ||
| 197 : | { | ||
| 198 : | UUID tempid = UUID.Zero; | ||
| 199 : | try | ||
| 200 : | { | ||
| 201 : | tempid = new UUID(vUUID); | ||
| 202 : | } | ||
| 203 : | catch (Exception) { } | ||
| 204 : | |||
| 205 : | if(tempid != UUID.Zero) | ||
| 206 : | { | ||
| 207 : | SceneObjectPart tempobj = myScriptEngine.World.GetSceneObjectPart(tempid); | ||
| 208 : | if(tempobj != null) | ||
| 209 : | return (int)tempobj.LocalId; | ||
| 210 : | else | ||
| 211 : | myScriptEngine.Log.WarnFormat("[PythonScript]: GetPrimLocalIdFromUUID did not find prim with uuid:" + vUUID); | ||
| 212 : | } | ||
| 213 : | return 0; | ||
| 214 : | } | ||
| 215 : | |||
| 216 : | |||
| 217 : | |||
| 218 : | // text messaging | ||
| 219 : | // ****************************** | ||
| 220 : | public void SendGeneralAlertAll(string vId, string vMessage) | ||
| 221 : | { | ||
| 222 : | tuco | 85 | m_log.Warn("[REXSCRIPT]: SendGeneralAlertAll not implemented"); |
| 223 : | mikkopa | 34 | //TODO: Fix this. Broken in newest OpenSim |
| 224 : | //myScriptEngine.World.SendGeneralAlert(vMessage); | ||
| 225 : | mikkopa | 12 | } |
| 226 : | |||
| 227 : | public void SendAlertToAvatar(string vId,string vPresenceId, string vMessage, bool vbModal) | ||
| 228 : | { | ||
| 229 : | UUID TempId = new UUID(vPresenceId); | ||
| 230 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 231 : | if (temppre != null) | ||
| 232 : | { | ||
| 233 : | temppre.ControllingClient.SendAgentAlertMessage(vMessage, vbModal); | ||
| 234 : | } | ||
| 235 : | } | ||
| 236 : | |||
| 237 : | |||
| 238 : | |||
| 239 : | // Actor finding. | ||
| 240 : | public List<string> GetRadiusActors(string vId,float vRadius) | ||
| 241 : | { | ||
| 242 : | List<string> TempList = new List<string>(); | ||
| 243 : | EntityBase tempobj = null; | ||
| 244 : | try | ||
| 245 : | { | ||
| 246 : | tempobj = GetEntityBase(System.Convert.ToUInt32(vId, 10)); | ||
| 247 : | } | ||
| 248 : | catch (Exception) { } | ||
| 249 : | try | ||
| 250 : | { | ||
| 251 : | if (tempobj == null) | ||
| 252 : | tempobj = myScriptEngine.World.GetScenePresence(new UUID(vId)); | ||
| 253 : | } | ||
| 254 : | catch (Exception) { } | ||
| 255 : | |||
| 256 : | if (tempobj != null) | ||
| 257 : | { | ||
| 258 : | List<EntityBase> EntitiesList = myScriptEngine.World.GetEntities(); | ||
| 259 : | foreach (EntityBase ent in EntitiesList) | ||
| 260 : | { | ||
| 261 : | if (ent is SceneObjectGroup || ent is ScenePresence) | ||
| 262 : | { | ||
| 263 : | if (Util.GetDistanceTo(ent.AbsolutePosition, tempobj.AbsolutePosition) < vRadius) | ||
| 264 : | TempList.Add(ent.LocalId.ToString()); | ||
| 265 : | } | ||
| 266 : | } | ||
| 267 : | } | ||
| 268 : | return TempList; | ||
| 269 : | } | ||
| 270 : | |||
| 271 : | public List<string> GetRadiusAvatars(string vId, float vRadius) | ||
| 272 : | { | ||
| 273 : | List<string> TempList = new List<string>(); | ||
| 274 : | EntityBase tempobj = null; | ||
| 275 : | |||
| 276 : | try | ||
| 277 : | { | ||
| 278 : | tempobj = GetEntityBase(System.Convert.ToUInt32(vId, 10)); | ||
| 279 : | } | ||
| 280 : | catch(Exception) { } | ||
| 281 : | try | ||
| 282 : | { | ||
| 283 : | if (tempobj == null) | ||
| 284 : | tempobj = myScriptEngine.World.GetScenePresence(new UUID(vId)); | ||
| 285 : | } | ||
| 286 : | catch (Exception) { } | ||
| 287 : | |||
| 288 : | if (tempobj != null) | ||
| 289 : | { | ||
| 290 : | List<EntityBase> EntitiesList = myScriptEngine.World.GetEntities(); | ||
| 291 : | foreach (EntityBase ent in EntitiesList) | ||
| 292 : | { | ||
| 293 : | if (ent is ScenePresence) | ||
| 294 : | { | ||
| 295 : | if (Util.GetDistanceTo(ent.AbsolutePosition, tempobj.AbsolutePosition) < vRadius) | ||
| 296 : | TempList.Add(ent.LocalId.ToString()); | ||
| 297 : | } | ||
| 298 : | } | ||
| 299 : | } | ||
| 300 : | return TempList; | ||
| 301 : | } | ||
| 302 : | |||
| 303 : | |||
| 304 : | |||
| 305 : | mikkopa | 49 | public string SpawnActor(LSL_Types.Vector3 location, int shape, bool temporary, string pythonClass) |
| 306 : | mikkopa | 12 | { |
| 307 : | mikkopa | 49 | UUID TempID = myScriptEngine.World.RegionInfo.MasterAvatarAssignedUUID; |
| 308 : | Vector3 pos = new Vector3((float)location.x, (float)location.y, (float)location.z); | ||
| 309 : | Quaternion rot = new Quaternion(0.0f, 0.0f, 0.0f, 1.0f); | ||
| 310 : | mikkopa | 12 | |
| 311 : | mikkopa | 49 | SceneObjectGroup sog = myScriptEngine.World.AddNewPrim(TempID, TempID, pos, rot, GetShape(shape)); |
| 312 : | uint AddResult = sog.RootPart.LocalId; | ||
| 313 : | |||
| 314 : | tuco | 57 | ModularRex.RexFramework.RexObjectProperties rop = m_rexObjects.GetObject(sog.RootPart.UUID); |
| 315 : | mikkopa | 49 | rop.RexClassName = pythonClass; |
| 316 : | |||
| 317 : | //TODO: vbTemporary | ||
| 318 : | //uint AddResult = myScriptEngine.World.AddNewPrimReturningId(TempID, pos, rot, GetShape(vShape), vbTemporary, vPyClass); | ||
| 319 : | return AddResult.ToString(); | ||
| 320 : | mikkopa | 12 | } |
| 321 : | |||
| 322 : | public bool DestroyActor(string vId) | ||
| 323 : | { | ||
| 324 : | tuco | 85 | m_log.Warn("[REXSCRIPT]: DestroyActor not implemented"); |
| 325 : | return true; | ||
| 326 : | mikkopa | 42 | //EntityBase tempobj = GetEntityBase(System.Convert.ToUInt32(vId, 10)); |
| 327 : | //if (tempobj != null && tempobj is RexObjects.RexObjectGroup) | ||
| 328 : | //{ | ||
| 329 : | // ((RexObjects.RexObjectGroup)tempobj).DeleteMe = true; // Do not call DeleteSceneObjectGroup for deleting directly | ||
| 330 : | // return true; | ||
| 331 : | //} | ||
| 332 : | //return false; | ||
| 333 : | mikkopa | 12 | } |
| 334 : | |||
| 335 : | private static PrimitiveBaseShape GetShape(int vShape) | ||
| 336 : | { | ||
| 337 : | PrimitiveBaseShape shape = new PrimitiveBaseShape(); | ||
| 338 : | |||
| 339 : | shape.PCode = 9; | ||
| 340 : | shape.PathBegin = 0; | ||
| 341 : | shape.PathEnd = 0; | ||
| 342 : | shape.PathScaleX = 100; | ||
| 343 : | shape.PathScaleY = 100; | ||
| 344 : | shape.PathShearX = 0; | ||
| 345 : | shape.PathShearY = 0; | ||
| 346 : | shape.PathSkew = 0; | ||
| 347 : | shape.ProfileBegin = 0; | ||
| 348 : | shape.ProfileEnd = 0; | ||
| 349 : | shape.Scale = new Vector3(0.5f, 0.5f, 0.5f); | ||
| 350 : | //shape.Scale.X = shape.Scale.Y = shape.Scale.Z = 0.5f; | ||
| 351 : | shape.PathCurve = 16; | ||
| 352 : | shape.ProfileCurve = 1; | ||
| 353 : | shape.ProfileHollow = 0; | ||
| 354 : | shape.PathRadiusOffset = 0; | ||
| 355 : | shape.PathRevolutions = 0; | ||
| 356 : | shape.PathTaperX = 0; | ||
| 357 : | shape.PathTaperY = 0; | ||
| 358 : | shape.PathTwist = 0; | ||
| 359 : | shape.PathTwistBegin = 0; | ||
| 360 : | Primitive.TextureEntry ntex = new Primitive.TextureEntry(new UUID("00000000-0000-1111-9999-000000000005")); | ||
| 361 : | shape.TextureEntry = ntex.ToBytes(); | ||
| 362 : | return shape; | ||
| 363 : | } | ||
| 364 : | |||
| 365 : | // Scenepresence related | ||
| 366 : | mikkopa | 20 | // These are now in RexClientView, although most of them are not working properly yet. |
| 367 : | |||
| 368 : | mikkopa | 12 | public string SPGetFullName(string vPresenceId) |
| 369 : | { | ||
| 370 : | UUID TempId = new UUID(vPresenceId); | ||
| 371 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 372 : | if (temppre != null) | ||
| 373 : | { | ||
| 374 : | string TempString = temppre.Firstname + " " + temppre.Lastname; | ||
| 375 : | return TempString; | ||
| 376 : | } | ||
| 377 : | else | ||
| 378 : | return ""; | ||
| 379 : | } | ||
| 380 : | public string SPGetFirstName(string vPresenceId) | ||
| 381 : | { | ||
| 382 : | UUID TempId = new UUID(vPresenceId); | ||
| 383 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 384 : | if (temppre != null) | ||
| 385 : | return temppre.Firstname; | ||
| 386 : | else | ||
| 387 : | return ""; | ||
| 388 : | } | ||
| 389 : | public string SPGetLastName(string vPresenceId) | ||
| 390 : | { | ||
| 391 : | UUID TempId = new UUID(vPresenceId); | ||
| 392 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 393 : | if (temppre != null) | ||
| 394 : | return temppre.Lastname; | ||
| 395 : | else | ||
| 396 : | return ""; | ||
| 397 : | } | ||
| 398 : | |||
| 399 : | public void SPDoLocalTeleport(string vPresenceId, LSL_Types.Vector3 vLocation) | ||
| 400 : | { | ||
| 401 : | UUID TempId = new UUID(vPresenceId); | ||
| 402 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 403 : | if (temppre != null) | ||
| 404 : | { | ||
| 405 : | Vector3 position = new Vector3((float)vLocation.x, (float)vLocation.y, (float)vLocation.z); | ||
| 406 : | Vector3 lookAt = new Vector3(0,0,0); | ||
| 407 : | temppre.ControllingClient.SendTeleportLocationStart(); | ||
| 408 : | temppre.ControllingClient.SendLocalTeleport(position, lookAt,0); | ||
| 409 : | temppre.Teleport(position); | ||
| 410 : | } | ||
| 411 : | } | ||
| 412 : | |||
| 413 : | public float SPGetMovementModifier(string vPresenceId) | ||
| 414 : | { | ||
| 415 : | UUID TempId = new UUID(vPresenceId); | ||
| 416 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 417 : | if (temppre != null) | ||
| 418 : | { | ||
| 419 : | if (temppre.ControllingClient is RexNetwork.RexClientView) | ||
| 420 : | { | ||
| 421 : | RexNetwork.RexClientView rexclient = (RexNetwork.RexClientView)temppre.ControllingClient; | ||
| 422 : | return rexclient.RexMovementSpeedMod; | ||
| 423 : | } | ||
| 424 : | } | ||
| 425 : | return 0.0f; | ||
| 426 : | } | ||
| 427 : | |||
| 428 : | public void SPSetMovementModifier(string vPresenceId,float vSpeedModifier) | ||
| 429 : | { | ||
| 430 : | |||
| 431 : | UUID TempId = new UUID(vPresenceId); | ||
| 432 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 433 : | if (temppre != null) | ||
| 434 : | { | ||
| 435 : | if (temppre.ControllingClient is RexNetwork.RexClientView) | ||
| 436 : | { | ||
| 437 : | RexNetwork.RexClientView rexclient = (RexNetwork.RexClientView)temppre.ControllingClient; | ||
| 438 : | rexclient.RexMovementSpeedMod = vSpeedModifier; | ||
| 439 : | } | ||
| 440 : | } | ||
| 441 : | } | ||
| 442 : | |||
| 443 : | public LSL_Types.Vector3 SPGetPos(string vPresenceId) | ||
| 444 : | { | ||
| 445 : | LSL_Types.Vector3 loc = new LSL_Types.Vector3(0, 0, 0); | ||
| 446 : | |||
| 447 : | UUID TempId = new UUID(vPresenceId); | ||
| 448 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 449 : | if (temppre != null) | ||
| 450 : | { | ||
| 451 : | loc.x = temppre.AbsolutePosition.X; | ||
| 452 : | loc.y = temppre.AbsolutePosition.Y; | ||
| 453 : | loc.z = temppre.AbsolutePosition.Z; | ||
| 454 : | } | ||
| 455 : | return loc; | ||
| 456 : | } | ||
| 457 : | |||
| 458 : | public LSL_Types.Quaternion SPGetRot(string vPresenceId) | ||
| 459 : | { | ||
| 460 : | LSL_Types.Quaternion rot = new LSL_Types.Quaternion(0, 0, 0, 1); | ||
| 461 : | |||
| 462 : | UUID TempId = new UUID(vPresenceId); | ||
| 463 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 464 : | if (temppre != null) | ||
| 465 : | { | ||
| 466 : | rot.x = temppre.Rotation.X; | ||
| 467 : | rot.y = temppre.Rotation.Y; | ||
| 468 : | rot.z = temppre.Rotation.Z; | ||
| 469 : | rot.s = temppre.Rotation.W; | ||
| 470 : | } | ||
| 471 : | return rot; | ||
| 472 : | } | ||
| 473 : | |||
| 474 : | public void SPSetRot(string vPresenceId,LSL_Types.Quaternion vRot, bool vbRelative) | ||
| 475 : | { | ||
| 476 : | UUID TempId = new UUID(vPresenceId); | ||
| 477 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 478 : | if (temppre != null) | ||
| 479 : | { | ||
| 480 : | if (temppre.ControllingClient is RexNetwork.RexClientView) | ||
| 481 : | { | ||
| 482 : | RexNetwork.RexClientView client = (RexNetwork.RexClientView)temppre.ControllingClient; | ||
| 483 : | string sparams = vRot.x.ToString() + " " + vRot.y.ToString() + " " + vRot.z.ToString() + " " + vRot.s.ToString(); | ||
| 484 : | sparams = sparams.Replace(",", "."); | ||
| 485 : | if (vbRelative) | ||
| 486 : | client.SendRexScriptCommand("client", "setrelrot", sparams); | ||
| 487 : | else | ||
| 488 : | client.SendRexScriptCommand("client", "setrot", sparams); | ||
| 489 : | } | ||
| 490 : | } | ||
| 491 : | } | ||
| 492 : | |||
| 493 : | public bool SPGetWalkDisabled(string vPresenceId) | ||
| 494 : | { | ||
| 495 : | |||
| 496 : | UUID TempId = new UUID(vPresenceId); | ||
| 497 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 498 : | if (temppre != null) | ||
| 499 : | { | ||
| 500 : | if (temppre.ControllingClient is RexNetwork.RexClientView) | ||
| 501 : | { | ||
| 502 : | RexNetwork.RexClientView rexclient = (RexNetwork.RexClientView)temppre.ControllingClient; | ||
| 503 : | return rexclient.RexWalkDisabled; | ||
| 504 : | } | ||
| 505 : | } | ||
| 506 : | return false; | ||
| 507 : | } | ||
| 508 : | |||
| 509 : | public void SPSetWalkDisabled(string vPresenceId, bool vbValue) | ||
| 510 : | { | ||
| 511 : | |||
| 512 : | UUID TempId = new UUID(vPresenceId); | ||
| 513 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 514 : | if (temppre != null) | ||
| 515 : | { | ||
| 516 : | if (temppre.ControllingClient is RexNetwork.RexClientView) | ||
| 517 : | { | ||
| 518 : | RexNetwork.RexClientView rexclient = (RexNetwork.RexClientView)temppre.ControllingClient; | ||
| 519 : | rexclient.RexWalkDisabled = vbValue; | ||
| 520 : | } | ||
| 521 : | } | ||
| 522 : | } | ||
| 523 : | |||
| 524 : | public bool SPGetFlyDisabled(string vPresenceId) | ||
| 525 : | { | ||
| 526 : | |||
| 527 : | UUID TempId = new UUID(vPresenceId); | ||
| 528 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 529 : | if (temppre != null) | ||
| 530 : | { | ||
| 531 : | if (temppre.ControllingClient is RexNetwork.RexClientView) | ||
| 532 : | { | ||
| 533 : | RexNetwork.RexClientView rexclient = (RexNetwork.RexClientView)temppre.ControllingClient; | ||
| 534 : | return rexclient.RexFlyDisabled; | ||
| 535 : | } | ||
| 536 : | } | ||
| 537 : | return false; | ||
| 538 : | } | ||
| 539 : | |||
| 540 : | public void SPSetFlyDisabled(string vPresenceId, bool vbValue) | ||
| 541 : | { | ||
| 542 : | |||
| 543 : | UUID TempId = new UUID(vPresenceId); | ||
| 544 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 545 : | if (temppre != null) | ||
| 546 : | { | ||
| 547 : | if (temppre.ControllingClient is RexNetwork.RexClientView) | ||
| 548 : | { | ||
| 549 : | RexNetwork.RexClientView rexclient = (RexNetwork.RexClientView)temppre.ControllingClient; | ||
| 550 : | rexclient.RexFlyDisabled = vbValue; | ||
| 551 : | } | ||
| 552 : | } | ||
| 553 : | } | ||
| 554 : | |||
| 555 : | mikkopa | 20 | public float SPGetVertMovementModifier(string vPresenceId) |
| 556 : | { | ||
| 557 : | UUID TempId = new UUID(vPresenceId); | ||
| 558 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 559 : | if (temppre != null) | ||
| 560 : | { | ||
| 561 : | if (temppre.ControllingClient is RexNetwork.RexClientView) | ||
| 562 : | { | ||
| 563 : | RexNetwork.RexClientView rexclient = (RexNetwork.RexClientView)temppre.ControllingClient; | ||
| 564 : | return rexclient.RexVertMovementSpeedMod; | ||
| 565 : | } | ||
| 566 : | } | ||
| 567 : | return 0.0f; | ||
| 568 : | } | ||
| 569 : | |||
| 570 : | public void SPSetVertMovementModifier(string vPresenceId, float vSpeedModifier) | ||
| 571 : | { | ||
| 572 : | |||
| 573 : | UUID TempId = new UUID(vPresenceId); | ||
| 574 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 575 : | if (temppre != null) | ||
| 576 : | if (temppre.ControllingClient is RexNetwork.RexClientView) | ||
| 577 : | { | ||
| 578 : | RexNetwork.RexClientView rexclient = (RexNetwork.RexClientView)temppre.ControllingClient; | ||
| 579 : | rexclient.RexVertMovementSpeedMod = vSpeedModifier; | ||
| 580 : | } | ||
| 581 : | } | ||
| 582 : | |||
| 583 : | |||
| 584 : | public bool SPGetSitDisabled(string vPresenceId) | ||
| 585 : | { | ||
| 586 : | |||
| 587 : | UUID TempId = new UUID(vPresenceId); | ||
| 588 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 589 : | if (temppre != null) | ||
| 590 : | { | ||
| 591 : | if (temppre.ControllingClient is RexNetwork.RexClientView) | ||
| 592 : | { | ||
| 593 : | RexNetwork.RexClientView rexclient = (RexNetwork.RexClientView)temppre.ControllingClient; | ||
| 594 : | return rexclient.RexSitDisabled; | ||
| 595 : | } | ||
| 596 : | } | ||
| 597 : | return false; | ||
| 598 : | } | ||
| 599 : | |||
| 600 : | public void SPSetSitDisabled(string vPresenceId, bool vbValue) | ||
| 601 : | { | ||
| 602 : | |||
| 603 : | UUID TempId = new UUID(vPresenceId); | ||
| 604 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 605 : | if (temppre != null) | ||
| 606 : | { | ||
| 607 : | if (temppre.ControllingClient is RexNetwork.RexClientView) | ||
| 608 : | { | ||
| 609 : | RexNetwork.RexClientView rexclient = (RexNetwork.RexClientView)temppre.ControllingClient; | ||
| 610 : | rexclient.RexSitDisabled = vbValue; | ||
| 611 : | } | ||
| 612 : | } | ||
| 613 : | } | ||
| 614 : | |||
| 615 : | |||
| 616 : | mikkopa | 12 | // Rexbot related |
| 617 : | public void BotWalkTo(string vPresenceId, LSL_Types.Vector3 vDest) | ||
| 618 : | { | ||
| 619 : | UUID TempId = new UUID(vPresenceId); | ||
| 620 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 621 : | if (temppre != null && temppre.ControllingClient is IRexBot) | ||
| 622 : | { | ||
| 623 : | Vector3 dest = new Vector3((float)vDest.x, (float)vDest.y, (float)vDest.z); | ||
| 624 : | (temppre.ControllingClient as IRexBot).WalkTo(dest); | ||
| 625 : | } | ||
| 626 : | mikkopa | 34 | |
| 627 : | |||
| 628 : | mikkopa | 12 | } |
| 629 : | |||
| 630 : | public void BotFlyTo(string vPresenceId, LSL_Types.Vector3 vDest) | ||
| 631 : | { | ||
| 632 : | UUID TempId = new UUID(vPresenceId); | ||
| 633 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 634 : | if (temppre != null && temppre.ControllingClient is IRexBot) | ||
| 635 : | { | ||
| 636 : | Vector3 dest = new Vector3((float)vDest.x, (float)vDest.y, (float)vDest.z); | ||
| 637 : | (temppre.ControllingClient as IRexBot).FlyTo(dest); | ||
| 638 : | } | ||
| 639 : | } | ||
| 640 : | |||
| 641 : | public void BotRotateTo(string vPresenceId, LSL_Types.Vector3 vTarget) | ||
| 642 : | { | ||
| 643 : | UUID TempId = new UUID(vPresenceId); | ||
| 644 : | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); | ||
| 645 : | if (temppre != null && temppre.ControllingClient is IRexBot) | ||
| 646 : | { | ||
| 647 : | Vector3 dest = new Vector3((float)vTarget.x, (float)vTarget.y, (float)vTarget.z); | ||
| 648 : | (temppre.ControllingClient as IRexBot).RotateTo(dest); | ||
| 649 : | } | ||
| 650 : | } | ||
| 651 : | |||
| 652 : | mikkopa | 20 | /// <summary> |
| 653 : | /// deprecated. prefer BotPauseAutoMove() or BotStopAutoMove() | ||
| 654 : | /// </summary> | ||
| 655 : | [Obsolete("use BotPauseAutoMove() or BotStopAutoMove()")] | ||
| 656 : | public void BotEnableAutoMove(string botId, bool vEnable) | ||
| 657 : | mikkopa | 12 | { |
| 658 : | mikkopa | 20 | UUID TempId = new UUID(botId); |
| 659 : | mikkopa | 12 | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); |
| 660 : | if (temppre != null && temppre.ControllingClient is IRexBot) | ||
| 661 : | { | ||
| 662 : | (temppre.ControllingClient as IRexBot).EnableAutoMove(vEnable, true); | ||
| 663 : | } | ||
| 664 : | } | ||
| 665 : | |||
| 666 : | mikkopa | 20 | /// <summary> |
| 667 : | /// Temporarily pause bot auto movement. bot will still warp to destination if it is deemed stuck | ||
| 668 : | /// </summary> | ||
| 669 : | /// <param name="botId">UUID of the bots ScenePresence</param> | ||
| 670 : | /// <param name="vEnable"></param> | ||
| 671 : | public void BotPauseAutoMove(string botId, bool vEnable) | ||
| 672 : | mikkopa | 12 | { |
| 673 : | mikkopa | 20 | UUID TempId = new UUID(botId); |
| 674 : | mikkopa | 12 | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); |
| 675 : | if (temppre != null && temppre.ControllingClient is IRexBot) | ||
| 676 : | { | ||
| 677 : | (temppre.ControllingClient as IRexBot).PauseAutoMove(vEnable); | ||
| 678 : | } | ||
| 679 : | } | ||
| 680 : | |||
| 681 : | mikkopa | 20 | /// <summary> |
| 682 : | /// Stop/start bot auto movement. Bot will not warp to destination after it has been stopped, | ||
| 683 : | /// no logic for checking if bot is stuck | ||
| 684 : | /// </summary> | ||
| 685 : | /// <param name="botId">UUID of the bots ScenePresence</param> | ||
| 686 : | /// <param name="vEnable"></param> | ||
| 687 : | public void BotStopAutoMove(string botId, bool vEnable) | ||
| 688 : | mikkopa | 12 | { |
| 689 : | mikkopa | 20 | UUID TempId = new UUID(botId); |
| 690 : | mikkopa | 12 | ScenePresence temppre = myScriptEngine.World.GetScenePresence(TempId); |
| 691 : | if (temppre != null && temppre.ControllingClient is IRexBot) | ||
| 692 : | { | ||
| 693 : | (temppre.ControllingClient as IRexBot).StopAutoMove(vEnable); | ||
| 694 : | } | ||
| 695 : | } | ||
| 696 : | |||
| 697 : | |||
| 698 : | mikkopa | 20 | #region Functions not supported at the moment. |
| 699 : | mikkopa | 12 | /* |
| 700 : | public bool GetFreezed(string vId) | ||
| 701 : | { | ||
| 702 : | EntityBase tempobj = GetEntityBase(System.Convert.ToUInt32(vId, 10)); | ||
| 703 : | if (tempobj != null) | ||
| 704 : | { | ||
| 705 : | return tempobj.IsFreezed; | ||
| 706 : | } | ||
| 707 : | else | ||
| 708 : | { | ||
| 709 : | return false; | ||
| 710 : | } | ||
| 711 : | |||
| 712 : | return false; | ||
| 713 : | } | ||
| 714 : | |||
| 715 : | public void SetFreezed(string vId, bool vbFreeze) | ||
| 716 : | { | ||
| 717 : | EntityBase tempobj = GetEntityBase(System.Convert.ToUInt32(vId, 10)); | ||
| 718 : | if (tempobj != null) | ||
| 719 : | { | ||
| 720 : | tempobj.IsFreezed = vbFreeze; | ||
| 721 : | if (tempobj is ScenePresence && vbFreeze) | ||
| 722 : | ((ScenePresence)tempobj).rxStopAvatarMovement(); | ||
| 723 : | } | ||
| 724 : | |||
| 725 : | } */ | ||
| 726 : | |||
| 727 : | /* | ||
| 728 : | public int GetPhysicsMode(string vId) | ||
| 729 : | { | ||
| 730 : | SceneObjectPart tempobj = myScriptEngine.World.GetSceneObjectPart(System.Convert.ToUInt32(vId, 10)); | ||
| 731 : | if (tempobj != null) | ||
| 732 : | return tempobj.GetPhysicsMode(); | ||
| 733 : | else | ||
| 734 : | return 0; | ||
| 735 : | |||
| 736 : | return 0; | ||
| 737 : | } | ||
| 738 : | |||
| 739 : | public void SetPhysicsMode(string vId, int vPhysicsMode) | ||
| 740 : | { | ||
| 741 : | SceneObjectPart tempobj = myScriptEngine.World.GetSceneObjectPart(System.Convert.ToUInt32(vId, 10)); | ||
| 742 : | if (tempobj != null) | ||
| 743 : | { | ||
| 744 : | tempobj.SetPhysicsMode(vPhysicsMode); | ||
| 745 : | } | ||
| 746 : | else | ||
| 747 : | myScriptEngine.Log.Verbose("PythonScript", "SetPhysicsMode for nonexisting object:" + vId); | ||
| 748 : | } | ||
| 749 : | */ | ||
| 750 : | |||
| 751 : | |||
| 752 : | /* | ||
| 753 : | public bool GetUseGravity(string vId) | ||
| 754 : | { | ||
| 755 : | SceneObjectPart tempobj = myScriptEngine.World.GetSceneObjectPart(System.Convert.ToUInt32(vId, 10)); | ||
| 756 : | if (tempobj != null) | ||
| 757 : | return tempobj.GetUseGravity(); | ||
| 758 : | else | ||
| 759 : | return false; | ||
| 760 : | |||
| 761 : | return false; | ||
| 762 : | } | ||
| 763 : | |||
| 764 : | public void SetUseGravity(string vId, bool vbUseGravity) | ||
| 765 : | { | ||
| 766 : | SceneObjectPart tempobj = myScriptEngine.World.GetSceneObjectPart(System.Convert.ToUInt32(vId, 10)); | ||
| 767 : | if (tempobj != null) | ||
| 768 : | tempobj.SetUseGravity(vbUseGravity); | ||
| 769 : | else | ||
| 770 : | myScriptEngine.Log.Verbose("PythonScript", "SetUseGravity for nonexisting object:" + vId); | ||
| 771 : | } | ||
| 772 : | */ | ||
| 773 : | |||
| 774 : | /* | ||
| 775 : | public void SetLocationFast(string vId,rxVector vLoc) | ||
| 776 : | { | ||
| 777 : | EntityBase tempobj = GetEntityBase(System.Convert.ToUInt32(vId, 10)); | ||
| 778 : | if (((SceneObjectGroup)tempobj) != null) | ||
| 779 : | { | ||
| 780 : | bool hasPrim = ((SceneObjectGroup)tempobj).HasChildPrim(tempobj.UUID); | ||
| 781 : | if (hasPrim != false) | ||
| 782 : | { | ||
| 783 : | LLVector3 TempLoc = new LLVector3((float)vLoc.x, (float)vLoc.y, (float)vLoc.z); | ||
| 784 : | LLVector3 TempOffset = new LLVector3(0, 0, 0); | ||
| 785 : | ((SceneObjectGroup)tempobj).GrabMovement(TempOffset, TempLoc, null); // tucofixme, might break some day, because sending null remoteClient parameter | ||
| 786 : | } | ||
| 787 : | } | ||
| 788 : | } | ||
| 789 : | */ | ||
| 790 : | mikkopa | 20 | #endregion |
| 791 : | mikkopa | 12 | |
| 792 : | public float TimeOfDay //is double in LL interface, but float inside opensim estate info | ||
| 793 : | { | ||
| 794 : | get | ||
| 795 : | { | ||
| 796 : | return (float)myScriptEngine.World.RegionInfo.EstateSettings.SunPosition;//sunHour; //llGetTimeOfDay(); | ||
| 797 : | } | ||
| 798 : | |||
| 799 : | set | ||
| 800 : | { | ||
| 801 : | myScriptEngine.World.RegionInfo.EstateSettings.SunPosition = value; | ||
| 802 : | IEstateModule estate = myScriptEngine.World.RequestModuleInterface<IEstateModule>(); | ||
| 803 : | tuco | 65 | if (estate is OpenSim.Region.CoreModules.World.Estate.EstateManagementModule) |
| 804 : | ((OpenSim.Region.CoreModules.World.Estate.EstateManagementModule)estate).sendRegionInfoPacketToAll(); | ||
| 805 : | mikkopa | 12 | } |
| 806 : | } | ||
| 807 : | } | ||
| 808 : | } | ||
| 809 : | |||
| 810 : | |||
| 811 : | |||
| 812 : | |||
| 813 : | |||
| 814 : | |||
| 815 : | |||
| 816 : | |||
| 817 : |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

