OSSL_Stub.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Runtime.Remoting.Lifetime;
  29. using System.Threading;
  30. using System.Reflection;
  31. using System.Collections;
  32. using System.Collections.Generic;
  33. using OpenSim.Framework;
  34. using OpenSim.Region.Framework.Interfaces;
  35. using OpenSim.Region.ScriptEngine.Interfaces;
  36. using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
  37. using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
  38. using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
  39. using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
  40. using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
  41. using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
  42. using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
  43. using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
  44. using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
  45. using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
  46. namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
  47. {
  48. public partial class ScriptBaseClass : MarshalByRefObject
  49. {
  50. public IOSSL_Api m_OSSL_Functions;
  51. public void ApiTypeOSSL(IScriptApi api)
  52. {
  53. if (!(api is IOSSL_Api))
  54. return;
  55. m_OSSL_Functions = (IOSSL_Api)api;
  56. Prim = new OSSLPrim(this);
  57. }
  58. public void osSetRegionWaterHeight(double height)
  59. {
  60. m_OSSL_Functions.osSetRegionWaterHeight(height);
  61. }
  62. public void osSetRegionSunSettings(bool useEstateSun, bool sunFixed, double sunHour)
  63. {
  64. m_OSSL_Functions.osSetRegionSunSettings(useEstateSun, sunFixed, sunHour);
  65. }
  66. public void osSetEstateSunSettings(bool sunFixed, double sunHour)
  67. {
  68. m_OSSL_Functions.osSetEstateSunSettings(sunFixed, sunHour);
  69. }
  70. public double osGetCurrentSunHour()
  71. {
  72. return m_OSSL_Functions.osGetCurrentSunHour();
  73. }
  74. public double osSunGetParam(string param)
  75. {
  76. return m_OSSL_Functions.osSunGetParam(param);
  77. }
  78. public void osSunSetParam(string param, double value)
  79. {
  80. m_OSSL_Functions.osSunSetParam(param, value);
  81. }
  82. public string osWindActiveModelPluginName()
  83. {
  84. return m_OSSL_Functions.osWindActiveModelPluginName();
  85. }
  86. // Not yet plugged in as available OSSL functions, so commented out
  87. // void osWindParamSet(string plugin, string param, float value)
  88. // {
  89. // m_OSSL_Functions.osWindParamSet(plugin, param, value);
  90. // }
  91. //
  92. // float osWindParamGet(string plugin, string param)
  93. // {
  94. // return m_OSSL_Functions.osWindParamGet(plugin, param);
  95. // }
  96. public void osParcelJoin(vector pos1, vector pos2)
  97. {
  98. m_OSSL_Functions.osParcelJoin(pos1,pos2);
  99. }
  100. public void osParcelSubdivide(vector pos1, vector pos2)
  101. {
  102. m_OSSL_Functions.osParcelSubdivide(pos1, pos2);
  103. }
  104. public void osParcelSetDetails(vector pos, LSL_List rules)
  105. {
  106. m_OSSL_Functions.osParcelSetDetails(pos,rules);
  107. }
  108. public double osList2Double(LSL_Types.list src, int index)
  109. {
  110. return m_OSSL_Functions.osList2Double(src, index);
  111. }
  112. public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams,
  113. int timer)
  114. {
  115. return m_OSSL_Functions.osSetDynamicTextureURL(dynamicID, contentType, url, extraParams, timer);
  116. }
  117. public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams,
  118. int timer)
  119. {
  120. return m_OSSL_Functions.osSetDynamicTextureData(dynamicID, contentType, data, extraParams, timer);
  121. }
  122. public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams,
  123. int timer, int alpha)
  124. {
  125. return m_OSSL_Functions.osSetDynamicTextureURLBlend(dynamicID, contentType, url, extraParams, timer, alpha);
  126. }
  127. public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams,
  128. int timer, int alpha)
  129. {
  130. return m_OSSL_Functions.osSetDynamicTextureDataBlend(dynamicID, contentType, data, extraParams, timer, alpha);
  131. }
  132. public string osSetDynamicTextureURLBlendFace(string dynamicID, string contentType, string url, string extraParams,
  133. bool blend, int disp, int timer, int alpha, int face)
  134. {
  135. return m_OSSL_Functions.osSetDynamicTextureURLBlendFace(dynamicID, contentType, url, extraParams,
  136. blend, disp, timer, alpha, face);
  137. }
  138. public string osSetDynamicTextureDataBlendFace(string dynamicID, string contentType, string data, string extraParams,
  139. bool blend, int disp, int timer, int alpha, int face)
  140. {
  141. return m_OSSL_Functions.osSetDynamicTextureDataBlendFace(dynamicID, contentType, data, extraParams,
  142. blend, disp, timer, alpha, face);
  143. }
  144. public LSL_Float osTerrainGetHeight(int x, int y)
  145. {
  146. return m_OSSL_Functions.osTerrainGetHeight(x, y);
  147. }
  148. public LSL_Integer osTerrainSetHeight(int x, int y, double val)
  149. {
  150. return m_OSSL_Functions.osTerrainSetHeight(x, y, val);
  151. }
  152. public void osTerrainFlush()
  153. {
  154. m_OSSL_Functions.osTerrainFlush();
  155. }
  156. public int osRegionRestart(double seconds)
  157. {
  158. return m_OSSL_Functions.osRegionRestart(seconds);
  159. }
  160. public void osRegionNotice(string msg)
  161. {
  162. m_OSSL_Functions.osRegionNotice(msg);
  163. }
  164. public bool osConsoleCommand(string Command)
  165. {
  166. return m_OSSL_Functions.osConsoleCommand(Command);
  167. }
  168. public void osSetParcelMediaURL(string url)
  169. {
  170. m_OSSL_Functions.osSetParcelMediaURL(url);
  171. }
  172. public void osSetParcelSIPAddress(string SIPAddress)
  173. {
  174. m_OSSL_Functions.osSetParcelSIPAddress(SIPAddress);
  175. }
  176. public void osSetPrimFloatOnWater(int floatYN)
  177. {
  178. m_OSSL_Functions.osSetPrimFloatOnWater(floatYN);
  179. }
  180. // Teleport Functions
  181. public void osTeleportAgent(string agent, string regionName, vector position, vector lookat)
  182. {
  183. m_OSSL_Functions.osTeleportAgent(agent, regionName, position, lookat);
  184. }
  185. public void osTeleportAgent(string agent, int regionX, int regionY, vector position, vector lookat)
  186. {
  187. m_OSSL_Functions.osTeleportAgent(agent, regionX, regionY, position, lookat);
  188. }
  189. public void osTeleportAgent(string agent, vector position, vector lookat)
  190. {
  191. m_OSSL_Functions.osTeleportAgent(agent, position, lookat);
  192. }
  193. // Avatar info functions
  194. public string osGetAgentIP(string agent)
  195. {
  196. return m_OSSL_Functions.osGetAgentIP(agent);
  197. }
  198. public LSL_List osGetAgents()
  199. {
  200. return m_OSSL_Functions.osGetAgents();
  201. }
  202. // Animation Functions
  203. public void osAvatarPlayAnimation(string avatar, string animation)
  204. {
  205. m_OSSL_Functions.osAvatarPlayAnimation(avatar, animation);
  206. }
  207. public void osAvatarStopAnimation(string avatar, string animation)
  208. {
  209. m_OSSL_Functions.osAvatarStopAnimation(avatar, animation);
  210. }
  211. //Texture Draw functions
  212. public string osMovePen(string drawList, int x, int y)
  213. {
  214. return m_OSSL_Functions.osMovePen(drawList, x, y);
  215. }
  216. public string osDrawLine(string drawList, int startX, int startY, int endX, int endY)
  217. {
  218. return m_OSSL_Functions.osDrawLine(drawList, startX, startY, endX, endY);
  219. }
  220. public string osDrawLine(string drawList, int endX, int endY)
  221. {
  222. return m_OSSL_Functions.osDrawLine(drawList, endX, endY);
  223. }
  224. public string osDrawText(string drawList, string text)
  225. {
  226. return m_OSSL_Functions.osDrawText(drawList, text);
  227. }
  228. public string osDrawEllipse(string drawList, int width, int height)
  229. {
  230. return m_OSSL_Functions.osDrawEllipse(drawList, width, height);
  231. }
  232. public string osDrawRectangle(string drawList, int width, int height)
  233. {
  234. return m_OSSL_Functions.osDrawRectangle(drawList, width, height);
  235. }
  236. public string osDrawFilledRectangle(string drawList, int width, int height)
  237. {
  238. return m_OSSL_Functions.osDrawFilledRectangle(drawList, width, height);
  239. }
  240. public string osDrawPolygon(string drawList, LSL_List x, LSL_List y)
  241. {
  242. return m_OSSL_Functions.osDrawPolygon(drawList, x, y);
  243. }
  244. public string osDrawFilledPolygon(string drawList, LSL_List x, LSL_List y)
  245. {
  246. return m_OSSL_Functions.osDrawFilledPolygon(drawList, x, y);
  247. }
  248. public string osSetFontSize(string drawList, int fontSize)
  249. {
  250. return m_OSSL_Functions.osSetFontSize(drawList, fontSize);
  251. }
  252. public string osSetFontName(string drawList, string fontName)
  253. {
  254. return m_OSSL_Functions.osSetFontName(drawList, fontName);
  255. }
  256. public string osSetPenSize(string drawList, int penSize)
  257. {
  258. return m_OSSL_Functions.osSetPenSize(drawList, penSize);
  259. }
  260. public string osSetPenCap(string drawList, string direction, string type)
  261. {
  262. return m_OSSL_Functions.osSetPenCap(drawList, direction, type);
  263. }
  264. public string osSetPenColour(string drawList, string colour)
  265. {
  266. return m_OSSL_Functions.osSetPenColour(drawList, colour);
  267. }
  268. public string osDrawImage(string drawList, int width, int height, string imageUrl)
  269. {
  270. return m_OSSL_Functions.osDrawImage(drawList, width, height, imageUrl);
  271. }
  272. public vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize)
  273. {
  274. return m_OSSL_Functions.osGetDrawStringSize(contentType, text, fontName, fontSize);
  275. }
  276. public void osSetStateEvents(int events)
  277. {
  278. m_OSSL_Functions.osSetStateEvents(events);
  279. }
  280. public string osGetScriptEngineName()
  281. {
  282. return m_OSSL_Functions.osGetScriptEngineName();
  283. }
  284. public string osGetSimulatorVersion()
  285. {
  286. return m_OSSL_Functions.osGetSimulatorVersion();
  287. }
  288. public Hashtable osParseJSON(string JSON)
  289. {
  290. return m_OSSL_Functions.osParseJSON(JSON);
  291. }
  292. public void osMessageObject(key objectUUID,string message)
  293. {
  294. m_OSSL_Functions.osMessageObject(objectUUID,message);
  295. }
  296. public void osMakeNotecard(string notecardName, LSL_Types.list contents)
  297. {
  298. m_OSSL_Functions.osMakeNotecard(notecardName, contents);
  299. }
  300. public string osGetNotecardLine(string name, int line)
  301. {
  302. return m_OSSL_Functions.osGetNotecardLine(name, line);
  303. }
  304. public string osGetNotecard(string name)
  305. {
  306. return m_OSSL_Functions.osGetNotecard(name);
  307. }
  308. public int osGetNumberOfNotecardLines(string name)
  309. {
  310. return m_OSSL_Functions.osGetNumberOfNotecardLines(name);
  311. }
  312. public string osAvatarName2Key(string firstname, string lastname)
  313. {
  314. return m_OSSL_Functions.osAvatarName2Key(firstname, lastname);
  315. }
  316. public string osKey2Name(string id)
  317. {
  318. return m_OSSL_Functions.osKey2Name(id);
  319. }
  320. public string osGetGridNick()
  321. {
  322. return m_OSSL_Functions.osGetGridNick();
  323. }
  324. public string osGetGridName()
  325. {
  326. return m_OSSL_Functions.osGetGridName();
  327. }
  328. public string osGetGridLoginURI()
  329. {
  330. return m_OSSL_Functions.osGetGridLoginURI();
  331. }
  332. public LSL_String osFormatString(string str, LSL_List strings)
  333. {
  334. return m_OSSL_Functions.osFormatString(str, strings);
  335. }
  336. public LSL_List osMatchString(string src, string pattern, int start)
  337. {
  338. return m_OSSL_Functions.osMatchString(src, pattern, start);
  339. }
  340. // Information about data loaded into the region
  341. public string osLoadedCreationDate()
  342. {
  343. return m_OSSL_Functions.osLoadedCreationDate();
  344. }
  345. public string osLoadedCreationTime()
  346. {
  347. return m_OSSL_Functions.osLoadedCreationTime();
  348. }
  349. public string osLoadedCreationID()
  350. {
  351. return m_OSSL_Functions.osLoadedCreationID();
  352. }
  353. public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules)
  354. {
  355. return m_OSSL_Functions.osGetLinkPrimitiveParams(linknumber, rules);
  356. }
  357. public key osNpcCreate(string user, string name, vector position, key cloneFrom)
  358. {
  359. return m_OSSL_Functions.osNpcCreate(user, name, position, cloneFrom);
  360. }
  361. public void osNpcMoveTo(key npc, vector position)
  362. {
  363. m_OSSL_Functions.osNpcMoveTo(npc, position);
  364. }
  365. public void osNpcSay(key npc, string message)
  366. {
  367. m_OSSL_Functions.osNpcSay(npc, message);
  368. }
  369. public void osNpcRemove(key npc)
  370. {
  371. m_OSSL_Functions.osNpcRemove(npc);
  372. }
  373. public OSSLPrim Prim;
  374. [Serializable]
  375. public class OSSLPrim
  376. {
  377. internal ScriptBaseClass OSSL;
  378. public OSSLPrim(ScriptBaseClass bc)
  379. {
  380. OSSL = bc;
  381. Position = new OSSLPrim_Position(this);
  382. Rotation = new OSSLPrim_Rotation(this);
  383. }
  384. public OSSLPrim_Position Position;
  385. public OSSLPrim_Rotation Rotation;
  386. private TextStruct _text;
  387. public TextStruct Text
  388. {
  389. get { return _text; }
  390. set
  391. {
  392. _text = value;
  393. OSSL.llSetText(_text.Text, _text.color, _text.alpha);
  394. }
  395. }
  396. [Serializable]
  397. public struct TextStruct
  398. {
  399. public string Text;
  400. public LSL_Types.Vector3 color;
  401. public double alpha;
  402. }
  403. }
  404. [Serializable]
  405. public class OSSLPrim_Position
  406. {
  407. private OSSLPrim prim;
  408. private LSL_Types.Vector3 Position;
  409. public OSSLPrim_Position(OSSLPrim _prim)
  410. {
  411. prim = _prim;
  412. }
  413. private void Load()
  414. {
  415. Position = prim.OSSL.llGetPos();
  416. }
  417. private void Save()
  418. {
  419. if (Position.x > ((int)Constants.RegionSize - 1))
  420. Position.x = ((int)Constants.RegionSize - 1);
  421. if (Position.x < 0)
  422. Position.x = 0;
  423. if (Position.y > ((int)Constants.RegionSize - 1))
  424. Position.y = ((int)Constants.RegionSize - 1);
  425. if (Position.y < 0)
  426. Position.y = 0;
  427. if (Position.z > 768)
  428. Position.z = 768;
  429. if (Position.z < 0)
  430. Position.z = 0;
  431. prim.OSSL.llSetPos(Position);
  432. }
  433. public double x
  434. {
  435. get
  436. {
  437. Load();
  438. return Position.x;
  439. }
  440. set
  441. {
  442. Load();
  443. Position.x = value;
  444. Save();
  445. }
  446. }
  447. public double y
  448. {
  449. get
  450. {
  451. Load();
  452. return Position.y;
  453. }
  454. set
  455. {
  456. Load();
  457. Position.y = value;
  458. Save();
  459. }
  460. }
  461. public double z
  462. {
  463. get
  464. {
  465. Load();
  466. return Position.z;
  467. }
  468. set
  469. {
  470. Load();
  471. Position.z = value;
  472. Save();
  473. }
  474. }
  475. }
  476. [Serializable]
  477. public class OSSLPrim_Rotation
  478. {
  479. private OSSLPrim prim;
  480. private LSL_Types.Quaternion Rotation;
  481. public OSSLPrim_Rotation(OSSLPrim _prim)
  482. {
  483. prim = _prim;
  484. }
  485. private void Load()
  486. {
  487. Rotation = prim.OSSL.llGetRot();
  488. }
  489. private void Save()
  490. {
  491. prim.OSSL.llSetRot(Rotation);
  492. }
  493. public double x
  494. {
  495. get
  496. {
  497. Load();
  498. return Rotation.x;
  499. }
  500. set
  501. {
  502. Load();
  503. Rotation.x = value;
  504. Save();
  505. }
  506. }
  507. public double y
  508. {
  509. get
  510. {
  511. Load();
  512. return Rotation.y;
  513. }
  514. set
  515. {
  516. Load();
  517. Rotation.y = value;
  518. Save();
  519. }
  520. }
  521. public double z
  522. {
  523. get
  524. {
  525. Load();
  526. return Rotation.z;
  527. }
  528. set
  529. {
  530. Load();
  531. Rotation.z = value;
  532. Save();
  533. }
  534. }
  535. public double s
  536. {
  537. get
  538. {
  539. Load();
  540. return Rotation.s;
  541. }
  542. set
  543. {
  544. Load();
  545. Rotation.s = value;
  546. Save();
  547. }
  548. }
  549. }
  550. public key osGetMapTexture()
  551. {
  552. return m_OSSL_Functions.osGetMapTexture();
  553. }
  554. public key osGetRegionMapTexture(string regionName)
  555. {
  556. return m_OSSL_Functions.osGetRegionMapTexture(regionName);
  557. }
  558. public LSL_List osGetRegionStats()
  559. {
  560. return m_OSSL_Functions.osGetRegionStats();
  561. }
  562. /// <summary>
  563. /// Returns the amount of memory in use by the Simulator Daemon.
  564. /// Amount in bytes - if >= 4GB, returns 4GB. (LSL is not 64-bit aware)
  565. /// </summary>
  566. /// <returns></returns>
  567. public LSL_Integer osGetSimulatorMemory()
  568. {
  569. return m_OSSL_Functions.osGetSimulatorMemory();
  570. }
  571. public void osKickAvatar(string FirstName,string SurName,string alert)
  572. {
  573. m_OSSL_Functions.osKickAvatar(FirstName, SurName, alert);
  574. }
  575. public void osSetSpeed(string UUID, float SpeedModifier)
  576. {
  577. m_OSSL_Functions.osSetSpeed(UUID, SpeedModifier);
  578. }
  579. public void osCauseDamage(string avatar, double damage)
  580. {
  581. m_OSSL_Functions.osCauseDamage(avatar, damage);
  582. }
  583. public void osCauseHealing(string avatar, double healing)
  584. {
  585. m_OSSL_Functions.osCauseHealing(avatar, healing);
  586. }
  587. public LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules)
  588. {
  589. return m_OSSL_Functions.osGetPrimitiveParams(prim, rules);
  590. }
  591. public void osSetPrimitiveParams(LSL_Key prim, LSL_List rules)
  592. {
  593. m_OSSL_Functions.osSetPrimitiveParams(prim, rules);
  594. }
  595. public LSL_List osGetAvatarList()
  596. {
  597. return m_OSSL_Functions.osGetAvatarList();
  598. }
  599. }
  600. }