diff options
author | lbsa71 | 2008-03-13 19:55:18 +0000 |
---|---|---|
committer | lbsa71 | 2008-03-13 19:55:18 +0000 |
commit | 8b6d29ff2ed7dde3abef0b1defabed3960e0d959 (patch) | |
tree | 7a2eaa940d45c6f5f763889054d2570843633f16 /OpenSim/Region/Examples/SimpleModule/RegionModule.cs | |
parent | * Put back a comment I just inexplicably zapped (diff) | |
download | opensim-SC-8b6d29ff2ed7dde3abef0b1defabed3960e0d959.zip opensim-SC-8b6d29ff2ed7dde3abef0b1defabed3960e0d959.tar.gz opensim-SC-8b6d29ff2ed7dde3abef0b1defabed3960e0d959.tar.bz2 opensim-SC-8b6d29ff2ed7dde3abef0b1defabed3960e0d959.tar.xz |
* SimpleApp is dead, long live OpenSim.Region.Examples.SimpleModule
* This module more or less crashes every region in the instance if you enable it by moving it from local /bin to global /bin
* But hey, it crashes in lots of interesting ways.
Diffstat (limited to 'OpenSim/Region/Examples/SimpleModule/RegionModule.cs')
-rw-r--r-- | OpenSim/Region/Examples/SimpleModule/RegionModule.cs | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/OpenSim/Region/Examples/SimpleModule/RegionModule.cs b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs new file mode 100644 index 0000000..6accb8a --- /dev/null +++ b/OpenSim/Region/Examples/SimpleModule/RegionModule.cs | |||
@@ -0,0 +1,114 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.IO; | ||
4 | using System.Text; | ||
5 | using libsecondlife; | ||
6 | using Nini.Config; | ||
7 | using OpenSim.Framework; | ||
8 | using OpenSim.Region.Environment.Interfaces; | ||
9 | using OpenSim.Region.Environment.Scenes; | ||
10 | |||
11 | namespace OpenSim.Region.Examples.SimpleModule | ||
12 | { | ||
13 | public class RegionModule : IRegionModule | ||
14 | { | ||
15 | #region IRegionModule Members | ||
16 | |||
17 | private Scene m_scene; | ||
18 | |||
19 | |||
20 | public void Initialise(Scene scene, IConfigSource source) | ||
21 | { | ||
22 | m_scene = scene; | ||
23 | } | ||
24 | |||
25 | public void PostInitialise() | ||
26 | { | ||
27 | RegionInfo regionInfo = m_scene.RegionInfo; | ||
28 | |||
29 | LLVector3 pos = new LLVector3(110, 129, 27); | ||
30 | |||
31 | AddCpuCounter(regionInfo, pos); | ||
32 | AddComplexObjects(regionInfo, pos); | ||
33 | AddAvatars(); | ||
34 | AddFileSystemObjects(); | ||
35 | } | ||
36 | |||
37 | private void AddFileSystemObjects() | ||
38 | { | ||
39 | DirectoryInfo dirInfo = new DirectoryInfo("."); | ||
40 | |||
41 | float x = 0; | ||
42 | float z = 0; | ||
43 | |||
44 | foreach (FileInfo fileInfo in dirInfo.GetFiles()) | ||
45 | { | ||
46 | LLVector3 filePos = new LLVector3(100 + x, 129, 27 + z); | ||
47 | x = x + 2; | ||
48 | if (x > 50) | ||
49 | { | ||
50 | x = 0; | ||
51 | z = z + 2; | ||
52 | } | ||
53 | |||
54 | FileSystemObject fileObject = new FileSystemObject(m_scene, fileInfo, filePos); | ||
55 | m_scene.AddEntity(fileObject); | ||
56 | } | ||
57 | } | ||
58 | |||
59 | private void AddAvatars() | ||
60 | { | ||
61 | for (int i = 0; i < 2; i++) | ||
62 | { | ||
63 | MyNpcCharacter m_character = new MyNpcCharacter(m_scene.EventManager); | ||
64 | m_scene.AddNewClient(m_character, false); | ||
65 | } | ||
66 | |||
67 | List<ScenePresence> avatars = m_scene.GetAvatars(); | ||
68 | foreach (ScenePresence avatar in avatars) | ||
69 | { | ||
70 | avatar.AbsolutePosition = | ||
71 | new LLVector3((float)Util.RandomClass.Next(100, 200), (float)Util.RandomClass.Next(30, 200), 2); | ||
72 | } | ||
73 | } | ||
74 | |||
75 | private void AddComplexObjects(RegionInfo regionInfo, LLVector3 pos) | ||
76 | { | ||
77 | int objs = 3; | ||
78 | |||
79 | for (int i = 0; i < (objs*objs*objs); i++) | ||
80 | { | ||
81 | LLVector3 posOffset = new LLVector3((i % objs) * 4, (i % (objs*objs)) / ( objs ) * 4, (i / (objs*objs)) * 4); | ||
82 | ComplexObject complexObject = | ||
83 | new ComplexObject(m_scene, regionInfo.RegionHandle, LLUUID.Zero, m_scene.PrimIDAllocate(), | ||
84 | pos + posOffset); | ||
85 | m_scene.AddEntity(complexObject); | ||
86 | } | ||
87 | } | ||
88 | |||
89 | private void AddCpuCounter(RegionInfo regionInfo, LLVector3 pos) | ||
90 | { | ||
91 | SceneObjectGroup sceneObject = | ||
92 | new CpuCounterObject(m_scene, regionInfo.RegionHandle, LLUUID.Zero, m_scene.PrimIDAllocate(), | ||
93 | pos + new LLVector3(1f, 1f, 1f)); | ||
94 | m_scene.AddEntity(sceneObject); | ||
95 | } | ||
96 | |||
97 | public void Close() | ||
98 | { | ||
99 | m_scene = null; | ||
100 | } | ||
101 | |||
102 | public string Name | ||
103 | { | ||
104 | get { return GetType().AssemblyQualifiedName; } | ||
105 | } | ||
106 | |||
107 | public bool IsSharedModule | ||
108 | { | ||
109 | get { return false; } | ||
110 | } | ||
111 | |||
112 | #endregion | ||
113 | } | ||
114 | } | ||