diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Sun/SunModule.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Sun/SunModule.cs | 64 |
1 files changed, 37 insertions, 27 deletions
diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs index 9a954b8..a321c09 100644 --- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs +++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenMetaverse; | 34 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
@@ -37,6 +38,7 @@ using OpenSim.Region.Framework.Scenes; | |||
37 | 38 | ||
38 | namespace OpenSim.Region.CoreModules | 39 | namespace OpenSim.Region.CoreModules |
39 | { | 40 | { |
41 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SunModule")] | ||
40 | public class SunModule : ISunModule | 42 | public class SunModule : ISunModule |
41 | { | 43 | { |
42 | /// <summary> | 44 | /// <summary> |
@@ -267,26 +269,17 @@ namespace OpenSim.Region.CoreModules | |||
267 | return GetCurrentSunHour() + 6.0f; | 269 | return GetCurrentSunHour() + 6.0f; |
268 | } | 270 | } |
269 | 271 | ||
270 | #region IRegion Methods | 272 | #region INonSharedRegion Methods |
271 | 273 | ||
272 | // Called immediately after the module is loaded for a given region | 274 | // Called immediately after the module is loaded for a given region |
273 | // i.e. Immediately after instance creation. | 275 | // i.e. Immediately after instance creation. |
274 | public void Initialise(Scene scene, IConfigSource config) | 276 | public void Initialise(IConfigSource config) |
275 | { | 277 | { |
276 | m_scene = scene; | ||
277 | m_frame = 0; | 278 | m_frame = 0; |
278 | 279 | ||
279 | // This one puts an entry in the main help screen | 280 | // This one puts an entry in the main help screen |
280 | // m_scene.AddCommand("Regions", this, "sun", "sun", "Usage: sun [param] [value] - Get or Update Sun module paramater", null); | 281 | // m_scene.AddCommand("Regions", this, "sun", "sun", "Usage: sun [param] [value] - Get or Update Sun module paramater", null); |
281 | 282 | ||
282 | // This one enables the ability to type just "sun" without any parameters | ||
283 | // m_scene.AddCommand("Regions", this, "sun", "", "", HandleSunConsoleCommand); | ||
284 | foreach (KeyValuePair<string, string> kvp in GetParamList()) | ||
285 | { | ||
286 | string sunCommand = string.Format("sun {0}", kvp.Key); | ||
287 | m_scene.AddCommand("Regions", this, sunCommand, string.Format("{0} [<value>]", sunCommand), kvp.Value, "", HandleSunConsoleCommand); | ||
288 | } | ||
289 | |||
290 | TimeZone local = TimeZone.CurrentTimeZone; | 283 | TimeZone local = TimeZone.CurrentTimeZone; |
291 | TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks; | 284 | TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks; |
292 | m_log.DebugFormat("[SUN]: localtime offset is {0}", TicksUTCOffset); | 285 | m_log.DebugFormat("[SUN]: localtime offset is {0}", TicksUTCOffset); |
@@ -358,15 +351,6 @@ namespace OpenSim.Region.CoreModules | |||
358 | HorizonShift = m_HorizonShift; // Z axis translation | 351 | HorizonShift = m_HorizonShift; // Z axis translation |
359 | // HoursToRadians = (SunCycle/24)*VWTimeRatio; | 352 | // HoursToRadians = (SunCycle/24)*VWTimeRatio; |
360 | 353 | ||
361 | // Insert our event handling hooks | ||
362 | |||
363 | scene.EventManager.OnFrame += SunUpdate; | ||
364 | scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; | ||
365 | scene.EventManager.OnEstateToolsSunUpdate += EstateToolsSunUpdate; | ||
366 | scene.EventManager.OnGetCurrentTimeAsLindenSunHour += GetCurrentTimeAsLindenSunHour; | ||
367 | |||
368 | ready = true; | ||
369 | |||
370 | m_log.Debug("[SUN]: Mode is " + m_RegionMode); | 354 | m_log.Debug("[SUN]: Mode is " + m_RegionMode); |
371 | m_log.Debug("[SUN]: Initialization completed. Day is " + SecondsPerSunCycle + " seconds, and year is " + m_YearLengthDays + " days"); | 355 | m_log.Debug("[SUN]: Initialization completed. Day is " + SecondsPerSunCycle + " seconds, and year is " + m_YearLengthDays + " days"); |
372 | m_log.Debug("[SUN]: Axis offset is " + m_HorizonShift); | 356 | m_log.Debug("[SUN]: Axis offset is " + m_HorizonShift); |
@@ -376,14 +360,37 @@ namespace OpenSim.Region.CoreModules | |||
376 | break; | 360 | break; |
377 | } | 361 | } |
378 | 362 | ||
379 | scene.RegisterModuleInterface<ISunModule>(this); | ||
380 | } | 363 | } |
381 | 364 | ||
382 | public void PostInitialise() | 365 | public Type ReplaceableInterface |
383 | { | 366 | { |
367 | get { return null; } | ||
384 | } | 368 | } |
385 | 369 | ||
386 | public void Close() | 370 | public void AddRegion(Scene scene) |
371 | { | ||
372 | m_scene = scene; | ||
373 | // Insert our event handling hooks | ||
374 | |||
375 | scene.EventManager.OnFrame += SunUpdate; | ||
376 | scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; | ||
377 | scene.EventManager.OnEstateToolsSunUpdate += EstateToolsSunUpdate; | ||
378 | scene.EventManager.OnGetCurrentTimeAsLindenSunHour += GetCurrentTimeAsLindenSunHour; | ||
379 | |||
380 | scene.RegisterModuleInterface<ISunModule>(this); | ||
381 | |||
382 | // This one enables the ability to type just "sun" without any parameters | ||
383 | // m_scene.AddCommand("Regions", this, "sun", "", "", HandleSunConsoleCommand); | ||
384 | foreach (KeyValuePair<string, string> kvp in GetParamList()) | ||
385 | { | ||
386 | string sunCommand = string.Format("sun {0}", kvp.Key); | ||
387 | m_scene.AddCommand("Regions", this, sunCommand, string.Format("{0} [<value>]", sunCommand), kvp.Value, "", HandleSunConsoleCommand); | ||
388 | } | ||
389 | |||
390 | ready = true; | ||
391 | } | ||
392 | |||
393 | public void RemoveRegion(Scene scene) | ||
387 | { | 394 | { |
388 | ready = false; | 395 | ready = false; |
389 | 396 | ||
@@ -394,14 +401,17 @@ namespace OpenSim.Region.CoreModules | |||
394 | m_scene.EventManager.OnGetCurrentTimeAsLindenSunHour -= GetCurrentTimeAsLindenSunHour; | 401 | m_scene.EventManager.OnGetCurrentTimeAsLindenSunHour -= GetCurrentTimeAsLindenSunHour; |
395 | } | 402 | } |
396 | 403 | ||
397 | public string Name | 404 | public void RegionLoaded(Scene scene) |
398 | { | 405 | { |
399 | get { return "SunModule"; } | ||
400 | } | 406 | } |
401 | 407 | ||
402 | public bool IsSharedModule | 408 | public void Close() |
403 | { | 409 | { |
404 | get { return false; } | 410 | } |
411 | |||
412 | public string Name | ||
413 | { | ||
414 | get { return "SunModule"; } | ||
405 | } | 415 | } |
406 | 416 | ||
407 | #endregion | 417 | #endregion |