コード例 #1
0
            static void Postfix(EnvMan __instance)
            {
                if (!modEnabled.Value)
                {
                    return;
                }

                for (int i = 0; i < __instance.m_environments.Count; i++)
                {
                    if (customMusicList.ContainsKey(__instance.m_environments[i].m_name + "Morning"))
                    {
                        AddMusicList(__instance, i, "Morning");
                    }
                    if (customMusicList.ContainsKey(__instance.m_environments[i].m_name + "Day"))
                    {
                        AddMusicList(__instance, i, "Day");
                    }
                    if (customMusicList.ContainsKey(__instance.m_environments[i].m_name + "Evening"))
                    {
                        AddMusicList(__instance, i, "Evening");
                    }
                    if (customMusicList.ContainsKey(__instance.m_environments[i].m_name + "Night"))
                    {
                        AddMusicList(__instance, i, "Night");
                    }
                }
            }
コード例 #2
0
        private static void AddMusicList(EnvMan envMan, int index, string which)
        {
            string name = envMan.m_environments[index].m_name + which;

            Dbgl($"Adding music list by name: {name} ({customMusicList[name].Count})");
            switch (which)
            {
            case "Morning":
                envMan.m_environments[index].m_musicMorning = name;
                break;

            case "Day":
                envMan.m_environments[index].m_musicDay = name;
                break;

            case "Evening":
                envMan.m_environments[index].m_musicEvening = name;
                break;

            case "Night":
                envMan.m_environments[index].m_musicNight = name;
                break;
            }
            MusicMan.instance.m_music.Add(new MusicMan.NamedMusic()
            {
                m_name = name, m_clips = customMusicList[name].Values.ToArray(), m_loop = true, m_ambientMusic = true, m_resume = true
            });
        }
コード例 #3
0
 private static void Prefix(ref EnvMan __instance)
 {
     if (Configuration.Current.Time.IsEnabled)
     {
         __instance.m_dayLengthSec = (long)Configuration.Current.Time.totalDayTimeInSeconds;
     }
 }
コード例 #4
0
 public static void Postfix(ref EnvMan __instance)
 {
     Environment.IsWet      = __instance.IsWet();
     Environment.WindAngle  = __instance.m_debugWindAngle;
     Environment.Biome      = __instance.GetCurrentBiome();
     Environment.IsCold     = __instance.IsCold();
     Environment.IsDaylight = __instance.IsDaylight();
     Environment.SunFog     = __instance.GetSunFogColor();
 }
コード例 #5
0
 private static void Prefix(ref EnvMan __instance)
 {
     if (Configuration.Current.Time.IsEnabled)
     {
         Boolean isNight = __instance.IsNight();
         if (isNight)
         {
             addToTime((long)Configuration.Current.Time.nightTimeSpeedMultiplier, Time.deltaTime);
         }
     }
 }
コード例 #6
0
            static void Postfix(EnvMan __instance)
            {
                try
                {
                    // eh.. .don't do this work if logging isn't verbose anyway...
                    if (Settings.PluginLoggingLevel.Value != Plugin.LoggingLevel.Verbose)
                    {
                        return;
                    }
                    environmentNames.Clear();

                    foreach (EnvSetup environment in __instance.m_environments)
                    {
                        Plugin.LogVerbose($"Environment Name:{environment.m_name}");
                        environmentNames.Add(environment.m_name);
                    }


                    prayedTime = DateTime.MinValue;

                    /*
                     * As of 148.6? 4/7/21
                     *  Environment Name:Clear
                     *  Environment Name:Twilight_Clear
                     *  Environment Name:Misty
                     *  Environment Name:Darklands_dark
                     *  Environment Name:Heath clear
                     *  Environment Name:DeepForest Mist
                     *  Environment Name:GDKing
                     *  Environment Name:Rain
                     *  Environment Name:LightRain
                     *  Environment Name:ThunderStorm
                     *  Environment Name:Eikthyr
                     *  Environment Name:GoblinKing
                     *  Environment Name:nofogts
                     *  Environment Name:SwampRain
                     *  Environment Name:Bonemass
                     *  Environment Name:Snow
                     *  Environment Name:Twilight_Snow
                     *  Environment Name:Twilight_SnowStorm
                     *  Environment Name:SnowStorm
                     *  Environment Name:Moder
                     *  Environment Name:Ashrain
                     *  Environment Name:Crypt
                     *  Environment Name:SunkenCrypt
                     */
                }
                catch (Exception ex)
                {
                    // do nothing, just swallow it up
                    Plugin.LogError(ex.ToString());
                }
            }
コード例 #7
0
            static void Prefix(EnvMan __instance, double ___m_totalSeconds)
            {
                if (!modEnabled.Value)
                {
                    return;
                }
                int day = (int)(___m_totalSeconds / (double)__instance.m_dayLengthSec);

                if (relocateInterval.Value > 0 && day - lastRelocateDay.Value >= relocateInterval.Value)
                {
                    RelocateMerchant();
                }
            }
コード例 #8
0
            public static void Prefix(EnvMan __instance)
            {
                var eikthyr = __instance.m_environments.Find(x => x.m_name == "Eikthyr");

                AddHelheimEnvironments(__instance, eikthyr, 1);

                var ashrain = __instance.m_environments.Find(x => x.m_name == "Ashrain");

                AddHelheimEnvironments(__instance, ashrain, 2);

                var moder = __instance.m_environments.Find(x => x.m_name == "Moder");

                AddHelheimEnvironments(__instance, moder, 3);
            }
コード例 #9
0
        public static void Postfix(ref EnvMan __instance)
        {
            Environment.IsWet = __instance.IsWet();

            Vector3 vecDir = __instance.GetWindDir();
            float   rad    = Mathf.Atan2(vecDir.x, vecDir.z);

            Environment.WindAngle = (rad >= 0 ? rad : (2 * (float)Math.PI + rad)) * 360 / (2 * (float)Math.PI);

            Environment.Biome      = __instance.GetCurrentBiome();
            Environment.IsCold     = __instance.IsCold();
            Environment.IsDaylight = __instance.IsDaylight();
            Environment.SunFog     = __instance.GetSunFogColor();
        }
コード例 #10
0
ファイル: PassTheTime.cs プロジェクト: manfredo52/ValheimMods
        public static string GetCurrentDay()
        {
            EnvMan env = EnvMan.instance;

            if (!env)
            {
                return("");
            }

            object[] parameters = null;
            int      currentDay = (int)typeof(EnvMan).GetMethod("GetCurrentDay", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(env, parameters);

            return("Day " + currentDay.ToString());
        }
コード例 #11
0
ファイル: EnvMan.cs プロジェクト: valheimPlus/ValheimPlus
        private static void Prefix(ref EnvMan __instance, ref EnvSetup env)
        {
            if (Configuration.Current.Game.IsEnabled && Configuration.Current.Game.disableFog)
            {
                env.m_fogDensityNight   = 0.0001f;
                env.m_fogDensityMorning = 0.0001f;
                env.m_fogDensityDay     = 0.0001f;
                env.m_fogDensityEvening = 0.0001f;
            }

            if (Configuration.Current.Brightness.IsEnabled)
            {
                applyEnvModifier(env);
            }
        }
コード例 #12
0
            public static bool Prefix(EnvMan __instance, long sec, Heightmap.Biome biome)
            {
                if (HasEnvChanged(Helheim.HelheimLevel, biome, __instance.GetCurrentEnvironment().m_name))
                {
                    Helheim.Log($"Helheim: {Helheim.HelheimLevel}, Biome: {biome}, Current: {__instance.GetCurrentEnvironment().m_name}, Wet: {__instance.IsWet()}, Freezing: {__instance.IsFreezing()}");
                }

                var allowBaseMethod = true;
                var forceSwitch     = Helheim.HelheimLevel != PreviousHelheimLevel;

                __instance.m_firstEnv = forceSwitch;

                if (Helheim.HelheimLevel > 0)
                {
                    var num = sec / __instance.m_environmentDuration;
                    if (!forceSwitch && __instance.m_currentEnv.m_name.StartsWith("Helheim") && __instance.m_environmentPeriod == num && __instance.m_currentBiome == biome)
                    {
                        return(false);
                    }

                    __instance.m_environmentPeriod = num;
                    __instance.m_currentBiome      = biome;
                    var state = Random.state;
                    Random.InitState((int)num);
                    var availableEnvironments = __instance.GetAvailableEnvironments(biome);
                    if (availableEnvironments != null && availableEnvironments.Count > 0)
                    {
                        var biomeEnv   = __instance.SelectWeightedEnvironment(availableEnvironments);
                        var helheimEnv = GetHelheimEnvironment(__instance, biomeEnv, Helheim.HelheimLevel);
                        __instance.QueueEnvironment(helheimEnv);
                        Helheim.LogWarning($"Changing Environment: {helheimEnv.m_name}");
                    }
                    Random.state    = state;
                    allowBaseMethod = false;
                }
                else
                {
                    if (forceSwitch)
                    {
                        __instance.m_currentBiome = Heightmap.Biome.None;
                    }
                }

                PreviousHelheimLevel = Helheim.HelheimLevel;
                PreviousBiome        = biome;
                PreviousEnvName      = __instance.GetCurrentEnvironment().m_name;
                return(allowBaseMethod);
            }
コード例 #13
0
        public static void FindAndCopyEnvObjectByName(EnvMan envMan, string name, EnvSetup targetEnv)
        {
            if (targetEnv.m_envObject.name == name)
            {
                return;
            }

            foreach (var env in envMan.m_environments)
            {
                if (env.m_envObject.name.Equals(name))
                {
                    targetEnv.m_envObject = env.m_envObject;
                    return;
                }
            }
        }
コード例 #14
0
            static void Prefix(EnvMan __instance, ref float dayInt, ref float nightInt, ref float morningInt, ref float eveningInt, float ___m_smoothDayFraction)
            {
                if (!modEnabled.Value)
                {
                    return;
                }
                nightInt   = Mathf.Pow(Mathf.Max(1f - Mathf.Clamp01(___m_smoothDayFraction / dayStart.Value), Mathf.Clamp01((___m_smoothDayFraction - nightStart.Value) / dayStart.Value)), 0.5f);
                dayInt     = Mathf.Pow(Mathf.Clamp01(1f - Mathf.Abs(___m_smoothDayFraction - 0.5f) / dayStart.Value), 0.5f);
                morningInt = Mathf.Min(Mathf.Clamp01(1f - (___m_smoothDayFraction - (dayStart.Value + 0.01f)) / -__instance.m_sunHorizonTransitionL), Mathf.Clamp01(1f - (___m_smoothDayFraction - (dayStart.Value + 0.01f)) / __instance.m_sunHorizonTransitionH));
                eveningInt = Mathf.Min(Mathf.Clamp01(1f - (___m_smoothDayFraction - (nightStart.Value - 0.01f)) / -__instance.m_sunHorizonTransitionH), Mathf.Clamp01(1f - (___m_smoothDayFraction - (nightStart.Value - 0.01f)) / __instance.m_sunHorizonTransitionL));
                float num9 = 1f / (nightInt + dayInt + morningInt + eveningInt);

                nightInt   *= num9;
                dayInt     *= num9;
                morningInt *= num9;
                eveningInt *= num9;
            }
コード例 #15
0
            static void Postfix(EnvMan __instance)
            {
                if (!modEnabled.Value)
                {
                    return;
                }
                int day = Traverse.Create(__instance).Method("GetCurrentDay").GetValue <int>();

                Dbgl($"Day {day} begins.");
                if (day - lastRegenDate.Value >= daysToRegen.Value)
                {
                    Dbgl("Reloading dungeons on new day.");
                    lastRegenDate.Value        = day;
                    regeneratedLocations.Value = "";
                    RegenDungeons(false);
                }
            }
コード例 #16
0
ファイル: EnvMan.cs プロジェクト: neoKushan/ValheimPlus
 private static void Prefix(ref EnvMan __instance)
 {
     if (Configuration.Current.Time.IsEnabled)
     {
         if (ZNet.instance.IsServer() && __instance.IsNight() && !__instance.IsTimeSkipping())
         {
             double timeSeconds     = ZNet.instance.GetTimeSeconds();
             double num             = timeSeconds + Helper.applyModifierValue(Configuration.Current.Time.nightTimeSpeedMultiplier, Time.deltaTime);
             double time            = timeSeconds - (double)((float)__instance.m_dayLengthSec * 0.25f);
             int    day             = __instance.GetDay(time);
             double morningStartSec = __instance.GetMorningStartSec(day + 1);
             // Make sure we don't go over the morning time
             if (num < morningStartSec)
             {
                 ZNet.instance.SetNetTime(num);
             }
         }
     }
 }
コード例 #17
0
        public static void FindAndCopyPsystemByName(EnvMan envMan, string name, EnvSetup targetEnv)
        {
            if (targetEnv.m_psystems.ToList().Exists(x => x.name == name))
            {
                return;
            }

            foreach (var env in envMan.m_environments)
            {
                foreach (var psystem in env.m_psystems)
                {
                    if (psystem.name.Equals(name))
                    {
                        targetEnv.m_psystems = targetEnv.m_psystems.AddToArray(psystem);
                        return;
                    }
                }
            }
        }
コード例 #18
0
ファイル: PassTheTime.cs プロジェクト: manfredo52/ValheimMods
        public static string GetCurrentTime()
        {
            EnvMan env = EnvMan.instance;

            if (!env)
            {
                return("");
            }

            float smoothDayFraction = (float)typeof(EnvMan).GetField("m_smoothDayFraction", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(env);

            int hours   = (int)(smoothDayFraction * 24.0);
            int minutes = (int)((smoothDayFraction * 24.0 - hours) * 60.0);
            int seconds = (int)(((smoothDayFraction * 24.0 - hours) * 60.0 - minutes) * 60.0);

            DateTime time            = DateTime.Today;
            DateTime currentGameTime = new DateTime(time.Year, time.Month, time.Day, hours, minutes, seconds);

            //dateTime.ToString("HH:mm" : "hh:mm tt");
            return(currentGameTime.ToString("hh:mm tt"));
        }
コード例 #19
0
        public static void AddHelheimEnvironments(EnvMan envMan, EnvSetup baseEnv, int level)
        {
            var helheimEnvBase = baseEnv.Clone();

            helheimEnvBase.m_name = GetHelheimEnvName(level, false, false);
            //FindAndCopyEnvObjectByName(envMan, "Thunder", helheimEnvBase);
            envMan.m_environments.Add(helheimEnvBase);

            var helheimEnvWet = helheimEnvBase.Clone();

            helheimEnvWet.m_name  = GetHelheimEnvName(level, true, false);
            helheimEnvWet.m_isWet = true;
            FindAndCopyPsystemByName(envMan, level == 1 ? "LightRain" : "Rain", helheimEnvWet);
            envMan.m_environments.Add(helheimEnvWet);

            var helheimEnvFreezing = helheimEnvBase.Clone();

            helheimEnvFreezing.m_name       = GetHelheimEnvName(level, false, true);
            helheimEnvFreezing.m_isFreezing = true;
            FindAndCopyPsystemByName(envMan, level == 1 ? "Snow" : "SnowStorm", helheimEnvFreezing);
            envMan.m_environments.Add(helheimEnvFreezing);
        }
コード例 #20
0
        public static EnvSetup GetHelheimEnvironment(EnvMan envMan, EnvSetup biomeEnv, int level)
        {
            var name = GetHelheimEnvName(level, biomeEnv.m_isWet, biomeEnv.m_isFreezing);

            return(envMan.GetEnv(name));
        }
コード例 #21
0
        private static void Postfix(ref Player __instance, ref Vector3 ___m_moveDir, ref Vector3 ___m_lookDir, ref GameObject ___m_placementGhost, Transform ___m_eye)
        {
            if ((Configuration.Current.Player.IsEnabled && Configuration.Current.Player.queueWeaponChanges) && (ZInput.GetButtonDown("Hide") || ZInput.GetButtonDown("JoyHide")))
            {
                if (__instance.InAttack() && (__instance.GetRightItem() != null || __instance.GetLeftItem() != null))
                {
                    // The game ignores this keypress, so queue it and take care of it when able (Player_FixedUpdate_Patch).
                    EquipPatchState.shouldHideItemsAfterAttack = true;
                }
            }

            if (!__instance.m_nview.IsValid() || !__instance.m_nview.IsOwner())
            {
                return;
            }

            if (Configuration.Current.AdvancedEditingMode.IsEnabled)
            {
                AEM.PlayerInstance = __instance;
                AEM.run();
            }

            if (Configuration.Current.AdvancedBuildingMode.IsEnabled)
            {
                ABM.Run(ref __instance);
            }

            if (Configuration.Current.Hotkeys.IsEnabled)
            {
                ApplyDodgeHotkeys(ref __instance, ref ___m_moveDir, ref ___m_lookDir);
            }


            if (Configuration.Current.GameClock.IsEnabled)
            {
                String hours_str   = "";
                String minutes_str = "";
                String amPM_str    = "";

                Hud hud = Hud.instance;

                Text timeText;
                if (timeObj == null)
                {
                    MessageHud msgHud = MessageHud.instance;

                    timeObj = new GameObject();
                    timeObj.transform.SetParent(hud.m_statusEffectListRoot.transform.parent);
                    timeObj.AddComponent <RectTransform>();

                    timeText = timeObj.AddComponent <Text>();

                    float rRatio = Mathf.Clamp01((float)Configuration.Current.GameClock.textRedChannel / 255f);
                    float gRatio = Mathf.Clamp01((float)Configuration.Current.GameClock.textGreenChannel / 255f);
                    float bRatio = Mathf.Clamp01((float)Configuration.Current.GameClock.textBlueChannel / 255f);
                    float aRatio = Mathf.Clamp01((float)Configuration.Current.GameClock.textTransparencyChannel / 255f);

                    timeText.color              = new Color(rRatio, gRatio, bRatio, aRatio);
                    timeText.font               = msgHud.m_messageCenterText.font;
                    timeText.fontSize           = Configuration.Current.GameClock.textFontSize;
                    timeText.enabled            = true;
                    timeText.alignment          = TextAnchor.MiddleCenter;
                    timeText.horizontalOverflow = HorizontalWrapMode.Overflow;
                }
                else
                {
                    timeText = timeObj.GetComponent <Text>();
                }

                EnvMan env = EnvMan.instance;
                if (savedEnvSeconds != env.m_totalSeconds)
                {
                    float minuteFrac = Mathf.Lerp(0, 24, env.GetDayFraction());
                    float hr24       = Mathf.Floor(minuteFrac);
                    minuteFrac = minuteFrac - hr24;
                    float minutes = Mathf.Lerp(0, 60, minuteFrac);

                    int hours_int   = Mathf.FloorToInt(hr24);
                    int minutes_int = Mathf.FloorToInt(minutes);

                    if (Configuration.Current.GameClock.useAMPM)
                    {
                        amPM_str = (hours_int < 12) ? " AM" : " PM";
                        if (hours_int > 12)
                        {
                            hours_int -= 12;
                        }
                    }

                    if (hours_int < 10)
                    {
                        hours_str = "0" + hours_int;
                    }
                    if (minutes_int < 10)
                    {
                        minutes_str = "0" + minutes_int;
                    }
                    if (hours_int >= 10)
                    {
                        hours_str = hours_int.ToString();
                    }
                    if (minutes_int >= 10)
                    {
                        minutes_str = minutes_int.ToString();
                    }

                    timeText.text = hours_str + ":" + minutes_str + amPM_str;
                    var staminaBarRec      = hud.m_staminaBar2Root.transform as RectTransform;
                    var statusEffictBarRec = hud.m_statusEffectListRoot.transform as RectTransform;
                    timeObj.GetComponent <RectTransform>().position = new Vector2(staminaBarRec.position.x, statusEffictBarRec.position.y);
                    timeObj.SetActive(true);
                    savedEnvSeconds = env.m_totalSeconds;
                }
            }
        }
コード例 #22
0
 public static void Prefix(EnvMan __instance)
 {
     __instance.m_environments.Add(DarknessRuneEffect.darkEnvSetup);
 }
コード例 #23
0
ファイル: EnvMan.cs プロジェクト: neoKushan/ValheimPlus
 private static void Prefix(ref EnvMan __instance)
 {
     SetupDayLength();
 }
コード例 #24
0
ファイル: Time.cs プロジェクト: lloesche/ValheimPlus
 private static void Postfix(ref EnvMan __instance)
 {
     // i am working on this, nx
 }
コード例 #25
0
 static void Prefix(EnvMan __instance)
 {
     ZRoutedRpc.instance.Register <string>("QueueEnvironment", Chat_InputText.RPC_QueueEnvironment);
 }