aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim.RegionServer/SimClient.cs26
-rw-r--r--OpenSim.RegionServer/world/World.cs63
2 files changed, 88 insertions, 1 deletions
diff --git a/OpenSim.RegionServer/SimClient.cs b/OpenSim.RegionServer/SimClient.cs
index 58cc625..6c64731 100644
--- a/OpenSim.RegionServer/SimClient.cs
+++ b/OpenSim.RegionServer/SimClient.cs
@@ -436,6 +436,32 @@ namespace OpenSim
436 this.OutPacket(replytask); 436 this.OutPacket(replytask);
437 } 437 }
438 break; 438 break;
439 case PacketType.UpdateTaskInventory:
440 Console.WriteLine(Pack.ToString());
441 UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
442 AgentInventory myinventory = this.m_inventoryCache.GetAgentsInventory(this.AgentID);
443 if (myinventory != null)
444 {
445 if (myinventory.InventoryItems[updatetask.InventoryData.ItemID] != null)
446 {
447 if (myinventory.InventoryItems[updatetask.InventoryData.ItemID].Type == 7)
448 {
449 LLUUID noteaid = myinventory.InventoryItems[updatetask.InventoryData.ItemID].AssetID;
450 AssetBase assBase = this.m_assetCache.GetAsset(noteaid);
451 if (assBase != null)
452 {
453 foreach (Entity ent in m_world.Entities.Values)
454 {
455 if (ent.localid == updatetask.UpdateData.LocalID)
456 {
457 this.m_world.AddScript(ent, Helpers.FieldToString(assBase.Data));
458 }
459 }
460 }
461 }
462 }
463 }
464 break;
439 case PacketType.AgentAnimation: 465 case PacketType.AgentAnimation:
440 //Console.WriteLine(Pack.ToString()); 466 //Console.WriteLine(Pack.ToString());
441 break; 467 break;
diff --git a/OpenSim.RegionServer/world/World.cs b/OpenSim.RegionServer/world/World.cs
index 6bc485f..408f68d 100644
--- a/OpenSim.RegionServer/world/World.cs
+++ b/OpenSim.RegionServer/world/World.cs
@@ -32,18 +32,20 @@ namespace OpenSim.world
32 private int storageCount; 32 private int storageCount;
33 private Dictionary<uint, SimClient> m_clientThreads; 33 private Dictionary<uint, SimClient> m_clientThreads;
34 private Dictionary<LLUUID, ScriptHandler> m_scriptHandlers; 34 private Dictionary<LLUUID, ScriptHandler> m_scriptHandlers;
35 private Dictionary<string, Script> m_scripts;
35 private ulong m_regionHandle; 36 private ulong m_regionHandle;
36 private string m_regionName; 37 private string m_regionName;
37 private InventoryCache _inventoryCache; 38 private InventoryCache _inventoryCache;
38 private AssetCache _assetCache; 39 private AssetCache _assetCache;
39 40
40 public World(Dictionary<uint, SimClient> clientThreads, ulong regionHandle, string regionName) 41 public World(Dictionary<uint, SimClient> clientThreads, ulong regionHandle, string regionName)
41 { 42 {
42 m_clientThreads = clientThreads; 43 m_clientThreads = clientThreads;
43 m_regionHandle = regionHandle; 44 m_regionHandle = regionHandle;
44 m_regionName = regionName; 45 m_regionName = regionName;
45 46
46 m_scriptHandlers = new Dictionary<LLUUID, ScriptHandler>(); 47 m_scriptHandlers = new Dictionary<LLUUID, ScriptHandler>();
48 m_scripts = new Dictionary<string, Script>();
47 49
48 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance"); 50 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance");
49 Entities = new Dictionary<libsecondlife.LLUUID, Entity>(); 51 Entities = new Dictionary<libsecondlife.LLUUID, Entity>();
@@ -55,6 +57,7 @@ namespace OpenSim.world
55 // Initialise this only after the world has loaded 57 // Initialise this only after the world has loaded
56 // Scripts = new ScriptEngine(this); 58 // Scripts = new ScriptEngine(this);
57 Avatar.LoadAnims(); 59 Avatar.LoadAnims();
60 this.SetDefaultScripts();
58 } 61 }
59 62
60 public void AddScript(Entity entity, Script script) 63 public void AddScript(Entity entity, Script script)
@@ -63,6 +66,37 @@ namespace OpenSim.world
63 m_scriptHandlers.Add(scriptHandler.ScriptId, scriptHandler); 66 m_scriptHandlers.Add(scriptHandler.ScriptId, scriptHandler);
64 } 67 }
65 68
69 public void AddScript(Entity entity, string scriptData)
70 {
71 int scriptstart = 0;
72 int scriptend = 0;
73 string substring;
74 scriptstart = scriptData.LastIndexOf("<Script>");
75 scriptend = scriptData.LastIndexOf("</Script>");
76 substring = scriptData.Substring(scriptstart + 8, scriptend - scriptstart - 8);
77 substring = substring.Trim();
78 Console.WriteLine("searching for script to add: " + substring);
79 if (this.m_scripts.ContainsKey(substring))
80 {
81 Console.WriteLine("added script");
82 this.AddScript(entity, this.m_scripts[substring]);
83 }
84 /*string delimStr = " ";
85 char[] delimiter = delimStr.ToCharArray();
86 string[] line;
87 line = scriptData.Split(delimiter);
88 if (line.Length > 1)
89 {
90 if (line[0] == "script:")
91 {
92 if (this.m_scripts.ContainsKey(line[1]))
93 {
94 this.AddScript(entity, this.m_scripts[line[1]]);
95 }
96 }
97 }*/
98 }
99
66 public InventoryCache InventoryCache 100 public InventoryCache InventoryCache
67 { 101 {
68 set 102 set
@@ -521,6 +555,33 @@ namespace OpenSim.world
521 return true; 555 return true;
522 } 556 }
523 557
558 public void SetDefaultScripts()
559 {
560 this.m_scripts.Add("Test", new TestScript1());
561 }
562
524 #endregion 563 #endregion
525 } 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 }
575
576 private void MyOnFrame(IScriptContext context)
577 {
578 toggle = 2 - toggle;
579
580 LLVector3 pos = context.GetPos();
581
582 pos.X += (toggle - 1);
583
584 context.MoveTo(pos);
585 }
586 }
526} 587}