using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using FairHazards.Logic;
using HarmonyLib;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using Zorro.Core;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("FairHazards")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+c9d9e81fff69b03f4b689165135dfc02615537da")]
[assembly: AssemblyProduct("FairHazards")]
[assembly: AssemblyTitle("FairHazards")]
[assembly: AssemblyVersion("1.1.0.0")]
namespace FairHazards
{
internal static class FogClearForReturning
{
internal const string Part = "fog clear for returning";
internal const float SettleSeconds = 2f;
private static readonly FieldRef<OrbFogHandler, FogSphere> SphereRef = AccessTools.FieldRefAccess<OrbFogHandler, FogSphere>("sphere");
private static readonly FieldRef<OrbFogHandler, FogSphereOrigin[]> OriginsRef = AccessTools.FieldRefAccess<OrbFogHandler, FogSphereOrigin[]>("origins");
private static readonly FieldRef<OrbFogHandler, PhotonView> ViewRef = AccessTools.FieldRefAccess<OrbFogHandler, PhotonView>("photonView");
private static readonly HashSet<int> Seen = new HashSet<int>();
private static readonly HashSet<int> Present = new HashSet<int>();
private static readonly Dictionary<int, float> DueAt = new Dictionary<int, float>();
private static readonly List<int> Gone = new List<int>();
private static bool primed;
internal static void Tick()
{
if (!Plugin.Active || !HazardConfig.ClearForReturningPlayers.Value || !PhotonNetwork.IsMasterClient)
{
Forget();
return;
}
float unscaledTime = Time.unscaledTime;
Present.Clear();
foreach (Character allCharacter in Character.AllCharacters)
{
if ((Object)(object)allCharacter == (Object)null || (Object)(object)allCharacter.data == (Object)null || !allCharacter.IsPlayerControlled)
{
continue;
}
int instanceID = ((Object)allCharacter).GetInstanceID();
Present.Add(instanceID);
float value;
if (Seen.Add(instanceID))
{
if (primed)
{
DueAt[instanceID] = unscaledTime + 2f;
}
}
else if (DueAt.TryGetValue(instanceID, out value) && !(unscaledTime < value))
{
DueAt.Remove(instanceID);
if (!allCharacter.data.dead)
{
TryClear(allCharacter, out var _, out var _);
}
}
}
primed = true;
Gone.Clear();
foreach (int item in Seen)
{
if (!Present.Contains(item))
{
Gone.Add(item);
}
}
foreach (int item2 in Gone)
{
Seen.Remove(item2);
DueAt.Remove(item2);
}
}
internal static bool TryClear(Character character, out float before, out float after)
{
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
before = 0f;
after = 0f;
OrbFogHandler instance = Singleton<OrbFogHandler>.Instance;
if ((Object)(object)instance == (Object)null || !instance.isMoving || instance.hasArrived)
{
return false;
}
FogSphere val = SphereRef.Invoke(instance);
FogSphereOrigin[] array = OriginsRef.Invoke(instance);
int currentID = instance.currentID;
if ((Object)(object)val == (Object)null || array == null || currentID < 0 || currentID >= array.Length || (Object)(object)array[currentID] == (Object)null)
{
return false;
}
float distance = Vector3.Distance(val.fogPoint, character.Center);
float? num = FogMath.ClearSize(instance.currentSize, distance, FogMath.MetersToUnits(HazardConfig.FogStopMarginMeters()), array[currentID].size);
if (!num.HasValue)
{
return false;
}
PhotonView val2 = ViewRef.Invoke(instance);
if ((Object)(object)val2 == (Object)null || !PhotonNetwork.InRoom)
{
return false;
}
before = instance.currentSize;
after = num.Value;
instance.currentSize = after;
try
{
val2.RPC("RPCA_SyncFog", (RpcTarget)1, new object[2] { instance.currentSize, instance.isMoving });
}
catch
{
instance.currentSize = before;
throw;
}
Plugin.Log.LogInfo((object)("FairHazards: the fog was pulled back for a player who appeared inside it (" + before.ToString("0.0", CultureInfo.InvariantCulture) + " -> " + after.ToString("0.0", CultureInfo.InvariantCulture) + ")."));
return true;
}
private static void Forget()
{
Seen.Clear();
DueAt.Clear();
primed = false;
}
}
[HarmonyPatch(typeof(OrbFogHandler), "Move")]
internal static class FogNoOvertake
{
private const float HoldTolerance = 0.05f;
private static readonly List<float> Distances = new List<float>();
internal static float? LastFloor { get; private set; }
internal static float StopSize()
{
if (!LastFloor.HasValue || !(LastFloor.Value > 30f))
{
return 30f;
}
return LastFloor.Value;
}
internal static bool IsHolding(float size)
{
if (LastFloor.HasValue && LastFloor.Value > 30f)
{
return size <= LastFloor.Value + 0.05f;
}
return false;
}
[HarmonyPrefix]
private static void Prefix(OrbFogHandler __instance, out float? __state)
{
__state = null;
try
{
__state = __instance.currentSize;
}
catch (Exception e)
{
Plugin.ReportOnce("fog hold", e);
}
}
[HarmonyPostfix]
private static void Postfix(OrbFogHandler __instance, FogSphere ___sphere, float? __state)
{
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
try
{
if (!__state.HasValue || !HostFlag.TryGetActive(out var info))
{
LastFloor = null;
return;
}
Distances.Clear();
if ((Object)(object)___sphere != (Object)null)
{
foreach (Character allCharacter in Character.AllCharacters)
{
if (!((Object)(object)allCharacter == (Object)null) && !((Object)(object)allCharacter.data == (Object)null) && allCharacter.IsPlayerControlled && !allCharacter.data.dead)
{
Distances.Add(Vector3.Distance(___sphere.fogPoint, allCharacter.Center));
}
}
}
float? num = FogMath.Floor(Distances, FogMath.MetersToUnits(info.MarginMeters));
float after = FogMath.ScaleShrink(__state.Value, __instance.currentSize, info.FogSpeed);
float num2 = FogMath.Hold(__state.Value, after, num);
bool flag = FogMath.Arrived(num2);
LastFloor = num;
__instance.currentSize = num2;
__instance.hasArrived = flag;
__instance.isMoving = !flag;
}
catch (Exception e)
{
Plugin.ReportOnce("fog hold", e);
}
}
}
[HarmonyPatch(typeof(OrbFogHandler), "TimeToMove")]
internal static class FogStartRule
{
[HarmonyPostfix]
private static void Postfix(OrbFogHandler __instance, ref bool __result)
{
try
{
if (Plugin.Active)
{
float waitSetting = HazardConfig.FogWait(__instance.currentID);
__result = FogMath.TimeStart(Ascents.currentAscent, __instance.currentID, __instance.currentWaitTime, waitSetting);
}
}
catch (Exception e)
{
Plugin.ReportOnce("fog time start", e);
}
}
}
[HarmonyPatch(typeof(OrbFogHandler), "Sync")]
internal static class FogSync
{
private const float GameInterval = 5f;
[HarmonyPrefix]
private static void Prefix(ref float ___syncCounter)
{
try
{
if (Plugin.Active && FogMath.IntervalPassed(___syncCounter, Time.deltaTime, HazardConfig.FogSync()))
{
___syncCounter = 5f;
}
}
catch (Exception e)
{
Plugin.ReportOnce("fog sync interval", e);
}
}
}
internal enum HudCorner
{
TopLeft,
TopRight,
BottomLeft,
BottomRight
}
internal static class HazardConfig
{
internal static ConfigEntry<bool> Enabled;
internal static ConfigEntry<HudCorner> HudAnchor;
internal static ConfigEntry<KeyCode> HudToggleKey;
internal static ConfigEntry<bool> ClearForReturningPlayers;
private static readonly ConfigEntry<float>[] FogTimeStart = new ConfigEntry<float>[6];
private static readonly ConfigEntry<float>[] RisingWaitEntries = new ConfigEntry<float>[3];
private static readonly ConfigEntry<float>[] RisingSpeedEntries = new ConfigEntry<float>[3];
private static readonly ConfigEntry<float>[] RisingSyncEntries = new ConfigEntry<float>[3];
private static readonly HashSet<string> Warned = new HashSet<string>();
private static ConfigEntry<float> fogStopMargin;
private static ConfigEntry<float> fogSpeed;
private static ConfigEntry<float> fogSync;
private static ConfigEntry<float> hudScale;
private static ConfigEntry<float> warnMeters;
private static ConfigEntry<float> warnSeconds;
internal static void Bind(ConfigFile config)
{
Enabled = config.Bind<bool>("General", "Enabled", true, "false = the game's own fog and rising hazards, and no overlay.");
fogStopMargin = config.Bind<float>("Fog", "FogStopMargin", 10f, "Meters the fog stays short of the living climber farthest from its center (0-50).");
fogSpeed = config.Bind<float>("Fog", "FogSpeedMultiplier", 1f, "Fog shrink speed multiplier (0.1-5).");
fogSync = config.Bind<float>("Fog", "FogSyncSeconds", 1f, "Seconds between the fog updates the host sends (0.5-5). The game uses 5.");
ClearForReturningPlayers = config.Bind<bool>("Fog", "ClearForReturningPlayers", true, "When a player appears inside the moving fog (for example after rejoining), the host pushes the fog back once to FogStopMargin past them. false = the fog never grows back.");
BindTimeStart(config, (Segment)1);
BindTimeStart(config, (Segment)2);
BindTimeStart(config, (Segment)3);
BindTimeStart(config, (Segment)5);
BindRising(config, (RisingFieldType)0);
BindRising(config, (RisingFieldType)1);
BindRising(config, (RisingFieldType)2);
HudAnchor = config.Bind<HudCorner>("Hud", "HudAnchor", HudCorner.TopLeft, "Screen corner of the overlay.");
hudScale = config.Bind<float>("Hud", "HudScale", 1f, "Overlay size (0.5-3).");
HudToggleKey = config.Bind<KeyCode>("Hud", "HudToggleKey", (KeyCode)289, "Key that shows or hides the overlay.");
warnMeters = config.Bind<float>("Hud", "WarnMeters", 10f, "Orange when a hazard is this many meters away or closer (0-100).");
warnSeconds = config.Bind<float>("Hud", "WarnSeconds", 20f, "Orange when a hazard reaches you in this many seconds or fewer (0-300).");
}
internal static float FogStopMarginMeters()
{
return Range(fogStopMargin, 0f, 50f);
}
internal static float FogSpeed()
{
return Range(fogSpeed, 0.1f, 5f);
}
internal static float FogSync()
{
return Range(fogSync, 0.5f, 5f);
}
internal static float FogWait(int fogId)
{
if (fogId < 0 || fogId >= FogTimeStart.Length || FogTimeStart[fogId] == null)
{
return -1f;
}
return Wait(FogTimeStart[fogId]);
}
internal static float RisingWait(int kind)
{
if (kind < 0 || kind >= RisingWaitEntries.Length)
{
return -1f;
}
return Wait(RisingWaitEntries[kind]);
}
internal static float RisingSpeed(int kind)
{
if (kind < 0 || kind >= RisingSpeedEntries.Length)
{
return 1f;
}
return Range(RisingSpeedEntries[kind], 0.1f, 5f);
}
internal static float RisingSync(int kind)
{
if (kind < 0 || kind >= RisingSyncEntries.Length)
{
return 15f;
}
return Range(RisingSyncEntries[kind], 1f, 15f);
}
internal static float HudScale()
{
return Range(hudScale, 0.5f, 3f);
}
internal static float WarnMeters()
{
return Range(warnMeters, 0f, 100f);
}
internal static float WarnSeconds()
{
return Range(warnSeconds, 0f, 300f);
}
internal static HostInfo LocalHostInfo(int actor)
{
float[] array = new float[6];
for (int i = 0; i < array.Length; i++)
{
array[i] = FogWait(i);
}
float[] array2 = new float[3];
float[] array3 = new float[3];
for (int j = 0; j < array2.Length; j++)
{
array2[j] = RisingWait(j);
array3[j] = RisingSpeed(j);
}
return new HostInfo(actor, FogSpeed(), FogStopMarginMeters(), array, array2, array3);
}
private unsafe static void BindTimeStart(ConfigFile config, Segment segment)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected I4, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
FogTimeStart[segment] = config.Bind<float>("FogTimeStart", ((object)(*(Segment*)(&segment))/*cast due to .constrained prefix*/).ToString(), -1f, $"Seconds the fog of segment {(int)segment} ({segment}) waits before moving on its own. -1 = never by time; it still moves once everyone has moved on.");
}
private unsafe static void BindRising(ConfigFile config, RisingFieldType kind)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected I4, but got Unknown
string text = ((object)(*(RisingFieldType*)(&kind))/*cast due to .constrained prefix*/).ToString();
int num = (int)kind;
RisingWaitEntries[num] = config.Bind<float>(text, "WaitSeconds", -1f, "Seconds before it starts rising. -1 = it never rises.");
RisingSpeedEntries[num] = config.Bind<float>(text, "SpeedMultiplier", 1f, "Rising speed multiplier (0.1-5).");
RisingSyncEntries[num] = config.Bind<float>(text, "SyncSeconds", 5f, "Seconds between the updates the host sends (1-15). The game uses 15.");
}
private static float Range(ConfigEntry<float> entry, float min, float max)
{
bool changed;
float num = ConfigRange.Clamp(entry.Value, min, max, out changed);
if (changed)
{
WarnOnce(entry, num);
}
return num;
}
private static float Wait(ConfigEntry<float> entry)
{
bool changed;
float num = ConfigRange.Wait(entry.Value, out changed);
if (changed)
{
WarnOnce(entry, num);
}
return num;
}
private static void WarnOnce(ConfigEntry<float> entry, float used)
{
string item = ((ConfigEntryBase)entry).Definition.Section + "." + ((ConfigEntryBase)entry).Definition.Key + "=" + entry.Value.ToString(CultureInfo.InvariantCulture);
if (Warned.Add(item))
{
Plugin.Log.LogWarning((object)$"{((ConfigEntryBase)entry).Definition.Section}.{((ConfigEntryBase)entry).Definition.Key} = {entry.Value} is out of range; using {used}.");
}
}
}
internal sealed class HazardHud
{
private const float RefreshSeconds = 0.1f;
private static readonly string[] FontNames = new string[4] { "Yu Gothic UI", "Meiryo", "MS Gothic", "Arial" };
private readonly List<HudLine> lines = new List<HudLine>();
private float nextRefresh;
private bool visible = true;
private Font font;
private GUIStyle style;
private int styleSize;
internal void Tick()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Invalid comparison between Unknown and I4
try
{
if (Input.GetKeyDown(HazardConfig.HudToggleKey.Value))
{
visible = !visible;
}
if (!(Time.unscaledTime < nextRefresh))
{
nextRefresh = Time.unscaledTime + 0.1f;
lines.Clear();
if (visible && ShouldShow())
{
bool japanese = (int)LocalizedText.CURRENT_LANGUAGE == 11;
HazardReadout.Build(lines, HudText.Pick(japanese));
}
}
}
catch (Exception e)
{
lines.Clear();
Plugin.ReportOnce("overlay", e);
}
}
internal void Draw()
{
if (!visible || lines.Count == 0 || !Plugin.Active)
{
return;
}
try
{
DrawLines();
}
catch (Exception e)
{
Plugin.ReportOnce("overlay drawing", e);
}
}
private static bool ShouldShow()
{
if (!Plugin.Active || (Object)(object)Character.localCharacter == (Object)null)
{
return false;
}
GUIManager instance = GUIManager.instance;
if ((Object)(object)instance == (Object)null || instance.windowBlockingInput)
{
return false;
}
return !GUIManager.InPauseMenu;
}
private void DrawLines()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected O, but got Unknown
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
float num = HazardConfig.HudScale();
EnsureStyle(Mathf.RoundToInt(16f * num));
float num2 = 6f * num;
float y = style.CalcSize(new GUIContent("Ag")).y;
float num3 = 0f;
foreach (HudLine line in lines)
{
num3 = Mathf.Max(num3, style.CalcSize(new GUIContent(line.Text)).x);
}
Rect val = Place(HazardConfig.HudAnchor.Value, num3 + num2 * 2f, y * (float)lines.Count + num2 * 2f, 12f * num);
Color color = GUI.color;
try
{
GUI.color = new Color(0f, 0f, 0f, 0.45f);
GUI.DrawTexture(val, (Texture)(object)Texture2D.whiteTexture);
Rect val2 = default(Rect);
for (int i = 0; i < lines.Count; i++)
{
((Rect)(ref val2))..ctor(((Rect)(ref val)).x + num2, ((Rect)(ref val)).y + num2 + (float)i * y, num3 + 2f, y);
GUI.color = Color.black;
GUI.Label(new Rect(((Rect)(ref val2)).x + 1f, ((Rect)(ref val2)).y + 1f, ((Rect)(ref val2)).width, ((Rect)(ref val2)).height), lines[i].Text, style);
GUI.color = ColorOf(lines[i].Level);
GUI.Label(val2, lines[i].Text, style);
}
}
finally
{
GUI.color = color;
}
}
private void EnsureStyle(int size)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
if (style == null || styleSize != size)
{
if ((Object)(object)font == (Object)null)
{
font = Font.CreateDynamicFontFromOSFont(FontNames, size);
}
style = new GUIStyle(GUI.skin.label)
{
font = font,
fontSize = size,
wordWrap = false,
richText = false
};
style.normal.textColor = Color.white;
styleSize = size;
}
}
private static Rect Place(HudCorner corner, float width, float height, float margin)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
bool num = corner == HudCorner.TopLeft || corner == HudCorner.BottomLeft;
bool flag = corner == HudCorner.TopLeft || corner == HudCorner.TopRight;
float num2 = (num ? margin : ((float)Screen.width - width - margin));
float num3 = (flag ? margin : ((float)Screen.height - height - margin));
return new Rect(num2, num3, width, height);
}
private static Color ColorOf(HudLevel level)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
return (Color)(level switch
{
HudLevel.Danger => new Color(1f, 0.3f, 0.25f),
HudLevel.Warn => new Color(1f, 0.65f, 0.2f),
_ => Color.white,
});
}
}
internal readonly struct HudLine
{
internal string Text { get; }
internal HudLevel Level { get; }
internal HudLine(string text, HudLevel level)
{
Text = text;
Level = level;
}
}
internal static class HazardReadout
{
private const float CampfireScanSeconds = 2f;
private const float CampfireOutSeconds = 10f;
private static FieldRef<OrbFogHandler, FogSphere> sphereOf;
private static FieldRef<LavaRising, float> startHeightOf;
private static Func<LavaRising, bool> readyToStartOf;
private static bool fieldsResolved;
private static readonly List<Campfire> Campfires = new List<Campfire>();
private static float nextCampfireScan;
private static Campfire shownCampfire;
private static float campfireOutUntil;
internal static void Build(List<HudLine> lines, HudText text)
{
ResolveFields();
Character val = (((Object)(object)Character.observedCharacter != (Object)null) ? Character.observedCharacter : Character.localCharacter);
if ((Object)(object)val == (Object)null)
{
return;
}
HostInfo info;
bool hostRuns = HostFlag.TryGetActive(out info);
float warnMeters = HazardConfig.WarnMeters();
float warnSeconds = HazardConfig.WarnSeconds();
try
{
if (sphereOf != null)
{
AddFog(lines, text, val, hostRuns, info, warnMeters, warnSeconds);
}
}
catch (Exception e)
{
Plugin.ReportOnce("overlay fog", e);
}
try
{
AddRising(lines, text, val, hostRuns, info, warnMeters, warnSeconds);
}
catch (Exception e2)
{
Plugin.ReportOnce("overlay rising", e2);
}
try
{
AddCampfire(lines, text, val, warnSeconds);
}
catch (Exception e3)
{
Plugin.ReportOnce("overlay campfire", e3);
}
if (Plugin.FailedParts.Count > 0)
{
lines.Add(new HudLine(text.PartlyStopped, HudLevel.Warn));
}
}
private static void ResolveFields()
{
if (fieldsResolved)
{
return;
}
fieldsResolved = true;
try
{
sphereOf = AccessTools.FieldRefAccess<OrbFogHandler, FogSphere>("sphere");
}
catch (Exception e)
{
Plugin.ReportOnce("overlay fog", e);
}
try
{
startHeightOf = AccessTools.FieldRefAccess<LavaRising, float>("startHeight");
}
catch (Exception e2)
{
Plugin.ReportOnce("overlay rising", e2);
}
try
{
readyToStartOf = AccessTools.MethodDelegate<Func<LavaRising, bool>>(AccessTools.Method(typeof(LavaRising), "ReadyToStart", (Type[])null, (Type[])null), (object)null, true);
}
catch (Exception e3)
{
Plugin.ReportOnce("overlay rising", e3);
}
}
private static void AddFog(List<HudLine> lines, HudText text, Character me, bool hostRuns, HostInfo host, float warnMeters, float warnSeconds)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
OrbFogHandler instance = Singleton<OrbFogHandler>.Instance;
if ((Object)(object)instance == (Object)null || !Ascents.fogEnabled)
{
return;
}
FogSphere val = sphereOf.Invoke(instance);
if ((Object)(object)val == (Object)null || !((Component)val).gameObject.activeInHierarchy)
{
return;
}
float num = Vector3.Distance(val.fogPoint, me.Center);
float num2 = HudMath.EdgeMeters(instance.currentSize, num);
float? seconds = ((!hostRuns && instance.isMoving && !instance.hasArrived) ? HudMath.SecondsToReach(instance.currentSize - num, instance.speed) : ((float?)null));
if (num2 < 0f)
{
bool flag = Mathf.Approximately(val.ENABLE, 1f);
lines.Add(new HudLine(text.FogInside(0f - num2), (!flag) ? HudLevel.Warn : HudLevel.Danger));
}
else
{
lines.Add(new HudLine(text.FogEdge(num2), HudMath.Level(num2, seconds, warnMeters, warnSeconds)));
}
if (instance.hasArrived)
{
return;
}
if (instance.isMoving)
{
if (hostRuns)
{
string text2 = (FogNoOvertake.IsHolding(instance.currentSize) ? text.FogHolding : text.FogMovingStopsIn(FogMath.UnitsToMeters(instance.currentSize - FogNoOvertake.StopSize())));
lines.Add(new HudLine(text2, HudLevel.Normal));
}
else if (seconds.HasValue)
{
lines.Add(new HudLine(text.FogReachesIn(HudMath.Clock(seconds.Value)), HudMath.Level(null, seconds, warnMeters, warnSeconds)));
}
}
else
{
float num3 = (hostRuns ? host.FogWait(instance.currentID) : instance.maxWaitTime);
if (FogMath.TimeStartPossible(Ascents.currentAscent, instance.currentID, num3))
{
lines.Add(new HudLine(text.FogStartsIn(HudMath.Clock(num3 - instance.currentWaitTime), instance.PlayersAreResting), HudLevel.Normal));
}
else
{
lines.Add(new HudLine(text.FogStartsWhenAllMoveOn, HudLevel.Normal));
}
}
}
private static void AddRising(List<HudLine> lines, HudText text, Character me, bool hostRuns, HostInfo host, float warnMeters, float warnSeconds)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected I4, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
MapHandler instance = Singleton<MapHandler>.Instance;
if ((Object)(object)instance == (Object)null)
{
return;
}
Segment currentSegment = instance.GetCurrentSegment();
foreach (LavaRising item in LavaRising.ALL_LAVA)
{
if ((Object)(object)item == (Object)null || !((Behaviour)item).isActiveAndEnabled || item.requiredSegment != currentSegment)
{
continue;
}
int kind = (int)item.risingFieldType;
float num = (((Object)(object)item.lava != (Object)null) ? item.lava.position.y : ((Component)item).transform.position.y);
float num2 = FogMath.UnitsToMeters(me.Center.y - num);
string status = null;
float? seconds = null;
if (item.started && !item.ended)
{
float multiplier = (hostRuns ? host.RisingSpeed(kind) : 1f);
float topY = (((Object)(object)item.topTransform != (Object)null) ? item.topTransform.position.y : num);
if (startHeightOf != null)
{
seconds = RisingMath.SecondsToReach(me.Center.y, num, startHeightOf.Invoke(item), topY, item.travelTime, multiplier);
}
if (seconds.HasValue)
{
status = text.RisingReachesIn(HudMath.Clock(seconds.Value));
}
}
else if (!item.started)
{
float num3 = ((!Ascents.fogEnabled) ? (-1f) : (hostRuns ? host.RisingWait(kind) : item.initialWaitTime));
status = ((num3 < 0f) ? text.RisingNever : (Counting(item) ? text.RisingStartsIn(HudMath.Clock(num3 - item.secondsWaitedToStart)) : text.RisingNotCounting(HudMath.Clock(num3 - Mathf.Max(0f, item.secondsWaitedToStart)))));
}
lines.Add(new HudLine(text.Rising(kind, num2, status), HudMath.Level(num2, seconds, warnMeters, warnSeconds)));
}
}
private static bool Counting(LavaRising rising)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Invalid comparison between Unknown and I4
if (rising.secondsWaitedToStart <= 0f)
{
return false;
}
if ((int)rising.risingFieldType != 1 || readyToStartOf == null)
{
return true;
}
return readyToStartOf(rising);
}
private static void AddCampfire(List<HudLine> lines, HudText text, Character me, float warnSeconds)
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Invalid comparison between Unknown and I4
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Invalid comparison between Unknown and I4
if (Time.unscaledTime >= nextCampfireScan)
{
nextCampfireScan = Time.unscaledTime + 2f;
Campfires.Clear();
Campfires.AddRange(Object.FindObjectsByType<Campfire>((FindObjectsSortMode)0));
}
Campfire val = null;
float num = float.MaxValue;
foreach (Campfire campfire in Campfires)
{
if (!((Object)(object)campfire == (Object)null) && (int)campfire.state == 1)
{
Vector3 val2 = ((Component)campfire).transform.position - me.Center;
float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
if (sqrMagnitude < num)
{
num = sqrMagnitude;
val = campfire;
}
}
}
if ((Object)(object)shownCampfire != (Object)null && (Object)(object)val != (Object)(object)shownCampfire && (int)shownCampfire.state == 2)
{
campfireOutUntil = Time.unscaledTime + 10f;
}
shownCampfire = val;
if ((Object)(object)val != (Object)null)
{
if (!val.CanBurnOut)
{
lines.Add(new HudLine(text.CampfireHeld, HudLevel.Normal));
return;
}
float num2 = val.burnsFor - val.beenBurningFor;
lines.Add(new HudLine(text.CampfireLeft(HudMath.Clock(num2)), HudMath.Level(null, num2, 0f, warnSeconds)));
}
else if (Time.unscaledTime < campfireOutUntil)
{
lines.Add(new HudLine(text.CampfireOut, HudLevel.Warn));
}
}
}
internal static class HostFlag
{
internal const string RoomKey = "t0y9n.fairhazards";
private const float WriteIntervalSeconds = 2f;
private static float nextWrite;
private static bool wasWriter;
private static bool lastActive;
private static int resolvedFrame = -1;
private static HostInfo resolvedInfo;
private static bool resolvedActive;
internal static void Tick()
{
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Expected O, but got Unknown
//IL_00bc: Expected O, but got Unknown
if (!PhotonNetwork.InRoom || !PhotonNetwork.IsMasterClient)
{
wasWriter = false;
return;
}
bool active = Plugin.Active;
if (!wasWriter || active != lastActive || !(Time.unscaledTime < nextWrite))
{
wasWriter = true;
lastActive = active;
nextWrite = Time.unscaledTime + 2f;
string text = (active ? HazardConfig.LocalHostInfo(PhotonNetwork.LocalPlayer.ActorNumber).Encode() : string.Empty);
Room currentRoom = PhotonNetwork.CurrentRoom;
if (!((Dictionary<object, object>)(object)((RoomInfo)currentRoom).CustomProperties).TryGetValue((object)"t0y9n.fairhazards", out object value) || !(value as string == text))
{
Hashtable val = new Hashtable();
((Dictionary<object, object>)val).Add((object)"t0y9n.fairhazards", (object)text);
currentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
}
}
}
internal static bool TryGetActive(out HostInfo info)
{
if (resolvedFrame != Time.frameCount)
{
resolvedFrame = Time.frameCount;
resolvedActive = Resolve(out resolvedInfo);
}
info = resolvedInfo;
return resolvedActive;
}
private static bool Resolve(out HostInfo info)
{
info = null;
if (!Plugin.Active)
{
return false;
}
if (PhotonNetwork.OfflineMode || PhotonNetwork.IsMasterClient)
{
int actor = ((PhotonNetwork.LocalPlayer != null) ? PhotonNetwork.LocalPlayer.ActorNumber : 0);
info = HazardConfig.LocalHostInfo(actor);
return true;
}
Room currentRoom = PhotonNetwork.CurrentRoom;
Player masterClient = PhotonNetwork.MasterClient;
if (currentRoom == null || masterClient == null)
{
return false;
}
if (!((Dictionary<object, object>)(object)((RoomInfo)currentRoom).CustomProperties).TryGetValue((object)"t0y9n.fairhazards", out object value))
{
return false;
}
return HostInfo.TryDecode(value as string, masterClient.ActorNumber, out info);
}
}
[BepInPlugin("t0y9n.peak.fairhazards", "FairHazards", "1.1.0")]
public sealed class Plugin : BaseUnityPlugin
{
public const string Guid = "t0y9n.peak.fairhazards";
internal static readonly List<string> FailedParts = new List<string>();
internal static ManualLogSource Log;
private static readonly (Type patch, string part)[] Parts = new(Type, string)[7]
{
(typeof(FogNoOvertake), "fog hold"),
(typeof(FogStartRule), "fog time start"),
(typeof(FogSync), "fog sync interval"),
(typeof(RisingControl.StartWait), "rising start"),
(typeof(RisingControl.Wait), "rising wait"),
(typeof(RisingControl.SyncInterval), "rising sync interval"),
(typeof(RisingControl.Speed), "rising speed")
};
private static readonly HashSet<string> Reported = new HashSet<string>();
private readonly HazardHud hud = new HazardHud();
internal static bool Active
{
get
{
if (HazardConfig.Enabled != null)
{
return HazardConfig.Enabled.Value;
}
return false;
}
}
internal static void ReportOnce(string part, Exception e)
{
if (Reported.Add(part))
{
if (!FailedParts.Contains(part))
{
FailedParts.Add(part);
}
Log.LogError((object)(part + " threw; the game's own values were kept (logged once): " + e));
}
}
private void Awake()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
HazardConfig.Bind(((BaseUnityPlugin)this).Config);
Harmony harmony = new Harmony("t0y9n.peak.fairhazards");
(Type, string)[] parts = Parts;
for (int i = 0; i < parts.Length; i++)
{
var (patch, part) = parts[i];
Apply(harmony, patch, part);
}
((BaseUnityPlugin)this).Logger.LogInfo((object)("FairHazards 1.1.0 loaded. Parts off: " + ((FailedParts.Count == 0) ? "none" : string.Join(", ", FailedParts))));
}
private void Update()
{
try
{
HostFlag.Tick();
}
catch (Exception e)
{
ReportOnce("host flag", e);
}
if (!FailedParts.Contains("fog clear for returning"))
{
try
{
FogClearForReturning.Tick();
}
catch (Exception e2)
{
ReportOnce("fog clear for returning", e2);
}
}
hud.Tick();
}
private void OnGUI()
{
hud.Draw();
}
private static void Apply(Harmony harmony, Type patch, string part)
{
try
{
harmony.CreateClassProcessor(patch).Patch();
}
catch (Exception ex)
{
FailedParts.Add(part);
Log.LogError((object)(part + " was not applied; the game's own behavior stays. " + ex.Message));
}
}
}
internal static class RisingControl
{
[HarmonyPatch(typeof(LavaRising), "StartWaiting")]
internal static class StartWait
{
[HarmonyPrefix]
private static bool Prefix(LavaRising __instance)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected I4, but got Unknown
try
{
if (!Plugin.Active)
{
return true;
}
return HazardConfig.RisingWait((int)__instance.risingFieldType) >= 0f;
}
catch (Exception e)
{
Plugin.ReportOnce("rising start", e);
}
return true;
}
}
[HarmonyPatch(typeof(LavaRising), "Update")]
internal static class Wait
{
[HarmonyPrefix]
private static void Prefix(LavaRising __instance, out float? __state)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected I4, but got Unknown
__state = null;
try
{
if (Plugin.Active && PhotonNetwork.IsMasterClient)
{
float num = HazardConfig.RisingWait((int)__instance.risingFieldType);
__state = __instance.initialWaitTime;
__instance.initialWaitTime = ((num < 0f) ? float.PositiveInfinity : num);
}
}
catch (Exception e)
{
Plugin.ReportOnce("rising wait", e);
}
}
[HarmonyFinalizer]
private static void Finalizer(LavaRising __instance, float? __state)
{
try
{
if (__state.HasValue)
{
__instance.initialWaitTime = __state.Value;
}
}
catch (Exception e)
{
Plugin.ReportOnce("rising wait", e);
}
}
}
[HarmonyPatch(typeof(LavaRising), "Update")]
internal static class SyncInterval
{
private const float GameInterval = 15f;
[HarmonyPrefix]
private static void Prefix(LavaRising __instance, ref float ___syncTime)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected I4, but got Unknown
try
{
if (Plugin.Active && PhotonNetwork.IsMasterClient)
{
float interval = HazardConfig.RisingSync((int)__instance.risingFieldType);
if (FogMath.IntervalPassed(___syncTime, Time.deltaTime, interval))
{
___syncTime = 15f;
}
}
}
catch (Exception e)
{
Plugin.ReportOnce("rising sync interval", e);
}
}
}
[HarmonyPatch(typeof(LavaRising), "Update")]
internal static class Speed
{
[HarmonyPostfix]
private static void Postfix(LavaRising __instance)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected I4, but got Unknown
try
{
if (__instance.started && !__instance.ended && HostFlag.TryGetActive(out var info))
{
float multiplier = info.RisingSpeed((int)__instance.risingFieldType);
__instance.timeTraveled = RisingMath.ExtraTravel(__instance.timeTraveled, Time.deltaTime, multiplier);
}
}
catch (Exception e)
{
Plugin.ReportOnce("rising speed", e);
}
}
}
}
}
namespace FairHazards.Logic
{
public static class ConfigRange
{
public const float MaxWait = 3600f;
public static float Clamp(float value, float min, float max, out bool changed)
{
float num = (float.IsNaN(value) ? min : ((value < min) ? min : ((value > max) ? max : value)));
changed = float.IsNaN(value) || num != value;
return num;
}
public static float Wait(float value, out bool changed)
{
float num = ((float.IsNaN(value) || value < 0f) ? (-1f) : ((value > 3600f) ? 3600f : value));
changed = float.IsNaN(value) || num != value;
return num;
}
}
public static class FogMath
{
public const float ArriveSize = 30f;
private const float MetersPerUnit = 1.6f;
public static float MetersToUnits(float meters)
{
return meters / 1.6f;
}
public static float UnitsToMeters(float units)
{
return units * 1.6f;
}
public static float? Floor(IReadOnlyList<float> livingDistances, float marginUnits)
{
float num = float.NegativeInfinity;
for (int i = 0; i < livingDistances.Count; i++)
{
float num2 = livingDistances[i];
if (!float.IsNaN(num2) && !float.IsInfinity(num2) && num2 > num)
{
num = num2;
}
}
if (!float.IsNegativeInfinity(num))
{
return num + marginUnits;
}
return null;
}
public static float ScaleShrink(float before, float after, float multiplier)
{
return before - (before - after) * multiplier;
}
public static float Hold(float before, float after, float? floor)
{
if (!floor.HasValue || floor.Value <= 30f || after >= floor.Value)
{
return after;
}
return Math.Min(before, floor.Value);
}
public static bool Arrived(float size)
{
return size <= 30f;
}
public static bool TimeStartPossible(int ascent, int fogId, float waitSetting)
{
if (waitSetting >= 0f && ascent >= 0)
{
return fogId > 0;
}
return false;
}
public static bool TimeStart(int ascent, int fogId, float waited, float waitSetting)
{
if (TimeStartPossible(ascent, fogId, waitSetting))
{
return waited > waitSetting;
}
return false;
}
public static bool IntervalPassed(float counter, float deltaTime, float interval)
{
return counter + deltaTime > interval;
}
public static float? ClearSize(float current, float distance, float marginUnits, float startSize)
{
if (float.IsNaN(distance) || float.IsInfinity(distance) || distance <= current)
{
return null;
}
float num = Math.Min(distance + marginUnits, startSize);
if (!(num > current))
{
return null;
}
return num;
}
}
public sealed class HostInfo
{
public const int FormatVersion = 1;
public const int FogIdCount = 6;
public const int RisingKindCount = 3;
private const float MinSpeed = 0.1f;
private const float MaxSpeed = 5f;
private const float MaxMargin = 50f;
private const float MaxWait = 3600f;
private readonly float[] fogWaits;
private readonly float[] risingWaits;
private readonly float[] risingSpeeds;
public int Actor { get; }
public float FogSpeed { get; }
public float MarginMeters { get; }
public HostInfo(int actor, float fogSpeed, float marginMeters, float[] fogWaits, float[] risingWaits, float[] risingSpeeds)
{
if (fogWaits == null || fogWaits.Length != 6)
{
throw new ArgumentException("fogWaits needs " + 6 + " values");
}
if (risingWaits == null || risingWaits.Length != 3)
{
throw new ArgumentException("risingWaits needs " + 3 + " values");
}
if (risingSpeeds == null || risingSpeeds.Length != 3)
{
throw new ArgumentException("risingSpeeds needs " + 3 + " values");
}
Actor = actor;
FogSpeed = fogSpeed;
MarginMeters = marginMeters;
this.fogWaits = (float[])fogWaits.Clone();
this.risingWaits = (float[])risingWaits.Clone();
this.risingSpeeds = (float[])risingSpeeds.Clone();
}
public float FogWait(int fogId)
{
if (fogId < 0 || fogId >= 6)
{
return -1f;
}
return fogWaits[fogId];
}
public float RisingWait(int kind)
{
if (kind < 0 || kind >= 3)
{
return -1f;
}
return risingWaits[kind];
}
public float RisingSpeed(int kind)
{
if (kind < 0 || kind >= 3)
{
return 1f;
}
return risingSpeeds[kind];
}
public string Encode()
{
return string.Join("|", 1.ToString(CultureInfo.InvariantCulture), Actor.ToString(CultureInfo.InvariantCulture), Number(FogSpeed), Number(MarginMeters), List(fogWaits), List(risingWaits), List(risingSpeeds));
}
public static bool TryDecode(string raw, int expectedActor, out HostInfo info)
{
info = null;
if (string.IsNullOrEmpty(raw))
{
return false;
}
string[] array = raw.Split('|');
if (array.Length != 7 || array[0] != 1.ToString(CultureInfo.InvariantCulture))
{
return false;
}
if (!int.TryParse(array[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) || result != expectedActor)
{
return false;
}
if (!TryNumber(array[2], 0.1f, 5f, out var value))
{
return false;
}
if (!TryNumber(array[3], 0f, 50f, out var value2))
{
return false;
}
if (!TryList(array[4], 6, -1f, 3600f, out var values))
{
return false;
}
if (!TryList(array[5], 3, -1f, 3600f, out var values2))
{
return false;
}
if (!TryList(array[6], 3, 0.1f, 5f, out var values3))
{
return false;
}
info = new HostInfo(result, value, value2, values, values2, values3);
return true;
}
private static string Number(float value)
{
return value.ToString("R", CultureInfo.InvariantCulture);
}
private static string List(float[] values)
{
string[] array = new string[values.Length];
for (int i = 0; i < values.Length; i++)
{
array[i] = Number(values[i]);
}
return string.Join(",", array);
}
private static bool TryNumber(string text, float min, float max, out float value)
{
if (float.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out value) && value >= min)
{
return value <= max;
}
return false;
}
private static bool TryList(string text, int count, float min, float max, out float[] values)
{
values = null;
string[] array = text.Split(',');
if (array.Length != count)
{
return false;
}
float[] array2 = new float[count];
for (int i = 0; i < count; i++)
{
if (!TryNumber(array[i], min, max, out array2[i]))
{
return false;
}
}
values = array2;
return true;
}
}
public enum HudLevel
{
Normal,
Warn,
Danger
}
public static class HudMath
{
private const int MaxClockSeconds = 5999;
public static string Clock(float seconds)
{
if (float.IsNaN(seconds) || seconds < 0f)
{
seconds = 0f;
}
double num = Math.Ceiling(seconds);
int num2 = ((num > 5999.0) ? 5999 : ((int)num));
return (num2 / 60).ToString("00", CultureInfo.InvariantCulture) + ":" + (num2 % 60).ToString("00", CultureInfo.InvariantCulture);
}
public static float EdgeMeters(float fogSize, float distance)
{
return FogMath.UnitsToMeters(fogSize - distance);
}
public static float? SecondsToReach(float gapUnits, float speedUnitsPerSecond)
{
if (!(gapUnits < 0f) && !(speedUnitsPerSecond <= 0f))
{
return gapUnits / speedUnitsPerSecond;
}
return null;
}
public static HudLevel Level(float? marginMeters, float? seconds, float warnMeters, float warnSeconds)
{
if (marginMeters.HasValue && marginMeters.Value < 0f)
{
return HudLevel.Danger;
}
bool num = marginMeters.HasValue && marginMeters.Value <= warnMeters;
bool flag = seconds.HasValue && seconds.Value <= warnSeconds;
if (!(num || flag))
{
return HudLevel.Normal;
}
return HudLevel.Warn;
}
}
public sealed class HudText
{
public static readonly HudText Japanese = new HudText(japanese: true);
public static readonly HudText English = new HudText(japanese: false);
private static readonly string[] JapaneseRising = new string[3] { "溶岩", "かげり", "霊" };
private static readonly string[] EnglishRising = new string[3] { "Lava", "Gloom", "Spirits" };
private readonly bool japanese;
public string FogHolding
{
get
{
if (!japanese)
{
return "Fog: holding for the last climber";
}
return "霧: 止まっている(いちばん後ろの人を待っている)";
}
}
public string FogStartsWhenAllMoveOn
{
get
{
if (!japanese)
{
return "Fog: starts when everyone moves on";
}
return "霧: 全員が先へ進むと動き出す";
}
}
public string RisingNever
{
get
{
if (!japanese)
{
return "off";
}
return "起きない";
}
}
public string CampfireHeld
{
get
{
if (!japanese)
{
return "Campfire: everyone is here, not burning down";
}
return "焚き火: 全員そろっていて減らない";
}
}
public string CampfireOut
{
get
{
if (!japanese)
{
return "Campfire: burned out";
}
return "焚き火: 消えた";
}
}
public string PartlyStopped
{
get
{
if (!japanese)
{
return "FairHazards: some parts are off";
}
return "FairHazards: 一部が止まっています";
}
}
private HudText(bool japanese)
{
this.japanese = japanese;
}
public static HudText Pick(bool japanese)
{
if (!japanese)
{
return English;
}
return Japanese;
}
public string FogEdge(float meters)
{
if (!japanese)
{
return "Fog edge " + M(meters) + " m";
}
return "霧の縁まで " + M(meters) + " m";
}
public string FogInside(float metersToSafety)
{
if (!japanese)
{
return "In the fog, safety in " + M(metersToSafety) + " m";
}
return "霧の中・安全まで " + M(metersToSafety) + " m";
}
public string FogMovingStopsIn(float meters)
{
if (!japanese)
{
return "Fog: moving, stops in " + M(meters) + " m";
}
return "霧: 動いている・あと " + M(meters) + " m で止まる";
}
public string FogStartsIn(string clock, bool resting)
{
if (!japanese)
{
return "Fog: starts in " + clock + (resting ? " (resting)" : string.Empty);
}
return "霧: 動き出すまで " + clock + (resting ? "(休憩中)" : string.Empty);
}
public string FogReachesIn(string clock)
{
if (!japanese)
{
return "Fog: reaches you in " + clock;
}
return "霧: 届くまで " + clock;
}
public string Rising(int kind, float gapMeters, string status)
{
string text = RisingName(kind);
if (gapMeters < 0f)
{
if (!japanese)
{
return "In the " + text.ToLowerInvariant();
}
return text + "の中";
}
string text2 = (japanese ? (text + "まで " + M(gapMeters) + " m") : (text + " " + M(gapMeters) + " m below"));
if (status != null)
{
return text2 + (japanese ? "・" : ", ") + status;
}
return text2;
}
public string RisingReachesIn(string clock)
{
if (!japanese)
{
return "reaches you in " + clock;
}
return "届くまで " + clock;
}
public string RisingStartsIn(string clock)
{
if (!japanese)
{
return "starts in " + clock;
}
return "始まるまで " + clock;
}
public string RisingNotCounting(string clock)
{
if (!japanese)
{
return "starts in " + clock + " (not counting yet)";
}
return "始まるまで " + clock + "(まだ数えていない)";
}
public string CampfireLeft(string clock)
{
if (!japanese)
{
return "Campfire: " + clock + " left";
}
return "焚き火: 残り " + clock;
}
private string RisingName(int kind)
{
string[] array = (japanese ? JapaneseRising : EnglishRising);
if (kind < 0 || kind >= array.Length)
{
if (!japanese)
{
return "Rising";
}
return "せり上がり";
}
return array[kind];
}
private static string M(float meters)
{
return ((int)Math.Round(Math.Max(0f, meters), MidpointRounding.AwayFromZero)).ToString(CultureInfo.InvariantCulture);
}
}
public static class RisingMath
{
public static float ExtraTravel(float timeTraveled, float deltaTime, float multiplier)
{
return Math.Max(0f, timeTraveled + deltaTime * (multiplier - 1f));
}
public static float? SecondsToReach(float playerY, float surfaceY, float startY, float topY, float travelTime, float multiplier)
{
if (travelTime <= 0f || multiplier <= 0f || playerY <= surfaceY || playerY > topY)
{
return null;
}
float num = (topY - startY) / travelTime * multiplier;
if (num <= 0f)
{
return null;
}
return (playerY - surfaceY) / num;
}
}
}