aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common/Executor.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/Executor.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/Executor.cs39
1 files changed, 39 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/Executor.cs b/OpenSim/Region/ScriptEngine/Common/Executor.cs
index 8e0d6f1..56baa66 100644
--- a/OpenSim/Region/ScriptEngine/Common/Executor.cs
+++ b/OpenSim/Region/ScriptEngine/Common/Executor.cs
@@ -35,9 +35,48 @@ namespace OpenSim.Region.ScriptEngine.Common
35 { 35 {
36 // Cache functions by keeping a reference to them in a dictionary 36 // Cache functions by keeping a reference to them in a dictionary
37 private Dictionary<string, MethodInfo> Events = new Dictionary<string, MethodInfo>(); 37 private Dictionary<string, MethodInfo> Events = new Dictionary<string, MethodInfo>();
38 private Dictionary<string, scriptEvents> m_stateEvents = new Dictionary<string, scriptEvents>();
38 39
39 public Executor(IScript script) : base(script) 40 public Executor(IScript script) : base(script)
40 { 41 {
42 initEventFlags();
43 }
44
45
46 protected override scriptEvents DoGetStateEventFlags()
47 {
48 // Console.WriteLine("Get event flags for " + m_Script.State);
49
50 // Check to see if we've already computed the flags for this state
51 scriptEvents eventFlags = scriptEvents.None;
52 if (m_stateEvents.ContainsKey(m_Script.State))
53 {
54 m_stateEvents.TryGetValue(m_Script.State, out eventFlags);
55 return eventFlags;
56 }
57
58 // Fill in the events for this state, cache the results in the map
59 foreach (KeyValuePair<string, scriptEvents> kvp in m_eventFlagsMap)
60 {
61 string evname = m_Script.State + "_event_" + kvp.Key;
62 Type type = m_Script.GetType();
63 try
64 {
65 MethodInfo mi = type.GetMethod(evname);
66 if (mi != null)
67 {
68 // Console.WriteLine("Found handler for " + kvp.Key);
69 eventFlags |= kvp.Value;
70 }
71 }
72 catch
73 {
74 }
75 }
76
77 // Save the flags we just computed and return the result
78 m_stateEvents.Add(m_Script.State, eventFlags);
79 return (eventFlags);
41 } 80 }
42 81
43 protected override void DoExecuteEvent(string FunctionName, object[] args) 82 protected override void DoExecuteEvent(string FunctionName, object[] args)