aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Sun
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Sun')
-rw-r--r--OpenSim/Region/CoreModules/World/Sun/SunModule.cs96
1 files changed, 43 insertions, 53 deletions
diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
index 948c47c..0712a7f 100644
--- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs
@@ -29,7 +29,6 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using log4net; 31using log4net;
32using Mono.Addins;
33using Nini.Config; 32using Nini.Config;
34using OpenMetaverse; 33using OpenMetaverse;
35using OpenSim.Framework; 34using OpenSim.Framework;
@@ -38,7 +37,6 @@ using OpenSim.Region.Framework.Scenes;
38 37
39namespace OpenSim.Region.CoreModules 38namespace OpenSim.Region.CoreModules
40{ 39{
41 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
42 public class SunModule : ISunModule 40 public class SunModule : ISunModule
43 { 41 {
44 /// <summary> 42 /// <summary>
@@ -280,12 +278,27 @@ namespace OpenSim.Region.CoreModules
280 return GetCurrentSunHour() + 6.0f; 278 return GetCurrentSunHour() + 6.0f;
281 } 279 }
282 280
283 #region INonSharedRegionModule Methods 281 #region IRegion Methods
284 282
285 // Called immediately after the module is loaded for a given region 283 // Called immediately after the module is loaded for a given region
286 // i.e. Immediately after instance creation. 284 // i.e. Immediately after instance creation.
287 public void Initialise(IConfigSource config) 285 public void Initialise(Scene scene, IConfigSource config)
288 { 286 {
287 m_scene = scene;
288 m_frame = 0;
289
290 // This one puts an entry in the main help screen
291 m_scene.AddCommand(this, String.Empty, "sun", "Usage: sun [param] [value] - Get or Update Sun module paramater", null);
292
293 // This one enables the ability to type just "sun" without any parameters
294 m_scene.AddCommand(this, "sun", "", "", HandleSunConsoleCommand);
295 foreach (KeyValuePair<string, string> kvp in GetParamList())
296 {
297 m_scene.AddCommand(this, String.Format("sun {0}", kvp.Key), String.Format("{0} - {1}", kvp.Key, kvp.Value), "", HandleSunConsoleCommand);
298 }
299
300
301
289 TimeZone local = TimeZone.CurrentTimeZone; 302 TimeZone local = TimeZone.CurrentTimeZone;
290 TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks; 303 TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks;
291 m_log.Debug("[SUN]: localtime offset is " + TicksUTCOffset); 304 m_log.Debug("[SUN]: localtime offset is " + TicksUTCOffset);
@@ -333,43 +346,7 @@ namespace OpenSim.Region.CoreModules
333 // m_latitude = d_latitude; 346 // m_latitude = d_latitude;
334 // m_longitude = d_longitude; 347 // m_longitude = d_longitude;
335 } 348 }
336 }
337
338 public void Close()
339 {
340 ready = false;
341
342 // Remove our hooks
343 m_scene.EventManager.OnFrame -= SunUpdate;
344 m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel;
345 m_scene.EventManager.OnEstateToolsSunUpdate -= EstateToolsSunUpdate;
346 m_scene.EventManager.OnGetCurrentTimeAsLindenSunHour -= GetCurrentTimeAsLindenSunHour;
347 }
348
349 public string Name
350 {
351 get { return "SunModule"; }
352 }
353
354 public Type ReplaceableInterface
355 {
356 get { return null; }
357 }
358
359 public void AddRegion(Scene scene)
360 {
361 m_scene = scene;
362 m_frame = 0;
363
364 // This one puts an entry in the main help screen
365 m_scene.AddCommand(this, String.Empty, "sun", "Usage: sun [param] [value] - Get or Update Sun module paramater", null);
366 349
367 // This one enables the ability to type just "sun" without any parameters
368 m_scene.AddCommand(this, "sun", "", "", HandleSunConsoleCommand);
369 foreach (KeyValuePair<string, string> kvp in GetParamList())
370 {
371 m_scene.AddCommand(this, String.Format("sun {0}", kvp.Key), String.Format("{0} - {1}", kvp.Key, kvp.Value), "", HandleSunConsoleCommand);
372 }
373 switch (m_RegionMode) 350 switch (m_RegionMode)
374 { 351 {
375 case "T1": 352 case "T1":
@@ -377,8 +354,8 @@ namespace OpenSim.Region.CoreModules
377 case "SL": 354 case "SL":
378 // Time taken to complete a cycle (day and season) 355 // Time taken to complete a cycle (day and season)
379 356
380 SecondsPerSunCycle = (uint)(m_DayLengthHours * 60 * 60); 357 SecondsPerSunCycle = (uint) (m_DayLengthHours * 60 * 60);
381 SecondsPerYear = (uint)(SecondsPerSunCycle * m_YearLengthDays); 358 SecondsPerYear = (uint) (SecondsPerSunCycle*m_YearLengthDays);
382 359
383 // Ration of real-to-virtual time 360 // Ration of real-to-virtual time
384 361
@@ -387,17 +364,17 @@ namespace OpenSim.Region.CoreModules
387 // Speed of rotation needed to complete a cycle in the 364 // Speed of rotation needed to complete a cycle in the
388 // designated period (day and season) 365 // designated period (day and season)
389 366
390 SunSpeed = m_SunCycle / SecondsPerSunCycle; 367 SunSpeed = m_SunCycle/SecondsPerSunCycle;
391 SeasonSpeed = m_SeasonalCycle / SecondsPerYear; 368 SeasonSpeed = m_SeasonalCycle/SecondsPerYear;
392 369
393 // Horizon translation 370 // Horizon translation
394 371
395 HorizonShift = m_HorizonShift; // Z axis translation 372 HorizonShift = m_HorizonShift; // Z axis translation
396 // HoursToRadians = (SunCycle/24)*VWTimeRatio; 373 // HoursToRadians = (SunCycle/24)*VWTimeRatio;
397 374
398 // Insert our event handling hooks 375 // Insert our event handling hooks
399 376
400 scene.EventManager.OnFrame += SunUpdate; 377 scene.EventManager.OnFrame += SunUpdate;
401 scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; 378 scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
402 scene.EventManager.OnEstateToolsSunUpdate += EstateToolsSunUpdate; 379 scene.EventManager.OnEstateToolsSunUpdate += EstateToolsSunUpdate;
403 scene.EventManager.OnGetCurrentTimeAsLindenSunHour += GetCurrentTimeAsLindenSunHour; 380 scene.EventManager.OnGetCurrentTimeAsLindenSunHour += GetCurrentTimeAsLindenSunHour;
@@ -414,21 +391,34 @@ namespace OpenSim.Region.CoreModules
414 } 391 }
415 392
416 scene.RegisterModuleInterface<ISunModule>(this); 393 scene.RegisterModuleInterface<ISunModule>(this);
394
417 } 395 }
418 396
419 public void RegionLoaded(Scene scene) 397
398 public void PostInitialise()
420 { 399 {
421 } 400 }
422 401
423 public void RemoveRegion(Scene scene) 402 public void Close()
424 { 403 {
425 scene.RegisterModuleInterface<ISunModule>(this); 404 ready = false;
426 scene.EventManager.OnFrame -= SunUpdate; 405
427 scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel; 406 // Remove our hooks
428 scene.EventManager.OnEstateToolsSunUpdate -= EstateToolsSunUpdate; 407 m_scene.EventManager.OnFrame -= SunUpdate;
429 scene.EventManager.OnGetCurrentTimeAsLindenSunHour -= GetCurrentTimeAsLindenSunHour; 408 m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel;
409 m_scene.EventManager.OnEstateToolsSunUpdate -= EstateToolsSunUpdate;
410 m_scene.EventManager.OnGetCurrentTimeAsLindenSunHour -= GetCurrentTimeAsLindenSunHour;
411 }
412
413 public string Name
414 {
415 get { return "SunModule"; }
430 } 416 }
431 417
418 public bool IsSharedModule
419 {
420 get { return false; }
421 }
432 #endregion 422 #endregion
433 423
434 #region EventManager Events 424 #region EventManager Events