clockwerk-opensim – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 /*
2 * Copyright (c) Contributors, http://opensimulator.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 OpenSimulator 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 OpenMetaverse;
30 using OpenMetaverse.StructuredData;
31  
32 namespace OpenSim.Framework
33 {
34 /// <summary>
35 /// Information about an Animation
36 /// </summary>
37 [Serializable]
38 public class Animation
39 {
40 private UUID animID;
41  
42 /// <summary>
43 /// ID of Animation
44 /// </summary>
45 public UUID AnimID
46 {
47 get { return animID; }
48 set { animID = value; }
49 }
50  
51 private int sequenceNum;
52 public int SequenceNum
53 {
54 get { return sequenceNum; }
55 set { sequenceNum = value; }
56 }
57  
58 private UUID objectID;
59  
60 /// <summary>
61 /// Unique ID of object that is being animated
62 /// </summary>
63 public UUID ObjectID
64 {
65 get { return objectID; }
66 set { objectID = value; }
67 }
68  
69 public Animation()
70 {
71 }
72  
73 /// <summary>
74 /// Creates an Animation based on the data
75 /// </summary>
76 /// <param name="animID">UUID ID of animation</param>
77 /// <param name="sequenceNum"></param>
78 /// <param name="objectID">ID of object to be animated</param>
79 public Animation(UUID animID, int sequenceNum, UUID objectID)
80 {
81 this.animID = animID;
82 this.sequenceNum = sequenceNum;
83 this.objectID = objectID;
84 }
85  
86 /// <summary>
87 /// Animation from OSDMap from LLSD XML or LLSD json
88 /// </summary>
89 /// <param name="args"></param>
90 public Animation(OSDMap args)
91 {
92 UnpackUpdateMessage(args);
93 }
94  
95  
96 /// <summary>
97 /// Pack this object up as an OSDMap for transferring via LLSD XML or LLSD json
98 /// </summary>
99 /// <returns></returns>
100 public OSDMap PackUpdateMessage()
101 {
102 OSDMap anim = new OSDMap();
103 anim["animation"] = OSD.FromUUID(animID);
104 anim["object_id"] = OSD.FromUUID(objectID);
105 anim["seq_num"] = OSD.FromInteger(sequenceNum);
106 return anim;
107 }
108  
109 /// <summary>
110 /// Fill object with data from OSDMap
111 /// </summary>
112 /// <param name="args"></param>
113 public void UnpackUpdateMessage(OSDMap args)
114 {
115 if (args["animation"] != null)
116 animID = args["animation"].AsUUID();
117 if (args["object_id"] != null)
118 objectID = args["object_id"].AsUUID();
119 if (args["seq_num"] != null)
120 sequenceNum = args["seq_num"].AsInteger();
121 }
122  
123 public override bool Equals(object obj)
124 {
125 Animation other = obj as Animation;
126 if (other != null)
127 {
128 return (other.AnimID.Equals(this.AnimID)
129 && other.SequenceNum == this.SequenceNum
130 && other.ObjectID.Equals(this.ObjectID) );
131 }
132 return base.Equals(obj);
133 }
134  
135 public override int GetHashCode()
136 {
137 return base.GetHashCode();
138 }
139  
140 public override string ToString()
141 {
142 return "AnimID=" + AnimID.ToString()
143 + "/seq=" + SequenceNum.ToString()
144 + "/objID=" + ObjectID.ToString();
145 }
146  
147 }
148 }