aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.RegionServer/world/Entity.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/OpenSim.RegionServer/world/Entity.cs')
-rw-r--r--OpenSim/OpenSim.RegionServer/world/Entity.cs124
1 files changed, 124 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.RegionServer/world/Entity.cs b/OpenSim/OpenSim.RegionServer/world/Entity.cs
new file mode 100644
index 0000000..96e039a
--- /dev/null
+++ b/OpenSim/OpenSim.RegionServer/world/Entity.cs
@@ -0,0 +1,124 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using Axiom.MathLib;
5using OpenSim.Physics.Manager;
6using OpenSim.types;
7using libsecondlife;
8using OpenSim.RegionServer.world.scripting;
9
10namespace OpenSim.world
11{
12 public abstract class Entity : IScriptReadonlyEntity
13 {
14 public libsecondlife.LLUUID uuid;
15 public uint localid;
16 public LLVector3 velocity;
17 public Quaternion rotation;
18 protected List<Entity> children;
19
20 protected string m_name;
21 public virtual string Name
22 {
23 get { return m_name; }
24 }
25
26 protected LLVector3 m_pos;
27 protected PhysicsActor _physActor;
28 protected World m_world;
29
30 public virtual 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 /// <summary>
66 /// Creates a new Entity (should not occur on it's own)
67 /// </summary>
68 public Entity()
69 {
70 uuid = new libsecondlife.LLUUID();
71 localid = 0;
72 m_pos = new LLVector3();
73 velocity = new LLVector3();
74 rotation = new Quaternion();
75 m_name = "(basic entity)";
76 children = new List<Entity>();
77 }
78
79 public virtual void addForces()
80 {
81 foreach (Entity child in children)
82 {
83 child.addForces();
84 }
85 }
86
87 /// <summary>
88 /// Performs any updates that need to be done at each frame. This function is overridable from it's children.
89 /// </summary>
90 public virtual void update() {
91 // Do any per-frame updates needed that are applicable to every type of entity
92 foreach (Entity child in children)
93 {
94 child.update();
95 }
96 }
97
98 /// <summary>
99 /// Returns a mesh for this object and any dependents
100 /// </summary>
101 /// <returns>The mesh of this entity tree</returns>
102 public virtual Mesh getMesh()
103 {
104 Mesh mesh = new Mesh();
105
106 foreach (Entity child in children)
107 {
108 mesh += child.getMesh();
109 }
110
111 return mesh;
112 }
113
114 public virtual void BackUp()
115 {
116
117 }
118
119 public virtual void LandRenegerated()
120 {
121
122 }
123 }
124}