diff options
author | lbsa71 | 2007-04-03 19:12:07 +0000 |
---|---|---|
committer | lbsa71 | 2007-04-03 19:12:07 +0000 |
commit | 7169acc47e8bb56581bd28c3bd921ca9236ba3c3 (patch) | |
tree | 4565785736fb759f0c665aac28cd88937042bdd3 /OpenSim.RegionServer/world | |
parent | Another temporary bug fix attempt, this time for the packet overflow problem,... (diff) | |
download | opensim-SC_OLD-7169acc47e8bb56581bd28c3bd921ca9236ba3c3.zip opensim-SC_OLD-7169acc47e8bb56581bd28c3bd921ca9236ba3c3.tar.gz opensim-SC_OLD-7169acc47e8bb56581bd28c3bd921ca9236ba3c3.tar.bz2 opensim-SC_OLD-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/world')
-rw-r--r-- | OpenSim.RegionServer/world/Avatar.cs | 25 | ||||
-rw-r--r-- | OpenSim.RegionServer/world/Entity.cs | 62 | ||||
-rw-r--r-- | OpenSim.RegionServer/world/Primitive.cs | 23 | ||||
-rw-r--r-- | OpenSim.RegionServer/world/World.cs | 6 | ||||
-rw-r--r-- | OpenSim.RegionServer/world/scripting/IScriptContext.cs | 4 | ||||
-rw-r--r-- | OpenSim.RegionServer/world/scripting/IScriptEntity.cs | 19 | ||||
-rw-r--r-- | OpenSim.RegionServer/world/scripting/IScriptHandler.cs | 66 | ||||
-rw-r--r-- | OpenSim.RegionServer/world/scripting/Script.cs | 3 |
8 files changed, 141 insertions, 67 deletions
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; | |||
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.Text; | 3 | using System.Text; |
4 | using Axiom.MathLib; | 4 | using Axiom.MathLib; |
5 | using OpenSim.Physics.Manager; | ||
5 | using OpenSim.types; | 6 | using OpenSim.types; |
6 | using libsecondlife; | 7 | using libsecondlife; |
8 | using OpenSim.RegionServer.world.scripting; | ||
7 | 9 | ||
8 | namespace OpenSim.world | 10 | namespace 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 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using libsecondlife; | ||
5 | |||
6 | namespace 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; | |||
4 | using libsecondlife; | 4 | using libsecondlife; |
5 | using OpenSim.Physics.Manager; | 5 | using OpenSim.Physics.Manager; |
6 | using OpenSim.world; | 6 | using OpenSim.world; |
7 | using Primitive=OpenSim.world.Primitive; | 7 | using Avatar=OpenSim.world.Avatar; |
8 | using Primitive = OpenSim.world.Primitive; | ||
8 | 9 | ||
9 | namespace OpenSim.RegionServer.world.scripting | 10 | namespace 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 |