diff options
author | lbsa71 | 2007-04-03 16:50:17 +0000 |
---|---|---|
committer | lbsa71 | 2007-04-03 16:50:17 +0000 |
commit | ad398971445a3aad5490ad4c3e6b7319f201bb8f (patch) | |
tree | 746655b671e158b1e578983d68eeb96976ebdf8f /OpenSim.RegionServer/world/scripting | |
parent | Limited (hacked) object linking. Note: once you have linked a set of prims to... (diff) | |
download | opensim-SC-ad398971445a3aad5490ad4c3e6b7319f201bb8f.zip opensim-SC-ad398971445a3aad5490ad4c3e6b7319f201bb8f.tar.gz opensim-SC-ad398971445a3aad5490ad4c3e6b7319f201bb8f.tar.bz2 opensim-SC-ad398971445a3aad5490ad4c3e6b7319f201bb8f.tar.xz |
* Script prototype
Diffstat (limited to '')
-rw-r--r-- | OpenSim.RegionServer/world/scripting/IScriptContext.cs | 13 | ||||
-rw-r--r-- | OpenSim.RegionServer/world/scripting/IScriptHandler.cs | 62 | ||||
-rw-r--r-- | OpenSim.RegionServer/world/scripting/Script.cs | 27 |
3 files changed, 102 insertions, 0 deletions
diff --git a/OpenSim.RegionServer/world/scripting/IScriptContext.cs b/OpenSim.RegionServer/world/scripting/IScriptContext.cs new file mode 100644 index 0000000..80878ef --- /dev/null +++ b/OpenSim.RegionServer/world/scripting/IScriptContext.cs | |||
@@ -0,0 +1,13 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using libsecondlife; | ||
5 | |||
6 | namespace OpenSim.RegionServer.world.scripting | ||
7 | { | ||
8 | public interface IScriptContext | ||
9 | { | ||
10 | bool MoveTo(LLVector3 newPos); | ||
11 | LLVector3 GetPos(); | ||
12 | } | ||
13 | } | ||
diff --git a/OpenSim.RegionServer/world/scripting/IScriptHandler.cs b/OpenSim.RegionServer/world/scripting/IScriptHandler.cs new file mode 100644 index 0000000..5addb35 --- /dev/null +++ b/OpenSim.RegionServer/world/scripting/IScriptHandler.cs | |||
@@ -0,0 +1,62 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using libsecondlife; | ||
5 | using OpenSim.Physics.Manager; | ||
6 | using OpenSim.world; | ||
7 | using Primitive=OpenSim.world.Primitive; | ||
8 | |||
9 | namespace OpenSim.RegionServer.world.scripting | ||
10 | { | ||
11 | public delegate void ScriptEventHandler( IScriptContext context ); | ||
12 | |||
13 | public class ScriptHandler : IScriptContext | ||
14 | { | ||
15 | private World m_world; | ||
16 | private Script m_script; | ||
17 | private Entity m_entity; | ||
18 | |||
19 | public LLUUID ScriptId | ||
20 | { | ||
21 | get | ||
22 | { | ||
23 | return m_script.ScriptId; | ||
24 | } | ||
25 | } | ||
26 | |||
27 | public void OnFrame() | ||
28 | { | ||
29 | m_script.OnFrame(this); | ||
30 | } | ||
31 | |||
32 | public ScriptHandler( Script script, Entity entity, World world ) | ||
33 | { | ||
34 | m_script = script; | ||
35 | m_entity = entity; | ||
36 | m_world = world; | ||
37 | } | ||
38 | |||
39 | #region IScriptContext Members | ||
40 | |||
41 | bool IScriptContext.MoveTo(LLVector3 newPos) | ||
42 | { | ||
43 | if (m_entity is Primitive) | ||
44 | { | ||
45 | Primitive prim = m_entity as Primitive; | ||
46 | // Of course, we really should have asked the physEngine if this is possible, and if not, returned false. | ||
47 | prim.UpdatePosition( newPos ); | ||
48 | return true; | ||
49 | } | ||
50 | |||
51 | return false; | ||
52 | } | ||
53 | |||
54 | LLVector3 IScriptContext.GetPos() | ||
55 | { | ||
56 | return m_entity.position; | ||
57 | } | ||
58 | |||
59 | #endregion | ||
60 | } | ||
61 | |||
62 | } | ||
diff --git a/OpenSim.RegionServer/world/scripting/Script.cs b/OpenSim.RegionServer/world/scripting/Script.cs new file mode 100644 index 0000000..3997b41 --- /dev/null +++ b/OpenSim.RegionServer/world/scripting/Script.cs | |||
@@ -0,0 +1,27 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using libsecondlife; | ||
5 | |||
6 | namespace OpenSim.RegionServer.world.scripting | ||
7 | { | ||
8 | public class Script | ||
9 | { | ||
10 | private LLUUID m_scriptId; | ||
11 | |||
12 | public virtual LLUUID ScriptId | ||
13 | { | ||
14 | get | ||
15 | { | ||
16 | return m_scriptId; | ||
17 | } | ||
18 | } | ||
19 | |||
20 | public Script( LLUUID scriptId ) | ||
21 | { | ||
22 | m_scriptId = scriptId; | ||
23 | } | ||
24 | |||
25 | public ScriptEventHandler OnFrame; | ||
26 | } | ||
27 | } | ||