diff options
author | Melanie Thielker | 2009-03-20 22:42:21 +0000 |
---|---|---|
committer | Melanie Thielker | 2009-03-20 22:42:21 +0000 |
commit | c6da0fda58ec2c0ff200cb0167c0cbcc76a8985e (patch) | |
tree | edc6448e13492d2691aba97ae8d6f9561c1a3da4 /OpenSim/Region/ScriptEngine/Shared/Api/Implementation | |
parent | * Ignored some gens (diff) | |
download | opensim-SC-c6da0fda58ec2c0ff200cb0167c0cbcc76a8985e.zip opensim-SC-c6da0fda58ec2c0ff200cb0167c0cbcc76a8985e.tar.gz opensim-SC-c6da0fda58ec2c0ff200cb0167c0cbcc76a8985e.tar.bz2 opensim-SC-c6da0fda58ec2c0ff200cb0167c0cbcc76a8985e.tar.xz |
Thank you, mcortez, for patch to add functionality to the sun module.
Fixes Mantis #3313
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index f4be267..8776524 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -807,6 +807,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
807 | //World.Permissions.GenericEstatePermission( | 807 | //World.Permissions.GenericEstatePermission( |
808 | if (World.Permissions.IsGod(m_host.OwnerID)) | 808 | if (World.Permissions.IsGod(m_host.OwnerID)) |
809 | { | 809 | { |
810 | while (sunHour > 24.0) | ||
811 | sunHour -= 24.0; | ||
812 | |||
813 | while (sunHour < 0) | ||
814 | sunHour += 24.0; | ||
815 | |||
816 | |||
810 | World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; | 817 | World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; |
811 | World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 | 818 | World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 |
812 | World.RegionInfo.RegionSettings.FixedSun = sunFixed; | 819 | World.RegionInfo.RegionSettings.FixedSun = sunFixed; |
@@ -816,6 +823,87 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
816 | } | 823 | } |
817 | } | 824 | } |
818 | 825 | ||
826 | /// <summary> | ||
827 | /// Changes the Estate Sun Settings, then Triggers a Sun Update | ||
828 | /// </summary> | ||
829 | /// <param name="sunFixed">True to keep the sun stationary, false to use global time</param> | ||
830 | /// <param name="sunHour">The "Sun Hour" that is desired, 0...24, with 0 just after SunRise</param> | ||
831 | public void osSetEstateSunSettings(bool sunFixed, double sunHour) | ||
832 | { | ||
833 | CheckThreatLevel(ThreatLevel.Nuisance, "osSetEstateSunSettings"); | ||
834 | |||
835 | m_host.AddScriptLPS(1); | ||
836 | //Check to make sure that the script's owner is the estate manager/master | ||
837 | //World.Permissions.GenericEstatePermission( | ||
838 | if (World.Permissions.IsGod(m_host.OwnerID)) | ||
839 | { | ||
840 | while (sunHour > 24.0) | ||
841 | sunHour -= 24.0; | ||
842 | |||
843 | while (sunHour < 0) | ||
844 | sunHour += 24.0; | ||
845 | |||
846 | World.RegionInfo.EstateSettings.UseGlobalTime = !sunFixed; | ||
847 | World.RegionInfo.EstateSettings.SunPosition = sunHour; | ||
848 | World.RegionInfo.EstateSettings.FixedSun = sunFixed; | ||
849 | World.RegionInfo.EstateSettings.Save(); | ||
850 | |||
851 | World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour); | ||
852 | } | ||
853 | } | ||
854 | |||
855 | /// <summary> | ||
856 | /// Return the current Sun Hour 0...24, with 0 being roughly sun-rise | ||
857 | /// </summary> | ||
858 | /// <returns></returns> | ||
859 | public double osGetCurrentSunHour() | ||
860 | { | ||
861 | CheckThreatLevel(ThreatLevel.None, "osGetCurrentSunHour"); | ||
862 | |||
863 | m_host.AddScriptLPS(1); | ||
864 | |||
865 | // Must adjust for the fact that Region Sun Settings are still LL offset | ||
866 | double sunHour = World.RegionInfo.RegionSettings.SunPosition - 6; | ||
867 | |||
868 | // See if the sun module has registered itself, if so it's authoritative | ||
869 | ISunModule module = World.RequestModuleInterface<ISunModule>(); | ||
870 | if (module != null) | ||
871 | { | ||
872 | sunHour = module.GetCurrentSunHour(); | ||
873 | } | ||
874 | |||
875 | return sunHour; | ||
876 | } | ||
877 | |||
878 | public double osSunGetParam(string param) | ||
879 | { | ||
880 | CheckThreatLevel(ThreatLevel.None, "osSunGetParam"); | ||
881 | m_host.AddScriptLPS(1); | ||
882 | |||
883 | double value = 0.0; | ||
884 | |||
885 | ISunModule module = World.RequestModuleInterface<ISunModule>(); | ||
886 | if (module != null) | ||
887 | { | ||
888 | value = module.GetSunParameter(param); | ||
889 | } | ||
890 | |||
891 | return value; | ||
892 | } | ||
893 | |||
894 | public void osSunSetParam(string param, double value) | ||
895 | { | ||
896 | CheckThreatLevel(ThreatLevel.None, "osSunSetParam"); | ||
897 | m_host.AddScriptLPS(1); | ||
898 | |||
899 | ISunModule module = World.RequestModuleInterface<ISunModule>(); | ||
900 | if (module != null) | ||
901 | { | ||
902 | module.SetSunParameter(param, value); | ||
903 | } | ||
904 | |||
905 | } | ||
906 | |||
819 | 907 | ||
820 | 908 | ||
821 | 909 | ||