aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.RegionServer
diff options
context:
space:
mode:
authorlbsa712007-04-03 19:12:07 +0000
committerlbsa712007-04-03 19:12:07 +0000
commit7169acc47e8bb56581bd28c3bd921ca9236ba3c3 (patch)
tree4565785736fb759f0c665aac28cd88937042bdd3 /OpenSim.RegionServer
parentAnother temporary bug fix attempt, this time for the packet overflow problem,... (diff)
downloadopensim-SC-7169acc47e8bb56581bd28c3bd921ca9236ba3c3.zip
opensim-SC-7169acc47e8bb56581bd28c3bd921ca9236ba3c3.tar.gz
opensim-SC-7169acc47e8bb56581bd28c3bd921ca9236ba3c3.tar.bz2
opensim-SC-7169acc47e8bb56581bd28c3bd921ca9236ba3c3.tar.xz
* Extended Script API with GetRandomAvatar
* The script will now get a IScriptEntity to it's host object with get/sets * The script gets a IScriptReadnlyEntity interface to entities other than the host object. * the test script now follows a random avatar.
Diffstat (limited to 'OpenSim.RegionServer')
-rw-r--r--OpenSim.RegionServer/CAPS/AdminWebFront.cs21
-rw-r--r--OpenSim.RegionServer/OpenSim.RegionServer.csproj3
-rw-r--r--OpenSim.RegionServer/OpenSim.RegionServer.dll.build1
-rw-r--r--OpenSim.RegionServer/world/Avatar.cs25
-rw-r--r--OpenSim.RegionServer/world/Entity.cs62
-rw-r--r--OpenSim.RegionServer/world/Primitive.cs23
-rw-r--r--OpenSim.RegionServer/world/World.cs6
-rw-r--r--OpenSim.RegionServer/world/scripting/IScriptContext.cs4
-rw-r--r--OpenSim.RegionServer/world/scripting/IScriptEntity.cs19
-rw-r--r--OpenSim.RegionServer/world/scripting/IScriptHandler.cs66
-rw-r--r--OpenSim.RegionServer/world/scripting/Script.cs3
11 files changed, 159 insertions, 74 deletions
diff --git a/OpenSim.RegionServer/CAPS/AdminWebFront.cs b/OpenSim.RegionServer/CAPS/AdminWebFront.cs
index 43996d0..0d03a57 100644
--- a/OpenSim.RegionServer/CAPS/AdminWebFront.cs
+++ b/OpenSim.RegionServer/CAPS/AdminWebFront.cs
@@ -9,6 +9,7 @@ using OpenSim.Assets;
9using OpenSim.Framework.Inventory; 9using OpenSim.Framework.Inventory;
10using libsecondlife; 10using libsecondlife;
11using OpenSim.RegionServer.world.scripting; 11using OpenSim.RegionServer.world.scripting;
12using Avatar=libsecondlife.Avatar;
12 13
13namespace OpenSim.CAPS 14namespace OpenSim.CAPS
14{ 15{
@@ -141,8 +142,6 @@ namespace OpenSim.CAPS
141 142
142 private class TestScript : Script 143 private class TestScript : Script
143 { 144 {
144 int toggle = 0;
145
146 public TestScript() 145 public TestScript()
147 : base(LLUUID.Random()) 146 : base(LLUUID.Random())
148 { 147 {
@@ -151,13 +150,21 @@ namespace OpenSim.CAPS
151 150
152 private void MyOnFrame(IScriptContext context) 151 private void MyOnFrame(IScriptContext context)
153 { 152 {
154 toggle = 2 - toggle; 153 LLVector3 pos = context.Entity.Pos;
155 154
156 LLVector3 pos = context.GetPos(); 155 IScriptReadonlyEntity avatar;
156
157 if( context.TryGetRandomAvatar( out avatar ) )
158 {
159 LLVector3 avatarPos = avatar.Pos;
157 160
158 pos.X += (toggle - 1); 161 float x = pos.X + ((float)avatarPos.X.CompareTo(pos.X))/2;
162 float y = pos.Y + ((float)avatarPos.Y.CompareTo(pos.Y))/2;
159 163
160 context.MoveTo(pos); 164 LLVector3 newPos = new LLVector3( x, y, pos.Z );
165
166 context.Entity.Pos = newPos;
167 }
161 } 168 }
162 } 169 }
163 170
@@ -194,7 +201,7 @@ namespace OpenSim.CAPS
194 foreach (Entity entity in m_world.Entities.Values) 201 foreach (Entity entity in m_world.Entities.Values)
195 { 202 {
196 string testScriptLink = "javascript:loadXMLDoc('Admin/AddTestScript/" + entity.uuid.ToString() + "');"; 203 string testScriptLink = "javascript:loadXMLDoc('Admin/AddTestScript/" + entity.uuid.ToString() + "');";
197 responseString += String.Format( "<li>[{0}] \"{1}\" @ {2} <a href=\"{3}\">add test script</a></li>", entity.uuid, entity.getName(), entity.position, testScriptLink ); 204 responseString += String.Format( "<li>[{0}] \"{1}\" @ {2} <a href=\"{3}\">add test script</a></li>", entity.uuid, entity.Name, entity.Pos, testScriptLink );
198 } 205 }
199 responseString += "</ul>"; 206 responseString += "</ul>";
200 return responseString; 207 return responseString;
diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.csproj b/OpenSim.RegionServer/OpenSim.RegionServer.csproj
index 73b627e..165b123 100644
--- a/OpenSim.RegionServer/OpenSim.RegionServer.csproj
+++ b/OpenSim.RegionServer/OpenSim.RegionServer.csproj
@@ -187,6 +187,9 @@
187 <Compile Include="world\scripting\IScriptContext.cs"> 187 <Compile Include="world\scripting\IScriptContext.cs">
188 <SubType>Code</SubType> 188 <SubType>Code</SubType>
189 </Compile> 189 </Compile>
190 <Compile Include="world\scripting\IScriptEntity.cs">
191 <SubType>Code</SubType>
192 </Compile>
190 <Compile Include="world\scripting\IScriptHandler.cs"> 193 <Compile Include="world\scripting\IScriptHandler.cs">
191 <SubType>Code</SubType> 194 <SubType>Code</SubType>
192 </Compile> 195 </Compile>
diff --git a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build
index bee15fd..47a983b 100644
--- a/OpenSim.RegionServer/OpenSim.RegionServer.dll.build
+++ b/OpenSim.RegionServer/OpenSim.RegionServer.dll.build
@@ -36,6 +36,7 @@
36 <include name="world/World.cs" /> 36 <include name="world/World.cs" />
37 <include name="world/scripting/IScript.cs" /> 37 <include name="world/scripting/IScript.cs" />
38 <include name="world/scripting/IScriptContext.cs" /> 38 <include name="world/scripting/IScriptContext.cs" />
39 <include name="world/scripting/IScriptEntity.cs" />
39 <include name="world/scripting/IScriptHandler.cs" /> 40 <include name="world/scripting/IScriptHandler.cs" />
40 <include name="world/scripting/Script.cs" /> 41 <include name="world/scripting/Script.cs" />
41 </sources> 42 </sources>
diff --git a/OpenSim.RegionServer/world/Avatar.cs b/OpenSim.RegionServer/world/Avatar.cs
index e1e314a..be47eda 100644
--- a/OpenSim.RegionServer/world/Avatar.cs
+++ b/OpenSim.RegionServer/world/Avatar.cs
@@ -19,7 +19,6 @@ namespace OpenSim.world
19 public SimClient ControllingClient; 19 public SimClient ControllingClient;
20 public LLUUID current_anim; 20 public LLUUID current_anim;
21 public int anim_seq; 21 public int anim_seq;
22 private PhysicsActor _physActor;
23 private static libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate; 22 private static libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock AvatarTemplate;
24 private bool updateflag = false; 23 private bool updateflag = false;
25 private byte movementflag = 0; 24 private byte movementflag = 0;
@@ -30,7 +29,6 @@ namespace OpenSim.world
30 private byte[] visualParams; 29 private byte[] visualParams;
31 private AvatarWearable[] Wearables; 30 private AvatarWearable[] Wearables;
32 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); 31 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
33 private World m_world;
34 private ulong m_regionHandle; 32 private ulong m_regionHandle;
35 private Dictionary<uint, SimClient> m_clientThreads; 33 private Dictionary<uint, SimClient> m_clientThreads;
36 private string m_regionName; 34 private string m_regionName;
@@ -45,8 +43,7 @@ namespace OpenSim.world
45 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)"); 43 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)");
46 ControllingClient = TheClient; 44 ControllingClient = TheClient;
47 localid = 8880000 + (this.m_world._localNumber++); 45 localid = 8880000 + (this.m_world._localNumber++);
48 position = new LLVector3(100.0f, 100.0f, 30.0f); 46 Pos = new LLVector3(100.0f, 100.0f, m_world.LandMap[(int)Pos.Y * 256 + (int)Pos.X] + 1);
49 position.Z = m_world.LandMap[(int)position.Y * 256 + (int)position.X] + 1;
50 visualParams = new byte[218]; 47 visualParams = new byte[218];
51 for (int i = 0; i < 218; i++) 48 for (int i = 0; i < 218; i++)
52 { 49 {
@@ -209,7 +206,7 @@ namespace OpenSim.world
209 this.uuid = objupdate.ObjectData[0].FullID = ControllingClient.AgentID; 206 this.uuid = objupdate.ObjectData[0].FullID = ControllingClient.AgentID;
210 objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0"); 207 objupdate.ObjectData[0].NameValue = _enc.GetBytes("FirstName STRING RW SV " + firstname + "\nLastName STRING RW SV " + lastname + " \0");
211 208
212 libsecondlife.LLVector3 pos2 = new LLVector3((float)this.position.X, (float)this.position.Y, (float)this.position.Z); 209 libsecondlife.LLVector3 pos2 = new LLVector3((float)this.Pos.X, (float)this.Pos.Y, (float)this.Pos.Z);
213 210
214 byte[] pb = pos2.GetBytes(); 211 byte[] pb = pos2.GetBytes();
215 212
@@ -614,23 +611,7 @@ namespace OpenSim.world
614 611
615 public override void LandRenegerated() 612 public override void LandRenegerated()
616 { 613 {
617 position = new LLVector3(100.0f, 100.0f, 30.0f); 614 Pos = new LLVector3(100.0f, 100.0f, this.m_world.LandMap[(int)Pos.Y * 256 + (int)Pos.X] + 50);
618 position.Z = this.m_world.LandMap[(int)position.Y * 256 + (int)position.X] + 50;
619 if (this._physActor != null)
620 {
621 try
622 {
623 lock (this.m_world.LockPhysicsEngine)
624 {
625
626 this._physActor.Position = new PhysicsVector(position.X, position.Y, position.Z);
627 }
628 }
629 catch (Exception e)
630 {
631 Console.WriteLine(e.Message);
632 }
633 }
634 } 615 }
635 } 616 }
636 617
diff --git a/OpenSim.RegionServer/world/Entity.cs b/OpenSim.RegionServer/world/Entity.cs
index 567c0b7..424d395 100644
--- a/OpenSim.RegionServer/world/Entity.cs
+++ b/OpenSim.RegionServer/world/Entity.cs
@@ -2,31 +2,78 @@ using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using Axiom.MathLib; 4using Axiom.MathLib;
5using OpenSim.Physics.Manager;
5using OpenSim.types; 6using OpenSim.types;
6using libsecondlife; 7using libsecondlife;
8using OpenSim.RegionServer.world.scripting;
7 9
8namespace OpenSim.world 10namespace OpenSim.world
9{ 11{
10 public class Entity 12 public abstract class Entity : IScriptReadonlyEntity
11 { 13 {
12 public libsecondlife.LLUUID uuid; 14 public libsecondlife.LLUUID uuid;
13 public uint localid; 15 public uint localid;
14 public LLVector3 position;
15 public LLVector3 velocity; 16 public LLVector3 velocity;
16 public Quaternion rotation; 17 public Quaternion rotation;
17 protected string name;
18 protected List<Entity> children; 18 protected List<Entity> children;
19 19
20 protected string m_name;
21 public virtual string Name
22 {
23 get { return m_name; }
24 }
25
26 private LLVector3 m_pos;
27 protected PhysicsActor _physActor;
28 protected World m_world;
29
30 public LLVector3 Pos
31 {
32 get
33 {
34 if (this._physActor != null)
35 {
36 m_pos.X = _physActor.Position.X;
37 m_pos.Y = _physActor.Position.Y;
38 m_pos.Z = _physActor.Position.Z;
39 }
40
41 return m_pos;
42 }
43 set
44 {
45 if (this._physActor != null)
46 {
47 try
48 {
49 lock (this.m_world.LockPhysicsEngine)
50 {
51
52 this._physActor.Position = new PhysicsVector(value.X, value.Y, value.Z);
53 }
54 }
55 catch (Exception e)
56 {
57 Console.WriteLine(e.Message);
58 }
59 }
60
61 m_pos = value;
62 }
63 }
64
65
20 public Entity() 66 public Entity()
21 { 67 {
22 uuid = new libsecondlife.LLUUID(); 68 uuid = new libsecondlife.LLUUID();
23 localid = 0; 69 localid = 0;
24 position = new LLVector3(); 70 m_pos = new LLVector3();
25 velocity = new LLVector3(); 71 velocity = new LLVector3();
26 rotation = new Quaternion(); 72 rotation = new Quaternion();
27 name = "(basic entity)"; 73 m_name = "(basic entity)";
28 children = new List<Entity>(); 74 children = new List<Entity>();
29 } 75 }
76
30 public virtual void addForces() 77 public virtual void addForces()
31 { 78 {
32 foreach (Entity child in children) 79 foreach (Entity child in children)
@@ -42,11 +89,6 @@ namespace OpenSim.world
42 } 89 }
43 } 90 }
44 91
45 public virtual string getName()
46 {
47 return name;
48 }
49
50 public virtual Mesh getMesh() 92 public virtual Mesh getMesh()
51 { 93 {
52 Mesh mesh = new Mesh(); 94 Mesh mesh = new Mesh();
diff --git a/OpenSim.RegionServer/world/Primitive.cs b/OpenSim.RegionServer/world/Primitive.cs
index 156bbfb..8ff66f9 100644
--- a/OpenSim.RegionServer/world/Primitive.cs
+++ b/OpenSim.RegionServer/world/Primitive.cs
@@ -19,13 +19,11 @@ namespace OpenSim.world
19 protected bool updateFlag = false; 19 protected bool updateFlag = false;
20 protected bool dirtyFlag = false; 20 protected bool dirtyFlag = false;
21 private ObjectUpdatePacket OurPacket; 21 private ObjectUpdatePacket OurPacket;
22 private PhysicsActor _physActor;
23 private bool physicsEnabled = false; 22 private bool physicsEnabled = false;
24 private bool physicstest = false; 23 private bool physicstest = false;
25 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0); 24 private LLVector3 positionLastFrame = new LLVector3(0, 0, 0);
26 private Dictionary<uint, SimClient> m_clientThreads; 25 private Dictionary<uint, SimClient> m_clientThreads;
27 private ulong m_regionHandle; 26 private ulong m_regionHandle;
28 private World m_world;
29 private const uint FULL_MASK_PERMISSIONS = 2147483647; 27 private const uint FULL_MASK_PERMISSIONS = 2147483647;
30 28
31 public bool PhysicsEnabled 29 public bool PhysicsEnabled
@@ -130,7 +128,7 @@ namespace OpenSim.world
130 128
131 public void UpdatePosition(LLVector3 pos) 129 public void UpdatePosition(LLVector3 pos)
132 { 130 {
133 this.position = pos; 131 this.Pos = pos;
134 if (this._physActor != null) // && this.physicsEnabled) 132 if (this._physActor != null) // && this.physicsEnabled)
135 { 133 {
136 try 134 try
@@ -208,7 +206,7 @@ namespace OpenSim.world
208 206
209 if (this.physicstest) 207 if (this.physicstest)
210 { 208 {
211 LLVector3 pos = this.position; 209 LLVector3 pos = this.Pos;
212 pos.Z += 0.0001f; 210 pos.Z += 0.0001f;
213 this.UpdatePosition(pos); 211 this.UpdatePosition(pos);
214 this.physicstest = false; 212 this.physicstest = false;
@@ -226,7 +224,7 @@ namespace OpenSim.world
226 } 224 }
227 else 225 else
228 { 226 {
229 lPos = this.position; 227 lPos = this.Pos;
230 } 228 }
231 byte[] pb = lPos.GetBytes(); 229 byte[] pb = lPos.GetBytes();
232 Array.Copy(pb, 0, OurPacket.ObjectData[0].ObjectData, 0, pb.Length); 230 Array.Copy(pb, 0, OurPacket.ObjectData[0].ObjectData, 0, pb.Length);
@@ -300,7 +298,7 @@ namespace OpenSim.world
300 this.physicsEnabled = pack.AgentData.UsePhysics; 298 this.physicsEnabled = pack.AgentData.UsePhysics;
301 if (this._physActor.Kinematic == false) 299 if (this._physActor.Kinematic == false)
302 { 300 {
303 LLVector3 pos = this.position; 301 LLVector3 pos = this.Pos;
304 this.UpdatePosition(pos); 302 this.UpdatePosition(pos);
305 pos.Z += 0.000001f; 303 pos.Z += 0.000001f;
306 this.UpdatePosition(pos); 304 this.UpdatePosition(pos);
@@ -310,7 +308,7 @@ namespace OpenSim.world
310 { 308 {
311 PhysicsVector vec = this._physActor.Position; 309 PhysicsVector vec = this._physActor.Position;
312 LLVector3 pos = new LLVector3(vec.X, vec.Y, vec.Z); 310 LLVector3 pos = new LLVector3(vec.X, vec.Y, vec.Z);
313 this.position = pos; 311 this.Pos = pos;
314 this.updateFlag = true; 312 this.updateFlag = true;
315 } 313 }
316 } 314 }
@@ -319,7 +317,7 @@ namespace OpenSim.world
319 public void MakeParent(Primitive prim) 317 public void MakeParent(Primitive prim)
320 { 318 {
321 this.primData.ParentID = prim.localid; 319 this.primData.ParentID = prim.localid;
322 this.position -= prim.position; 320 this.Pos -= prim.Pos;
323 this.dirtyFlag = true; 321 this.dirtyFlag = true;
324 } 322 }
325 323
@@ -385,7 +383,7 @@ namespace OpenSim.world
385 this.newPrimFlag = true; 383 this.newPrimFlag = true;
386 this.primData.FullID = this.uuid = objupdate.ObjectData[0].FullID; 384 this.primData.FullID = this.uuid = objupdate.ObjectData[0].FullID;
387 this.localid = objupdate.ObjectData[0].ID; 385 this.localid = objupdate.ObjectData[0].ID;
388 this.primData.Position = this.position = pos1; 386 this.primData.Position = this.Pos = pos1;
389 this.OurPacket = objupdate; 387 this.OurPacket = objupdate;
390 } 388 }
391 389
@@ -466,7 +464,7 @@ namespace OpenSim.world
466 464
467 this.uuid = objupdate.ObjectData[0].FullID; 465 this.uuid = objupdate.ObjectData[0].FullID;
468 this.localid = objupdate.ObjectData[0].ID; 466 this.localid = objupdate.ObjectData[0].ID;
469 this.position = pos1; 467 this.Pos = pos1;
470 this.OurPacket = objupdate; 468 this.OurPacket = objupdate;
471 if (newprim) 469 if (newprim)
472 { 470 {
@@ -501,7 +499,7 @@ namespace OpenSim.world
501 } 499 }
502 else 500 else
503 { 501 {
504 lPos = this.position; 502 lPos = this.Pos;
505 lRot = this.rotation; 503 lRot = this.rotation;
506 } 504 }
507 byte[] pb = lPos.GetBytes(); 505 byte[] pb = lPos.GetBytes();
@@ -557,10 +555,9 @@ namespace OpenSim.world
557 { 555 {
558 this.primData.FullID = this.uuid; 556 this.primData.FullID = this.uuid;
559 this.primData.LocalID = this.localid; 557 this.primData.LocalID = this.localid;
560 this.primData.Position = this.position; 558 this.primData.Position = this.Pos;
561 this.primData.Rotation = new LLQuaternion(this.rotation.x, this.rotation.y, this.rotation.z, this.rotation.w); 559 this.primData.Rotation = new LLQuaternion(this.rotation.x, this.rotation.y, this.rotation.z, this.rotation.w);
562 this.m_world.localStorage.StorePrim(this.primData); 560 this.m_world.localStorage.StorePrim(this.primData);
563 } 561 }
564 } 562 }
565
566} 563}
diff --git a/OpenSim.RegionServer/world/World.cs b/OpenSim.RegionServer/world/World.cs
index 408f68d..c775429 100644
--- a/OpenSim.RegionServer/world/World.cs
+++ b/OpenSim.RegionServer/world/World.cs
@@ -335,7 +335,7 @@ namespace OpenSim.world
335 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world"); 335 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Adding new avatar to world");
336 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake "); 336 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs:AddViewerAgent() - Starting RegionHandshake ");
337 NewAvatar.SendRegionHandshake(this); 337 NewAvatar.SendRegionHandshake(this);
338 PhysicsVector pVec = new PhysicsVector(NewAvatar.position.X, NewAvatar.position.Y, NewAvatar.position.Z); 338 PhysicsVector pVec = new PhysicsVector(NewAvatar.Pos.X, NewAvatar.Pos.Y, NewAvatar.Pos.Z);
339 lock (this.LockPhysicsEngine) 339 lock (this.LockPhysicsEngine)
340 { 340 {
341 NewAvatar.PhysActor = this.phyScene.AddAvatar(pVec); 341 NewAvatar.PhysActor = this.phyScene.AddAvatar(pVec);
@@ -348,7 +348,7 @@ namespace OpenSim.world
348 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: AddNewPrim() - Creating new prim"); 348 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("World.cs: AddNewPrim() - Creating new prim");
349 Primitive prim = new Primitive(m_clientThreads, m_regionHandle, this); 349 Primitive prim = new Primitive(m_clientThreads, m_regionHandle, this);
350 prim.CreateFromPacket(addPacket, AgentClient.AgentID, this._primCount); 350 prim.CreateFromPacket(addPacket, AgentClient.AgentID, this._primCount);
351 PhysicsVector pVec = new PhysicsVector(prim.position.X, prim.position.Y, prim.position.Z); 351 PhysicsVector pVec = new PhysicsVector(prim.Pos.X, prim.Pos.Y, prim.Pos.Z);
352 PhysicsVector pSize = new PhysicsVector(0.255f, 0.255f, 0.255f); 352 PhysicsVector pSize = new PhysicsVector(0.255f, 0.255f, 0.255f);
353 if (OpenSim.world.Avatar.PhysicsEngineFlying) 353 if (OpenSim.world.Avatar.PhysicsEngineFlying)
354 { 354 {
@@ -521,7 +521,7 @@ namespace OpenSim.world
521 reply.ChatData.Message = inchatpack.ChatData.Message; 521 reply.ChatData.Message = inchatpack.ChatData.Message;
522 reply.ChatData.ChatType = 1; 522 reply.ChatData.ChatType = 1;
523 reply.ChatData.SourceType = 1; 523 reply.ChatData.SourceType = 1;
524 reply.ChatData.Position = simClient.ClientAvatar.position; 524 reply.ChatData.Position = simClient.ClientAvatar.Pos;
525 reply.ChatData.FromName = enc.GetBytes(simClient.ClientAvatar.firstname + " " + simClient.ClientAvatar.lastname + "\0"); 525 reply.ChatData.FromName = enc.GetBytes(simClient.ClientAvatar.firstname + " " + simClient.ClientAvatar.lastname + "\0");
526 reply.ChatData.OwnerID = simClient.AgentID; 526 reply.ChatData.OwnerID = simClient.AgentID;
527 reply.ChatData.SourceID = simClient.AgentID; 527 reply.ChatData.SourceID = simClient.AgentID;
diff --git a/OpenSim.RegionServer/world/scripting/IScriptContext.cs b/OpenSim.RegionServer/world/scripting/IScriptContext.cs
index 80878ef..465c23b 100644
--- a/OpenSim.RegionServer/world/scripting/IScriptContext.cs
+++ b/OpenSim.RegionServer/world/scripting/IScriptContext.cs
@@ -7,7 +7,7 @@ namespace OpenSim.RegionServer.world.scripting
7{ 7{
8 public interface IScriptContext 8 public interface IScriptContext
9 { 9 {
10 bool MoveTo(LLVector3 newPos); 10 IScriptEntity Entity { get; }
11 LLVector3 GetPos(); 11 bool TryGetRandomAvatar(out IScriptReadonlyEntity avatar);
12 } 12 }
13} 13}
diff --git a/OpenSim.RegionServer/world/scripting/IScriptEntity.cs b/OpenSim.RegionServer/world/scripting/IScriptEntity.cs
new file mode 100644
index 0000000..2ef16a4
--- /dev/null
+++ b/OpenSim.RegionServer/world/scripting/IScriptEntity.cs
@@ -0,0 +1,19 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using libsecondlife;
5
6namespace OpenSim.RegionServer.world.scripting
7{
8 public interface IScriptReadonlyEntity
9 {
10 LLVector3 Pos { get; }
11 string Name { get; }
12 }
13
14 public interface IScriptEntity
15 {
16 LLVector3 Pos { get; set; }
17 string Name { get; }
18 }
19}
diff --git a/OpenSim.RegionServer/world/scripting/IScriptHandler.cs b/OpenSim.RegionServer/world/scripting/IScriptHandler.cs
index 5addb35..15efc49 100644
--- a/OpenSim.RegionServer/world/scripting/IScriptHandler.cs
+++ b/OpenSim.RegionServer/world/scripting/IScriptHandler.cs
@@ -4,18 +4,19 @@ using System.Text;
4using libsecondlife; 4using libsecondlife;
5using OpenSim.Physics.Manager; 5using OpenSim.Physics.Manager;
6using OpenSim.world; 6using OpenSim.world;
7using Primitive=OpenSim.world.Primitive; 7using Avatar=OpenSim.world.Avatar;
8using Primitive = OpenSim.world.Primitive;
8 9
9namespace OpenSim.RegionServer.world.scripting 10namespace OpenSim.RegionServer.world.scripting
10{ 11{
11 public delegate void ScriptEventHandler( IScriptContext context ); 12 public delegate void ScriptEventHandler(IScriptContext context);
12 13
13 public class ScriptHandler : IScriptContext 14 public class ScriptHandler : IScriptContext, IScriptEntity, IScriptReadonlyEntity
14 { 15 {
15 private World m_world; 16 private World m_world;
16 private Script m_script; 17 private Script m_script;
17 private Entity m_entity; 18 private Entity m_entity;
18 19
19 public LLUUID ScriptId 20 public LLUUID ScriptId
20 { 21 {
21 get 22 get
@@ -23,13 +24,13 @@ namespace OpenSim.RegionServer.world.scripting
23 return m_script.ScriptId; 24 return m_script.ScriptId;
24 } 25 }
25 } 26 }
26 27
27 public void OnFrame() 28 public void OnFrame()
28 { 29 {
29 m_script.OnFrame(this); 30 m_script.OnFrame(this);
30 } 31 }
31 32
32 public ScriptHandler( Script script, Entity entity, World world ) 33 public ScriptHandler(Script script, Entity entity, World world)
33 { 34 {
34 m_script = script; 35 m_script = script;
35 m_entity = entity; 36 m_entity = entity;
@@ -38,22 +39,57 @@ namespace OpenSim.RegionServer.world.scripting
38 39
39 #region IScriptContext Members 40 #region IScriptContext Members
40 41
41 bool IScriptContext.MoveTo(LLVector3 newPos) 42 IScriptEntity IScriptContext.Entity
43 {
44 get
45 {
46 return this;
47 }
48 }
49
50 bool IScriptContext.TryGetRandomAvatar(out IScriptReadonlyEntity avatar)
42 { 51 {
43 if (m_entity is Primitive) 52 foreach (Entity entity in m_world.Entities.Values )
44 { 53 {
45 Primitive prim = m_entity as Primitive; 54 if( entity is Avatar )
46 // Of course, we really should have asked the physEngine if this is possible, and if not, returned false. 55 {
47 prim.UpdatePosition( newPos ); 56 avatar = entity;
48 return true; 57 return true;
58 }
49 } 59 }
50 60
61 avatar = null;
51 return false; 62 return false;
52 } 63 }
53 64
54 LLVector3 IScriptContext.GetPos() 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
55 { 78 {
56 return m_entity.position; 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 }
57 } 93 }
58 94
59 #endregion 95 #endregion
diff --git a/OpenSim.RegionServer/world/scripting/Script.cs b/OpenSim.RegionServer/world/scripting/Script.cs
index 3997b41..48c18ff 100644
--- a/OpenSim.RegionServer/world/scripting/Script.cs
+++ b/OpenSim.RegionServer/world/scripting/Script.cs
@@ -7,8 +7,7 @@ namespace OpenSim.RegionServer.world.scripting
7{ 7{
8 public class Script 8 public class Script
9 { 9 {
10 private LLUUID m_scriptId; 10 private LLUUID m_scriptId;
11
12 public virtual LLUUID ScriptId 11 public virtual LLUUID ScriptId
13 { 12 {
14 get 13 get