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 bool m_LSFunctionsEnabled = false;
  59. internal IScriptModuleComms m_comms = null;
  60. public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
  61. {
  62. m_ScriptEngine = ScriptEngine;
  63. m_host = host;
  64. if (m_ScriptEngine.Config.GetBoolean("AllowLightShareFunctions", false))
  65. m_LSFunctionsEnabled = true;
  66. m_comms = m_ScriptEngine.World.RequestModuleInterface<IScriptModuleComms>();
  67. if (m_comms == null)
  68. m_LSFunctionsEnabled = false;
  69. }
  70. public override Object InitializeLifetimeService()
  71. {
  72. ILease lease = (ILease)base.InitializeLifetimeService();
  73. if (lease.CurrentState == LeaseState.Initial)
  74. {
  75. lease.InitialLeaseTime = TimeSpan.FromMinutes(0);
  76. // lease.RenewOnCallTime = TimeSpan.FromSeconds(10.0);
  77. // lease.SponsorshipTimeout = TimeSpan.FromMinutes(1.0);
  78. }
  79. return lease;
  80. }
  81. public Scene World
  82. {
  83. get { return m_ScriptEngine.World; }
  84. }
  85. //
  86. //Dumps an error message on the debug console.
  87. //
  88. internal void LSShoutError(string message)
  89. {
  90. if (message.Length > 1023)
  91. message = message.Substring(0, 1023);
  92. World.SimChat(Utils.StringToBytes(message),
  93. ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.ParentGroup.RootPart.AbsolutePosition, m_host.Name, m_host.UUID, true);
  94. IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>();
  95. wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
  96. }
  97. /// <summary>
  98. /// Get the current Windlight scene
  99. /// </summary>
  100. /// <returns>List of windlight parameters</returns>
  101. public LSL_List lsGetWindlightScene(LSL_List rules)
  102. {
  103. if (!m_LSFunctionsEnabled)
  104. {
  105. LSShoutError("LightShare functions are not enabled.");
  106. return new LSL_List();
  107. }
  108. m_host.AddScriptLPS(1);
  109. RegionLightShareData wl = m_host.ParentGroup.Scene.RegionInfo.WindlightSettings;
  110. LSL_List values = new LSL_List();
  111. int idx = 0;
  112. while (idx < rules.Length)
  113. {
  114. LSL_Integer ruleInt = rules.GetLSLIntegerItem(idx);
  115. uint rule = (uint)ruleInt;
  116. LSL_List toadd = new LSL_List();
  117. switch (rule)
  118. {
  119. case (int)ScriptBaseClass.WL_AMBIENT:
  120. toadd.Add(new LSL_Rotation(wl.ambient.X, wl.ambient.Y, wl.ambient.Z, wl.ambient.W));
  121. break;
  122. case (int)ScriptBaseClass.WL_BIG_WAVE_DIRECTION:
  123. toadd.Add(new LSL_Vector(wl.bigWaveDirection.X, wl.bigWaveDirection.Y, 0.0f));
  124. break;
  125. case (int)ScriptBaseClass.WL_BLUE_DENSITY:
  126. toadd.Add(new LSL_Rotation(wl.blueDensity.X, wl.blueDensity.Y, wl.blueDensity.Z, wl.blueDensity.W));
  127. break;
  128. case (int)ScriptBaseClass.WL_BLUR_MULTIPLIER:
  129. toadd.Add(new LSL_Float(wl.blurMultiplier));
  130. break;
  131. case (int)ScriptBaseClass.WL_CLOUD_COLOR:
  132. toadd.Add(new LSL_Rotation(wl.cloudColor.X, wl.cloudColor.Y, wl.cloudColor.Z, wl.cloudColor.W));
  133. break;
  134. case (int)ScriptBaseClass.WL_CLOUD_COVERAGE:
  135. toadd.Add(new LSL_Float(wl.cloudCoverage));
  136. break;
  137. case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
  138. toadd.Add(new LSL_Vector(wl.cloudDetailXYDensity.X, wl.cloudDetailXYDensity.Y, wl.cloudDetailXYDensity.Z));
  139. break;
  140. case (int)ScriptBaseClass.WL_CLOUD_SCALE:
  141. toadd.Add(new LSL_Float(wl.cloudScale));
  142. break;
  143. case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X:
  144. toadd.Add(new LSL_Float(wl.cloudScrollX));
  145. break;
  146. case (int)ScriptBaseClass.WL_CLOUD_SCROLL_X_LOCK:
  147. toadd.Add(new LSL_Integer(wl.cloudScrollXLock ? 1 : 0));
  148. break;
  149. case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y:
  150. toadd.Add(new LSL_Float(wl.cloudScrollY));
  151. break;
  152. case (int)ScriptBaseClass.WL_CLOUD_SCROLL_Y_LOCK:
  153. toadd.Add(new LSL_Integer(wl.cloudScrollYLock ? 1 : 0));
  154. break;
  155. case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
  156. toadd.Add(new LSL_Vector(wl.cloudXYDensity.X, wl.cloudXYDensity.Y, wl.cloudXYDensity.Z));
  157. break;
  158. case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
  159. toadd.Add(new LSL_Float(wl.densityMultiplier));
  160. break;
  161. case (int)ScriptBaseClass.WL_DISTANCE_MULTIPLIER:
  162. toadd.Add(new LSL_Float(wl.distanceMultiplier));
  163. break;
  164. case (int)ScriptBaseClass.WL_DRAW_CLASSIC_CLOUDS:
  165. toadd.Add(new LSL_Integer(wl.drawClassicClouds ? 1 : 0));
  166. break;
  167. case (int)ScriptBaseClass.WL_EAST_ANGLE:
  168. toadd.Add(new LSL_Float(wl.eastAngle));
  169. break;
  170. case (int)ScriptBaseClass.WL_FRESNEL_OFFSET:
  171. toadd.Add(new LSL_Float(wl.fresnelOffset));
  172. break;
  173. case (int)ScriptBaseClass.WL_FRESNEL_SCALE:
  174. toadd.Add(new LSL_Float(wl.fresnelScale));
  175. break;
  176. case (int)ScriptBaseClass.WL_HAZE_DENSITY:
  177. toadd.Add(new LSL_Float(wl.hazeDensity));
  178. break;
  179. case (int)ScriptBaseClass.WL_HAZE_HORIZON:
  180. toadd.Add(new LSL_Float(wl.hazeHorizon));
  181. break;
  182. case (int)ScriptBaseClass.WL_HORIZON:
  183. toadd.Add(new LSL_Rotation(wl.horizon.X, wl.horizon.Y, wl.horizon.Z, wl.horizon.W));
  184. break;
  185. case (int)ScriptBaseClass.WL_LITTLE_WAVE_DIRECTION:
  186. toadd.Add(new LSL_Vector(wl.littleWaveDirection.X, wl.littleWaveDirection.Y, 0.0f));
  187. break;
  188. case (int)ScriptBaseClass.WL_MAX_ALTITUDE:
  189. toadd.Add(new LSL_Integer(wl.maxAltitude));
  190. break;
  191. case (int)ScriptBaseClass.WL_NORMAL_MAP_TEXTURE:
  192. toadd.Add(new LSL_Key(wl.normalMapTexture.ToString()));
  193. break;
  194. case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
  195. toadd.Add(new LSL_Vector(wl.reflectionWaveletScale.X, wl.reflectionWaveletScale.Y, wl.reflectionWaveletScale.Z));
  196. break;
  197. case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
  198. toadd.Add(new LSL_Float(wl.refractScaleAbove));
  199. break;
  200. case (int)ScriptBaseClass.WL_REFRACT_SCALE_BELOW:
  201. toadd.Add(new LSL_Float(wl.refractScaleBelow));
  202. break;
  203. case (int)ScriptBaseClass.WL_SCENE_GAMMA:
  204. toadd.Add(new LSL_Float(wl.sceneGamma));
  205. break;
  206. case (int)ScriptBaseClass.WL_STAR_BRIGHTNESS:
  207. toadd.Add(new LSL_Float(wl.starBrightness));
  208. break;
  209. case (int)ScriptBaseClass.WL_SUN_GLOW_FOCUS:
  210. toadd.Add(new LSL_Float(wl.sunGlowFocus));
  211. break;
  212. case (int)ScriptBaseClass.WL_SUN_GLOW_SIZE:
  213. toadd.Add(new LSL_Float(wl.sunGlowSize));
  214. break;
  215. case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
  216. toadd.Add(new LSL_Rotation(wl.sunMoonColor.X, wl.sunMoonColor.Y, wl.sunMoonColor.Z, wl.sunMoonColor.W));
  217. break;
  218. case (int)ScriptBaseClass.WL_SUN_MOON_POSITION:
  219. toadd.Add(new LSL_Float(wl.sunMoonPosition));
  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(ruleInt);
  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 = iV;
  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 = iV;
  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 = iV;
  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 = iV;
  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.IsEstateManagerOrOwner(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. wl.valid = true;
  439. m_host.ParentGroup.Scene.StoreWindlightProfile(wl);
  440. success = 1;
  441. }
  442. else
  443. {
  444. LSShoutError("Windlight module is disabled");
  445. return 0;
  446. }
  447. return success;
  448. }
  449. public void lsClearWindlightScene()
  450. {
  451. if (!m_LSFunctionsEnabled)
  452. {
  453. LSShoutError("LightShare functions are not enabled.");
  454. return;
  455. }
  456. if (!World.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_host.OwnerID) && World.GetScenePresence(m_host.OwnerID).GodLevel < 200)
  457. {
  458. LSShoutError("lsSetWindlightScene can only be used by estate managers or owners.");
  459. return;
  460. }
  461. m_host.ParentGroup.Scene.RegionInfo.WindlightSettings.valid = false;
  462. if (m_host.ParentGroup.Scene.SimulationDataService != null)
  463. m_host.ParentGroup.Scene.SimulationDataService.RemoveRegionWindlightSettings(m_host.ParentGroup.Scene.RegionInfo.RegionID);
  464. m_host.ParentGroup.Scene.EventManager.TriggerOnSaveNewWindlightProfile();
  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.IsEstateManagerOrOwner(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. }