1
0

RegionSettings.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  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.Collections.Generic;
  29. using System.IO;
  30. using OpenMetaverse;
  31. namespace OpenSim.Framework
  32. {
  33. public struct SpawnPoint
  34. {
  35. public float Yaw;
  36. public float Pitch;
  37. public float Distance;
  38. public void SetLocation(Vector3 pos, Quaternion rot, Vector3 point)
  39. {
  40. // The point is an absolute position, so we need the relative
  41. // location to the spawn point
  42. Vector3 offset = point - pos;
  43. Distance = Vector3.Mag(offset);
  44. // Next we need to rotate this vector into the spawn point's
  45. // coordinate system
  46. rot.W = -rot.W;
  47. offset = offset * rot;
  48. Vector3 dir = Vector3.Normalize(offset);
  49. // Get the bearing (yaw)
  50. Yaw = (float)Math.Atan2(dir.Y, dir.X);
  51. // Get the elevation (pitch)
  52. Pitch = (float)-Math.Atan2(dir.Z, Math.Sqrt(dir.X * dir.X + dir.Y * dir.Y));
  53. }
  54. public Vector3 GetLocation(Vector3 pos, Quaternion rot)
  55. {
  56. Quaternion y = Quaternion.CreateFromEulers(0, 0, Yaw);
  57. Quaternion p = Quaternion.CreateFromEulers(0, Pitch, 0);
  58. Vector3 dir = new Vector3(1, 0, 0) * p * y;
  59. Vector3 offset = dir * (float)Distance;
  60. offset *= rot;
  61. return pos + offset;
  62. }
  63. }
  64. public class RegionSettings
  65. {
  66. public delegate void SaveDelegate(RegionSettings rs);
  67. public event SaveDelegate OnSave;
  68. /// <value>
  69. /// These appear to be terrain textures that are shipped with the client.
  70. /// </value>
  71. public static readonly UUID DEFAULT_TERRAIN_TEXTURE_1 = new UUID("b8d3965a-ad78-bf43-699b-bff8eca6c975");
  72. public static readonly UUID DEFAULT_TERRAIN_TEXTURE_2 = new UUID("abb783e6-3e93-26c0-248a-247666855da3");
  73. public static readonly UUID DEFAULT_TERRAIN_TEXTURE_3 = new UUID("179cdabd-398a-9b6b-1391-4dc333ba321f");
  74. public static readonly UUID DEFAULT_TERRAIN_TEXTURE_4 = new UUID("beb169c7-11ea-fff2-efe5-0f24dc881df2");
  75. public void Save()
  76. {
  77. if (OnSave != null)
  78. OnSave(this);
  79. }
  80. private UUID m_RegionUUID = UUID.Zero;
  81. public UUID RegionUUID
  82. {
  83. get { return m_RegionUUID; }
  84. set { m_RegionUUID = value; }
  85. }
  86. private bool m_BlockTerraform = false;
  87. public bool BlockTerraform
  88. {
  89. get { return m_BlockTerraform; }
  90. set { m_BlockTerraform = value; }
  91. }
  92. private bool m_BlockFly = false;
  93. public bool BlockFly
  94. {
  95. get { return m_BlockFly; }
  96. set { m_BlockFly = value; }
  97. }
  98. private bool m_AllowDamage = false;
  99. public bool AllowDamage
  100. {
  101. get { return m_AllowDamage; }
  102. set { m_AllowDamage = value; }
  103. }
  104. private bool m_RestrictPushing = false;
  105. public bool RestrictPushing
  106. {
  107. get { return m_RestrictPushing; }
  108. set { m_RestrictPushing = value; }
  109. }
  110. private bool m_AllowLandResell = true;
  111. public bool AllowLandResell
  112. {
  113. get { return m_AllowLandResell; }
  114. set { m_AllowLandResell = value; }
  115. }
  116. private bool m_AllowLandJoinDivide = true;
  117. public bool AllowLandJoinDivide
  118. {
  119. get { return m_AllowLandJoinDivide; }
  120. set { m_AllowLandJoinDivide = value; }
  121. }
  122. private bool m_BlockShowInSearch = false;
  123. public bool BlockShowInSearch
  124. {
  125. get { return m_BlockShowInSearch; }
  126. set { m_BlockShowInSearch = value; }
  127. }
  128. private int m_AgentLimit = 40;
  129. public int AgentLimit
  130. {
  131. get { return m_AgentLimit; }
  132. set { m_AgentLimit = value; }
  133. }
  134. private double m_ObjectBonus = 1.0;
  135. public double ObjectBonus
  136. {
  137. get { return m_ObjectBonus; }
  138. set { m_ObjectBonus = value; }
  139. }
  140. private int m_Maturity = 1;
  141. public int Maturity
  142. {
  143. get { return m_Maturity; }
  144. set { m_Maturity = value; }
  145. }
  146. private bool m_DisableScripts = false;
  147. public bool DisableScripts
  148. {
  149. get { return m_DisableScripts; }
  150. set { m_DisableScripts = value; }
  151. }
  152. private bool m_DisableCollisions = false;
  153. public bool DisableCollisions
  154. {
  155. get { return m_DisableCollisions; }
  156. set { m_DisableCollisions = value; }
  157. }
  158. private bool m_DisablePhysics = false;
  159. public bool DisablePhysics
  160. {
  161. get { return m_DisablePhysics; }
  162. set { m_DisablePhysics = value; }
  163. }
  164. private UUID m_TerrainTexture1 = UUID.Zero;
  165. public UUID TerrainTexture1
  166. {
  167. get { return m_TerrainTexture1; }
  168. set
  169. {
  170. if (value == UUID.Zero)
  171. m_TerrainTexture1 = DEFAULT_TERRAIN_TEXTURE_1;
  172. else
  173. m_TerrainTexture1 = value;
  174. }
  175. }
  176. private UUID m_TerrainTexture2 = UUID.Zero;
  177. public UUID TerrainTexture2
  178. {
  179. get { return m_TerrainTexture2; }
  180. set
  181. {
  182. if (value == UUID.Zero)
  183. m_TerrainTexture2 = DEFAULT_TERRAIN_TEXTURE_2;
  184. else
  185. m_TerrainTexture2 = value;
  186. }
  187. }
  188. private UUID m_TerrainTexture3 = UUID.Zero;
  189. public UUID TerrainTexture3
  190. {
  191. get { return m_TerrainTexture3; }
  192. set
  193. {
  194. if (value == UUID.Zero)
  195. m_TerrainTexture3 = DEFAULT_TERRAIN_TEXTURE_3;
  196. else
  197. m_TerrainTexture3 = value;
  198. }
  199. }
  200. private UUID m_TerrainTexture4 = UUID.Zero;
  201. public UUID TerrainTexture4
  202. {
  203. get { return m_TerrainTexture4; }
  204. set
  205. {
  206. if (value == UUID.Zero)
  207. m_TerrainTexture4 = DEFAULT_TERRAIN_TEXTURE_4;
  208. else
  209. m_TerrainTexture4 = value;
  210. }
  211. }
  212. private double m_Elevation1NW = 10;
  213. public double Elevation1NW
  214. {
  215. get { return m_Elevation1NW; }
  216. set { m_Elevation1NW = value; }
  217. }
  218. private double m_Elevation2NW = 60;
  219. public double Elevation2NW
  220. {
  221. get { return m_Elevation2NW; }
  222. set { m_Elevation2NW = value; }
  223. }
  224. private double m_Elevation1NE = 10;
  225. public double Elevation1NE
  226. {
  227. get { return m_Elevation1NE; }
  228. set { m_Elevation1NE = value; }
  229. }
  230. private double m_Elevation2NE = 60;
  231. public double Elevation2NE
  232. {
  233. get { return m_Elevation2NE; }
  234. set { m_Elevation2NE = value; }
  235. }
  236. private double m_Elevation1SE = 10;
  237. public double Elevation1SE
  238. {
  239. get { return m_Elevation1SE; }
  240. set { m_Elevation1SE = value; }
  241. }
  242. private double m_Elevation2SE = 60;
  243. public double Elevation2SE
  244. {
  245. get { return m_Elevation2SE; }
  246. set { m_Elevation2SE = value; }
  247. }
  248. private double m_Elevation1SW = 10;
  249. public double Elevation1SW
  250. {
  251. get { return m_Elevation1SW; }
  252. set { m_Elevation1SW = value; }
  253. }
  254. private double m_Elevation2SW = 60;
  255. public double Elevation2SW
  256. {
  257. get { return m_Elevation2SW; }
  258. set { m_Elevation2SW = value; }
  259. }
  260. private double m_WaterHeight = 20;
  261. public double WaterHeight
  262. {
  263. get { return m_WaterHeight; }
  264. set { m_WaterHeight = value; }
  265. }
  266. private double m_TerrainRaiseLimit = 100;
  267. public double TerrainRaiseLimit
  268. {
  269. get { return m_TerrainRaiseLimit; }
  270. set { m_TerrainRaiseLimit = value; }
  271. }
  272. private double m_TerrainLowerLimit = -100;
  273. public double TerrainLowerLimit
  274. {
  275. get { return m_TerrainLowerLimit; }
  276. set { m_TerrainLowerLimit = value; }
  277. }
  278. private bool m_UseEstateSun = true;
  279. public bool UseEstateSun
  280. {
  281. get { return m_UseEstateSun; }
  282. set { m_UseEstateSun = value; }
  283. }
  284. private bool m_Sandbox = false;
  285. public bool Sandbox
  286. {
  287. get { return m_Sandbox; }
  288. set { m_Sandbox = value; }
  289. }
  290. private Vector3 m_SunVector;
  291. public Vector3 SunVector
  292. {
  293. get { return m_SunVector; }
  294. set { m_SunVector = value; }
  295. }
  296. private UUID m_ParcelImageID;
  297. public UUID ParcelImageID
  298. {
  299. get { return m_ParcelImageID; }
  300. set { m_ParcelImageID = value; }
  301. }
  302. private UUID m_TerrainImageID;
  303. public UUID TerrainImageID
  304. {
  305. get { return m_TerrainImageID; }
  306. set { m_TerrainImageID = value; }
  307. }
  308. private bool m_FixedSun = false;
  309. public bool FixedSun
  310. {
  311. get { return m_FixedSun; }
  312. set { m_FixedSun = value; }
  313. }
  314. private double m_SunPosition = 0.0;
  315. public double SunPosition
  316. {
  317. get { return m_SunPosition; }
  318. set { m_SunPosition = value; }
  319. }
  320. private UUID m_Covenant = UUID.Zero;
  321. public UUID Covenant
  322. {
  323. get { return m_Covenant; }
  324. set { m_Covenant = value; }
  325. }
  326. private int m_CovenantChanged = 0;
  327. public int CovenantChangedDateTime
  328. {
  329. get { return m_CovenantChanged; }
  330. set { m_CovenantChanged = value; }
  331. }
  332. private int m_LoadedCreationDateTime;
  333. public int LoadedCreationDateTime
  334. {
  335. get { return m_LoadedCreationDateTime; }
  336. set { m_LoadedCreationDateTime = value; }
  337. }
  338. public String LoadedCreationDate
  339. {
  340. get
  341. {
  342. TimeSpan ts = new TimeSpan(0, 0, LoadedCreationDateTime);
  343. DateTime stamp = new DateTime(1970, 1, 1) + ts;
  344. return stamp.ToLongDateString();
  345. }
  346. }
  347. public String LoadedCreationTime
  348. {
  349. get
  350. {
  351. TimeSpan ts = new TimeSpan(0, 0, LoadedCreationDateTime);
  352. DateTime stamp = new DateTime(1970, 1, 1) + ts;
  353. return stamp.ToLongTimeString();
  354. }
  355. }
  356. private String m_LoadedCreationID;
  357. public String LoadedCreationID
  358. {
  359. get { return m_LoadedCreationID; }
  360. set { m_LoadedCreationID = value; }
  361. }
  362. // Connected Telehub object
  363. private UUID m_TelehubObject;
  364. public UUID TelehubObject
  365. {
  366. get
  367. {
  368. return m_TelehubObject;
  369. }
  370. set
  371. {
  372. m_TelehubObject = value;
  373. }
  374. }
  375. // Our Connected Telehub's SpawnPoints
  376. public List<SpawnPoint> l_SpawnPoints = new List<SpawnPoint>();
  377. // Add a SpawnPoint
  378. // ** These are not region coordinates **
  379. // They are relative to the Telehub coordinates
  380. //
  381. public void AddSpawnPoint(SpawnPoint point)
  382. {
  383. l_SpawnPoints.Add(point);
  384. }
  385. // Remove a SpawnPoint
  386. public void RemoveSpawnPoint(int point_index)
  387. {
  388. l_SpawnPoints.RemoveAt(point_index);
  389. }
  390. // Return the List of SpawnPoints
  391. public List<SpawnPoint> SpawnPoints()
  392. {
  393. return l_SpawnPoints;
  394. }
  395. // Clear the SpawnPoints List of all entries
  396. public void ClearSpawnPoints()
  397. {
  398. l_SpawnPoints.Clear();
  399. }
  400. }
  401. }