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