aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.Region/Scene/scripting/IScriptHandler.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/OpenSim.Region/Scene/scripting/IScriptHandler.cs')
-rw-r--r--OpenSim/OpenSim.Region/Scene/scripting/IScriptHandler.cs125
1 files changed, 125 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.Region/Scene/scripting/IScriptHandler.cs b/OpenSim/OpenSim.Region/Scene/scripting/IScriptHandler.cs
new file mode 100644
index 0000000..f1a236f
--- /dev/null
+++ b/OpenSim/OpenSim.Region/Scene/scripting/IScriptHandler.cs
@@ -0,0 +1,125 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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*/
28using System;
29using System.Collections.Generic;
30using System.Text;
31using libsecondlife;
32using OpenSim.Physics.Manager;
33using OpenSim.Region;
34using Avatar=OpenSim.Region.Avatar;
35using Primitive = OpenSim.Region.Primitive;
36
37namespace OpenSim.Region.Scripting
38{
39 public delegate void ScriptEventHandler(IScriptContext context);
40
41 public class ScriptHandler : IScriptContext, IScriptEntity, IScriptReadonlyEntity
42 {
43 private World m_world;
44 private Script m_script;
45 private Entity m_entity;
46
47 public LLUUID ScriptId
48 {
49 get
50 {
51 return m_script.ScriptId;
52 }
53 }
54
55 public void OnFrame()
56 {
57 m_script.OnFrame(this);
58 }
59
60 public ScriptHandler(Script script, Entity entity, World world)
61 {
62 m_script = script;
63 m_entity = entity;
64 m_world = world;
65 }
66
67 #region IScriptContext Members
68
69 IScriptEntity IScriptContext.Entity
70 {
71 get
72 {
73 return this;
74 }
75 }
76
77 bool IScriptContext.TryGetRandomAvatar(out IScriptReadonlyEntity avatar)
78 {
79 foreach (Entity entity in m_world.Entities.Values )
80 {
81 if( entity is Avatar )
82 {
83 avatar = entity;
84 return true;
85 }
86 }
87
88 avatar = null;
89 return false;
90 }
91
92 #endregion
93
94 #region IScriptEntity and IScriptReadonlyEntity Members
95
96 public string Name
97 {
98 get
99 {
100 return m_entity.Name;
101 }
102 }
103
104 public LLVector3 Pos
105 {
106 get
107 {
108 return m_entity.Pos;
109 }
110
111 set
112 {
113 if (m_entity is Primitive)
114 {
115 Primitive prim = m_entity as Primitive;
116 // Of course, we really should have asked the physEngine if this is possible, and if not, returned false.
117 // prim.UpdatePosition( value );
118 }
119 }
120 }
121
122 #endregion
123 }
124
125}