From 7169acc47e8bb56581bd28c3bd921ca9236ba3c3 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 3 Apr 2007 19:12:07 +0000 Subject: * 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. --- OpenSim.RegionServer/world/Entity.cs | 62 ++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 10 deletions(-) (limited to 'OpenSim.RegionServer/world/Entity.cs') 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; using System.Collections.Generic; using System.Text; using Axiom.MathLib; +using OpenSim.Physics.Manager; using OpenSim.types; using libsecondlife; +using OpenSim.RegionServer.world.scripting; namespace OpenSim.world { - public class Entity + public abstract class Entity : IScriptReadonlyEntity { public libsecondlife.LLUUID uuid; public uint localid; - public LLVector3 position; public LLVector3 velocity; public Quaternion rotation; - protected string name; protected List children; + protected string m_name; + public virtual string Name + { + get { return m_name; } + } + + private LLVector3 m_pos; + protected PhysicsActor _physActor; + protected World m_world; + + public LLVector3 Pos + { + get + { + if (this._physActor != null) + { + m_pos.X = _physActor.Position.X; + m_pos.Y = _physActor.Position.Y; + m_pos.Z = _physActor.Position.Z; + } + + return m_pos; + } + set + { + if (this._physActor != null) + { + try + { + lock (this.m_world.LockPhysicsEngine) + { + + this._physActor.Position = new PhysicsVector(value.X, value.Y, value.Z); + } + } + catch (Exception e) + { + Console.WriteLine(e.Message); + } + } + + m_pos = value; + } + } + + public Entity() { uuid = new libsecondlife.LLUUID(); localid = 0; - position = new LLVector3(); + m_pos = new LLVector3(); velocity = new LLVector3(); rotation = new Quaternion(); - name = "(basic entity)"; + m_name = "(basic entity)"; children = new List(); } + public virtual void addForces() { foreach (Entity child in children) @@ -42,11 +89,6 @@ namespace OpenSim.world } } - public virtual string getName() - { - return name; - } - public virtual Mesh getMesh() { Mesh mesh = new Mesh(); -- cgit v1.1