diff options
author | Teravus Ovares | 2008-05-30 12:27:06 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-05-30 12:27:06 +0000 |
commit | 1a47ff8094ee414a47aebd310826906d89428a09 (patch) | |
tree | 0e90b3a33f43ff8617a077bb57b86d6b28e63e71 /OpenSim/Region/ScriptEngine/XEngine/ExecutorBase.cs | |
parent | * Fixed a dangling event hook that I added. (diff) | |
download | opensim-SC_OLD-1a47ff8094ee414a47aebd310826906d89428a09.zip opensim-SC_OLD-1a47ff8094ee414a47aebd310826906d89428a09.tar.gz opensim-SC_OLD-1a47ff8094ee414a47aebd310826906d89428a09.tar.bz2 opensim-SC_OLD-1a47ff8094ee414a47aebd310826906d89428a09.tar.xz |
* This is Melanie's XEngine script engine. I've not tested this real well, however, it's confirmed to compile and OpenSimulator to run successfully without this script engine active.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/ExecutorBase.cs | 181 |
1 files changed, 181 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/ExecutorBase.cs b/OpenSim/Region/ScriptEngine/XEngine/ExecutorBase.cs new file mode 100644 index 0000000..3775372 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/XEngine/ExecutorBase.cs | |||
@@ -0,0 +1,181 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Runtime.Remoting.Lifetime; | ||
31 | using OpenSim.Region.ScriptEngine.XEngine.Script; | ||
32 | |||
33 | namespace OpenSim.Region.ScriptEngine.XEngine | ||
34 | { | ||
35 | public abstract class ExecutorBase : MarshalByRefObject | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// Contains the script to execute functions in. | ||
39 | /// </summary> | ||
40 | protected IScript m_Script; | ||
41 | |||
42 | protected Dictionary<string, scriptEvents> m_eventFlagsMap = new Dictionary<string, scriptEvents>(); | ||
43 | |||
44 | [Flags] | ||
45 | public enum scriptEvents : int | ||
46 | { | ||
47 | None = 0, | ||
48 | attach = 1, | ||
49 | collision = 15, | ||
50 | collision_end = 32, | ||
51 | collision_start = 64, | ||
52 | control = 128, | ||
53 | dataserver = 256, | ||
54 | email = 512, | ||
55 | http_response = 1024, | ||
56 | land_collision = 2048, | ||
57 | land_collision_end = 4096, | ||
58 | land_collision_start = 8192, | ||
59 | at_target = 16384, | ||
60 | listen = 32768, | ||
61 | money = 65536, | ||
62 | moving_end = 131072, | ||
63 | moving_start = 262144, | ||
64 | not_at_rot_target = 524288, | ||
65 | not_at_target = 1048576, | ||
66 | remote_data = 8388608, | ||
67 | run_time_permissions = 268435456, | ||
68 | state_entry = 1073741824, | ||
69 | state_exit = 2, | ||
70 | timer = 4, | ||
71 | touch = 8, | ||
72 | touch_end = 536870912, | ||
73 | touch_start = 2097152, | ||
74 | object_rez = 4194304 | ||
75 | } | ||
76 | |||
77 | /// <summary> | ||
78 | /// Create a new instance of ExecutorBase | ||
79 | /// </summary> | ||
80 | /// <param name="Script"></param> | ||
81 | public ExecutorBase(IScript Script) | ||
82 | { | ||
83 | m_Script = Script; | ||
84 | initEventFlags(); | ||
85 | } | ||
86 | |||
87 | /// <summary> | ||
88 | /// Make sure our object does not timeout when in AppDomain. (Called by ILease base class) | ||
89 | /// </summary> | ||
90 | /// <returns></returns> | ||
91 | public override Object InitializeLifetimeService() | ||
92 | { | ||
93 | //Console.WriteLine("Executor: InitializeLifetimeService()"); | ||
94 | // return null; | ||
95 | ILease lease = (ILease)base.InitializeLifetimeService(); | ||
96 | |||
97 | if (lease.CurrentState == LeaseState.Initial) | ||
98 | { | ||
99 | lease.InitialLeaseTime = TimeSpan.Zero; // TimeSpan.FromMinutes(1); | ||
100 | // lease.SponsorshipTimeout = TimeSpan.FromMinutes(2); | ||
101 | // lease.RenewOnCallTime = TimeSpan.FromSeconds(2); | ||
102 | } | ||
103 | return lease; | ||
104 | } | ||
105 | |||
106 | /// <summary> | ||
107 | /// Get current AppDomain | ||
108 | /// </summary> | ||
109 | /// <returns>Current AppDomain</returns> | ||
110 | public AppDomain GetAppDomain() | ||
111 | { | ||
112 | return AppDomain.CurrentDomain; | ||
113 | } | ||
114 | |||
115 | /// <summary> | ||
116 | /// Execute a specific function/event in script. | ||
117 | /// </summary> | ||
118 | /// <param name="FunctionName">Name of function to execute</param> | ||
119 | /// <param name="args">Arguments to pass to function</param> | ||
120 | public void ExecuteEvent(string FunctionName, object[] args) | ||
121 | { | ||
122 | DoExecuteEvent(FunctionName, args); | ||
123 | } | ||
124 | |||
125 | protected abstract void DoExecuteEvent(string FunctionName, object[] args); | ||
126 | |||
127 | /// <summary> | ||
128 | /// Compute the events handled by the current state of the script | ||
129 | /// </summary> | ||
130 | /// <returns>state mask</returns> | ||
131 | public scriptEvents GetStateEventFlags() | ||
132 | { | ||
133 | return DoGetStateEventFlags(); | ||
134 | } | ||
135 | |||
136 | protected abstract scriptEvents DoGetStateEventFlags(); | ||
137 | |||
138 | protected void initEventFlags() | ||
139 | { | ||
140 | // Initialize the table if it hasn't already been done | ||
141 | if (m_eventFlagsMap.Count > 0) | ||
142 | { | ||
143 | return; | ||
144 | } | ||
145 | |||
146 | m_eventFlagsMap.Add("attach", scriptEvents.attach); | ||
147 | // m_eventFlagsMap.Add("at_rot_target",(long)scriptEvents.at_rot_target); | ||
148 | m_eventFlagsMap.Add("at_target", scriptEvents.at_target); | ||
149 | // m_eventFlagsMap.Add("changed",(long)scriptEvents.changed); | ||
150 | m_eventFlagsMap.Add("collision", scriptEvents.collision); | ||
151 | m_eventFlagsMap.Add("collision_end", scriptEvents.collision_end); | ||
152 | m_eventFlagsMap.Add("collision_start", scriptEvents.collision_start); | ||
153 | m_eventFlagsMap.Add("control", scriptEvents.control); | ||
154 | m_eventFlagsMap.Add("dataserver", scriptEvents.dataserver); | ||
155 | m_eventFlagsMap.Add("email", scriptEvents.email); | ||
156 | m_eventFlagsMap.Add("http_response", scriptEvents.http_response); | ||
157 | m_eventFlagsMap.Add("land_collision", scriptEvents.land_collision); | ||
158 | m_eventFlagsMap.Add("land_collision_end", scriptEvents.land_collision_end); | ||
159 | m_eventFlagsMap.Add("land_collision_start", scriptEvents.land_collision_start); | ||
160 | // m_eventFlagsMap.Add("link_message",scriptEvents.link_message); | ||
161 | m_eventFlagsMap.Add("listen", scriptEvents.listen); | ||
162 | m_eventFlagsMap.Add("money", scriptEvents.money); | ||
163 | m_eventFlagsMap.Add("moving_end", scriptEvents.moving_end); | ||
164 | m_eventFlagsMap.Add("moving_start", scriptEvents.moving_start); | ||
165 | m_eventFlagsMap.Add("not_at_rot_target", scriptEvents.not_at_rot_target); | ||
166 | m_eventFlagsMap.Add("not_at_target", scriptEvents.not_at_target); | ||
167 | // m_eventFlagsMap.Add("no_sensor",(long)scriptEvents.no_sensor); | ||
168 | // m_eventFlagsMap.Add("on_rez",(long)scriptEvents.on_rez); | ||
169 | m_eventFlagsMap.Add("remote_data", scriptEvents.remote_data); | ||
170 | m_eventFlagsMap.Add("run_time_permissions", scriptEvents.run_time_permissions); | ||
171 | // m_eventFlagsMap.Add("sensor",(long)scriptEvents.sensor); | ||
172 | m_eventFlagsMap.Add("state_entry", scriptEvents.state_entry); | ||
173 | m_eventFlagsMap.Add("state_exit", scriptEvents.state_exit); | ||
174 | m_eventFlagsMap.Add("timer", scriptEvents.timer); | ||
175 | m_eventFlagsMap.Add("touch", scriptEvents.touch); | ||
176 | m_eventFlagsMap.Add("touch_end", scriptEvents.touch_end); | ||
177 | m_eventFlagsMap.Add("touch_start", scriptEvents.touch_start); | ||
178 | m_eventFlagsMap.Add("object_rez", scriptEvents.object_rez); | ||
179 | } | ||
180 | } | ||
181 | } | ||