diff options
author | MW | 2007-06-15 10:29:49 +0000 |
---|---|---|
committer | MW | 2007-06-15 10:29:49 +0000 |
commit | 3697408fae0a4c9b6bedf441450b3e8bc8fdcd24 (patch) | |
tree | 12e367b4f4ca2028b227c09002fd322940685fa4 /OpenSim/OpenSim.Region/Scenes/Entity.cs | |
parent | trying to clean up the namespaces. (diff) | |
download | opensim-SC_OLD-3697408fae0a4c9b6bedf441450b3e8bc8fdcd24.zip opensim-SC_OLD-3697408fae0a4c9b6bedf441450b3e8bc8fdcd24.tar.gz opensim-SC_OLD-3697408fae0a4c9b6bedf441450b3e8bc8fdcd24.tar.bz2 opensim-SC_OLD-3697408fae0a4c9b6bedf441450b3e8bc8fdcd24.tar.xz |
some more rearranging
Diffstat (limited to 'OpenSim/OpenSim.Region/Scenes/Entity.cs')
-rw-r--r-- | OpenSim/OpenSim.Region/Scenes/Entity.cs | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.Region/Scenes/Entity.cs b/OpenSim/OpenSim.Region/Scenes/Entity.cs new file mode 100644 index 0000000..d4c981a --- /dev/null +++ b/OpenSim/OpenSim.Region/Scenes/Entity.cs | |||
@@ -0,0 +1,148 @@ | |||
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 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using Axiom.MathLib; | ||
32 | using OpenSim.Physics.Manager; | ||
33 | using libsecondlife; | ||
34 | using OpenSim.Region.Scripting; | ||
35 | |||
36 | namespace OpenSim.Region.Scenes | ||
37 | { | ||
38 | public abstract class Entity : IScriptReadonlyEntity | ||
39 | { | ||
40 | public libsecondlife.LLUUID uuid; | ||
41 | public uint localid; | ||
42 | public LLVector3 velocity; | ||
43 | public Quaternion rotation; | ||
44 | protected List<Entity> children; | ||
45 | protected LLVector3 m_pos; | ||
46 | protected PhysicsActor _physActor; | ||
47 | protected Scene m_world; | ||
48 | protected string m_name; | ||
49 | |||
50 | /// <summary> | ||
51 | /// | ||
52 | /// </summary> | ||
53 | public virtual string Name | ||
54 | { | ||
55 | get { return m_name; } | ||
56 | } | ||
57 | |||
58 | /// <summary> | ||
59 | /// | ||
60 | /// </summary> | ||
61 | public virtual LLVector3 Pos | ||
62 | { | ||
63 | get | ||
64 | { | ||
65 | if (this._physActor != null) | ||
66 | { | ||
67 | m_pos.X = _physActor.Position.X; | ||
68 | m_pos.Y = _physActor.Position.Y; | ||
69 | m_pos.Z = _physActor.Position.Z; | ||
70 | } | ||
71 | |||
72 | return m_pos; | ||
73 | } | ||
74 | set | ||
75 | { | ||
76 | if (this._physActor != null) | ||
77 | { | ||
78 | try | ||
79 | { | ||
80 | lock (this.m_world.SyncRoot) | ||
81 | { | ||
82 | |||
83 | this._physActor.Position = new PhysicsVector(value.X, value.Y, value.Z); | ||
84 | } | ||
85 | } | ||
86 | catch (Exception e) | ||
87 | { | ||
88 | Console.WriteLine(e.Message); | ||
89 | } | ||
90 | } | ||
91 | |||
92 | m_pos = value; | ||
93 | } | ||
94 | } | ||
95 | |||
96 | /// <summary> | ||
97 | /// Creates a new Entity (should not occur on it's own) | ||
98 | /// </summary> | ||
99 | public Entity() | ||
100 | { | ||
101 | uuid = new libsecondlife.LLUUID(); | ||
102 | localid = 0; | ||
103 | m_pos = new LLVector3(); | ||
104 | velocity = new LLVector3(); | ||
105 | rotation = new Quaternion(); | ||
106 | m_name = "(basic entity)"; | ||
107 | children = new List<Entity>(); | ||
108 | } | ||
109 | |||
110 | /// <summary> | ||
111 | /// | ||
112 | /// </summary> | ||
113 | public virtual void addForces() | ||
114 | { | ||
115 | foreach (Entity child in children) | ||
116 | { | ||
117 | child.addForces(); | ||
118 | } | ||
119 | } | ||
120 | |||
121 | /// <summary> | ||
122 | /// Performs any updates that need to be done at each frame. This function is overridable from it's children. | ||
123 | /// </summary> | ||
124 | public virtual void update() { | ||
125 | // Do any per-frame updates needed that are applicable to every type of entity | ||
126 | foreach (Entity child in children) | ||
127 | { | ||
128 | child.update(); | ||
129 | } | ||
130 | } | ||
131 | |||
132 | /// <summary> | ||
133 | /// Called at a set interval to inform entities that they should back themsleves up to the DB | ||
134 | /// </summary> | ||
135 | public virtual void BackUp() | ||
136 | { | ||
137 | |||
138 | } | ||
139 | |||
140 | /// <summary> | ||
141 | /// Infoms the entity that the land (heightmap) has changed | ||
142 | /// </summary> | ||
143 | public virtual void LandRenegerated() | ||
144 | { | ||
145 | |||
146 | } | ||
147 | } | ||
148 | } | ||