diff options
author | Teravus Ovares | 2008-05-01 16:39:02 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-05-01 16:39:02 +0000 |
commit | c803e0cca1ef1e81bec4dcd615aea955f3756b19 (patch) | |
tree | 97c1ff9b468e930e8152a8d6e8df523353229d16 /OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs | |
parent | * Spring cleaning on Region.Environment. (diff) | |
download | opensim-SC_OLD-c803e0cca1ef1e81bec4dcd615aea955f3756b19.zip opensim-SC_OLD-c803e0cca1ef1e81bec4dcd615aea955f3756b19.tar.gz opensim-SC_OLD-c803e0cca1ef1e81bec4dcd615aea955f3756b19.tar.bz2 opensim-SC_OLD-c803e0cca1ef1e81bec4dcd615aea955f3756b19.tar.xz |
* Deletes my EventReader ScriptRewriter. It isn't required to rewrite the script to publish the events anymore.
* Introduces a language(regex) independent event recognizer and publishes the events the script listens.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs | 101 |
1 files changed, 97 insertions, 4 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs b/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs index 19fb487..2e35b46 100644 --- a/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs +++ b/OpenSim/Region/ScriptEngine/Common/ExecutorBase.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.Runtime.Remoting.Lifetime; | 30 | using System.Runtime.Remoting.Lifetime; |
30 | 31 | ||
31 | namespace OpenSim.Region.ScriptEngine.Common | 32 | namespace OpenSim.Region.ScriptEngine.Common |
@@ -54,10 +55,46 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
54 | public bool Running | 55 | public bool Running |
55 | { | 56 | { |
56 | get { return m_Running; } | 57 | get { return m_Running; } |
57 | set { | 58 | set |
58 | if(!m_Disable) | 59 | { |
59 | m_Running = value; | 60 | if (!m_Disable) |
60 | } | 61 | m_Running = value; |
62 | } | ||
63 | } | ||
64 | |||
65 | protected Dictionary<string, scriptEvents> m_eventFlagsMap = new Dictionary<string, scriptEvents>(); | ||
66 | |||
67 | [Flags] | ||
68 | public enum scriptEvents : int | ||
69 | { | ||
70 | None = 0, | ||
71 | attach = 1, | ||
72 | collision = 15, | ||
73 | collision_end = 32, | ||
74 | collision_start = 64, | ||
75 | control = 128, | ||
76 | dataserver = 256, | ||
77 | email = 512, | ||
78 | http_response = 1024, | ||
79 | land_collision = 2048, | ||
80 | land_collision_end = 4096, | ||
81 | land_collision_start = 8192, | ||
82 | at_target = 16384, | ||
83 | listen = 32768, | ||
84 | money = 65536, | ||
85 | moving_end = 131072, | ||
86 | moving_start = 262144, | ||
87 | not_at_rot_target = 524288, | ||
88 | not_at_target = 1048576, | ||
89 | remote_data = 8388608, | ||
90 | run_time_permissions = 268435456, | ||
91 | state_entry = 1073741824, | ||
92 | state_exit = 2, | ||
93 | timer = 4, | ||
94 | touch = 8, | ||
95 | touch_end = 536870912, | ||
96 | touch_start = 2097152, | ||
97 | object_rez = 4194304 | ||
61 | } | 98 | } |
62 | 99 | ||
63 | /// <summary> | 100 | /// <summary> |
@@ -67,6 +104,7 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
67 | public ExecutorBase(IScript Script) | 104 | public ExecutorBase(IScript Script) |
68 | { | 105 | { |
69 | m_Script = Script; | 106 | m_Script = Script; |
107 | initEventFlags(); | ||
70 | } | 108 | } |
71 | 109 | ||
72 | /// <summary> | 110 | /// <summary> |
@@ -111,9 +149,21 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
111 | } | 149 | } |
112 | DoExecuteEvent(FunctionName, args); | 150 | DoExecuteEvent(FunctionName, args); |
113 | } | 151 | } |
152 | |||
114 | protected abstract void DoExecuteEvent(string FunctionName, object[] args); | 153 | protected abstract void DoExecuteEvent(string FunctionName, object[] args); |
115 | 154 | ||
116 | /// <summary> | 155 | /// <summary> |
156 | /// Compute the events handled by the current state of the script | ||
157 | /// </summary> | ||
158 | /// <returns>state mask</returns> | ||
159 | public scriptEvents GetStateEventFlags() | ||
160 | { | ||
161 | return DoGetStateEventFlags(); | ||
162 | } | ||
163 | |||
164 | protected abstract scriptEvents DoGetStateEventFlags(); | ||
165 | |||
166 | /// <summary> | ||
117 | /// Stop script from running. Event execution will be ignored. | 167 | /// Stop script from running. Event execution will be ignored. |
118 | /// </summary> | 168 | /// </summary> |
119 | public void StopScript() | 169 | public void StopScript() |
@@ -121,5 +171,48 @@ namespace OpenSim.Region.ScriptEngine.Common | |||
121 | m_Running = false; | 171 | m_Running = false; |
122 | m_Disable = true; | 172 | m_Disable = true; |
123 | } | 173 | } |
174 | |||
175 | protected void initEventFlags() | ||
176 | { | ||
177 | // Initialize the table if it hasn't already been done | ||
178 | if (m_eventFlagsMap.Count > 0) | ||
179 | { | ||
180 | return; | ||
181 | } | ||
182 | |||
183 | m_eventFlagsMap.Add("attach", scriptEvents.attach); | ||
184 | // m_eventFlagsMap.Add("at_rot_target",(long)scriptEvents.at_rot_target); | ||
185 | m_eventFlagsMap.Add("at_target", scriptEvents.at_target); | ||
186 | // m_eventFlagsMap.Add("changed",(long)scriptEvents.changed); | ||
187 | m_eventFlagsMap.Add("collision", scriptEvents.collision); | ||
188 | m_eventFlagsMap.Add("collision_end", scriptEvents.collision_end); | ||
189 | m_eventFlagsMap.Add("collision_start", scriptEvents.collision_start); | ||
190 | m_eventFlagsMap.Add("control", scriptEvents.control); | ||
191 | m_eventFlagsMap.Add("dataserver", scriptEvents.dataserver); | ||
192 | m_eventFlagsMap.Add("email", scriptEvents.email); | ||
193 | m_eventFlagsMap.Add("http_response", scriptEvents.http_response); | ||
194 | m_eventFlagsMap.Add("land_collision", scriptEvents.land_collision); | ||
195 | m_eventFlagsMap.Add("land_collision_end", scriptEvents.land_collision_end); | ||
196 | m_eventFlagsMap.Add("land_collision_start", scriptEvents.land_collision_start); | ||
197 | // m_eventFlagsMap.Add("link_message",scriptEvents.link_message); | ||
198 | m_eventFlagsMap.Add("listen", scriptEvents.listen); | ||
199 | m_eventFlagsMap.Add("money", scriptEvents.money); | ||
200 | m_eventFlagsMap.Add("moving_end", scriptEvents.moving_end); | ||
201 | m_eventFlagsMap.Add("moving_start", scriptEvents.moving_start); | ||
202 | m_eventFlagsMap.Add("not_at_rot_target", scriptEvents.not_at_rot_target); | ||
203 | m_eventFlagsMap.Add("not_at_target", scriptEvents.not_at_target); | ||
204 | // m_eventFlagsMap.Add("no_sensor",(long)scriptEvents.no_sensor); | ||
205 | // m_eventFlagsMap.Add("on_rez",(long)scriptEvents.on_rez); | ||
206 | m_eventFlagsMap.Add("remote_data", scriptEvents.remote_data); | ||
207 | m_eventFlagsMap.Add("run_time_permissions", scriptEvents.run_time_permissions); | ||
208 | // m_eventFlagsMap.Add("sensor",(long)scriptEvents.sensor); | ||
209 | m_eventFlagsMap.Add("state_entry", scriptEvents.state_entry); | ||
210 | m_eventFlagsMap.Add("state_exit", scriptEvents.state_exit); | ||
211 | m_eventFlagsMap.Add("timer", scriptEvents.timer); | ||
212 | m_eventFlagsMap.Add("touch", scriptEvents.touch); | ||
213 | m_eventFlagsMap.Add("touch_end", scriptEvents.touch_end); | ||
214 | m_eventFlagsMap.Add("touch_start", scriptEvents.touch_start); | ||
215 | m_eventFlagsMap.Add("object_rez", scriptEvents.object_rez); | ||
216 | } | ||
124 | } | 217 | } |
125 | } | 218 | } |