aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.Region/World/scripting/IScriptHandler.cs
diff options
context:
space:
mode:
authorMW2007-06-10 12:37:51 +0000
committerMW2007-06-10 12:37:51 +0000
commit96c09a66c4d6019bd9e06cba141591b0faeb4a70 (patch)
tree85ee53c10de8f6c3616899a3bdc8b8c93f28dac7 /OpenSim/OpenSim.Region/World/scripting/IScriptHandler.cs
parentpart two of the folder renaming fix. (diff)
downloadopensim-SC_OLD-96c09a66c4d6019bd9e06cba141591b0faeb4a70.zip
opensim-SC_OLD-96c09a66c4d6019bd9e06cba141591b0faeb4a70.tar.gz
opensim-SC_OLD-96c09a66c4d6019bd9e06cba141591b0faeb4a70.tar.bz2
opensim-SC_OLD-96c09a66c4d6019bd9e06cba141591b0faeb4a70.tar.xz
More rearranging.
Diffstat (limited to 'OpenSim/OpenSim.Region/World/scripting/IScriptHandler.cs')
-rw-r--r--OpenSim/OpenSim.Region/World/scripting/IScriptHandler.cs98
1 files changed, 98 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.Region/World/scripting/IScriptHandler.cs b/OpenSim/OpenSim.Region/World/scripting/IScriptHandler.cs
new file mode 100644
index 0000000..6644649
--- /dev/null
+++ b/OpenSim/OpenSim.Region/World/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}