World.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. using System;
  2. using libsecondlife;
  3. using libsecondlife.Packets;
  4. using System.Collections.Generic;
  5. using System.Text;
  6. using System.Reflection;
  7. using System.IO;
  8. using System.Threading;
  9. using OpenSim.Physics.Manager;
  10. using OpenSim.Framework.Interfaces;
  11. using OpenSim.Framework.Types;
  12. using OpenSim.Framework.Terrain;
  13. using OpenSim.Framework.Inventory;
  14. using OpenSim.Assets;
  15. //using OpenSim.world.scripting;
  16. using OpenSim.RegionServer.world.scripting;
  17. using OpenSim.RegionServer.world.scripting.Scripts;
  18. using OpenSim.Terrain;
  19. namespace OpenSim.world
  20. {
  21. public partial class World : ILocalStorageReceiver, IScriptAPI
  22. {
  23. public object LockPhysicsEngine = new object();
  24. public Dictionary<libsecondlife.LLUUID, Entity> Entities;
  25. public Dictionary<libsecondlife.LLUUID, Avatar> Avatars;
  26. public Dictionary<libsecondlife.LLUUID, Primitive> Prims;
  27. //public ScriptEngine Scripts;
  28. public TerrainEngine Terrain; //TODO: Replace TerrainManager with this.
  29. public uint _localNumber = 0;
  30. private PhysicsScene phyScene;
  31. private float timeStep = 0.1f;
  32. private libsecondlife.TerrainManager TerrainManager; // To be referenced via TerrainEngine
  33. public ILocalStorage localStorage;
  34. private Random Rand = new Random();
  35. private uint _primCount = 702000;
  36. private int storageCount;
  37. private Dictionary<uint, SimClient> m_clientThreads;
  38. private Dictionary<LLUUID, ScriptHandler> m_scriptHandlers;
  39. private Dictionary<string, ScriptFactory> m_scripts;
  40. private ulong m_regionHandle;
  41. private string m_regionName;
  42. private InventoryCache _inventoryCache;
  43. private AssetCache _assetCache;
  44. private Mutex updateLock;
  45. public string m_datastore;
  46. /// <summary>
  47. /// Creates a new World class, and a region to go with it.
  48. /// </summary>
  49. /// <param name="clientThreads">Dictionary to contain client threads</param>
  50. /// <param name="regionHandle">Region Handle for this region</param>
  51. /// <param name="regionName">Region Name for this region</param>
  52. public World(Dictionary<uint, SimClient> clientThreads, ulong regionHandle, string regionName)
  53. {
  54. try
  55. {
  56. updateLock = new Mutex(false);
  57. m_clientThreads = clientThreads;
  58. m_regionHandle = regionHandle;
  59. m_regionName = regionName;
  60. m_scriptHandlers = new Dictionary<LLUUID, ScriptHandler>();
  61. m_scripts = new Dictionary<string, ScriptFactory>();
  62. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance");
  63. Entities = new Dictionary<libsecondlife.LLUUID, Entity>();
  64. Avatars = new Dictionary<LLUUID, Avatar>();
  65. Prims = new Dictionary<LLUUID, Primitive>();
  66. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating LandMap");
  67. TerrainManager = new TerrainManager(new SecondLife());
  68. Terrain = new TerrainEngine();
  69. Avatar.SetupTemplate("avatar-texture.dat");
  70. // MainConsole.Instance.WriteLine("World.cs - Creating script engine instance");
  71. // Initialise this only after the world has loaded
  72. // Scripts = new ScriptEngine(this);
  73. Avatar.LoadAnims();
  74. this.SetDefaultScripts();
  75. this.LoadScriptEngines();
  76. }
  77. catch (Exception e)
  78. {
  79. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: Constructor failed with exception " + e.ToString());
  80. }
  81. }
  82. /// <summary>
  83. /// Loads a new script into the specified entity
  84. /// </summary>
  85. /// <param name="entity">Entity to be scripted</param>
  86. /// <param name="script">The script to load</param>
  87. public void AddScript(Entity entity, Script script)
  88. {
  89. try
  90. {
  91. ScriptHandler scriptHandler = new ScriptHandler(script, entity, this);
  92. m_scriptHandlers.Add(scriptHandler.ScriptId, scriptHandler);
  93. }
  94. catch (Exception e)
  95. {
  96. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: AddScript() - Failed with exception " + e.ToString());
  97. }
  98. }
  99. /// <summary>
  100. /// Loads a new script into the specified entity, using a script loaded from a string.
  101. /// </summary>
  102. /// <param name="entity">The entity to be scripted</param>
  103. /// <param name="scriptData">The string containing the script</param>
  104. public void AddScript(Entity entity, string scriptData)
  105. {
  106. try
  107. {
  108. int scriptstart = 0;
  109. int scriptend = 0;
  110. string substring;
  111. scriptstart = scriptData.LastIndexOf("<Script>");
  112. scriptend = scriptData.LastIndexOf("</Script>");
  113. substring = scriptData.Substring(scriptstart + 8, scriptend - scriptstart - 8);
  114. substring = substring.Trim();
  115. //Console.WriteLine("searching for script to add: " + substring);
  116. ScriptFactory scriptFactory;
  117. //Console.WriteLine("script string is " + substring);
  118. if (substring.StartsWith("<ScriptEngine:"))
  119. {
  120. string substring1 = "";
  121. string script = "";
  122. // Console.WriteLine("searching for script engine");
  123. substring1 = substring.Remove(0, 14);
  124. int dev = substring1.IndexOf(',');
  125. string sEngine = substring1.Substring(0, dev);
  126. substring1 = substring1.Remove(0, dev + 1);
  127. int end = substring1.IndexOf('>');
  128. string sName = substring1.Substring(0, end);
  129. //Console.WriteLine(" script info : " + sEngine + " , " + sName);
  130. int startscript = substring.IndexOf('>');
  131. script = substring.Remove(0, startscript + 1);
  132. // Console.WriteLine("script data is " + script);
  133. if (this.scriptEngines.ContainsKey(sEngine))
  134. {
  135. this.scriptEngines[sEngine].LoadScript(script, sName, entity.localid);
  136. }
  137. }
  138. else if (this.m_scripts.TryGetValue(substring, out scriptFactory))
  139. {
  140. //Console.WriteLine("added script");
  141. this.AddScript(entity, scriptFactory());
  142. }
  143. }
  144. catch (Exception e)
  145. {
  146. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: AddScript() - Failed with exception " + e.ToString());
  147. }
  148. }
  149. public InventoryCache InventoryCache
  150. {
  151. set
  152. {
  153. this._inventoryCache = value;
  154. }
  155. }
  156. public AssetCache AssetCache
  157. {
  158. set
  159. {
  160. this._assetCache = value;
  161. }
  162. }
  163. public PhysicsScene PhysScene
  164. {
  165. set
  166. {
  167. this.phyScene = value;
  168. }
  169. get
  170. {
  171. return (this.phyScene);
  172. }
  173. }
  174. /// <summary>
  175. /// Performs per-frame updates on the world, this should be the central world loop
  176. /// </summary>
  177. public void Update()
  178. {
  179. updateLock.WaitOne();
  180. try
  181. {
  182. if (this.phyScene.IsThreaded)
  183. {
  184. this.phyScene.GetResults();
  185. }
  186. foreach (libsecondlife.LLUUID UUID in Entities.Keys)
  187. {
  188. Entities[UUID].addForces();
  189. }
  190. lock (this.LockPhysicsEngine)
  191. {
  192. this.phyScene.Simulate(timeStep);
  193. }
  194. foreach (libsecondlife.LLUUID UUID in Entities.Keys)
  195. {
  196. Entities[UUID].update();
  197. }
  198. foreach (ScriptHandler scriptHandler in m_scriptHandlers.Values)
  199. {
  200. scriptHandler.OnFrame();
  201. }
  202. foreach (IScriptEngine scripteng in this.scriptEngines.Values)
  203. {
  204. scripteng.OnFrame();
  205. }
  206. //backup world data
  207. this.storageCount++;
  208. if (storageCount > 1200) //set to how often you want to backup
  209. {
  210. this.Backup();
  211. storageCount = 0;
  212. }
  213. }
  214. catch (Exception e)
  215. {
  216. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: Update() - Failed with exception " + e.ToString());
  217. }
  218. updateLock.ReleaseMutex();
  219. }
  220. /// <summary>
  221. /// Loads a new storage subsystem from a named library
  222. /// </summary>
  223. /// <param name="dllName">Storage Library</param>
  224. /// <returns>Successful or not</returns>
  225. public bool LoadStorageDLL(string dllName)
  226. {
  227. try
  228. {
  229. Assembly pluginAssembly = Assembly.LoadFrom(dllName);
  230. ILocalStorage store = null;
  231. foreach (Type pluginType in pluginAssembly.GetTypes())
  232. {
  233. if (pluginType.IsPublic)
  234. {
  235. if (!pluginType.IsAbstract)
  236. {
  237. Type typeInterface = pluginType.GetInterface("ILocalStorage", true);
  238. if (typeInterface != null)
  239. {
  240. ILocalStorage plug = (ILocalStorage)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
  241. store = plug;
  242. store.Initialise(this.m_datastore);
  243. break;
  244. }
  245. typeInterface = null;
  246. }
  247. }
  248. }
  249. pluginAssembly = null;
  250. this.localStorage = store;
  251. return (store == null);
  252. }
  253. catch (Exception e)
  254. {
  255. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: LoadStorageDLL() - Failed with exception " + e.ToString());
  256. return false;
  257. }
  258. }
  259. #region Regenerate Terrain
  260. /// <summary>
  261. /// Rebuilds the terrain using a procedural algorithm
  262. /// </summary>
  263. public void RegenerateTerrain()
  264. {
  265. try
  266. {
  267. Terrain.hills();
  268. lock (this.LockPhysicsEngine)
  269. {
  270. this.phyScene.SetTerrain(Terrain.getHeights1D());
  271. }
  272. this.localStorage.SaveMap(this.Terrain.getHeights1D());
  273. foreach (SimClient client in m_clientThreads.Values)
  274. {
  275. this.SendLayerData(client);
  276. }
  277. foreach (libsecondlife.LLUUID UUID in Entities.Keys)
  278. {
  279. Entities[UUID].LandRenegerated();
  280. }
  281. }
  282. catch (Exception e)
  283. {
  284. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
  285. }
  286. }
  287. /// <summary>
  288. /// Rebuilds the terrain using a 2D float array
  289. /// </summary>
  290. /// <param name="newMap">256,256 float array containing heights</param>
  291. public void RegenerateTerrain(float[,] newMap)
  292. {
  293. try
  294. {
  295. this.Terrain.setHeights2D(newMap);
  296. lock (this.LockPhysicsEngine)
  297. {
  298. this.phyScene.SetTerrain(this.Terrain.getHeights1D());
  299. }
  300. this.localStorage.SaveMap(this.Terrain.getHeights1D());
  301. foreach (SimClient client in m_clientThreads.Values)
  302. {
  303. this.SendLayerData(client);
  304. }
  305. foreach (libsecondlife.LLUUID UUID in Entities.Keys)
  306. {
  307. Entities[UUID].LandRenegerated();
  308. }
  309. }
  310. catch (Exception e)
  311. {
  312. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
  313. }
  314. }
  315. /// <summary>
  316. /// Rebuilds the terrain assuming changes occured at a specified point[?]
  317. /// </summary>
  318. /// <param name="changes">???</param>
  319. /// <param name="pointx">???</param>
  320. /// <param name="pointy">???</param>
  321. public void RegenerateTerrain(bool changes, int pointx, int pointy)
  322. {
  323. try
  324. {
  325. if (changes)
  326. {
  327. lock (this.LockPhysicsEngine)
  328. {
  329. this.phyScene.SetTerrain(this.Terrain.getHeights1D());
  330. }
  331. this.localStorage.SaveMap(this.Terrain.getHeights1D());
  332. foreach (SimClient client in m_clientThreads.Values)
  333. {
  334. this.SendLayerData(pointx, pointy, client);
  335. }
  336. }
  337. }
  338. catch (Exception e)
  339. {
  340. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: RegenerateTerrain() - Failed with exception " + e.ToString());
  341. }
  342. }
  343. #endregion
  344. /// <summary>
  345. /// Loads the World heightmap
  346. /// </summary>
  347. public void LoadWorldMap()
  348. {
  349. try
  350. {
  351. float[] map = this.localStorage.LoadWorld();
  352. if (map == null)
  353. {
  354. Console.WriteLine("creating new terrain");
  355. this.Terrain.hills();
  356. this.localStorage.SaveMap(this.Terrain.getHeights1D());
  357. }
  358. else
  359. {
  360. this.Terrain.setHeights1D(map);
  361. }
  362. }
  363. catch (Exception e)
  364. {
  365. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: LoadWorldMap() - Failed with exception " + e.ToString());
  366. }
  367. }
  368. /// <summary>
  369. /// Loads the World's objects
  370. /// </summary>
  371. public void LoadPrimsFromStorage()
  372. {
  373. try
  374. {
  375. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: LoadPrimsFromStorage() - Loading primitives");
  376. this.localStorage.LoadPrimitives(this);
  377. }
  378. catch (Exception e)
  379. {
  380. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: LoadPrimsFromStorage() - Failed with exception " + e.ToString());
  381. }
  382. }
  383. /// <summary>
  384. /// Loads a specific object from storage
  385. /// </summary>
  386. /// <param name="prim">The object to load</param>
  387. public void PrimFromStorage(PrimData prim)
  388. {
  389. try
  390. {
  391. if (prim.LocalID >= this._primCount)
  392. {
  393. _primCount = prim.LocalID + 1;
  394. }
  395. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: PrimFromStorage() - Reloading prim (localId " + prim.LocalID + " ) from storage");
  396. Primitive nPrim = new Primitive(m_clientThreads, m_regionHandle, this);
  397. nPrim.CreateFromStorage(prim);
  398. this.Entities.Add(nPrim.uuid, nPrim);
  399. }
  400. catch (Exception e)
  401. {
  402. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: PrimFromStorage() - Failed with exception " + e.ToString());
  403. }
  404. }
  405. /// <summary>
  406. /// Tidy before shutdown
  407. /// </summary>
  408. public void Close()
  409. {
  410. try
  411. {
  412. this.localStorage.ShutDown();
  413. }
  414. catch (Exception e)
  415. {
  416. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: Close() - Failed with exception " + e.ToString());
  417. }
  418. }
  419. /// <summary>
  420. /// Send the region heightmap to the client
  421. /// </summary>
  422. /// <param name="RemoteClient">Client to send to</param>
  423. public void SendLayerData(SimClient RemoteClient)
  424. {
  425. try
  426. {
  427. int[] patches = new int[4];
  428. for (int y = 0; y < 16; y++)
  429. {
  430. for (int x = 0; x < 16; x = x + 4)
  431. {
  432. patches[0] = x + 0 + y * 16;
  433. patches[1] = x + 1 + y * 16;
  434. patches[2] = x + 2 + y * 16;
  435. patches[3] = x + 3 + y * 16;
  436. Packet layerpack = TerrainManager.CreateLandPacket(Terrain.getHeights1D(), patches);
  437. RemoteClient.OutPacket(layerpack);
  438. }
  439. }
  440. }
  441. catch (Exception e)
  442. {
  443. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: SendLayerData() - Failed with exception " + e.ToString());
  444. }
  445. }
  446. /// <summary>
  447. /// Sends a specified patch to a client
  448. /// </summary>
  449. /// <param name="px">Patch coordinate (x) 0..16</param>
  450. /// <param name="py">Patch coordinate (y) 0..16</param>
  451. /// <param name="RemoteClient">The client to send to</param>
  452. public void SendLayerData(int px, int py, SimClient RemoteClient)
  453. {
  454. try
  455. {
  456. int[] patches = new int[1];
  457. int patchx, patchy;
  458. patchx = px / 16;
  459. /* if (patchx > 12)
  460. {
  461. patchx = 12;
  462. }*/
  463. patchy = py / 16;
  464. patches[0] = patchx + 0 + patchy * 16;
  465. //patches[1] = patchx + 1 + patchy * 16;
  466. //patches[2] = patchx + 2 + patchy * 16;
  467. //patches[3] = patchx + 3 + patchy * 16;
  468. Packet layerpack = TerrainManager.CreateLandPacket(Terrain.getHeights1D(), patches);
  469. RemoteClient.OutPacket(layerpack);
  470. }
  471. catch (Exception e)
  472. {
  473. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: SendLayerData() - Failed with exception " + e.ToString());
  474. }
  475. }
  476. /// <summary>
  477. /// Sends prims to a client
  478. /// </summary>
  479. /// <param name="RemoteClient">Client to send to</param>
  480. public void GetInitialPrims(SimClient RemoteClient)
  481. {
  482. try
  483. {
  484. foreach (libsecondlife.LLUUID UUID in Entities.Keys)
  485. {
  486. if (Entities[UUID] is Primitive)
  487. {
  488. Primitive primitive = Entities[UUID] as Primitive;
  489. primitive.UpdateClient(RemoteClient);
  490. }
  491. }
  492. }
  493. catch (Exception e)
  494. {
  495. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: GetInitialPrims() - Failed with exception " + e.ToString());
  496. }
  497. }
  498. public void AddViewerAgent(SimClient agentClient)
  499. {
  500. try
  501. {
  502. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Creating new avatar for remote viewer agent");
  503. Avatar newAvatar = new Avatar(agentClient, this, m_regionName, m_clientThreads, m_regionHandle, true, 20);
  504. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world");
  505. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake ");
  506. newAvatar.SendRegionHandshake(this);
  507. if (!agentClient.m_child)
  508. {
  509. PhysicsVector pVec = new PhysicsVector(newAvatar.Pos.X, newAvatar.Pos.Y, newAvatar.Pos.Z);
  510. lock (this.LockPhysicsEngine)
  511. {
  512. newAvatar.PhysActor = this.phyScene.AddAvatar(pVec);
  513. }
  514. }
  515. lock (Entities)
  516. {
  517. this.Entities.Add(agentClient.AgentID, newAvatar);
  518. }
  519. lock (Avatars)
  520. {
  521. this.Avatars.Add(agentClient.AgentID, newAvatar);
  522. }
  523. }
  524. catch (Exception e)
  525. {
  526. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: AddViewerAgent() - Failed with exception " + e.ToString());
  527. }
  528. }
  529. public void RemoveViewerAgent(SimClient agentClient)
  530. {
  531. try
  532. {
  533. lock (Entities)
  534. {
  535. Entities.Remove(agentClient.AgentID);
  536. }
  537. lock (Avatars)
  538. {
  539. Avatars.Remove(agentClient.AgentID);
  540. }
  541. }
  542. catch (Exception e)
  543. {
  544. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: RemoveViewerAgent() - Failed with exception " + e.ToString());
  545. }
  546. }
  547. public void AddNewPrim(ObjectAddPacket addPacket, SimClient AgentClient)
  548. {
  549. try
  550. {
  551. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: AddNewPrim() - Creating new prim");
  552. Primitive prim = new Primitive(m_clientThreads, m_regionHandle, this);
  553. prim.CreateFromPacket(addPacket, AgentClient.AgentID, this._primCount);
  554. PhysicsVector pVec = new PhysicsVector(prim.Pos.X, prim.Pos.Y, prim.Pos.Z);
  555. PhysicsVector pSize = new PhysicsVector(0.255f, 0.255f, 0.255f);
  556. if (OpenSim.world.Avatar.PhysicsEngineFlying)
  557. {
  558. lock (this.LockPhysicsEngine)
  559. {
  560. prim.PhysActor = this.phyScene.AddPrim(pVec, pSize);
  561. }
  562. }
  563. this.Entities.Add(prim.uuid, prim);
  564. this._primCount++;
  565. }
  566. catch (Exception e)
  567. {
  568. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: AddNewPrim() - Failed with exception " + e.ToString());
  569. }
  570. }
  571. public bool Backup()
  572. {
  573. try
  574. {
  575. // Terrain backup routines
  576. if (Terrain.tainted > 0)
  577. {
  578. Terrain.tainted = 0;
  579. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: Backup() - Terrain tainted, saving.");
  580. localStorage.SaveMap(Terrain.getHeights1D());
  581. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: Backup() - Terrain saved, informing Physics.");
  582. phyScene.SetTerrain(Terrain.getHeights1D());
  583. }
  584. // Primitive backup routines
  585. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: Backup() - Backing up Primitives");
  586. foreach (libsecondlife.LLUUID UUID in Entities.Keys)
  587. {
  588. Entities[UUID].BackUp();
  589. }
  590. // Backup successful
  591. return true;
  592. }
  593. catch (Exception e)
  594. {
  595. // Backup failed
  596. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: Backup() - Backup Failed with exception " + e.ToString());
  597. return false;
  598. }
  599. }
  600. public void SetDefaultScripts()
  601. {
  602. try
  603. {
  604. this.m_scripts.Add("FollowRandomAvatar", delegate()
  605. {
  606. return new FollowRandomAvatar();
  607. });
  608. }
  609. catch (Exception e)
  610. {
  611. OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: SetDefaultScripts() - Failed with exception " + e.ToString());
  612. }
  613. }
  614. }
  615. }