diff options
author | Justin Clark-Casey (justincc) | 2013-08-20 17:43:02 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2013-08-20 17:43:02 +0100 |
commit | e384ff604e081970ae9351431115a87e82345b18 (patch) | |
tree | 964fca4ce9ba6b4298ef65d4e37fe08bc6718b31 /OpenSim | |
parent | Add pCampbot console commands to sit all bots on ground and stand all bots (diff) | |
download | opensim-SC_OLD-e384ff604e081970ae9351431115a87e82345b18.zip opensim-SC_OLD-e384ff604e081970ae9351431115a87e82345b18.tar.gz opensim-SC_OLD-e384ff604e081970ae9351431115a87e82345b18.tar.bz2 opensim-SC_OLD-e384ff604e081970ae9351431115a87e82345b18.tar.xz |
Add experimental "sit user name" and "stand user name" console commands in SitStandCommandsModule.
"sit user name" will currently only sit the given avatar on prims which have a sit target set and are not already sat upon.
Chiefly for debug purposes.
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs | 180 |
1 files changed, 180 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs b/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs new file mode 100644 index 0000000..874723c --- /dev/null +++ b/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs | |||
@@ -0,0 +1,180 @@ | |||
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 System.Collections.Generic; | ||
30 | using System.Linq; | ||
31 | using System.Reflection; | ||
32 | using System.Text; | ||
33 | using log4net; | ||
34 | using Mono.Addins; | ||
35 | using Nini.Config; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Framework.Console; | ||
39 | using OpenSim.Framework.Monitoring; | ||
40 | using OpenSim.Region.ClientStack.LindenUDP; | ||
41 | using OpenSim.Region.Framework.Interfaces; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | using OpenSim.Region.Framework.Scenes.Animation; | ||
44 | using OpenSim.Services.Interfaces; | ||
45 | |||
46 | namespace OpenSim.Region.OptionalModules.Avatar.SitStand | ||
47 | { | ||
48 | /// <summary> | ||
49 | /// A module that just holds commands for changing avatar sitting and standing states. | ||
50 | /// </summary> | ||
51 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AnimationsCommandModule")] | ||
52 | public class SitStandCommandModule : INonSharedRegionModule | ||
53 | { | ||
54 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
55 | |||
56 | private Scene m_scene; | ||
57 | |||
58 | public string Name { get { return "SitStand Command Module"; } } | ||
59 | |||
60 | public Type ReplaceableInterface { get { return null; } } | ||
61 | |||
62 | public void Initialise(IConfigSource source) | ||
63 | { | ||
64 | // m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: INITIALIZED MODULE"); | ||
65 | } | ||
66 | |||
67 | public void PostInitialise() | ||
68 | { | ||
69 | // m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: POST INITIALIZED MODULE"); | ||
70 | } | ||
71 | |||
72 | public void Close() | ||
73 | { | ||
74 | // m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: CLOSED MODULE"); | ||
75 | } | ||
76 | |||
77 | public void AddRegion(Scene scene) | ||
78 | { | ||
79 | // m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); | ||
80 | } | ||
81 | |||
82 | public void RemoveRegion(Scene scene) | ||
83 | { | ||
84 | // m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); | ||
85 | } | ||
86 | |||
87 | public void RegionLoaded(Scene scene) | ||
88 | { | ||
89 | // m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); | ||
90 | |||
91 | m_scene = scene; | ||
92 | |||
93 | scene.AddCommand( | ||
94 | "Users", this, "sit user name", | ||
95 | "sit user name <first-name> <last-name>", | ||
96 | "Sit the named user on an unoccupied object with a sit target.\n" | ||
97 | + "If there are no such objects then nothing happens", | ||
98 | HandleSitUserNameCommand); | ||
99 | |||
100 | scene.AddCommand( | ||
101 | "Users", this, "stand user name", | ||
102 | "stand user name <first-name> <last-name>", | ||
103 | "Stand the named user.", | ||
104 | HandleStandUserNameCommand); | ||
105 | } | ||
106 | |||
107 | protected void HandleSitUserNameCommand(string module, string[] cmd) | ||
108 | { | ||
109 | if (MainConsole.Instance.ConsoleScene != m_scene && MainConsole.Instance.ConsoleScene != null) | ||
110 | return; | ||
111 | |||
112 | if (cmd.Length != 5) | ||
113 | { | ||
114 | MainConsole.Instance.Output("Usage: sit user name <first-name> <last-name>"); | ||
115 | return; | ||
116 | } | ||
117 | |||
118 | string firstName = cmd[3]; | ||
119 | string lastName = cmd[4]; | ||
120 | |||
121 | ScenePresence sp = m_scene.GetScenePresence(firstName, lastName); | ||
122 | |||
123 | if (sp == null || sp.IsChildAgent) | ||
124 | return; | ||
125 | |||
126 | SceneObjectPart sitPart = null; | ||
127 | List<SceneObjectGroup> sceneObjects = m_scene.GetSceneObjectGroups(); | ||
128 | |||
129 | foreach (SceneObjectGroup sceneObject in sceneObjects) | ||
130 | { | ||
131 | foreach (SceneObjectPart part in sceneObject.Parts) | ||
132 | { | ||
133 | if (part.IsSitTargetSet && part.SitTargetAvatar == UUID.Zero) | ||
134 | { | ||
135 | sitPart = part; | ||
136 | break; | ||
137 | } | ||
138 | } | ||
139 | } | ||
140 | |||
141 | if (sitPart != null) | ||
142 | { | ||
143 | MainConsole.Instance.OutputFormat( | ||
144 | "Sitting {0} on {1} {2} in {3}", | ||
145 | sp.Name, sitPart.ParentGroup.Name, sitPart.ParentGroup.UUID, m_scene.Name); | ||
146 | |||
147 | sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, sitPart.UUID, Vector3.Zero); | ||
148 | sp.HandleAgentSit(sp.ControllingClient, sp.UUID); | ||
149 | } | ||
150 | else | ||
151 | { | ||
152 | MainConsole.Instance.OutputFormat( | ||
153 | "Could not find any unoccupied set seat on which to sit {0} in {1}", | ||
154 | sp.Name, m_scene.Name); | ||
155 | } | ||
156 | } | ||
157 | |||
158 | protected void HandleStandUserNameCommand(string module, string[] cmd) | ||
159 | { | ||
160 | if (MainConsole.Instance.ConsoleScene != m_scene && MainConsole.Instance.ConsoleScene != null) | ||
161 | return; | ||
162 | |||
163 | if (cmd.Length != 5) | ||
164 | { | ||
165 | MainConsole.Instance.Output("Usage: stand user name <first-name> <last-name>"); | ||
166 | return; | ||
167 | } | ||
168 | |||
169 | string firstName = cmd[3]; | ||
170 | string lastName = cmd[4]; | ||
171 | |||
172 | ScenePresence sp = m_scene.GetScenePresence(firstName, lastName); | ||
173 | |||
174 | if (sp == null || sp.IsChildAgent) | ||
175 | return; | ||
176 | |||
177 | sp.StandUp(); | ||
178 | } | ||
179 | } | ||
180 | } \ No newline at end of file | ||