diff options
Diffstat (limited to 'OpenSim/Framework/AnimationSet.cs')
-rw-r--r-- | OpenSim/Framework/AnimationSet.cs | 61 |
1 files changed, 26 insertions, 35 deletions
diff --git a/OpenSim/Framework/AnimationSet.cs b/OpenSim/Framework/AnimationSet.cs index c5ab634..e81d978 100644 --- a/OpenSim/Framework/AnimationSet.cs +++ b/OpenSim/Framework/AnimationSet.cs | |||
@@ -35,53 +35,44 @@ namespace OpenSim.Framework | |||
35 | 35 | ||
36 | public class AnimationSet | 36 | public class AnimationSet |
37 | { | 37 | { |
38 | private readonly int m_maxAnimations = 255; | 38 | private bool m_parseError = false; |
39 | 39 | ||
40 | public int AnimationCount { get; private set; } | 40 | public int AnimationCount { get; private set; } |
41 | private Dictionary<int, UUID> m_animations = new Dictionary<int, UUID>(); | 41 | private Dictionary<string, UUID> m_animations = new Dictionary<string, UUID>(); |
42 | 42 | public AnimationSet(Byte[] data) | |
43 | public UUID AnimationAt(int index) | ||
44 | { | ||
45 | if (m_animations.ContainsKey(index)) | ||
46 | return m_animations[index]; | ||
47 | return UUID.Zero; | ||
48 | } | ||
49 | |||
50 | public void SetAnimation(int index, UUID animation) | ||
51 | { | 43 | { |
52 | if (index < 0 || index > m_maxAnimations) | 44 | string assetData = System.Text.Encoding.ASCII.GetString(data); |
53 | return; | 45 | Console.WriteLine("--------------------"); |
54 | 46 | Console.WriteLine("AnimationSet length {0} bytes", assetData.Length); | |
55 | m_animations[index] = animation; | 47 | Console.WriteLine("Data: {0}", assetData); |
56 | } | 48 | Console.WriteLine("--------------------"); |
57 | |||
58 | public AnimationSet(Byte[] assetData) | ||
59 | { | ||
60 | if (assetData.Length < 2) | ||
61 | throw new System.ArgumentException(); | ||
62 | |||
63 | if (assetData[0] != 1) // Only version 1 is supported | ||
64 | throw new System.ArgumentException(); | ||
65 | |||
66 | AnimationCount = assetData[1]; | ||
67 | if (assetData.Length - 2 != 16 * AnimationCount) | ||
68 | throw new System.ArgumentException(); | ||
69 | |||
70 | // TODO: Read anims from blob | ||
71 | } | 49 | } |
72 | 50 | ||
73 | public Byte[] ToBytes() | 51 | public Byte[] ToBytes() |
74 | { | 52 | { |
75 | // TODO: Make blob from anims | 53 | // If there was an error parsing the input, we give back an |
76 | return new Byte[0]; | 54 | // empty set rather than the original data. |
55 | if (m_parseError) | ||
56 | { | ||
57 | string dummy = "version 1\ncount 0\n"; | ||
58 | return System.Text.Encoding.ASCII.GetBytes(dummy); | ||
59 | } | ||
60 | |||
61 | string assetData = String.Format("version 1\ncount {0}\n", m_animations.Count); | ||
62 | foreach (KeyValuePair<string, UUID> kvp in m_animations) | ||
63 | assetData += String.Format("{0} {1}\n", kvp.Key, kvp.Value.ToString()); | ||
64 | return System.Text.Encoding.ASCII.GetBytes(assetData); | ||
77 | } | 65 | } |
78 | 66 | ||
79 | public bool Validate(AnimationSetValidator val) | 67 | public bool Validate(AnimationSetValidator val) |
80 | { | 68 | { |
81 | List<int> badAnims = new List<int>(); | 69 | if (m_parseError) |
70 | return false; | ||
71 | |||
72 | List<string> badAnims = new List<string>(); | ||
82 | 73 | ||
83 | bool allOk = true; | 74 | bool allOk = true; |
84 | foreach (KeyValuePair<int, UUID> kvp in m_animations) | 75 | foreach (KeyValuePair<string, UUID> kvp in m_animations) |
85 | { | 76 | { |
86 | if (!val(kvp.Value)) | 77 | if (!val(kvp.Value)) |
87 | { | 78 | { |
@@ -90,7 +81,7 @@ namespace OpenSim.Framework | |||
90 | } | 81 | } |
91 | } | 82 | } |
92 | 83 | ||
93 | foreach (int idx in badAnims) | 84 | foreach (string idx in badAnims) |
94 | m_animations.Remove(idx); | 85 | m_animations.Remove(idx); |
95 | 86 | ||
96 | return allOk; | 87 | return allOk; |