29 using System.Collections.Generic;
30 using System.Diagnostics;
31 using System.Reflection;
32 using System.Runtime.Remoting.Lifetime;
33 using OpenSim.Region.ScriptEngine.Shared;
34 using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
37 namespace OpenSim.
Region.ScriptEngine.Shared.ScriptBase
48 protected Dictionary<string, scriptEvents> m_eventFlagsMap =
new Dictionary<string, scriptEvents>();
62 land_collision = 2048,
63 land_collision_end = 4096,
64 land_collision_start = 8192,
66 at_rot_target = 16777216,
70 moving_start = 262144,
71 not_at_rot_target = 524288,
72 not_at_target = 1048576,
73 remote_data = 8388608,
74 run_time_permissions = 268435456,
75 state_entry = 1073741824,
79 touch_end = 536870912,
80 touch_start = 2097152,
81 transaction_result = 33554432,
86 private Dictionary<string, MethodInfo> Events =
new Dictionary<string, MethodInfo>();
87 private Dictionary<string, scriptEvents> m_stateEvents =
new Dictionary<string, scriptEvents>();
101 if (m_stateEvents.ContainsKey(state))
103 m_stateEvents.TryGetValue(state, out eventFlags);
107 Type type=m_Script.GetType();
110 foreach (KeyValuePair<string, scriptEvents> kvp
in m_eventFlagsMap)
112 string evname = state +
"_event_" + kvp.Key;
116 MethodInfo mi = type.GetMethod(evname);
120 eventFlags |= kvp.Value;
131 m_stateEvents.Add(state, eventFlags);
137 [DebuggerNonUserCode]
138 public void ExecuteEvent(
string state,
string FunctionName,
object[] args)
143 string EventName = state +
"_event_" + FunctionName;
149 if (Events.ContainsKey(EventName) ==
false)
152 Type type = m_Script.GetType();
155 MethodInfo mi = type.GetMethod(EventName);
156 Events.Add(EventName, mi);
162 Events.Add(EventName, null);
167 MethodInfo ev = null;
168 Events.TryGetValue(EventName, out ev);
183 ev.Invoke(m_Script, args);
185 catch (TargetInvocationException tie)
204 if (m_eventFlagsMap.Count > 0)
209 m_eventFlagsMap.Add(
"attach", scriptEvents.attach);
210 m_eventFlagsMap.Add(
"at_rot_target", scriptEvents.at_rot_target);
211 m_eventFlagsMap.Add(
"at_target", scriptEvents.at_target);
213 m_eventFlagsMap.Add(
"collision", scriptEvents.collision);
214 m_eventFlagsMap.Add(
"collision_end", scriptEvents.collision_end);
215 m_eventFlagsMap.Add(
"collision_start", scriptEvents.collision_start);
216 m_eventFlagsMap.Add(
"control", scriptEvents.control);
217 m_eventFlagsMap.Add(
"dataserver", scriptEvents.dataserver);
218 m_eventFlagsMap.Add(
"email", scriptEvents.email);
219 m_eventFlagsMap.Add(
"http_response", scriptEvents.http_response);
220 m_eventFlagsMap.Add(
"land_collision", scriptEvents.land_collision);
221 m_eventFlagsMap.Add(
"land_collision_end", scriptEvents.land_collision_end);
222 m_eventFlagsMap.Add(
"land_collision_start", scriptEvents.land_collision_start);
224 m_eventFlagsMap.Add(
"listen", scriptEvents.listen);
225 m_eventFlagsMap.Add(
"money", scriptEvents.money);
226 m_eventFlagsMap.Add(
"moving_end", scriptEvents.moving_end);
227 m_eventFlagsMap.Add(
"moving_start", scriptEvents.moving_start);
228 m_eventFlagsMap.Add(
"not_at_rot_target", scriptEvents.not_at_rot_target);
229 m_eventFlagsMap.Add(
"not_at_target", scriptEvents.not_at_target);
232 m_eventFlagsMap.Add(
"remote_data", scriptEvents.remote_data);
233 m_eventFlagsMap.Add(
"run_time_permissions", scriptEvents.run_time_permissions);
235 m_eventFlagsMap.Add(
"state_entry", scriptEvents.state_entry);
236 m_eventFlagsMap.Add(
"state_exit", scriptEvents.state_exit);
237 m_eventFlagsMap.Add(
"timer", scriptEvents.timer);
238 m_eventFlagsMap.Add(
"touch", scriptEvents.touch);
239 m_eventFlagsMap.Add(
"touch_end", scriptEvents.touch_end);
240 m_eventFlagsMap.Add(
"touch_start", scriptEvents.touch_start);
241 m_eventFlagsMap.Add(
"transaction_result", scriptEvents.transaction_result);
242 m_eventFlagsMap.Add(
"object_rez", scriptEvents.object_rez);
void ExecuteEvent(string state, string FunctionName, object[] args)
scriptEvents GetStateEventFlags(string state)
IScript m_Script
Contains the script to execute functions in.