From 9511a8c76370f21e839114007dcd2b25c69b009a Mon Sep 17 00:00:00 2001 From: Tedd Hansen Date: Sat, 8 Nov 2008 17:35:48 +0000 Subject: Work in progress on SECS stuff. Have been holding it off until after 0.6 release. Still messy as hell and doesn't really work yet. Will undergo dramatic changes. AND MOST IMPORTANTLY: Will be conformed to work in coop with todays DNE and XEngine, hopefully one day providing a common interface for all components. --- .../DotNetEngine/Events/LSLEventProvider.cs | 81 ++++++++++++++++++++-- 1 file changed, 77 insertions(+), 4 deletions(-) (limited to 'OpenSim/ScriptEngine/Components/DotNetEngine/Events') diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Events/LSLEventProvider.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Events/LSLEventProvider.cs index b42ceec..794b132 100644 --- a/OpenSim/ScriptEngine/Components/DotNetEngine/Events/LSLEventProvider.cs +++ b/OpenSim/ScriptEngine/Components/DotNetEngine/Events/LSLEventProvider.cs @@ -27,19 +27,92 @@ using System; using System.Collections.Generic; using System.Text; -using OpenSim.ApplicationPlugins.ScriptEngine.Components; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.ScriptEngine.Shared; +using OpenSim.ScriptEngine.Shared; +using EventParams=OpenSim.ScriptEngine.Shared.EventParams; namespace OpenSim.ScriptEngine.Components.DotNetEngine.Events { - public class LSLEventProvider: EventBase + public class LSLEventProvider : IScriptEventProvider { + public delegate void RezScriptDelegate(uint localID, UUID itemID, string script, int startParam, bool postOnRez, + string engine); + public event RezScriptDelegate RezScript; + public delegate void RemoveScriptDelegate(uint localID, UUID itemID); + public event RemoveScriptDelegate RemoveScript; + public delegate void ScriptChangedDelegate(uint localID, uint change); + public event ScriptChangedDelegate ScriptChanged; - public override void Start() + private RegionInfoStructure CurrentRegion; + public void Initialize(RegionInfoStructure currentRegion) { + CurrentRegion = currentRegion; + HookupEvents(); } - public override void Close() + private void HookupEvents() { + CurrentRegion.Scene.EventManager.OnObjectGrab += OnObjectGrab; + CurrentRegion.Scene.EventManager.OnRezScript += OnRezScript; + CurrentRegion.Scene.EventManager.OnRemoveScript += OnRemoveScript; + CurrentRegion.Scene.EventManager.OnScriptChangedEvent += OnScriptChangedEvent; + + + } + + private void OnScriptChangedEvent(uint localID, uint change) + { + // Script is being changed, fire event + if (ScriptChanged != null) + ScriptChanged(localID, change); + } + + private void OnRemoveScript(uint localID, UUID itemID) + { + // Script is being removed, fire event + if (RemoveScript != null) + RemoveScript(localID, itemID); + } + + private void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine) + { + // New script being created, fire event + if (RezScript != null) + RezScript(localID, itemID, script, startParam, postOnRez, engine); + } + + private void OnObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient) + { + // Add to queue for all scripts in ObjectID object + DetectParams[] det = new DetectParams[1]; + det[0] = new DetectParams(); + det[0].Key = remoteClient.AgentId; + //det[0].Populate(World); + + if (originalID == 0) + { + SceneObjectPart part = + CurrentRegion.Scene.GetSceneObjectPart(localID); + + if (part == null) + return; + + det[0].LinkNum = part.LinkNum; + } + else + { + SceneObjectPart originalPart = + CurrentRegion.Scene.GetSceneObjectPart(originalID); + det[0].LinkNum = originalPart.LinkNum; + } + + Shared.EventParams ep = + new Shared.EventParams(localID, "touch_start", new Object[] {new LSL_Types.LSLInteger(1)}, det); + CurrentRegion.Executors_Execute(ep); + } } } -- cgit v1.1