aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.World/scripting/IScriptHandler.cs
diff options
context:
space:
mode:
authorMW2007-05-26 14:55:17 +0000
committerMW2007-05-26 14:55:17 +0000
commit06387d0344b8fa84b790a9dd910fda8a0a1128bb (patch)
treefaf19abd4c940e6c6fddf805beaee47b9b175e32 /OpenSim/OpenSim.World/scripting/IScriptHandler.cs
parentDie WebFrontEnd, Die Grid class! (diff)
downloadopensim-SC_OLD-06387d0344b8fa84b790a9dd910fda8a0a1128bb.zip
opensim-SC_OLD-06387d0344b8fa84b790a9dd910fda8a0a1128bb.tar.gz
opensim-SC_OLD-06387d0344b8fa84b790a9dd910fda8a0a1128bb.tar.bz2
opensim-SC_OLD-06387d0344b8fa84b790a9dd910fda8a0a1128bb.tar.xz
Goodbye World
Diffstat (limited to 'OpenSim/OpenSim.World/scripting/IScriptHandler.cs')
-rw-r--r--OpenSim/OpenSim.World/scripting/IScriptHandler.cs98
1 files changed, 98 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.World/scripting/IScriptHandler.cs b/OpenSim/OpenSim.World/scripting/IScriptHandler.cs
new file mode 100644
index 0000000..15efc49
--- /dev/null
+++ b/OpenSim/OpenSim.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.world;
7using Avatar=OpenSim.world.Avatar;
8using Primitive = OpenSim.world.Primitive;
9
10namespace OpenSim.RegionServer.world.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}