diff options
author | lbsa71 | 2007-12-27 21:41:48 +0000 |
---|---|---|
committer | lbsa71 | 2007-12-27 21:41:48 +0000 |
commit | efd90b56b761219af6425b1c7a2cdd3b6ffb4de2 (patch) | |
tree | bf5b897e1e3c13211e3e2fc61d30508b94c928c0 /OpenSim/Region/Environment/Modules/SunModule.cs | |
parent | * removed always true if (diff) | |
download | opensim-SC-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.zip opensim-SC-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.gz opensim-SC-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.bz2 opensim-SC-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.xz |
* Optimized usings
* shortened references
* Removed redundant 'this'
* Normalized EOF
Diffstat (limited to 'OpenSim/Region/Environment/Modules/SunModule.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/SunModule.cs | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/OpenSim/Region/Environment/Modules/SunModule.cs b/OpenSim/Region/Environment/Modules/SunModule.cs index 233c83c..bd6cd63 100644 --- a/OpenSim/Region/Environment/Modules/SunModule.cs +++ b/OpenSim/Region/Environment/Modules/SunModule.cs | |||
@@ -28,13 +28,12 @@ | |||
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using libsecondlife; | ||
31 | using Nini.Config; | 32 | using Nini.Config; |
32 | using OpenSim.Region.Environment.Interfaces; | ||
33 | using OpenSim.Region.Environment.Scenes; | ||
34 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Console; | 34 | using OpenSim.Framework.Console; |
36 | using libsecondlife; | 35 | using OpenSim.Region.Environment.Interfaces; |
37 | 36 | using OpenSim.Region.Environment.Scenes; | |
38 | 37 | ||
39 | namespace OpenSim.Region.Environment.Modules | 38 | namespace OpenSim.Region.Environment.Modules |
40 | { | 39 | { |
@@ -55,17 +54,20 @@ namespace OpenSim.Region.Environment.Modules | |||
55 | { | 54 | { |
56 | m_start = DateTime.Now.Ticks; | 55 | m_start = DateTime.Now.Ticks; |
57 | m_frame = 0; | 56 | m_frame = 0; |
58 | 57 | ||
59 | // Just in case they don't have the stanzas | 58 | // Just in case they don't have the stanzas |
60 | try { | 59 | try |
60 | { | ||
61 | m_day_length = config.Configs["Sun"].GetDouble("day_length", m_real_day); | 61 | m_day_length = config.Configs["Sun"].GetDouble("day_length", m_real_day); |
62 | m_frame_mod = config.Configs["Sun"].GetInt("frame_rate", m_default_frame); | 62 | m_frame_mod = config.Configs["Sun"].GetInt("frame_rate", m_default_frame); |
63 | } catch (Exception) { | 63 | } |
64 | catch (Exception) | ||
65 | { | ||
64 | m_day_length = m_real_day; | 66 | m_day_length = m_real_day; |
65 | m_frame_mod = m_default_frame; | 67 | m_frame_mod = m_default_frame; |
66 | } | 68 | } |
67 | 69 | ||
68 | m_dilation = (int)(m_real_day / m_day_length); | 70 | m_dilation = (int) (m_real_day/m_day_length); |
69 | m_scene = scene; | 71 | m_scene = scene; |
70 | m_log = MainLog.Instance; | 72 | m_log = MainLog.Instance; |
71 | scene.EventManager.OnFrame += SunUpdate; | 73 | scene.EventManager.OnFrame += SunUpdate; |
@@ -94,10 +96,11 @@ namespace OpenSim.Region.Environment.Modules | |||
94 | { | 96 | { |
95 | client.SendSunPos(SunPos(HourOfTheDay()), new LLVector3(0, 0.0f, 10.0f)); | 97 | client.SendSunPos(SunPos(HourOfTheDay()), new LLVector3(0, 0.0f, 10.0f)); |
96 | } | 98 | } |
97 | 99 | ||
98 | public void SunUpdate() | 100 | public void SunUpdate() |
99 | { | 101 | { |
100 | if (m_frame < m_frame_mod) { | 102 | if (m_frame < m_frame_mod) |
103 | { | ||
101 | m_frame++; | 104 | m_frame++; |
102 | return; | 105 | return; |
103 | } | 106 | } |
@@ -115,20 +118,20 @@ namespace OpenSim.Region.Environment.Modules | |||
115 | // time when the simulator starts, then run time forward | 118 | // time when the simulator starts, then run time forward |
116 | // faster based on time dilation factor. This means that | 119 | // faster based on time dilation factor. This means that |
117 | // ticks don't get out of hand | 120 | // ticks don't get out of hand |
118 | private double HourOfTheDay() | 121 | private double HourOfTheDay() |
119 | { | 122 | { |
120 | long m_addticks = (DateTime.Now.Ticks - m_start) * m_dilation; | 123 | long m_addticks = (DateTime.Now.Ticks - m_start)*m_dilation; |
121 | DateTime dt = new DateTime(m_start + m_addticks); | 124 | DateTime dt = new DateTime(m_start + m_addticks); |
122 | return (double)dt.Hour + ((double)dt.Minute / 60.0); | 125 | return (double) dt.Hour + ((double) dt.Minute/60.0); |
123 | } | 126 | } |
124 | 127 | ||
125 | private LLVector3 SunPos(double hour) | 128 | private LLVector3 SunPos(double hour) |
126 | { | 129 | { |
127 | // now we have our radian position | 130 | // now we have our radian position |
128 | double rad = (hour / m_real_day) * 2 * Math.PI - (Math.PI / 2.0); | 131 | double rad = (hour/m_real_day)*2*Math.PI - (Math.PI/2.0); |
129 | double z = Math.Sin(rad); | 132 | double z = Math.Sin(rad); |
130 | double x = Math.Cos(rad); | 133 | double x = Math.Cos(rad); |
131 | return new LLVector3((float)x, 0f, (float)z); | 134 | return new LLVector3((float) x, 0f, (float) z); |
132 | } | 135 | } |
133 | 136 | ||
134 | // TODO: clear this out. This is here so that I remember to | 137 | // TODO: clear this out. This is here so that I remember to |