From f12ceff6925236ca184c5a7a9c010b5e4bdb1b70 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 3 Apr 2007 20:08:30 +0000 Subject: * 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 --- OpenSim.RegionServer/world/World.cs | 49 ++++++++++++++----------------------- 1 file changed, 19 insertions(+), 30 deletions(-) (limited to 'OpenSim.RegionServer/world/World.cs') 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; using OpenSim.Assets; using OpenSim.world.scripting; using OpenSim.RegionServer.world.scripting; +using OpenSim.RegionServer.world.scripting.Scripts; namespace OpenSim.world { @@ -32,20 +33,20 @@ namespace OpenSim.world private int storageCount; private Dictionary m_clientThreads; private Dictionary m_scriptHandlers; - private Dictionary m_scripts; + private Dictionary m_scripts; private ulong m_regionHandle; private string m_regionName; private InventoryCache _inventoryCache; private AssetCache _assetCache; public World(Dictionary clientThreads, ulong regionHandle, string regionName) - { + { m_clientThreads = clientThreads; m_regionHandle = regionHandle; m_regionName = regionName; m_scriptHandlers = new Dictionary(); - m_scripts = new Dictionary(); + m_scripts = new Dictionary(); OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs - creating new entitities instance"); Entities = new Dictionary(); @@ -75,11 +76,17 @@ namespace OpenSim.world scriptend = scriptData.LastIndexOf(""); substring = scriptData.Substring(scriptstart + 8, scriptend - scriptstart - 8); substring = substring.Trim(); - Console.WriteLine("searching for script to add: " + substring); - if (this.m_scripts.ContainsKey(substring)) + Console.WriteLine("searching for script to add: " + substring); + + ScriptFactory scriptFactory; + + if (this.m_scripts.TryGetValue(substring, out scriptFactory )) { Console.WriteLine("added script"); - this.AddScript(entity, this.m_scripts[substring]); + + + + this.AddScript(entity, scriptFactory()); } /*string delimStr = " "; char[] delimiter = delimStr.ToCharArray(); @@ -357,7 +364,7 @@ namespace OpenSim.world prim.PhysActor = this.phyScene.AddPrim(pVec, pSize); } } - + this.Entities.Add(prim.uuid, prim); this._primCount++; } @@ -557,31 +564,13 @@ namespace OpenSim.world public void SetDefaultScripts() { - this.m_scripts.Add("Test", new TestScript1()); - } - - #endregion - } - - public class TestScript1 : Script - { - int toggle = 0; - - public TestScript1() - : base(LLUUID.Random()) - { - OnFrame += MyOnFrame; + this.m_scripts.Add("FollowRandomAvatar", delegate() + { + return new FollowRandomAvatar(); + }); } - private void MyOnFrame(IScriptContext context) - { - toggle = 2 - toggle; - LLVector3 pos = context.GetPos(); - - pos.X += (toggle - 1); - - context.MoveTo(pos); - } + #endregion } } -- cgit v1.1