LS_Api.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  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. uint rule = (uint)rules.GetLSLIntegerItem(idx);
  119. LSL_List toadd = new LSL_List();
  120. switch (rule)
  121. {
  122. case (int)ScriptBaseClass.WL_AMBIENT:
  123. toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W));
  124. break;
  125. case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
  126. toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f));
  127. break;
  128. case (int)ScriptBaseClass.WL_BLUE_DENSITY:
  129. toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W));
  130. break;
  131. case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
  132. toadd.Add(new LSL_Float(wl.blurMultiplier));
  133. break;
  134. case (int)ScriptBaseClass.WL_CLOUD_COLOR:
  135. toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W));
  136. break;
  137. case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
  138. toadd.Add(new LSL_Float(wl.cloudCoverage));
  139. break;
  140. case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
  141. toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z));
  142. break;
  143. case (int)ScriptBaseClass.WL_CLOUD_SCALE:
  144. toadd.Add(new LSL_Float(wl.cloudScale));
  145. break;
  146. case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
  147. toadd.Add(new LSL_Float(wl.cloudScrollX));
  148. break;
  149. case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
  150. toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0));
  151. break;
  152. case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
  153. toadd.Add(new LSL_Float(wl.cloudScrollY));
  154. break;
  155. case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
  156. toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0));
  157. break;
  158. case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
  159. toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z));
  160. break;
  161. case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
  162. toadd.Add(new LSL_Float(wl.densityMultiplier));
  163. break;
  164. case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
  165. toadd.Add(new LSL_Float(wl.distanceMultiplier));
  166. break;
  167. case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
  168. toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0));
  169. break;
  170. case (int)ScriptBaseClass.WL_EAST_ANGLE:
  171. toadd.Add(new LSL_Float(wl.eastAngle));
  172. break;
  173. case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
  174. toadd.Add(new LSL_Float(wl.fresnelOffset));
  175. break;
  176. case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
  177. toadd.Add(new LSL_Float(wl.fresnelScale));
  178. break;
  179. case (int)ScriptBaseClass.WL_HAZE_DENSITY:
  180. toadd.Add(new LSL_Float(wl.hazeDensity));
  181. break;
  182. case (int)ScriptBaseClass.WL_HAZE_HORIZON:
  183. toadd.Add(new LSL_Float(wl.hazeHorizon));
  184. break;
  185. case (int)ScriptBaseClass.WL_HORIZON:
  186. toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W));
  187. break;
  188. case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
  189. toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f));
  190. break;
  191. case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
  192. toadd.Add(new LSL_Integer(wl.maxAltitude));
  193. break;
  194. case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
  195. toadd.Add(new LSL_Key(wl.normalMapTexture.ToString()));
  196. break;
  197. case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
  198. toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z));
  199. break;
  200. case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
  201. toadd.Add(new LSL_Float(wl.refractScaleAbove));
  202. break;
  203. case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
  204. toadd.Add(new LSL_Float(wl.refractScaleBelow));
  205. break;
  206. case (int)ScriptBaseClass.WL_SCENE_GAMMA:
  207. toadd.Add(new LSL_Float(wl.sceneGamma));
  208. break;
  209. case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
  210. toadd.Add(new LSL_Float(wl.starBrightness));
  211. break;
  212. case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
  213. toadd.Add(new LSL_Float(wl.sunGlowFocus));
  214. break;
  215. case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
  216. toadd.Add(new LSL_Float(wl.sunGlowSize));
  217. break;
  218. case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
  219. toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W));
  220. break;
  221. case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
  222. toadd.Add(new LSL_Float(wl.underwaterFogModifier));
  223. break;
  224. case (int)ScriptBaseClass.WL_WATER_COLOR:
  225. toadd.Add(new LSL_Vector(wl.waterColor.X, wl.waterColor.Y, wl.waterColor.Z));
  226. break;
  227. case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
  228. toadd.Add(new LSL_Float(wl.waterFogDensityExponent));
  229. break;
  230. }
  231. if (toadd.Length > 0)
  232. {
  233. values.Add(rule);
  234. values.Add(toadd.Data[0]);
  235. }
  236. idx++;
  237. }
  238. return values;
  239. }
  240. private RegionLightShareData getWindlightProfileFromRules(LSL_List rules)
  241. {
  242. RegionLightShareData wl = (RegionLightShareData)m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.Clone();
  243. LSL_List values = new LSL_List();
  244. int idx = 0;
  245. while (idx < rules.Length)
  246. {
  247. uint rule = (uint)rules.GetLSLIntegerItem(idx);
  248. LSL_Types.Quaternion iQ;
  249. LSL_Types.Vector3 iV;
  250. switch (rule)
  251. {
  252. case (int)ScriptBaseClass.WL_SUN_MOON_POSITION:
  253. idx++;
  254. wl.sunMoonPosition = (float)rules.GetLSLFloatItem(idx);
  255. break;
  256. case (int)ScriptBaseClass.WL_AMBIENT:
  257. idx++;
  258. iQ = rules.GetQuaternionItem(idx);
  259. wl.ambient = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
  260. break;
  261. case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
  262. idx++;
  263. iV = rules.GetVector3Item(idx);
  264. wl.bigWaveDirection = new Vector2((float)iV.x, (float)iV.y);
  265. break;
  266. case (int)ScriptBaseClass.WL_BLUE_DENSITY:
  267. idx++;
  268. iQ = rules.GetQuaternionItem(idx);
  269. wl.blueDensity = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
  270. break;
  271. case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
  272. idx++;
  273. wl.blurMultiplier = (float)rules.GetLSLFloatItem(idx);
  274. break;
  275. case (int)ScriptBaseClass.WL_CLOUD_COLOR:
  276. idx++;
  277. iQ = rules.GetQuaternionItem(idx);
  278. wl.cloudColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
  279. break;
  280. case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
  281. idx++;
  282. wl.cloudCoverage = (float)rules.GetLSLFloatItem(idx);
  283. break;
  284. case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
  285. idx++;
  286. iV = rules.GetVector3Item(idx);
  287. wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
  288. break;
  289. case (int)ScriptBaseClass.WL_CLOUD_SCALE:
  290. idx++;
  291. wl.cloudScale = (float)rules.GetLSLFloatItem(idx);
  292. break;
  293. case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
  294. idx++;
  295. wl.cloudScrollX = (float)rules.GetLSLFloatItem(idx);
  296. break;
  297. case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
  298. idx++;
  299. wl.cloudScrollXLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
  300. break;
  301. case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
  302. idx++;
  303. wl.cloudScrollY = (float)rules.GetLSLFloatItem(idx);
  304. break;
  305. case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
  306. idx++;
  307. wl.cloudScrollYLock = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
  308. break;
  309. case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
  310. idx++;
  311. iV = rules.GetVector3Item(idx);
  312. wl.cloudXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
  313. break;
  314. case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
  315. idx++;
  316. wl.densityMultiplier = (float)rules.GetLSLFloatItem(idx);
  317. break;
  318. case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
  319. idx++;
  320. wl.distanceMultiplier = (float)rules.GetLSLFloatItem(idx);
  321. break;
  322. case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
  323. idx++;
  324. wl.drawClassicClouds = rules.GetLSLIntegerItem(idx).value == 1 ? true : false;
  325. break;
  326. case (int)ScriptBaseClass.WL_EAST_ANGLE:
  327. idx++;
  328. wl.eastAngle = (float)rules.GetLSLFloatItem(idx);
  329. break;
  330. case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
  331. idx++;
  332. wl.fresnelOffset = (float)rules.GetLSLFloatItem(idx);
  333. break;
  334. case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
  335. idx++;
  336. wl.fresnelScale = (float)rules.GetLSLFloatItem(idx);
  337. break;
  338. case (int)ScriptBaseClass.WL_HAZE_DENSITY:
  339. idx++;
  340. wl.hazeDensity = (float)rules.GetLSLFloatItem(idx);
  341. break;
  342. case (int)ScriptBaseClass.WL_HAZE_HORIZON:
  343. idx++;
  344. wl.hazeHorizon = (float)rules.GetLSLFloatItem(idx);
  345. break;
  346. case (int)ScriptBaseClass.WL_HORIZON:
  347. idx++;
  348. iQ = rules.GetQuaternionItem(idx);
  349. wl.horizon = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
  350. break;
  351. case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
  352. idx++;
  353. iV = rules.GetVector3Item(idx);
  354. wl.littleWaveDirection = new Vector2((float)iV.x, (float)iV.y);
  355. break;
  356. case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
  357. idx++;
  358. wl.maxAltitude = (ushort)rules.GetLSLIntegerItem(idx).value;
  359. break;
  360. case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
  361. idx++;
  362. wl.normalMapTexture = new UUID(rules.GetLSLStringItem(idx).m_string);
  363. break;
  364. case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
  365. idx++;
  366. iV = rules.GetVector3Item(idx);
  367. wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
  368. break;
  369. case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
  370. idx++;
  371. wl.refractScaleAbove = (float)rules.GetLSLFloatItem(idx);
  372. break;
  373. case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
  374. idx++;
  375. wl.refractScaleBelow = (float)rules.GetLSLFloatItem(idx);
  376. break;
  377. case (int)ScriptBaseClass.WL_SCENE_GAMMA:
  378. idx++;
  379. wl.sceneGamma = (float)rules.GetLSLFloatItem(idx);
  380. break;
  381. case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
  382. idx++;
  383. wl.starBrightness = (float)rules.GetLSLFloatItem(idx);
  384. break;
  385. case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
  386. idx++;
  387. wl.sunGlowFocus = (float)rules.GetLSLFloatItem(idx);
  388. break;
  389. case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
  390. idx++;
  391. wl.sunGlowSize = (float)rules.GetLSLFloatItem(idx);
  392. break;
  393. case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
  394. idx++;
  395. iQ = rules.GetQuaternionItem(idx);
  396. wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);
  397. break;
  398. case (int)ScriptBaseClass.WL_UNDERWATER_FOG_MODIFIER:
  399. idx++;
  400. wl.underwaterFogModifier = (float)rules.GetLSLFloatItem(idx);
  401. break;
  402. case (int)ScriptBaseClass.WL_WATER_COLOR:
  403. idx++;
  404. iV = rules.GetVector3Item(idx);
  405. wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z);
  406. break;
  407. case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
  408. idx++;
  409. wl.waterFogDensityExponent = (float)rules.GetLSLFloatItem(idx);
  410. break;
  411. }
  412. idx++;
  413. }
  414. return wl;
  415. }
  416. /// <summary>
  417. /// Set the current Windlight scene
  418. /// </summary>
  419. /// <param name="rules"></param>
  420. /// <returns>success: true or false</returns>
  421. public int lsSetWindlightScene(LSL_List rules)
  422. {
  423. if (!m_LSFunctionsEnabled)
  424. {
  425. LSShoutError("LightShare functions are not enabled.");
  426. return 0;
  427. }
  428. if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
  429. {
  430. LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
  431. return 0;
  432. }
  433. int success = 0;
  434. m_host.AddScriptLPS(1);
  435. if (LightShareModule.EnableWindlight)
  436. {
  437. RegionLightShareData wl = getWindlightProfileFromRules(rules);
  438. m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
  439. success = 1;
  440. }
  441. else
  442. {
  443. LSShoutError("Windlight module is disabled");
  444. return 0;
  445. }
  446. return success;
  447. }
  448. /// <summary>
  449. /// Set the current Windlight scene to a target avatar
  450. /// </summary>
  451. /// <param name="rules"></param>
  452. /// <returns>success: true or false</returns>
  453. public int lsSetWindlightSceneTargeted(LSL_List rules, LSL_Key target)
  454. {
  455. if (!m_LSFunctionsEnabled)
  456. {
  457. LSShoutError("LightShare functions are not enabled.");
  458. return 0;
  459. }
  460. if (!World.RegionInfo.EstateSettings.IsEstateManager(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
  461. {
  462. LSShoutError("lsSetWindlightSceneTargeted can only be used by estate managers or owners.");
  463. return 0;
  464. }
  465. int success = 0;
  466. m_host.AddScriptLPS(1);
  467. if (LightShareModule.EnableWindlight)
  468. {
  469. RegionLightShareData wl = getWindlightProfileFromRules(rules);
  470. World.EventManager.TriggerOnSendNewWindlightProfileTargeted(wl, new UUID(target.m_string));
  471. success = 1;
  472. }
  473. else
  474. {
  475. LSShoutError("Windlight module is disabled");
  476. return 0;
  477. }
  478. return success;
  479. }
  480. }
  481. }