aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.Region/scripting/IScriptHandler.cs
diff options
context:
space:
mode:
authorMW2007-06-10 12:31:16 +0000
committerMW2007-06-10 12:31:16 +0000
commitb898914715da7559c6b32f911c5eea3150a0dfef (patch)
treed6537e179441af48b56c085d79aa663977f08b49 /OpenSim/OpenSim.Region/scripting/IScriptHandler.cs
parentMessed up the renaming of the folder, so part one of the fix (diff)
downloadopensim-SC_OLD-b898914715da7559c6b32f911c5eea3150a0dfef.zip
opensim-SC_OLD-b898914715da7559c6b32f911c5eea3150a0dfef.tar.gz
opensim-SC_OLD-b898914715da7559c6b32f911c5eea3150a0dfef.tar.bz2
opensim-SC_OLD-b898914715da7559c6b32f911c5eea3150a0dfef.tar.xz
part two of the folder renaming fix.
Diffstat (limited to 'OpenSim/OpenSim.Region/scripting/IScriptHandler.cs')
-rw-r--r--OpenSim/OpenSim.Region/scripting/IScriptHandler.cs98
1 files changed, 98 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.Region/scripting/IScriptHandler.cs b/OpenSim/OpenSim.Region/scripting/IScriptHandler.cs
new file mode 100644
index 0000000..6644649
--- /dev/null
+++ b/OpenSim/OpenSim.Region/scripting/IScriptHandler.cs
@@ -0,0 +1,98 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5using OpenSim.Physics.Manager;
6using OpenSim.Region;
7using Avatar=OpenSim.Region.Avatar;
8using Primitive = OpenSim.Region.Primitive;
9
10namespace OpenSim.Region.Scripting
11{
12 public delegate void ScriptEventHandler(IScriptContext context);
13
14 public class ScriptHandler : IScriptContext, IScriptEntity, IScriptReadonlyEntity
15 {
16 private World m_world;
17 private Script m_script;
18 private Entity m_entity;
19
20 public LLUUID ScriptId
21 {
22 get
23 {
24 return m_script.ScriptId;
25 }
26 }
27
28 public void OnFrame()
29 {
30 m_script.OnFrame(this);
31 }
32
33 public ScriptHandler(Script script, Entity entity, World world)
34 {
35 m_script = script;
36 m_entity = entity;
37 m_world = world;
38 }
39
40 #region IScriptContext Members
41
42 IScriptEntity IScriptContext.Entity
43 {
44 get
45 {
46 return this;
47 }
48 }
49
50 bool IScriptContext.TryGetRandomAvatar(out IScriptReadonlyEntity avatar)
51 {
52 foreach (Entity entity in m_world.Entities.Values )
53 {
54 if( entity is Avatar )
55 {
56 avatar = entity;
57 return true;
58 }
59 }
60
61 avatar = null;
62 return false;
63 }
64
65 #endregion
66
67 #region IScriptEntity and IScriptReadonlyEntity Members
68
69 public string Name
70 {
71 get
72 {
73 return m_entity.Name;
74 }
75 }
76
77 public LLVector3 Pos
78 {
79 get
80 {
81 return m_entity.Pos;
82 }
83
84 set
85 {
86 if (m_entity is Primitive)
87 {
88 Primitive prim = m_entity as Primitive;
89 // Of course, we really should have asked the physEngine if this is possible, and if not, returned false.
90 // prim.UpdatePosition( value );
91 }
92 }
93 }
94
95 #endregion
96 }
97
98}