aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer/world/World.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim.RegionServer/world/World.cs49
1 files changed, 19 insertions, 30 deletions
diff --git a/OpenSim.RegionServer/world/World.cs b/OpenSim.RegionServer/world/World.cs
index c775429..0799e38 100644
--- a/OpenSim.RegionServer/world/World.cs
+++ b/OpenSim.RegionServer/world/World.cs
@@ -13,6 +13,7 @@ using OpenSim.Framework.Inventory;
13using OpenSim.Assets; 13using OpenSim.Assets;
14using OpenSim.world.scripting; 14using OpenSim.world.scripting;
15using OpenSim.RegionServer.world.scripting; 15using OpenSim.RegionServer.world.scripting;
16using OpenSim.RegionServer.world.scripting.Scripts;
16 17
17namespace OpenSim.world 18namespace OpenSim.world
18{ 19{
@@ -32,20 +33,20 @@ namespace OpenSim.world
32 private int storageCount; 33 private int storageCount;
33 private Dictionary<uint, SimClient> m_clientThreads; 34 private Dictionary<uint, SimClient> m_clientThreads;
34 private Dictionary<LLUUID, ScriptHandler> m_scriptHandlers; 35 private Dictionary<LLUUID, ScriptHandler> m_scriptHandlers;
35 private Dictionary<string, Script> m_scripts; 36 private Dictionary<string, ScriptFactory> m_scripts;
36 private ulong m_regionHandle; 37 private ulong m_regionHandle;
37 private string m_regionName; 38 private string m_regionName;
38 private InventoryCache _inventoryCache; 39 private InventoryCache _inventoryCache;
39 private AssetCache _assetCache; 40 private AssetCache _assetCache;
40 41
41 public World(Dictionary<uint, SimClient> clientThreads, ulong regionHandle, string regionName) 42 public World(Dictionary<uint, SimClient> clientThreads, ulong regionHandle, string regionName)
42 { 43 {
43 m_clientThreads = clientThreads; 44 m_clientThreads = clientThreads;
44 m_regionHandle = regionHandle; 45 m_regionHandle = regionHandle;
45 m_regionName = regionName; 46 m_regionName = regionName;
46 47
47 m_scriptHandlers = new Dictionary<LLUUID, ScriptHandler>(); 48 m_scriptHandlers = new Dictionary<LLUUID, ScriptHandler>();
48 m_scripts = new Dictionary<string, Script>(); 49 m_scripts = new Dictionary<string, ScriptFactory>();
49 50
50 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance"); 51 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance");
51 Entities = new Dictionary<libsecondlife.LLUUID, Entity>(); 52 Entities = new Dictionary<libsecondlife.LLUUID, Entity>();
@@ -75,11 +76,17 @@ namespace OpenSim.world
75 scriptend = scriptData.LastIndexOf("</Script>"); 76 scriptend = scriptData.LastIndexOf("</Script>");
76 substring = scriptData.Substring(scriptstart + 8, scriptend - scriptstart - 8); 77 substring = scriptData.Substring(scriptstart + 8, scriptend - scriptstart - 8);
77 substring = substring.Trim(); 78 substring = substring.Trim();
78 Console.WriteLine("searching for script to add: " + substring); 79 Console.WriteLine("searching for script to add: " + substring);
79 if (this.m_scripts.ContainsKey(substring)) 80
81 ScriptFactory scriptFactory;
82
83 if (this.m_scripts.TryGetValue(substring, out scriptFactory ))
80 { 84 {
81 Console.WriteLine("added script"); 85 Console.WriteLine("added script");
82 this.AddScript(entity, this.m_scripts[substring]); 86
87
88
89 this.AddScript(entity, scriptFactory());
83 } 90 }
84 /*string delimStr = " "; 91 /*string delimStr = " ";
85 char[] delimiter = delimStr.ToCharArray(); 92 char[] delimiter = delimStr.ToCharArray();
@@ -357,7 +364,7 @@ namespace OpenSim.world
357 prim.PhysActor = this.phyScene.AddPrim(pVec, pSize); 364 prim.PhysActor = this.phyScene.AddPrim(pVec, pSize);
358 } 365 }
359 } 366 }
360 367
361 this.Entities.Add(prim.uuid, prim); 368 this.Entities.Add(prim.uuid, prim);
362 this._primCount++; 369 this._primCount++;
363 } 370 }
@@ -557,31 +564,13 @@ namespace OpenSim.world
557 564
558 public void SetDefaultScripts() 565 public void SetDefaultScripts()
559 { 566 {
560 this.m_scripts.Add("Test", new TestScript1()); 567 this.m_scripts.Add("FollowRandomAvatar", delegate()
561 } 568 {
562 569 return new FollowRandomAvatar();
563 #endregion 570 });
564 }
565
566 public class TestScript1 : Script
567 {
568 int toggle = 0;
569
570 public TestScript1()
571 : base(LLUUID.Random())
572 {
573 OnFrame += MyOnFrame;
574 } 571 }
575 572
576 private void MyOnFrame(IScriptContext context)
577 {
578 toggle = 2 - toggle;
579 573
580 LLVector3 pos = context.GetPos(); 574 #endregion
581
582 pos.X += (toggle - 1);
583
584 context.MoveTo(pos);
585 }
586 } 575 }
587} 576}