diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs')
-rw-r--r-- | OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs | 264 |
1 files changed, 132 insertions, 132 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs index ad7182e..832050e 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/ObjectAccessor.cs | |||
@@ -1,132 +1,132 @@ | |||
1 | using System; | 1 | using System; |
2 | using System.Collections; | 2 | using System.Collections; |
3 | using System.Collections.Generic; | 3 | using System.Collections.Generic; |
4 | using OpenMetaverse; | 4 | using OpenMetaverse; |
5 | using OpenSim.Region.Framework.Scenes; | 5 | using OpenSim.Region.Framework.Scenes; |
6 | using IEnumerable=System.Collections.IEnumerable; | 6 | using IEnumerable=System.Collections.IEnumerable; |
7 | 7 | ||
8 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | 8 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule |
9 | { | 9 | { |
10 | 10 | ||
11 | internal class IObjEnum : IEnumerator<IObject> | 11 | internal class IObjEnum : IEnumerator<IObject> |
12 | { | 12 | { |
13 | private readonly Scene m_scene; | 13 | private readonly Scene m_scene; |
14 | private readonly IEnumerator<EntityBase> m_sogEnum; | 14 | private readonly IEnumerator<EntityBase> m_sogEnum; |
15 | 15 | ||
16 | public IObjEnum(Scene scene) | 16 | public IObjEnum(Scene scene) |
17 | { | 17 | { |
18 | m_scene = scene; | 18 | m_scene = scene; |
19 | m_sogEnum = m_scene.Entities.GetAllByType<SceneObjectGroup>().GetEnumerator(); | 19 | m_sogEnum = m_scene.Entities.GetAllByType<SceneObjectGroup>().GetEnumerator(); |
20 | } | 20 | } |
21 | 21 | ||
22 | public void Dispose() | 22 | public void Dispose() |
23 | { | 23 | { |
24 | m_sogEnum.Dispose(); | 24 | m_sogEnum.Dispose(); |
25 | } | 25 | } |
26 | 26 | ||
27 | public bool MoveNext() | 27 | public bool MoveNext() |
28 | { | 28 | { |
29 | return m_sogEnum.MoveNext(); | 29 | return m_sogEnum.MoveNext(); |
30 | } | 30 | } |
31 | 31 | ||
32 | public void Reset() | 32 | public void Reset() |
33 | { | 33 | { |
34 | m_sogEnum.Reset(); | 34 | m_sogEnum.Reset(); |
35 | } | 35 | } |
36 | 36 | ||
37 | public IObject Current | 37 | public IObject Current |
38 | { | 38 | { |
39 | get | 39 | get |
40 | { | 40 | { |
41 | return new SOPObject(m_scene, m_sogEnum.Current.LocalId); | 41 | return new SOPObject(m_scene, m_sogEnum.Current.LocalId); |
42 | } | 42 | } |
43 | } | 43 | } |
44 | 44 | ||
45 | object IEnumerator.Current | 45 | object IEnumerator.Current |
46 | { | 46 | { |
47 | get { return Current; } | 47 | get { return Current; } |
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | public class ObjectAccessor : IObjectAccessor | 51 | public class ObjectAccessor : IObjectAccessor |
52 | { | 52 | { |
53 | private readonly Scene m_scene; | 53 | private readonly Scene m_scene; |
54 | 54 | ||
55 | public ObjectAccessor(Scene scene) | 55 | public ObjectAccessor(Scene scene) |
56 | { | 56 | { |
57 | m_scene = scene; | 57 | m_scene = scene; |
58 | } | 58 | } |
59 | 59 | ||
60 | public IObject this[int index] | 60 | public IObject this[int index] |
61 | { | 61 | { |
62 | get | 62 | get |
63 | { | 63 | { |
64 | return new SOPObject(m_scene, m_scene.Entities[(uint)index].LocalId); | 64 | return new SOPObject(m_scene, m_scene.Entities[(uint)index].LocalId); |
65 | } | 65 | } |
66 | } | 66 | } |
67 | 67 | ||
68 | public IObject this[uint index] | 68 | public IObject this[uint index] |
69 | { | 69 | { |
70 | get | 70 | get |
71 | { | 71 | { |
72 | return new SOPObject(m_scene, m_scene.Entities[index].LocalId); | 72 | return new SOPObject(m_scene, m_scene.Entities[index].LocalId); |
73 | } | 73 | } |
74 | } | 74 | } |
75 | 75 | ||
76 | public IObject this[UUID index] | 76 | public IObject this[UUID index] |
77 | { | 77 | { |
78 | get | 78 | get |
79 | { | 79 | { |
80 | return new SOPObject(m_scene, m_scene.Entities[index].LocalId); | 80 | return new SOPObject(m_scene, m_scene.Entities[index].LocalId); |
81 | } | 81 | } |
82 | } | 82 | } |
83 | 83 | ||
84 | public IEnumerator<IObject> GetEnumerator() | 84 | public IEnumerator<IObject> GetEnumerator() |
85 | { | 85 | { |
86 | return new IObjEnum(m_scene); | 86 | return new IObjEnum(m_scene); |
87 | } | 87 | } |
88 | 88 | ||
89 | IEnumerator IEnumerable.GetEnumerator() | 89 | IEnumerator IEnumerable.GetEnumerator() |
90 | { | 90 | { |
91 | return GetEnumerator(); | 91 | return GetEnumerator(); |
92 | } | 92 | } |
93 | 93 | ||
94 | public void Add(IObject item) | 94 | public void Add(IObject item) |
95 | { | 95 | { |
96 | throw new NotSupportedException("Collection is read-only. This is an API TODO FIX, creation of objects is presently impossible."); | 96 | throw new NotSupportedException("Collection is read-only. This is an API TODO FIX, creation of objects is presently impossible."); |
97 | } | 97 | } |
98 | 98 | ||
99 | public void Clear() | 99 | public void Clear() |
100 | { | 100 | { |
101 | throw new NotSupportedException("Collection is read-only. TODO FIX."); | 101 | throw new NotSupportedException("Collection is read-only. TODO FIX."); |
102 | } | 102 | } |
103 | 103 | ||
104 | public bool Contains(IObject item) | 104 | public bool Contains(IObject item) |
105 | { | 105 | { |
106 | return m_scene.Entities.ContainsKey(item.LocalID); | 106 | return m_scene.Entities.ContainsKey(item.LocalID); |
107 | } | 107 | } |
108 | 108 | ||
109 | public void CopyTo(IObject[] array, int arrayIndex) | 109 | public void CopyTo(IObject[] array, int arrayIndex) |
110 | { | 110 | { |
111 | for (int i = arrayIndex; i < Count + arrayIndex; i++) | 111 | for (int i = arrayIndex; i < Count + arrayIndex; i++) |
112 | { | 112 | { |
113 | array[i] = this[i - arrayIndex]; | 113 | array[i] = this[i - arrayIndex]; |
114 | } | 114 | } |
115 | } | 115 | } |
116 | 116 | ||
117 | public bool Remove(IObject item) | 117 | public bool Remove(IObject item) |
118 | { | 118 | { |
119 | throw new NotSupportedException("Collection is read-only. TODO FIX."); | 119 | throw new NotSupportedException("Collection is read-only. TODO FIX."); |
120 | } | 120 | } |
121 | 121 | ||
122 | public int Count | 122 | public int Count |
123 | { | 123 | { |
124 | get { return m_scene.Entities.Count; } | 124 | get { return m_scene.Entities.Count; } |
125 | } | 125 | } |
126 | 126 | ||
127 | public bool IsReadOnly | 127 | public bool IsReadOnly |
128 | { | 128 | { |
129 | get { return true; } | 129 | get { return true; } |
130 | } | 130 | } |
131 | } | 131 | } |
132 | } | 132 | } |