LS_Api.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  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.Reflection;
  29. using System.Collections;
  30. using System.Collections.Generic;
  31. using System.Runtime.Remoting.Lifetime;
  32. using OpenMetaverse;
  33. using Nini.Config;
  34. using OpenSim;
  35. using OpenSim.Framework;
  36. using OpenSim.Region.CoreModules.World.LightShare;
  37. using OpenSim.Region.Framework.Interfaces;
  38. using OpenSim.Region.Framework.Scenes;
  39. using OpenSim.Region.ScriptEngine.Shared;
  40. using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
  41. using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
  42. using OpenSim.Region.ScriptEngine.Interfaces;
  43. using OpenSim.Region.ScriptEngine.Shared.Api.Interfaces;
  44. using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat;
  45. using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger;
  46. using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
  47. using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list;
  48. using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion;
  49. using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
  50. using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3;
  51. namespace OpenSim.Region.ScriptEngine.Shared.Api
  52. {
  53. [Serializable]
  54. public class LS_Api : MarshalByRefObject, ILS_Api, IScriptApi
  55. {
  56. internal IScriptEngine m_ScriptEngine;
  57. internal SceneObjectPart m_host;
  58. internal uint m_localID;
  59. internal UUID m_itemID;
  60. internal bool m_LSFunctionsEnabled = false;
  61. internal IScriptModuleComms m_comms = null;
  62. public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, uint localID, UUID itemID)
  63. {
  64. m_ScriptEngine = ScriptEngine;
  65. m_host = host;
  66. m_localID = localID;
  67. m_itemID = itemID;
  68. if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false))
  69. m_LSFunctionsEnabled = true;
  70. m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>();
  71. if (m_comms == null)
  72. m_LSFunctionsEnabled = false;
  73. }
  74. public override Object InitializeLifetimeService()
  75. {
  76. ILease lease = (ILease)base.InitializeLifetimeService();
  77. if (lease.CurrentState == LeaseState.Initial)
  78. {
  79. lease.InitialLeaseTime = TimeSpan.FromMinutes(0);
  80. // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0);
  81. // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0);
  82. }
  83. return lease;
  84. }
  85. public Scene World
  86. {
  87. get { return m_ScriptEngine.World; }
  88. }
  89. //
  90. //Dumps an error message on the debug console.
  91. //
  92. internal void LSShoutError(string message)
  93. {
  94. if (message.Length > 1023)
  95. message = message.Substring(0, 1023);
  96. World.SimChat(Utils.StringToBytes(message),
  97. ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true);
  98. IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
  99. wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
  100. }
  101. /// <summary>
  102. /// Get the current Windlight scene
  103. /// </summary>
  104. /// <returns>List of windlight parameters</returns>
  105. public LSL_List lsGetWindlightScene(LSL_List rules)
  106. {
  107. if (!m_LSFunctionsEnabled)
  108. {
  109. LSShoutError("LightShare functions are not enabled.");
  110. return new LSL_List();
  111. }
  112. m_host.AddScriptLPS(1);
  113. RegionLightShareData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings;
  114. LSL_List values = new LSL_List();
  115. int idx = 0;
  116. while (idx < rules.Length)
  117. {
  118. LSL_Integer ruleInt = rules.GetLSLIntegerItem(idx);
  119. uint rule = (uint)ruleInt;
  120. LSL_List toadd = new LSL_List();
  121. switch (rule)
  122. {
  123. case (int)ScriptBaseClass.WL_AMBIENT:
  124. toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W));
  125. break;
  126. case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
  127. toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f));
  128. break;
  129. case (int)ScriptBaseClass.WL_BLUE_DENSITY:
  130. toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W));
  131. break;
  132. case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
  133. toadd.Add(new LSL_Float(wl.blurMultiplier));
  134. break;
  135. case (int)ScriptBaseClass.WL_CLOUD_COLOR:
  136. toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W));
  137. break;
  138. case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
  139. toadd.Add(new LSL_Float(wl.cloudCoverage));
  140. break;
  141. case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
  142. toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z));
  143. break;
  144. case (int)ScriptBaseClass.WL_CLOUD_SCALE:
  145. toadd.Add(new LSL_Float(wl.cloudScale));
  146. break;
  147. case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
  148. toadd.Add(new LSL_Float(wl.cloudScrollX));
  149. break;
  150. case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
  151. toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0));
  152. break;
  153. case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
  154. toadd.Add(new LSL_Float(wl.cloudScrollY));
  155. break;
  156. case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
  157. toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0));
  158. break;
  159. case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
  160. toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z));
  161. break;
  162. case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
  163. toadd.Add(new LSL_Float(wl.densityMultiplier));
  164. break;
  165. case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
  166. toadd.Add(new LSL_Float(wl.distanceMultiplier));
  167. break;
  168. case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
  169. toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0));
  170. break;
  171. case (int)ScriptBaseClass.WL_EAST_ANGLE:
  172. toadd.Add(new LSL_Float(wl.eastAngle));
  173. break;
  174. case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
  175. toadd.Add(new LSL_Float(wl.fresnelOffset));
  176. break;
  177. case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
  178. toadd.Add(new LSL_Float(wl.fresnelScale));
  179. break;
  180. case (int)ScriptBaseClass.WL_HAZE_DENSITY:
  181. toadd.Add(new LSL_Float(wl.hazeDensity));
  182. break;
  183. case (int)ScriptBaseClass.WL_HAZE_HORIZON:
  184. toadd.Add(new LSL_Float(wl.hazeHorizon));
  185. break;
  186. case (int)ScriptBaseClass.WL_HORIZON:
  187. toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W));
  188. break;
  189. case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
  190. toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f));
  191. break;
  192. case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
  193. toadd.Add(new LSL_Integer(wl.maxAltitude));
  194. break;
  195. case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
  196. toadd.Add(new LSL_Key(wl.normalMapTexture.ToString()));
  197. break;
  198. case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
  199. toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z));
  200. break;
  201. case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
  202. toadd.Add(new LSL_Float(wl.refractScaleAbove));
  203. break;
  204. case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
  205. toadd.Add(new LSL_Float(wl.refractScaleBelow));
  206. break;
  207. case (int)ScriptBaseClass.WL_SCENE_GAMMA:
  208. toadd.Add(new LSL_Float(wl.sceneGamma));
  209. break;
  210. case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
  211. toadd.Add(new LSL_Float(wl.starBrightness));
  212. break;
  213. case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
  214. toadd.Add(new LSL_Float(wl.sunGlowFocus));
  215. break;
  216. case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
  217. toadd.Add(new LSL_Float(wl.sunGlowSize));
  218. break;
  219. case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
  220. toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W));
  221. break;
  222. case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
  223. toadd.Add(new LSL_Float(wl.underwaterFogModifier));
  224. break;
  225. case (int)ScriptBaseClass.WL_WATER_COLOR:
  226. toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z));
  227. break;
  228. case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
  229. toadd.Add(new LSL_Float(wl.waterFogDensityExponent));
  230. break;
  231. }
  232. if (toadd.Length > 0)
  233. {
  234. values.Add(ruleInt);
  235. values.Add(toadd.Data[0]);
  236. }
  237. idx++;
  238. }
  239. return values;
  240. }
  241. private RegionLightShareData getWindlightProfileFromRules(LSL_List rules)
  242. {
  243. RegionLightShareData wl = (RegionLightShareData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone();
  244. // LSL_List values = new LSL_List();
  245. int idx = 0;
  246. while (idx < rules.Length)
  247. {
  248. uint rule = (uint)rules.GetLSLIntegerItem(idx);
  249. LSL_Types.Quaternion iQ;
  250. LSL_Types.Vector3 iV;
  251. switch (rule)
  252. {
  253. case (int)ScriptBaseClass.WL_SUN_MOON_POSITION:
  254. idx++;
  255. wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx);
  256. break;
  257. case (int)ScriptBaseClass.WL_AMBIENT:
  258. idx++;
  259. iQ = rules.GetQuaternionItem(idx);
  260. wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
  261. break;
  262. case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
  263. idx++;
  264. iV = rules.GetVector3Item(idx);
  265. wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y);
  266. break;
  267. case (int)ScriptBaseClass.WL_BLUE_DENSITY:
  268. idx++;
  269. iQ = rules.GetQuaternionItem(idx);
  270. wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
  271. break;
  272. case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
  273. idx++;
  274. wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx);
  275. break;
  276. case (int)ScriptBaseClass.WL_CLOUD_COLOR:
  277. idx++;
  278. iQ = rules.GetQuaternionItem(idx);
  279. wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
  280. break;
  281. case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
  282. idx++;
  283. wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx);
  284. break;
  285. case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
  286. idx++;
  287. iV = rules.GetVector3Item(idx);
  288. wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
  289. break;
  290. case (int)ScriptBaseClass.WL_CLOUD_SCALE:
  291. idx++;
  292. wl.cloudScale = (float)rules.GetLSLFloatItem(idx);
  293. break;
  294. case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
  295. idx++;
  296. wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx);
  297. break;
  298. case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
  299. idx++;
  300. wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
  301. break;
  302. case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
  303. idx++;
  304. wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx);
  305. break;
  306. case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
  307. idx++;
  308. wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
  309. break;
  310. case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
  311. idx++;
  312. iV = rules.GetVector3Item(idx);
  313. wl.cloudXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
  314. break;
  315. case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
  316. idx++;
  317. wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx);
  318. break;
  319. case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
  320. idx++;
  321. wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx);
  322. break;
  323. case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
  324. idx++;
  325. wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
  326. break;
  327. case (int)ScriptBaseClass.WL_EAST_ANGLE:
  328. idx++;
  329. wl.eastAngle = (float)rules.GetLSLFloatItem(idx);
  330. break;
  331. case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
  332. idx++;
  333. wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx);
  334. break;
  335. case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
  336. idx++;
  337. wl.fresnelScale = (float)rules.GetLSLFloatItem(idx);
  338. break;
  339. case (int)ScriptBaseClass.WL_HAZE_DENSITY:
  340. idx++;
  341. wl.hazeDensity = (float)rules.GetLSLFloatItem(idx);
  342. break;
  343. case (int)ScriptBaseClass.WL_HAZE_HORIZON:
  344. idx++;
  345. wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx);
  346. break;
  347. case (int)ScriptBaseClass.WL_HORIZON:
  348. idx++;
  349. iQ = rules.GetQuaternionItem(idx);
  350. wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
  351. break;
  352. case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
  353. idx++;
  354. iV = rules.GetVector3Item(idx);
  355. wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y);
  356. break;
  357. case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
  358. idx++;
  359. wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value;
  360. break;
  361. case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
  362. idx++;
  363. wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string);
  364. break;
  365. case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
  366. idx++;
  367. iV = rules.GetVector3Item(idx);
  368. wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
  369. break;
  370. case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
  371. idx++;
  372. wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx);
  373. break;
  374. case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
  375. idx++;
  376. wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx);
  377. break;
  378. case (int)ScriptBaseClass.WL_SCENE_GAMMA:
  379. idx++;
  380. wl.sceneGamma = (float)rules.GetLSLFloatItem(idx);
  381. break;
  382. case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
  383. idx++;
  384. wl.starBrightness = (float)rules.GetLSLFloatItem(idx);
  385. break;
  386. case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
  387. idx++;
  388. wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx);
  389. break;
  390. case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
  391. idx++;
  392. wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx);
  393. break;
  394. case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
  395. idx++;
  396. iQ = rules.GetQuaternionItem(idx);
  397. wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
  398. break;
  399. case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
  400. idx++;
  401. wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx);
  402. break;
  403. case (int)ScriptBaseClass.WL_WATER_COLOR:
  404. idx++;
  405. iV = rules.GetVector3Item(idx);
  406. wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
  407. break;
  408. case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
  409. idx++;
  410. wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx);
  411. break;
  412. }
  413. idx++;
  414. }
  415. return wl;
  416. }
  417. /// <summary>
  418. /// Set the current Windlight scene
  419. /// </summary>
  420. /// <param name="rules"></param>
  421. /// <returns>success: true or false</returns>
  422. public int lsSetWindlightScene(LSL_List rules)
  423. {
  424. if (!m_LSFunctionsEnabled)
  425. {
  426. LSShoutError("LightShare functions are not enabled.");
  427. return 0;
  428. }
  429. if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
  430. {
  431. LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
  432. return 0;
  433. }
  434. int success = 0;
  435. m_host.AddScriptLPS(1);
  436. if (LightShareModule.EnableWindlight)
  437. {
  438. RegionLightShareData wl = getWindlightProfileFromRules(rules);
  439. wl.valid = true;
  440. m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
  441. success = 1;
  442. }
  443. else
  444. {
  445. LSShoutError("Windlight module is disabled");
  446. return 0;
  447. }
  448. return success;
  449. }
  450. public void lsClearWindlightScene()
  451. {
  452. if (!m_LSFunctionsEnabled)
  453. {
  454. LSShoutError("LightShare functions are not enabled.");
  455. return;
  456. }
  457. if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
  458. {
  459. LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
  460. return;
  461. }
  462. m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.valid = false;
  463. if (m_host.ParentGroup.Scene.SimulationDataService != null)
  464. m_host.ParentGroup.Scene.SimulationDataService.RemoveRegionWindlightSettings(m_host.ParentGroup.Scene.RegionInfo.RegionID);
  465. }
  466. /// <summary>
  467. /// Set the current Windlight scene to a target avatar
  468. /// </summary>
  469. /// <param name="rules"></param>
  470. /// <returns>success: true or false</returns>
  471. public int lsSetWindlightSceneTargeted(LSL_List rules, LSL_Key target)
  472. {
  473. if (!m_LSFunctionsEnabled)
  474. {
  475. LSShoutError("LightShare functions are not enabled.");
  476. return 0;
  477. }
  478. if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
  479. {
  480. LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners.");
  481. return 0;
  482. }
  483. int success = 0;
  484. m_host.AddScriptLPS(1);
  485. if (LightShareModule.EnableWindlight)
  486. {
  487. RegionLightShareData wl = getWindlightProfileFromRules(rules);
  488. World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string));
  489. success = 1;
  490. }
  491. else
  492. {
  493. LSShoutError("Windlight module is disabled");
  494. return 0;
  495. }
  496. return success;
  497. }
  498. }
  499. }