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