OSSL_Stub.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  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 OpenSim 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.Region.Framework.Interfaces;
  34. using OpenSim.Region.ScriptEngine.Interfaces;
  35. using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
  36. using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
  37. using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
  38. using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
  39. using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
  40. using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
  41. using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
  42. namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
  43. {
  44. public partial class ScriptBaseClass : MarshalByRefObject
  45. {
  46. public IOSSL_Api m_OSSL_Functions;
  47. public void ApiTypeOSSL(IScriptApi api)
  48. {
  49. if (!(api is IOSSL_Api))
  50. return;
  51. m_OSSL_Functions = (IOSSL_Api)api;
  52. Prim = new OSSLPrim(this);
  53. }
  54. public void osSetRegionWaterHeight(double height)
  55. {
  56. m_OSSL_Functions.osSetRegionWaterHeight(height);
  57. }
  58. public double osList2Double(LSL_Types.list src, int index)
  59. {
  60. return m_OSSL_Functions.osList2Double(src, index);
  61. }
  62. public string osSetDynamicTextureURL(string dynamicID, string contentType, string url, string extraParams,
  63. int timer)
  64. {
  65. return m_OSSL_Functions.osSetDynamicTextureURL(dynamicID, contentType, url, extraParams, timer);
  66. }
  67. public string osSetDynamicTextureData(string dynamicID, string contentType, string data, string extraParams,
  68. int timer)
  69. {
  70. return m_OSSL_Functions.osSetDynamicTextureData(dynamicID, contentType, data, extraParams, timer);
  71. }
  72. public string osSetDynamicTextureURLBlend(string dynamicID, string contentType, string url, string extraParams,
  73. int timer, int alpha)
  74. {
  75. return m_OSSL_Functions.osSetDynamicTextureURLBlend(dynamicID, contentType, url, extraParams, timer, alpha);
  76. }
  77. public string osSetDynamicTextureDataBlend(string dynamicID, string contentType, string data, string extraParams,
  78. int timer, int alpha)
  79. {
  80. return m_OSSL_Functions.osSetDynamicTextureDataBlend(dynamicID, contentType, data, extraParams, timer, alpha);
  81. }
  82. public double osTerrainGetHeight(int x, int y)
  83. {
  84. return m_OSSL_Functions.osTerrainGetHeight(x, y);
  85. }
  86. public int osTerrainSetHeight(int x, int y, double val)
  87. {
  88. return m_OSSL_Functions.osTerrainSetHeight(x, y, val);
  89. }
  90. public int osRegionRestart(double seconds)
  91. {
  92. return m_OSSL_Functions.osRegionRestart(seconds);
  93. }
  94. public void osRegionNotice(string msg)
  95. {
  96. m_OSSL_Functions.osRegionNotice(msg);
  97. }
  98. public bool osConsoleCommand(string Command)
  99. {
  100. return m_OSSL_Functions.osConsoleCommand(Command);
  101. }
  102. public void osSetParcelMediaURL(string url)
  103. {
  104. m_OSSL_Functions.osSetParcelMediaURL(url);
  105. }
  106. public void osSetPrimFloatOnWater(int floatYN)
  107. {
  108. m_OSSL_Functions.osSetPrimFloatOnWater(floatYN);
  109. }
  110. // Teleport Functions
  111. public void osTeleportAgent(string agent, string regionName, vector position, vector lookat)
  112. {
  113. m_OSSL_Functions.osTeleportAgent(agent, regionName, position, lookat);
  114. }
  115. public void osTeleportAgent(string agent, long regionX, long regionY, vector position, vector lookat)
  116. {
  117. m_OSSL_Functions.osTeleportAgent(agent, (uint) regionX, (uint) regionY, position, lookat);
  118. }
  119. public void osTeleportAgent(string agent, vector position, vector lookat)
  120. {
  121. m_OSSL_Functions.osTeleportAgent(agent, position, lookat);
  122. }
  123. // Avatar info functions
  124. public string osGetAgentIP(string agent)
  125. {
  126. return m_OSSL_Functions.osGetAgentIP(agent);
  127. }
  128. // Animation Functions
  129. public void osAvatarPlayAnimation(string avatar, string animation)
  130. {
  131. m_OSSL_Functions.osAvatarPlayAnimation(avatar, animation);
  132. }
  133. public void osAvatarStopAnimation(string avatar, string animation)
  134. {
  135. m_OSSL_Functions.osAvatarStopAnimation(avatar, animation);
  136. }
  137. //Texture Draw functions
  138. public string osMovePen(string drawList, int x, int y)
  139. {
  140. return m_OSSL_Functions.osMovePen(drawList, x, y);
  141. }
  142. public string osDrawLine(string drawList, int startX, int startY, int endX, int endY)
  143. {
  144. return m_OSSL_Functions.osDrawLine(drawList, startX, startY, endX, endY);
  145. }
  146. public string osDrawLine(string drawList, int endX, int endY)
  147. {
  148. return m_OSSL_Functions.osDrawLine(drawList, endX, endY);
  149. }
  150. public string osDrawText(string drawList, string text)
  151. {
  152. return m_OSSL_Functions.osDrawText(drawList, text);
  153. }
  154. public string osDrawEllipse(string drawList, int width, int height)
  155. {
  156. return m_OSSL_Functions.osDrawEllipse(drawList, width, height);
  157. }
  158. public string osDrawRectangle(string drawList, int width, int height)
  159. {
  160. return m_OSSL_Functions.osDrawRectangle(drawList, width, height);
  161. }
  162. public string osDrawFilledRectangle(string drawList, int width, int height)
  163. {
  164. return m_OSSL_Functions.osDrawFilledRectangle(drawList, width, height);
  165. }
  166. public string osSetFontSize(string drawList, int fontSize)
  167. {
  168. return m_OSSL_Functions.osSetFontSize(drawList, fontSize);
  169. }
  170. public string osSetPenSize(string drawList, int penSize)
  171. {
  172. return m_OSSL_Functions.osSetPenSize(drawList, penSize);
  173. }
  174. public string osSetPenColour(string drawList, string colour)
  175. {
  176. return m_OSSL_Functions.osSetPenColour(drawList, colour);
  177. }
  178. public string osDrawImage(string drawList, int width, int height, string imageUrl)
  179. {
  180. return m_OSSL_Functions.osDrawImage(drawList, width, height, imageUrl);
  181. }
  182. public vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize)
  183. {
  184. return m_OSSL_Functions.osGetDrawStringSize(contentType, text, fontName, fontSize);
  185. }
  186. public void osSetStateEvents(int events)
  187. {
  188. m_OSSL_Functions.osSetStateEvents(events);
  189. }
  190. public string osGetScriptEngineName()
  191. {
  192. return m_OSSL_Functions.osGetScriptEngineName();
  193. }
  194. public string osGetSimulatorVersion()
  195. {
  196. return m_OSSL_Functions.osGetSimulatorVersion();
  197. }
  198. public Hashtable osParseJSON(string JSON)
  199. {
  200. return m_OSSL_Functions.osParseJSON(JSON);
  201. }
  202. public void osMessageObject(key objectUUID,string message)
  203. {
  204. m_OSSL_Functions.osMessageObject(objectUUID,message);
  205. }
  206. public void osMakeNotecard(string notecardName, LSL_Types.list contents)
  207. {
  208. m_OSSL_Functions.osMakeNotecard(notecardName, contents);
  209. }
  210. public string osGetGridNick()
  211. {
  212. return m_OSSL_Functions.osGetGridNick();
  213. }
  214. public string osGetGridName()
  215. {
  216. return m_OSSL_Functions.osGetGridName();
  217. }
  218. public string osGetGridLoginURI()
  219. {
  220. return m_OSSL_Functions.osGetGridLoginURI();
  221. }
  222. public LSL_String osFormatString(string str, LSL_List strings)
  223. {
  224. return m_OSSL_Functions.osFormatString(str, strings);
  225. }
  226. public LSL_List osMatchString(string src, string pattern, int start)
  227. {
  228. return m_OSSL_Functions.osMatchString(src, pattern, start);
  229. }
  230. public OSSLPrim Prim;
  231. [Serializable]
  232. public class OSSLPrim
  233. {
  234. internal ScriptBaseClass OSSL;
  235. public OSSLPrim(ScriptBaseClass bc)
  236. {
  237. OSSL = bc;
  238. Position = new OSSLPrim_Position(this);
  239. Rotation = new OSSLPrim_Rotation(this);
  240. }
  241. public OSSLPrim_Position Position;
  242. public OSSLPrim_Rotation Rotation;
  243. private TextStruct _text;
  244. public TextStruct Text
  245. {
  246. get { return _text; }
  247. set
  248. {
  249. _text = value;
  250. OSSL.llSetText(_text.Text, _text.color, _text.alpha);
  251. }
  252. }
  253. [Serializable]
  254. public struct TextStruct
  255. {
  256. public string Text;
  257. public LSL_Types.Vector3 color;
  258. public double alpha;
  259. }
  260. }
  261. [Serializable]
  262. public class OSSLPrim_Position
  263. {
  264. private OSSLPrim prim;
  265. private LSL_Types.Vector3 Position;
  266. public OSSLPrim_Position(OSSLPrim _prim)
  267. {
  268. prim = _prim;
  269. }
  270. private void Load()
  271. {
  272. Position = prim.OSSL.llGetPos();
  273. }
  274. private void Save()
  275. {
  276. if (Position.x > 255)
  277. Position.x = 255;
  278. if (Position.x < 0)
  279. Position.x = 0;
  280. if (Position.y > 255)
  281. Position.y = 255;
  282. if (Position.y < 0)
  283. Position.y = 0;
  284. if (Position.z > 768)
  285. Position.z = 768;
  286. if (Position.z < 0)
  287. Position.z = 0;
  288. prim.OSSL.llSetPos(Position);
  289. }
  290. public double x
  291. {
  292. get
  293. {
  294. Load();
  295. return Position.x;
  296. }
  297. set
  298. {
  299. Load();
  300. Position.x = value;
  301. Save();
  302. }
  303. }
  304. public double y
  305. {
  306. get
  307. {
  308. Load();
  309. return Position.y;
  310. }
  311. set
  312. {
  313. Load();
  314. Position.y = value;
  315. Save();
  316. }
  317. }
  318. public double z
  319. {
  320. get
  321. {
  322. Load();
  323. return Position.z;
  324. }
  325. set
  326. {
  327. Load();
  328. Position.z = value;
  329. Save();
  330. }
  331. }
  332. }
  333. [Serializable]
  334. public class OSSLPrim_Rotation
  335. {
  336. private OSSLPrim prim;
  337. private LSL_Types.Quaternion Rotation;
  338. public OSSLPrim_Rotation(OSSLPrim _prim)
  339. {
  340. prim = _prim;
  341. }
  342. private void Load()
  343. {
  344. Rotation = prim.OSSL.llGetRot();
  345. }
  346. private void Save()
  347. {
  348. prim.OSSL.llSetRot(Rotation);
  349. }
  350. public double x
  351. {
  352. get
  353. {
  354. Load();
  355. return Rotation.x;
  356. }
  357. set
  358. {
  359. Load();
  360. Rotation.x = value;
  361. Save();
  362. }
  363. }
  364. public double y
  365. {
  366. get
  367. {
  368. Load();
  369. return Rotation.y;
  370. }
  371. set
  372. {
  373. Load();
  374. Rotation.y = value;
  375. Save();
  376. }
  377. }
  378. public double z
  379. {
  380. get
  381. {
  382. Load();
  383. return Rotation.z;
  384. }
  385. set
  386. {
  387. Load();
  388. Rotation.z = value;
  389. Save();
  390. }
  391. }
  392. public double s
  393. {
  394. get
  395. {
  396. Load();
  397. return Rotation.s;
  398. }
  399. set
  400. {
  401. Load();
  402. Rotation.s = value;
  403. Save();
  404. }
  405. }
  406. }
  407. }
  408. }