diff options
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/AnimationSet.cs')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/AnimationSet.cs | 155 |
1 files changed, 0 insertions, 155 deletions
diff --git a/OpenSim/Region/Environment/Scenes/AnimationSet.cs b/OpenSim/Region/Environment/Scenes/AnimationSet.cs deleted file mode 100644 index df25173..0000000 --- a/OpenSim/Region/Environment/Scenes/AnimationSet.cs +++ /dev/null | |||
@@ -1,155 +0,0 @@ | |||
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 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 OpenMetaverse; | ||
31 | |||
32 | namespace OpenSim.Region.Environment.Scenes | ||
33 | { | ||
34 | public class AnimationSet | ||
35 | { | ||
36 | public static AvatarAnimations Animations = new AvatarAnimations(); | ||
37 | |||
38 | private Animation m_defaultAnimation = new Animation(); | ||
39 | private List<Animation> m_animations = new List<Animation>(); | ||
40 | |||
41 | public Animation DefaultAnimation | ||
42 | { | ||
43 | get { return m_defaultAnimation; } | ||
44 | } | ||
45 | public AnimationSet() | ||
46 | { | ||
47 | ResetDefaultAnimation(); | ||
48 | } | ||
49 | |||
50 | public bool HasAnimation(UUID animID) | ||
51 | { | ||
52 | if (m_defaultAnimation.AnimID == animID) | ||
53 | return true; | ||
54 | |||
55 | for (int i = 0; i < m_animations.Count; ++i) | ||
56 | { | ||
57 | if (m_animations[i].AnimID == animID) | ||
58 | return true; | ||
59 | } | ||
60 | |||
61 | return false; | ||
62 | } | ||
63 | |||
64 | public bool Add(UUID animID, int sequenceNum) | ||
65 | { | ||
66 | lock (m_animations) | ||
67 | { | ||
68 | if (!HasAnimation(animID)) | ||
69 | { | ||
70 | m_animations.Add(new Animation(animID, sequenceNum)); | ||
71 | return true; | ||
72 | } | ||
73 | } | ||
74 | return false; | ||
75 | } | ||
76 | |||
77 | public bool Remove(UUID animID) | ||
78 | { | ||
79 | lock (m_animations) | ||
80 | { | ||
81 | if (m_defaultAnimation.AnimID == animID) | ||
82 | { | ||
83 | ResetDefaultAnimation(); | ||
84 | } | ||
85 | else if (HasAnimation(animID)) | ||
86 | { | ||
87 | for (int i = 0; i < m_animations.Count; i++) | ||
88 | { | ||
89 | if (m_animations[i].AnimID == animID) | ||
90 | { | ||
91 | m_animations.RemoveAt(i); | ||
92 | return true; | ||
93 | } | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | return false; | ||
98 | } | ||
99 | |||
100 | public void Clear() | ||
101 | { | ||
102 | ResetDefaultAnimation(); | ||
103 | m_animations.Clear(); | ||
104 | } | ||
105 | |||
106 | /// <summary> | ||
107 | /// The default animation is reserved for "main" animations | ||
108 | /// that are mutually exclusive, e.g. flying and sitting. | ||
109 | /// </summary> | ||
110 | public bool SetDefaultAnimation(UUID animID, int sequenceNum) | ||
111 | { | ||
112 | if (m_defaultAnimation.AnimID != animID) | ||
113 | { | ||
114 | m_defaultAnimation = new Animation(animID, sequenceNum); | ||
115 | return true; | ||
116 | } | ||
117 | return false; | ||
118 | } | ||
119 | |||
120 | protected bool ResetDefaultAnimation() | ||
121 | { | ||
122 | return TrySetDefaultAnimation("STAND", 1); | ||
123 | } | ||
124 | |||
125 | /// <summary> | ||
126 | /// Set the animation as the default animation if it's known | ||
127 | /// </summary> | ||
128 | public bool TrySetDefaultAnimation(string anim, int sequenceNum) | ||
129 | { | ||
130 | if (Animations.AnimsUUID.ContainsKey(anim)) | ||
131 | { | ||
132 | return SetDefaultAnimation(Animations.AnimsUUID[anim], sequenceNum); | ||
133 | } | ||
134 | return false; | ||
135 | } | ||
136 | |||
137 | public void GetArrays(out UUID[] animIDs, out int[] sequenceNums) | ||
138 | { | ||
139 | lock (m_animations) | ||
140 | { | ||
141 | animIDs = new UUID[m_animations.Count + 1]; | ||
142 | sequenceNums = new int[m_animations.Count + 1]; | ||
143 | |||
144 | animIDs[0] = m_defaultAnimation.AnimID; | ||
145 | sequenceNums[0] = m_defaultAnimation.SequenceNum; | ||
146 | |||
147 | for (int i = 0; i < m_animations.Count; ++i) | ||
148 | { | ||
149 | animIDs[i + 1] = m_animations[i].AnimID; | ||
150 | sequenceNums[i + 1] = m_animations[i].SequenceNum; | ||
151 | } | ||
152 | } | ||
153 | } | ||
154 | } | ||
155 | } | ||