diff options
author | lbsa71 | 2007-04-03 20:08:30 +0000 |
---|---|---|
committer | lbsa71 | 2007-04-03 20:08:30 +0000 |
commit | f12ceff6925236ca184c5a7a9c010b5e4bdb1b70 (patch) | |
tree | 9c83230be4bbdc19501e854df63084399cd742ba /OpenSim.RegionServer/world/World.cs | |
parent | * Extended Script API with GetRandomAvatar (diff) | |
download | opensim-SC_OLD-f12ceff6925236ca184c5a7a9c010b5e4bdb1b70.zip opensim-SC_OLD-f12ceff6925236ca184c5a7a9c010b5e4bdb1b70.tar.gz opensim-SC_OLD-f12ceff6925236ca184c5a7a9c010b5e4bdb1b70.tar.bz2 opensim-SC_OLD-f12ceff6925236ca184c5a7a9c010b5e4bdb1b70.tar.xz |
* The world can not contain ScriptFactories that creates unique instances of scripts for entities.
* Created Scripts folder to house trusted Scripts
* The test script now lives in Scripts/FollowRandomAvatar.cs
Diffstat (limited to 'OpenSim.RegionServer/world/World.cs')
-rw-r--r-- | OpenSim.RegionServer/world/World.cs | 49 |
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; | |||
13 | using OpenSim.Assets; | 13 | using OpenSim.Assets; |
14 | using OpenSim.world.scripting; | 14 | using OpenSim.world.scripting; |
15 | using OpenSim.RegionServer.world.scripting; | 15 | using OpenSim.RegionServer.world.scripting; |
16 | using OpenSim.RegionServer.world.scripting.Scripts; | ||
16 | 17 | ||
17 | namespace OpenSim.world | 18 | namespace 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 | } |