aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.Region/World/Entities/Entity.cs
diff options
context:
space:
mode:
authorMW2007-06-12 14:50:08 +0000
committerMW2007-06-12 14:50:08 +0000
commita7b55fb26fad9c66df091e0787afe89e021229f1 (patch)
tree7920939c67a9275d72dc4a494032b66355d6eb9f /OpenSim/OpenSim.Region/World/Entities/Entity.cs
parentSome Work on the Primitive class (diff)
downloadopensim-SC-a7b55fb26fad9c66df091e0787afe89e021229f1.zip
opensim-SC-a7b55fb26fad9c66df091e0787afe89e021229f1.tar.gz
opensim-SC-a7b55fb26fad9c66df091e0787afe89e021229f1.tar.bz2
opensim-SC-a7b55fb26fad9c66df091e0787afe89e021229f1.tar.xz
Some rearranging of folders in OpenSim.Region
Diffstat (limited to 'OpenSim/OpenSim.Region/World/Entities/Entity.cs')
-rw-r--r--OpenSim/OpenSim.Region/World/Entities/Entity.cs165
1 files changed, 165 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.Region/World/Entities/Entity.cs b/OpenSim/OpenSim.Region/World/Entities/Entity.cs
new file mode 100644
index 0000000..1620c89
--- /dev/null
+++ b/OpenSim/OpenSim.Region/World/Entities/Entity.cs
@@ -0,0 +1,165 @@
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 OpenSim.Region.types;
34using libsecondlife;
35using OpenSim.Region.Scripting;
36
37namespace OpenSim.Region
38{
39 public abstract class Entity : IScriptReadonlyEntity
40 {
41 public libsecondlife.LLUUID uuid;
42 public uint localid;
43 public LLVector3 velocity;
44 public Quaternion rotation;
45 protected List<Entity> children;
46 protected LLVector3 m_pos;
47 protected PhysicsActor _physActor;
48 protected World m_world;
49 protected string m_name;
50
51 /// <summary>
52 ///
53 /// </summary>
54 public virtual string Name
55 {
56 get { return m_name; }
57 }
58
59 /// <summary>
60 ///
61 /// </summary>
62 public virtual LLVector3 Pos
63 {
64 get
65 {
66 if (this._physActor != null)
67 {
68 m_pos.X = _physActor.Position.X;
69 m_pos.Y = _physActor.Position.Y;
70 m_pos.Z = _physActor.Position.Z;
71 }
72
73 return m_pos;
74 }
75 set
76 {
77 if (this._physActor != null)
78 {
79 try
80 {
81 lock (this.m_world.SyncRoot)
82 {
83
84 this._physActor.Position = new PhysicsVector(value.X, value.Y, value.Z);
85 }
86 }
87 catch (Exception e)
88 {
89 Console.WriteLine(e.Message);
90 }
91 }
92
93 m_pos = value;
94 }
95 }
96
97 /// <summary>
98 /// Creates a new Entity (should not occur on it's own)
99 /// </summary>
100 public Entity()
101 {
102 uuid = new libsecondlife.LLUUID();
103 localid = 0;
104 m_pos = new LLVector3();
105 velocity = new LLVector3();
106 rotation = new Quaternion();
107 m_name = "(basic entity)";
108 children = new List<Entity>();
109 }
110
111 /// <summary>
112 ///
113 /// </summary>
114 public virtual void addForces()
115 {
116 foreach (Entity child in children)
117 {
118 child.addForces();
119 }
120 }
121
122 /// <summary>
123 /// Performs any updates that need to be done at each frame. This function is overridable from it's children.
124 /// </summary>
125 public virtual void update() {
126 // Do any per-frame updates needed that are applicable to every type of entity
127 foreach (Entity child in children)
128 {
129 child.update();
130 }
131 }
132
133 /// <summary>
134 /// Returns a mesh for this object and any dependents
135 /// </summary>
136 /// <returns>The mesh of this entity tree</returns>
137 public virtual Mesh getMesh()
138 {
139 Mesh mesh = new Mesh();
140
141 foreach (Entity child in children)
142 {
143 mesh += child.getMesh();
144 }
145
146 return mesh;
147 }
148
149 /// <summary>
150 /// Called at a set interval to inform entities that they should back themsleves up to the DB
151 /// </summary>
152 public virtual void BackUp()
153 {
154
155 }
156
157 /// <summary>
158 /// Infoms the entity that the land (heightmap) has changed
159 /// </summary>
160 public virtual void LandRenegerated()
161 {
162
163 }
164 }
165}