aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Simulation/Scenes/Entity.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Simulation/Scenes/Entity.cs')
-rw-r--r--OpenSim/Region/Simulation/Scenes/Entity.cs194
1 files changed, 194 insertions, 0 deletions
diff --git a/OpenSim/Region/Simulation/Scenes/Entity.cs b/OpenSim/Region/Simulation/Scenes/Entity.cs
new file mode 100644
index 0000000..f8754f5
--- /dev/null
+++ b/OpenSim/Region/Simulation/Scenes/Entity.cs
@@ -0,0 +1,194 @@
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 Axiom.MathLib;
32using OpenSim.Physics.Manager;
33using libsecondlife;
34using OpenSim.Region.Scripting;
35
36namespace OpenSim.Region.Scenes
37{
38 public abstract class Entity : IScriptReadonlyEntity
39 {
40 public libsecondlife.LLUUID uuid;
41 public Quaternion rotation;
42 protected List<Entity> children;
43
44 protected PhysicsActor _physActor;
45 protected Scene m_world;
46 protected string m_name;
47
48 /// <summary>
49 ///
50 /// </summary>
51 public virtual string Name
52 {
53 get { return m_name; }
54 }
55
56 protected LLVector3 m_pos;
57 /// <summary>
58 ///
59 /// </summary>
60 public virtual LLVector3 Pos
61 {
62 get
63 {
64 if (this._physActor != null)
65 {
66 m_pos.X = _physActor.Position.X;
67 m_pos.Y = _physActor.Position.Y;
68 m_pos.Z = _physActor.Position.Z;
69 }
70
71 return m_pos;
72 }
73 set
74 {
75 if (this._physActor != null)
76 {
77 try
78 {
79 lock (this.m_world.SyncRoot)
80 {
81
82 this._physActor.Position = new PhysicsVector(value.X, value.Y, value.Z);
83 }
84 }
85 catch (Exception e)
86 {
87 Console.WriteLine(e.Message);
88 }
89 }
90
91 m_pos = value;
92 }
93 }
94
95 public LLVector3 velocity;
96
97 /// <summary>
98 ///
99 /// </summary>
100 public virtual LLVector3 Velocity
101 {
102 get
103 {
104 if (this._physActor != null)
105 {
106 velocity.X = _physActor.Velocity.X;
107 velocity.Y = _physActor.Velocity.Y;
108 velocity.Z = _physActor.Velocity.Z;
109 }
110
111 return velocity;
112 }
113 set
114 {
115 if (this._physActor != null)
116 {
117 try
118 {
119 lock (this.m_world.SyncRoot)
120 {
121
122 this._physActor.Velocity = new PhysicsVector(value.X, value.Y, value.Z);
123 }
124 }
125 catch (Exception e)
126 {
127 Console.WriteLine(e.Message);
128 }
129 }
130
131 velocity = value;
132 }
133 }
134
135 protected uint m_localId;
136
137 public uint LocalId
138 {
139 get { return m_localId; }
140 }
141
142 /// <summary>
143 /// Creates a new Entity (should not occur on it's own)
144 /// </summary>
145 public Entity()
146 {
147 uuid = new libsecondlife.LLUUID();
148
149 m_pos = new LLVector3();
150 velocity = new LLVector3();
151 rotation = new Quaternion();
152 m_name = "(basic entity)";
153 children = new List<Entity>();
154 }
155
156 /// <summary>
157 ///
158 /// </summary>
159 public virtual void updateMovement()
160 {
161 foreach (Entity child in children)
162 {
163 child.updateMovement();
164 }
165 }
166
167 /// <summary>
168 /// Performs any updates that need to be done at each frame. This function is overridable from it's children.
169 /// </summary>
170 public virtual void update() {
171 // Do any per-frame updates needed that are applicable to every type of entity
172 foreach (Entity child in children)
173 {
174 child.update();
175 }
176 }
177
178 /// <summary>
179 /// Called at a set interval to inform entities that they should back themsleves up to the DB
180 /// </summary>
181 public virtual void BackUp()
182 {
183
184 }
185
186 /// <summary>
187 /// Infoms the entity that the land (heightmap) has changed
188 /// </summary>
189 public virtual void LandRenegerated()
190 {
191
192 }
193 }
194}