Decompiled source of NightCamp v0.8.3
NightCamp.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Newtonsoft.Json.Linq; using NightCamp.Items; using NightCamp.Models; using NightCamp.Net; using NightCamp.Systems; using NightCamp.World; using Photon.Pun; using Photon.Realtime; using TMPro; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; 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: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("NightCamp")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("NightCamp")] [assembly: AssemblyTitle("NightCamp")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace NightCamp { internal static class DevKeys { public static void Tick() { if (!Plugin.DeveloperMode.Value || Keyboard.current == null || !Game.InLevel) { return; } Keyboard current = Keyboard.current; Character localCharacter = Character.localCharacter; if (((ButtonControl)current.f6Key).wasPressedThisFrame) { SetTime(Settings.WarningHour - 0.1f); } if (((ButtonControl)current.f10Key).wasPressedThisFrame) { SetTime(Game.Clock.dayEnd - 0.1f); } if (((ButtonControl)current.f7Key).wasPressedThisFrame) { BranchScatter.SpawnItemNear(localCharacter, "NC_Tent", 2f); } if (((ButtonControl)current.f8Key).wasPressedThisFrame) { for (int i = 0; i < 3; i++) { BranchScatter.SpawnItemNear(localCharacter, "NC_Branches", 1.5f + (float)i * 0.5f); } } if (((ButtonControl)current.f9Key).wasPressedThisFrame) { LogState(localCharacter); } if (((ButtonControl)current.f11Key).wasPressedThisFrame) { DevOverlay.Visible = !DevOverlay.Visible; } } private static void SetTime(float hour) { if (!PhotonNetwork.IsMasterClient) { Plugin.Log.LogWarning((object)"Only the host can change the time."); return; } Game.SetTimeForAll(hour, Game.Clock.dayCount); Plugin.Log.LogInfo((object)$"Time set to {hour:0.00}"); } private static void LogState(Character me) { //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) DayNightManager clock = Game.Clock; Plugin.Log.LogInfo((object)($"time {clock.timeOfDay:0.00} day {clock.dayCount} night={Game.IsNight} nightish={Game.IsNightish} | " + $"inZone={SafeZones.IsInSafeZone(me)} sleeping={SleepManager.IsSleeping} ({SleepManager.Asleep}/{SleepManager.Needed}) | " + $"firePits={FirePit.All.Count} (lit {FirePit.All.Count((FirePit p) => p.lit)}) tents={PlacedTent.All.Count} | " + $"branches on ground={Item.ALL_ITEMS.Count((Item i) => (Object)(object)i != (Object)null && ItemRegistry.IsBranches(i) && (int)i.itemState == 0)}")); if ((Object)(object)MainCamera.instance != (Object)null) { Transform transform = ((Component)MainCamera.instance).transform; Vector3 spot = transform.position + transform.forward * 2f; IEnumerable<string> values = (from r in Object.FindObjectsByType<MeshRenderer>((FindObjectsSortMode)0).Where(delegate(MeshRenderer r) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = ((Renderer)r).bounds; return ((Bounds)(ref bounds)).SqrDistance(spot) < 4f; }) select (!((Object)(object)((Component)r).transform.parent != (Object)null)) ? ((Object)r).name : (((Object)((Component)r).transform.parent).name + "/" + ((Object)r).name)).Distinct().Take(20); Plugin.Log.LogInfo((object)("Meshes in front of you: " + string.Join(", ", values))); } Scoutmaster val = default(Scoutmaster); if (Scoutmaster.GetPrimaryScoutmaster(ref val)) { ManualLogSource log = Plugin.Log; string obj = (Object.op_Implicit((Object)(object)val.currentTarget) ? val.currentTarget.characterName : "none"); object arg = val.targetForced; Character character = val.character; log.LogInfo((object)("Scout Master: target=" + obj + " " + $"forced={arg} pos={((character != null) ? new Vector3?(character.Center) : ((Vector3?)null))} preventSpawning={val.preventSpawning}")); } else { Plugin.Log.LogInfo((object)"Scout Master: none in this level"); } } } internal static class DevOverlay { private const float BranchRange = 150f; private const float BushRange = 60f; public static bool Visible; private static GUIStyle text; private static GUIStyle marker; public static void Draw() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.DeveloperMode.Value || !Game.InLevel || !Visible || (int)Event.current.type != 7) { return; } if (DevOverlay.text == null) { GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 18 }; val.normal.textColor = Color.white; DevOverlay.text = val; } if (marker == null) { GUIStyle val2 = new GUIStyle(GUI.skin.label) { fontSize = 16, alignment = (TextAnchor)4 }; val2.normal.textColor = new Color(1f, 0.7f, 0.2f); marker = val2; } Character me = Character.localCharacter; Camera val3 = (((Object)(object)MainCamera.instance != (Object)null) ? ((Component)MainCamera.instance).GetComponent<Camera>() : Camera.main); List<Vector3> list = (from i in Item.ALL_ITEMS where (Object)(object)i != (Object)null && ItemRegistry.IsBranches(i) && (int)i.itemState == 0 select i.transform.position into p where Vector3.Distance(p, me.Center) < 150f select p).ToList(); Bushes.CountNear(me.Center, 60f, out var total, out var unsearched); string text = (MapHandler.Exists ? ((object)MapHandler.CurrentMapSegment.biome/*cast due to .constrained prefix*/).ToString() : "?"); GUI.Label(new Rect(20f, 20f, 700f, 90f), "[NightCamp dev] biome: " + text + "\n" + $"Branches on ground within {150f:0} m: {list.Count} ({Settings.BranchesPerBiome} scattered per biome)\n" + $"Searchable bushes within {60f:0} m: {total} ({unsearched} not searched yet)", DevOverlay.text); if ((Object)(object)val3 == (Object)null) { return; } foreach (Vector3 item in list) { Vector3 val4 = val3.WorldToScreenPoint(item + Vector3.up * 0.5f); if (!(val4.z <= 0f)) { GUI.Label(new Rect(val4.x - 50f, (float)Screen.height - val4.y - 12f, 100f, 24f), $"▼ {Vector3.Distance(item, me.Center):0} m", marker); } } } } [BepInPlugin("joket.nightcamp", "NightCamp", "0.8.3")] public class Plugin : BaseUnityPlugin { public const string GUID = "joket.nightcamp"; public const string NAME = "NightCamp"; public const string VERSION = "0.8.3"; internal static ManualLogSource Log; public static ConfigEntry<float> WarningHour; public static ConfigEntry<float> WarningVolume; public static ConfigEntry<float> FireZoneRadius; public static ConfigEntry<float> ColdProtection; public static ConfigEntry<int> BranchesToBuild; public static ConfigEntry<int> BranchesPerBiome; public static ConfigEntry<float> CozyFullSeconds; public static ConfigEntry<float> CozyBonusStamina; public static ConfigEntry<float> BushBranchChance; public static ConfigEntry<string> BushNameKeywords; public static ConfigEntry<string> TreeNameKeywords; public static ConfigEntry<bool> SearchableTrees; public static ConfigEntry<float> NightHuntInterval; public static ConfigEntry<bool> TentAtRunStart; public static ConfigEntry<bool> TentAtCampfires; public static ConfigEntry<bool> NightHunt; public static ConfigEntry<bool> ScoutScreenEffect; public static ConfigEntry<bool> Sleepiness; public static ConfigEntry<float> DrowsyPerNight; public static ConfigEntry<string> BranchesSourceItem; public static ConfigEntry<bool> DeveloperMode; public static ConfigEntry<float> DayLengthMultiplier; public static ConfigEntry<float> NightLengthMultiplier; public static ConfigEntry<Key> MenuKey; private void Awake() { //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Expected O, but got Unknown //IL_0369: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; WarningHour = ((BaseUnityPlugin)this).Config.Bind<float>("Night", "WarningHour", 19.5f, "In-game hour (0-24) when the 'night is coming' warning plays. Night starts at 21:00. Sleeping is allowed from this hour on."); DayLengthMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Night", "DayLengthMultiplier", 2f, "How long the day lasts compared to vanilla (1 = vanilla, 2 = twice as long)."); NightLengthMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Night", "NightLengthMultiplier", 1.5f, "How long the night lasts compared to vanilla (1 = vanilla, about 3.3 minutes; 1.5 = about 5 minutes). Sleeping still skips it."); WarningVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Night", "WarningVolume", 0.8f, "Volume of the dusk warning sound (0-1)."); FireZoneRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Campfire", "FireZoneRadius", 8f, "Radius in meters of the safe zone around a lit player-built campfire."); ColdProtection = ((BaseUnityPlugin)this).Config.Bind<float>("Campfire", "ColdProtection", 0.8f, "Share (0-1) of incoming cold blocked while at a lit player-built campfire (snow, wind, night cold). Existing cold also melts away there."); BranchesToBuild = ((BaseUnityPlugin)this).Config.Bind<int>("Campfire", "BranchesToBuild", 3, "Branches needed in a pile before it can be lit."); BranchesPerBiome = ((BaseUnityPlugin)this).Config.Bind<int>("Branches", "BranchesPerBiome", 20, "Branches scattered on the ground under bushes when a biome loads. They don't respawn."); CozyFullSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Cozy", "FullAfterSeconds", 200f, "Real seconds awake at a lit campfire at night to fill the cozy meter."); CozyBonusStamina = ((BaseUnityPlugin)this).Config.Bind<float>("Cozy", "BonusStamina", 0.25f, "Extra stamina (1 = a full extra bar) gained by filling the cozy meter at a campfire; it builds up as the meter fills."); BushBranchChance = ((BaseUnityPlugin)this).Config.Bind<float>("Branches", "BushBranchChance", 0.5f, "Chance (0-1) that searching a bush drops a branch. Each bush can be searched once per level."); BushNameKeywords = ((BaseUnityPlugin)this).Config.Bind<string>("Branches", "BushNameKeywords", "bush,shrub", "Comma-separated words; level objects whose name contains one of them can be searched for branches."); SearchableTrees = ((BaseUnityPlugin)this).Config.Bind<bool>("Branches", "TreesGiveBranches", true, "Trees can be shaken for branches too (at the trunk)."); TreeNameKeywords = ((BaseUnityPlugin)this).Config.Bind<string>("Branches", "ExtraTreeNameKeywords", "", "Extra comma-separated words for tree meshes that can be shaken for branches, on top of the built-in list (palms, jungle trees, willows, redwoods, mangroves, pines, logs, stumps)."); NightHunt = ((BaseUnityPlugin)this).Config.Bind<bool>("ScoutMaster", "NightHunt", false, "Hard mode: at night the Scout Master hunts anyone outside a campfire zone. Off = vanilla Scout Master (he still never grabs anyone in a zone)."); ScoutScreenEffect = ((BaseUnityPlugin)this).Config.Bind<bool>("ScoutMaster", "ScreenEffect", false, "The grainy/distorted screen while the Scout Master chases you. Off by default: it can get stuck on screen."); Sleepiness = ((BaseUnityPlugin)this).Config.Bind<bool>("Night", "Sleepiness", true, "Staying awake at night slowly makes you drowsy (the pink status), and it stays until you sleep a night through in a tent."); DrowsyPerNight = ((BaseUnityPlugin)this).Config.Bind<float>("Night", "DrowsyPerAwakeNight", 0.23f, "Drowsy (share of the stamina bar) that builds up over a whole night spent awake. It stays until you sleep a night through."); NightHuntInterval = ((BaseUnityPlugin)this).Config.Bind<float>("ScoutMaster", "NightHuntInterval", 20f, "At night, seconds between the Scout Master picking a new victim outside a campfire zone."); TentAtRunStart = ((BaseUnityPlugin)this).Config.Bind<bool>("Tent", "TentAtRunStart", true, "The host spawns a tent next to themselves at the start of a level if nobody has one."); TentAtCampfires = ((BaseUnityPlugin)this).Config.Bind<bool>("Tent", "TentAtCampfires", true, "The host puts a spare tent next to the campfire at the end of every biome."); BranchesSourceItem = ((BaseUnityPlugin)this).Config.Bind<string>("Advanced", "BranchesSourceItem", "", "Prefab name of the placeable item that Branches is cloned from. Empty = pick automatically (see log)."); DeveloperMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Developer", "DeveloperMode", false, "Enables debug hotkeys: F6 time->19:24, F7 spawn tent, F8 spawn 3 branches, F9 log state, F10 time->20:54, F11 branch/bush overlay."); MenuKey = ((BaseUnityPlugin)this).Config.Bind<Key>("General", "MenuKey", (Key)96, "Key that opens the in-game NightCamp settings menu."); Settings.Init(); new Harmony("joket.nightcamp").PatchAll(); GameObject val = new GameObject("NightCamp_Runner"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; val.AddComponent<Runner>(); Log.LogInfo((object)"NightCamp 0.8.3 loaded"); } } internal class Runner : MonoBehaviour { private IEnumerator Start() { while ((Object)(object)SingletonAsset<ItemDatabase>.Instance == (Object)null || !(PhotonNetwork.PrefabPool is DefaultPool)) { yield return null; } ItemRegistry.RegisterAll(); ModNet.Init(); } private void Update() { Settings.Tick(); SettingsMenu.Tick(); DayLength.Tick(); if (ItemRegistry.Ready) { NightController.Tick(); SleepManager.Tick(); Cozy.Tick(); Sleepiness.Tick(); Bushes.Tick(); BranchScatter.Tick(); DevKeys.Tick(); Hud.Tick(); } } private void OnGUI() { SettingsMenu.Draw(); DevOverlay.Draw(); } } internal static class Game { public static DayNightManager Clock => DayNightManager.instance; public static bool InLevel { get { if ((Object)(object)GameUtils.instance != (Object)null && !GameUtils.instance.m_inAirport && (Object)(object)DayNightManager.instance != (Object)null && (Object)(object)Character.localCharacter != (Object)null) { return PhotonNetwork.InRoom; } return false; } } public static bool IsNight { get { if ((Object)(object)Clock != (Object)null) { return Clock.isDay < 0.5f; } return false; } } public static bool IsNightish { get { if ((Object)(object)Clock != (Object)null) { if (!(Clock.timeOfDay >= Settings.WarningHour)) { return Clock.timeOfDay < Clock.dayStart; } return true; } return false; } } public static void SetTimeForAll(float hour, int day) { DayNightManager clock = Clock; if (!((Object)(object)clock == (Object)null) && PhotonNetwork.IsMasterClient) { clock.timeOfDay = hour; clock.dayCount = day; clock.photonView.RPC("RPCA_SyncTime", (RpcTarget)0, new object[2] { day, hour }); } } } internal static class Settings { internal sealed class Entry { public readonly ConfigEntryBase Config; public readonly string Label; public readonly float Min; public readonly float Max; public readonly float Step; public bool IsBool => Config.SettingType == typeof(bool); public bool IsInt => Config.SettingType == typeof(int); public float LocalValue { get { object boxedValue = Config.BoxedValue; if (!(boxedValue is bool)) { if (!(boxedValue is int num)) { if (boxedValue is float result) { return result; } return 0f; } return num; } return ((bool)boxedValue) ? 1f : 0f; } set { if (IsBool) { Config.BoxedValue = value > 0.5f; } else if (IsInt) { Config.BoxedValue = Mathf.RoundToInt(value); } else { Config.BoxedValue = value; } } } public Entry(ConfigEntryBase config, string label, float min, float max, float step) { Config = config; Label = label; Min = min; Max = max; Step = step; } } private const string RoomKey = "nc_cfg"; private const float PublishInterval = 1f; public static readonly List<Entry> Entries = new List<Entry>(); private static float[] local = new float[0]; private static float[] remote; private static float[] lastPublished; private static float publishTimer; private static int iWarningHour; private static int iFireZone; private static int iCold; private static int iToBuild; private static int iBranchesPerBiome; private static int iCozySeconds; private static int iCozyBonus; private static int iBushChance; private static int iHuntInterval; private static int iTentAtStart; private static int iDayLength; private static int iNightLength; private static int iTrees; private static int iTentAtCampfires; private static int iNightHunt; private static int iScreenEffect; private static int iSleepiness; private static int iSleepinessRate; public static bool FromHost { get { if (PhotonNetwork.InRoom && !PhotonNetwork.IsMasterClient) { return remote != null; } return false; } } public static float WarningHour => Value(iWarningHour); public static float FireZoneRadius => Value(iFireZone); public static float ColdProtection => Value(iCold); public static int BranchesToBuild => Mathf.RoundToInt(Value(iToBuild)); public static int BranchesPerBiome => Mathf.RoundToInt(Value(iBranchesPerBiome)); public static float CozyFullSeconds => Value(iCozySeconds); public static float CozyBonusStamina => Value(iCozyBonus); public static float BushBranchChance => Value(iBushChance); public static float NightHuntInterval => Value(iHuntInterval); public static bool TentAtRunStart => Value(iTentAtStart) > 0.5f; public static bool SearchableTrees => Value(iTrees) > 0.5f; public static bool TentAtCampfires => Value(iTentAtCampfires) > 0.5f; public static bool NightHunt => Value(iNightHunt) > 0.5f; public static bool ScoutScreenEffect => Value(iScreenEffect) > 0.5f; public static bool Sleepiness => Value(iSleepiness) > 0.5f; public static float DrowsyPerNight => Value(iSleepinessRate); public static float DayLengthMultiplier => Value(iDayLength); public static float NightLengthMultiplier => Value(iNightLength); public static void Init() { iDayLength = Add((ConfigEntryBase)(object)Plugin.DayLengthMultiplier, "Day length (x vanilla)", 0.5f, 5f, 0.25f); iNightLength = Add((ConfigEntryBase)(object)Plugin.NightLengthMultiplier, "Night length (x vanilla)", 0.5f, 5f, 0.25f); iWarningHour = Add((ConfigEntryBase)(object)Plugin.WarningHour, "Night warning at (hour)", 17f, 20.9f, 0.1f); iSleepiness = Add((ConfigEntryBase)(object)Plugin.Sleepiness, "Drowsy when awake at night", 0f, 1f, 1f); iSleepinessRate = Add((ConfigEntryBase)(object)Plugin.DrowsyPerNight, "Drowsy per night awake", 0.05f, 0.5f, 0.05f); iBranchesPerBiome = Add((ConfigEntryBase)(object)Plugin.BranchesPerBiome, "Branches per biome", 0f, 60f, 1f); iBushChance = Add((ConfigEntryBase)(object)Plugin.BushBranchChance, "Search branch chance", 0f, 1f, 0.05f); iTrees = Add((ConfigEntryBase)(object)Plugin.SearchableTrees, "Trees give branches too", 0f, 1f, 1f); iToBuild = Add((ConfigEntryBase)(object)Plugin.BranchesToBuild, "Branches for a campfire", 1f, 6f, 1f); iFireZone = Add((ConfigEntryBase)(object)Plugin.FireZoneRadius, "Campfire safe radius (m)", 4f, 20f, 0.5f); iCold = Add((ConfigEntryBase)(object)Plugin.ColdProtection, "Campfire cold protection", 0f, 1f, 0.05f); iCozySeconds = Add((ConfigEntryBase)(object)Plugin.CozyFullSeconds, "Cozy meter fill time (s)", 30f, 600f, 10f); iCozyBonus = Add((ConfigEntryBase)(object)Plugin.CozyBonusStamina, "Campfire bonus stamina", 0f, 1f, 0.05f); iNightHunt = Add((ConfigEntryBase)(object)Plugin.NightHunt, "Scout Master hunts at night (hard)", 0f, 1f, 1f); iHuntInterval = Add((ConfigEntryBase)(object)Plugin.NightHuntInterval, "Scout Master hunt interval (s)", 5f, 120f, 1f); iScreenEffect = Add((ConfigEntryBase)(object)Plugin.ScoutScreenEffect, "Scout Master grainy screen", 0f, 1f, 1f); iTentAtStart = Add((ConfigEntryBase)(object)Plugin.TentAtRunStart, "Free tent at level start", 0f, 1f, 1f); iTentAtCampfires = Add((ConfigEntryBase)(object)Plugin.TentAtCampfires, "Spare tent at each biome's campfire", 0f, 1f, 1f); local = new float[Entries.Count]; Refresh(); } private static int Add(ConfigEntryBase config, string label, float min, float max, float step) { Entries.Add(new Entry(config, label, min, max, step)); return Entries.Count - 1; } public static float Value(int index) { if (!FromHost || index >= remote.Length) { return local[index]; } return remote[index]; } public static void Tick() { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00b6: Expected O, but got Unknown Refresh(); if (!PhotonNetwork.InRoom) { remote = null; lastPublished = null; } else if (PhotonNetwork.IsMasterClient) { remote = null; publishTimer += Time.unscaledDeltaTime; if (!(publishTimer < 1f)) { publishTimer = 0f; if (!((Dictionary<object, object>)(object)((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties).ContainsKey((object)"nc_cfg") || lastPublished == null || !Same(lastPublished, local)) { lastPublished = (float[])local.Clone(); Room currentRoom = PhotonNetwork.CurrentRoom; Hashtable val = new Hashtable(); ((Dictionary<object, object>)val).Add((object)"nc_cfg", (object)lastPublished); currentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null); } } } else { lastPublished = null; remote = (((Dictionary<object, object>)(object)((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties).TryGetValue((object)"nc_cfg", out object value) ? (value as float[]) : null); } } private static void Refresh() { for (int i = 0; i < Entries.Count; i++) { local[i] = Entries[i].LocalValue; } } private static bool Same(float[] a, float[] b) { if (a.Length != b.Length) { return false; } for (int i = 0; i < a.Length; i++) { if (!Mathf.Approximately(a[i], b[i])) { return false; } } return true; } } } namespace NightCamp.World { internal enum SearchKind { Bush, Tree, Driftwood } internal static class Bushes { private struct Bush { public Renderer Renderer; public Vector3 Center; public float Radius; public Vector3Int Key; public SearchKind Kind; } private const float CellSize = 10f; private const float Reach = 2f; private const float MaxBushSize = 6f; private const float MaxDriftwoodSize = 10f; private const float MinTreeHeight = 2.5f; private const float MaxTreeSize = 80f; private const float TrunkSearchHeight = 1.3f; private const float TrunkRadius = 0.8f; private static readonly string[] BuiltInTreeWords = new string[12] { "palmtree", "palm tree", "jungle_tree", "jungle_willow", "willow", "treebark", "redwood", "mangrove", "trunk", "pine", "stump", "logs" }; private static readonly string[] TreeExclusions = new string[7] { "leaves", "leaf", "crown", "flower", "petrified", "mirage", "moss" }; private static readonly Dictionary<Vector2Int, List<Bush>> grid = new Dictionary<Vector2Int, List<Bush>>(); private static readonly HashSet<Vector3Int> searched = new HashSet<Vector3Int>(); private static int sceneHandle = -1; private static int indexedSegment = -2; private static float sceneTime; public static int IndexedSegment => indexedSegment; public static void Tick() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); int num = SceneHandle.op_Implicit(((Scene)(ref activeScene)).handle); if (num != sceneHandle) { sceneHandle = num; sceneTime = 0f; indexedSegment = -2; grid.Clear(); searched.Clear(); } if (Game.InLevel) { sceneTime += Time.deltaTime; int num2 = (MapHandler.Exists ? Singleton<MapHandler>.Instance.currentSegment : (-1)); if (sceneTime > 3f && num2 != indexedSegment) { indexedSegment = num2; BuildIndex(); } } } private static void BuildIndex() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_0195: 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_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) grid.Clear(); string[] keywords = Words(Plugin.BushNameKeywords.Value); string[] keywords2 = BuiltInTreeWords.Concat(Words(Plugin.TreeNameKeywords.Value)).Distinct().ToArray(); Dictionary<string, int> dictionary = new Dictionary<string, int>(); int num = 0; int num2 = 0; int num3 = 0; MeshRenderer[] array = Object.FindObjectsByType<MeshRenderer>((FindObjectsInactive)1, (FindObjectsSortMode)0); Vector3 extents; foreach (MeshRenderer val in array) { if ((Object)(object)val == (Object)null) { continue; } Bounds bounds = ((Renderer)val).bounds; float num4 = Mathf.Max(new float[3] { ((Bounds)(ref bounds)).size.x, ((Bounds)(ref bounds)).size.y, ((Bounds)(ref bounds)).size.z }); string text = ((Object)val).name.ToLowerInvariant(); string text2 = (((Object)(object)((Component)val).transform.parent != (Object)null) ? ((Object)((Component)val).transform.parent).name.ToLowerInvariant() : ""); if (text.Contains("driftwood") || text2.Contains("driftwood")) { if (num4 < 0.3f || num4 > 10f) { continue; } Vector3 center = ((Bounds)(ref bounds)).center; extents = ((Bounds)(ref bounds)).extents; Add((Renderer)(object)val, center, Mathf.Max(0.5f, ((Vector3)(ref extents)).magnitude * 0.6f), SearchKind.Driftwood); num3++; } else if (Matches((Renderer)(object)val, keywords)) { if (num4 < 0.3f || num4 > 6f) { continue; } Vector3 center2 = ((Bounds)(ref bounds)).center; extents = ((Bounds)(ref bounds)).extents; Add((Renderer)(object)val, center2, Mathf.Max(0.4f, ((Vector3)(ref extents)).magnitude * 0.7f), SearchKind.Bush); num++; } else { if (!Matches((Renderer)(object)val, keywords2) || TreeExclusions.Any(text.Contains) || ((Bounds)(ref bounds)).size.y < 2.5f || num4 > 80f) { continue; } Add((Renderer)(object)val, TrunkPoint((Renderer)(object)val, bounds), 0.8f, SearchKind.Tree); num2++; } dictionary[((Object)val).name] = ((!dictionary.TryGetValue(((Object)val).name, out var value)) ? 1 : (value + 1)); } BerryBush[] array2 = Object.FindObjectsByType<BerryBush>((FindObjectsInactive)1, (FindObjectsSortMode)0); for (int i = 0; i < array2.Length; i++) { MeshRenderer componentInChildren = ((Component)array2[i]).GetComponentInChildren<MeshRenderer>(true); if (!((Object)(object)componentInChildren == (Object)null) && !IsIndexed((Renderer)(object)componentInChildren)) { Bounds bounds2 = ((Renderer)componentInChildren).bounds; Vector3 center3 = ((Bounds)(ref bounds2)).center; bounds2 = ((Renderer)componentInChildren).bounds; extents = ((Bounds)(ref bounds2)).extents; Add((Renderer)(object)componentInChildren, center3, Mathf.Max(0.5f, ((Vector3)(ref extents)).magnitude * 0.7f), SearchKind.Bush); num++; } } Plugin.Log.LogInfo((object)$"Indexed searchable plants: {num} bushes, {num2} tree trunks, {num3} driftwood."); if (Plugin.DeveloperMode.Value) { Plugin.Log.LogInfo((object)("Searchable meshes: " + string.Join(", ", from kv in dictionary.OrderByDescending((KeyValuePair<string, int> kv) => kv.Value).Take(40) select $"{kv.Key} x{kv.Value}"))); } } private static bool IsIndexed(Renderer r) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = r.bounds; Vector2Int key = CellOf(((Bounds)(ref bounds)).center); if (grid.TryGetValue(key, out var value)) { return value.Any((Bush b) => (Object)(object)b.Renderer == (Object)(object)r); } return false; } private static string[] Words(string csv) { return (from k in csv.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries) select k.Trim().ToLowerInvariant() into k where k.Length > 0 select k).ToArray(); } private static Vector3 TrunkPoint(Renderer r, Bounds b) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)r).transform.position; return ((position.y - ((Bounds)(ref b)).min.y < 1.5f && position.x >= ((Bounds)(ref b)).min.x && position.x <= ((Bounds)(ref b)).max.x && position.z >= ((Bounds)(ref b)).min.z && position.z <= ((Bounds)(ref b)).max.z) ? new Vector3(position.x, ((Bounds)(ref b)).min.y, position.z) : new Vector3(((Bounds)(ref b)).center.x, ((Bounds)(ref b)).min.y, ((Bounds)(ref b)).center.z)) + Vector3.up * 1.3f; } private static bool Matches(Renderer r, string[] keywords) { string text = ((Object)r).name.ToLowerInvariant(); string text2 = (((Object)(object)((Component)r).transform.parent != (Object)null) ? ((Object)((Component)r).transform.parent).name.ToLowerInvariant() : ""); foreach (string value in keywords) { if (text.Contains(value) || text2.Contains(value)) { return true; } } return false; } private static void Add(Renderer r, Vector3 center, float radius, SearchKind kind) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) Bush item = new Bush { Renderer = r, Center = center, Radius = radius, Key = KeyOf(center), Kind = kind }; Vector2Int key = CellOf(center); if (!grid.TryGetValue(key, out var value)) { value = (grid[key] = new List<Bush>()); } value.Add(item); } private static Vector2Int CellOf(Vector3 p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) return new Vector2Int(Mathf.FloorToInt(p.x / 10f), Mathf.FloorToInt(p.z / 10f)); } private static Vector3Int KeyOf(Vector3 p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) return Vector3Int.RoundToInt(p * 4f); } public static BushTarget FindLookedAt() { //IL_0027: 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) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) if (grid.Count == 0 || (Object)(object)MainCamera.instance == (Object)null) { return null; } Transform transform = ((Component)MainCamera.instance).transform; Vector3 position = transform.position; Vector2Int val = CellOf(position); bool searchableTrees = Settings.SearchableTrees; Bush bush = default(Bush); float num = float.MaxValue; for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (!grid.TryGetValue(new Vector2Int(((Vector2Int)(ref val)).x + i, ((Vector2Int)(ref val)).y + j), out var value)) { continue; } foreach (Bush item in value) { if ((Object)(object)item.Renderer == (Object)null || !((Component)item.Renderer).gameObject.activeInHierarchy || (item.Kind == SearchKind.Tree && !searchableTrees)) { continue; } Vector3 val2 = item.Center - position; float magnitude = ((Vector3)(ref val2)).magnitude; if (!(magnitude - item.Radius > 2f) && !(magnitude >= num)) { float num2 = Mathf.Atan2(item.Radius, Mathf.Max(magnitude, 0.1f)) * 57.29578f + 5f; if (!(Vector3.Angle(transform.forward, val2) > num2)) { bush = item; num = magnitude; } } } } } if (num == float.MaxValue) { return null; } List<Renderer> list = new List<Renderer>(); foreach (List<Bush> item2 in NeighbourLists(bush.Center)) { foreach (Bush item3 in item2) { if (item3.Key == bush.Key && (Object)(object)item3.Renderer != (Object)null && !list.Contains(item3.Renderer)) { list.Add(item3.Renderer); } } } BushTarget instance = BushTarget.Instance; instance.Set(bush.Center, bush.Radius, bush.Key, list, bush.Kind); return instance; } public static bool IsSearched(Vector3Int key) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return searched.Contains(key); } private static IEnumerable<List<Bush>> NeighbourLists(Vector3 p) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Vector2Int cell = CellOf(p); for (int dx = -1; dx <= 1; dx++) { for (int dz = -1; dz <= 1; dz++) { if (grid.TryGetValue(new Vector2Int(((Vector2Int)(ref cell)).x + dx, ((Vector2Int)(ref cell)).y + dz), out var value)) { yield return value; } } } } public static int ActiveSearchableCount() { bool searchableTrees = Settings.SearchableTrees; int num = 0; foreach (List<Bush> value in grid.Values) { foreach (Bush item in value) { if ((Object)(object)item.Renderer != (Object)null && ((Component)item.Renderer).gameObject.activeInHierarchy && (searchableTrees || item.Kind != SearchKind.Tree)) { num++; } } } return num; } public static List<(Vector3 center, float radius)> ActiveBushes() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) List<(Vector3, float)> list = new List<(Vector3, float)>(); foreach (List<Bush> value in grid.Values) { foreach (Bush item in value) { if ((Object)(object)item.Renderer != (Object)null && ((Component)item.Renderer).gameObject.activeInHierarchy) { list.Add((item.Center, item.Radius)); } } } return list; } public static void CountNear(Vector3 pos, float radius, out int total, out int unsearched) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) total = (unsearched = 0); Vector2Int val = CellOf(pos - new Vector3(radius, 0f, radius)); Vector2Int val2 = CellOf(pos + new Vector3(radius, 0f, radius)); for (int i = ((Vector2Int)(ref val)).x; i <= ((Vector2Int)(ref val2)).x; i++) { for (int j = ((Vector2Int)(ref val)).y; j <= ((Vector2Int)(ref val2)).y; j++) { if (!grid.TryGetValue(new Vector2Int(i, j), out var value)) { continue; } foreach (Bush item in value) { if (!(Vector3.Distance(item.Center, pos) > radius)) { total++; if (!searched.Contains(item.Key)) { unsearched++; } } } } } } public static void HostSearch(Vector3 center, float radius, Vector3 searcher, Character who) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) Vector3Int item = KeyOf(center); if (searched.Add(item)) { ModNet.BroadcastBushSearched(center); float value = Random.value; bool flag = value <= Settings.BushBranchChance; if (Plugin.DeveloperMode.Value) { Plugin.Log.LogInfo((object)string.Format("Search at {0}: roll {1:0.00} vs chance {2:0.00} -> {3}", center, value, Settings.BushBranchChance, flag ? "branch" : "nothing")); } if (flag && !GiveTo(who)) { Vector3 val = Vector3.ProjectOnPlane(searcher - center, Vector3.up); Vector3 val2 = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : Vector3.forward); float num = Mathf.Min(radius + 0.3f, Mathf.Max(0.6f, ((Vector3)(ref val)).magnitude - 0.4f)); Vector3 val3 = center + val2 * num; LayerMask mask = HelperFunctions.GetMask((LayerType)1); RaycastHit val4 = default(RaycastHit); val3 = ((!Physics.Raycast(val3 + Vector3.up * 3f, Vector3.down, ref val4, 8f, LayerMask.op_Implicit(mask))) ? (val3 + Vector3.up * 0.5f) : (((RaycastHit)(ref val4)).point + Vector3.up * 0.4f)); Quaternion randomRotationWithUp = HelperFunctions.GetRandomRotationWithUp(Vector3.up); GameObject val5 = PhotonNetwork.InstantiateItemRoom("NC_Branches", val3, randomRotationWithUp, true); val5.GetComponent<PhotonView>().RPC("SetKinematicRPC", (RpcTarget)0, new object[3] { false, val5.transform.position, val5.transform.rotation }); } } } private static bool GiveTo(Character who) { if ((Object)(object)who == (Object)null || (Object)(object)who.player == (Object)null || (Object)(object)ItemRegistry.Branches == (Object)null) { return false; } ItemSlot val = default(ItemSlot); if (!who.player.AddItem(ItemRegistry.Branches.itemID, (ItemInstanceData)null, ref val) || val == null) { return false; } who.refs.view.RPC("OnPickupAccepted", ((MonoBehaviourPun)who.player).photonView.Owner, new object[1] { val.itemSlotID }); return true; } public static void MarkSearched(Vector3 center) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) searched.Add(KeyOf(center)); } } internal class BushTarget : MonoBehaviour, IInteractibleConstant, IInteractible { private static BushTarget instance; private static readonly string[] ColorProps = new string[4] { "_BaseColor", "_Color", "_Tint", "_MainColor" }; private const float HoverBrighten = 1.45f; private float radius; private Vector3Int key; private SearchKind kind; private List<Renderer> renderers = new List<Renderer>(); private Vector3Int? highlightedKey; private readonly List<Renderer> highlighted = new List<Renderer>(); private MaterialPropertyBlock mpb; private readonly Dictionary<Renderer, Material[]> originalMaterials = new Dictionary<Renderer, Material[]>(); private readonly HashSet<Renderer> tinted = new HashSet<Renderer>(); private readonly Dictionary<Material, Material> highlightCopies = new Dictionary<Material, Material>(); public static BushTarget Instance { get { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if ((Object)(object)instance == (Object)null) { GameObject val = new GameObject("NC_BushTarget"); Object.DontDestroyOnLoad((Object)val); instance = val.AddComponent<BushTarget>(); } return instance; } } private bool Searched => Bushes.IsSearched(key); public bool IsUsedUp => Searched; public bool holdOnFinish => false; public void Set(Vector3 center, float r, Vector3Int k, List<Renderer> rends, SearchKind searchKind) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = center; radius = r; key = k; renderers = rends; kind = searchKind; } private void LateUpdate() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) GUIManager val = GUIManager.instance; Vector3Int? val2 = (((Object)(object)val != (Object)null && (object)val.currentInteractable == this && !Searched) ? new Vector3Int?(key) : ((Vector3Int?)null)); Vector3Int? val3 = val2; Vector3Int? val4 = highlightedKey; if (val3.HasValue == val4.HasValue && (!val3.HasValue || val3.GetValueOrDefault() == val4.GetValueOrDefault())) { return; } foreach (Renderer item in highlighted) { if ((Object)(object)item != (Object)null) { SetHighlight(item, on: false); } } highlighted.Clear(); if (val2.HasValue) { foreach (Renderer renderer in renderers) { if ((Object)(object)renderer != (Object)null) { SetHighlight(renderer, on: true); highlighted.Add(renderer); } } } highlightedKey = val2; } private void SetHighlight(Renderer r, bool on) { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) if (!on) { if (originalMaterials.TryGetValue(r, out var value)) { r.sharedMaterials = value; } originalMaterials.Remove(r); if (tinted.Remove(r)) { r.SetPropertyBlock((MaterialPropertyBlock)null); } } else { if (originalMaterials.ContainsKey(r) || tinted.Contains(r)) { return; } Material[] sharedMaterials = r.sharedMaterials; if (sharedMaterials.Length != 0 && (Object)(object)sharedMaterials[0] != (Object)null && sharedMaterials[0].HasProperty(Item.PROPERTY_INTERACTABLE)) { originalMaterials[r] = sharedMaterials; Material[] array = (Material[])(object)new Material[sharedMaterials.Length]; for (int i = 0; i < sharedMaterials.Length; i++) { array[i] = HighlightCopy(sharedMaterials[i]); } r.sharedMaterials = array; return; } Material val = ((sharedMaterials.Length != 0) ? sharedMaterials[0] : null); if ((Object)(object)val == (Object)null) { return; } if (mpb == null) { mpb = new MaterialPropertyBlock(); } mpb.Clear(); string[] colorProps = ColorProps; foreach (string text in colorProps) { if (val.HasProperty(text)) { Color color = val.GetColor(text); mpb.SetColor(text, new Color(color.r * 1.45f, color.g * 1.45f, color.b * 1.45f, color.a)); r.SetPropertyBlock(mpb); tinted.Add(r); break; } } } } private Material HighlightCopy(Material m) { //IL_0027: 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) //IL_0043: Expected O, but got Unknown //IL_004f: 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) if ((Object)(object)m == (Object)null) { return null; } if (highlightCopies.TryGetValue(m, out var value) && (Object)(object)value != (Object)null) { return value; } value = new Material(m) { name = ((Object)m).name + " (NC hover)" }; List<string> list = new List<string>(); LocalKeywordSpace keywordSpace = m.shader.keywordSpace; string[] keywordNames = ((LocalKeywordSpace)(ref keywordSpace)).keywordNames; foreach (string text in keywordNames) { if (text.IndexOf("INTERACTABLE", StringComparison.OrdinalIgnoreCase) >= 0) { value.EnableKeyword(text); list.Add(text); } } value.SetFloat(Item.PROPERTY_INTERACTABLE, 1f); if (value.HasProperty("_INTERACTABLE")) { value.SetFloat("_INTERACTABLE", 1f); } if (Plugin.DeveloperMode.Value) { Plugin.Log.LogInfo((object)("Bush hover material for '" + ((Object)m).name + "' (" + ((Object)m.shader).name + "): keywords [" + string.Join(", ", list) + "]")); } highlightCopies[m] = value; return value; } public bool IsInteractible(Character interactor) { return true; } public void Interact(Character interactor) { } public void HoverEnter() { } public void HoverExit() { } public Vector3 Center() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ((Component)this).transform.position; } public Transform GetTransform() { return ((Component)this).transform; } public string GetName() { return kind switch { SearchKind.Tree => "Tree", SearchKind.Driftwood => "Driftwood", _ => "Bush", }; } public string GetInteractionText() { return kind switch { SearchKind.Tree => Searched ? "Already shaken" : "Shake for branches", SearchKind.Driftwood => Searched ? "Nothing left to break off" : "Break off a branch", _ => Searched ? "Already searched" : "Search for branches", }; } public bool IsConstantlyInteractable(Character interactor) { return !Searched; } public float GetInteractTime(Character interactor) { return 1.5f; } public void Interact_CastFinished(Character interactor) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (!Searched) { ModNet.RequestSearchBush(((Component)this).transform.position, radius, interactor.Center); } } public void CancelCast(Character interactor) { } public void ReleaseInteract(Character interactor) { } } internal class FirePit : MonoBehaviourPun, IInteractibleConstant, IInteractible { public static readonly List<FirePit> All = new List<FirePit>(); private const float MergeRadius = 2.5f; private const float WarmthPerSecond = 0.05f; private const float CookTime = 5f; private const float FireScale = 0.45f; public int branchCount = 1; public bool lit; private GameObject[] branchVisuals; private GameObject fire; private Light fireLight; private bool wasNight; private Item cooking; private static int Needed => Mathf.Max(1, Settings.BranchesToBuild); public bool holdOnFinish => false; private void Awake() { All.Add(this); List<GameObject> list = new List<GameObject>(); int num = 0; while (true) { Transform val = ((Component)this).transform.Find("Branch_" + num); if ((Object)(object)val == (Object)null) { break; } list.Add(((Component)val).gameObject); num++; } branchVisuals = list.ToArray(); } private void Start() { object[] instantiationData = ((MonoBehaviourPun)this).photonView.InstantiationData; if (instantiationData != null && instantiationData.Length > 0 && instantiationData[0] is int num) { branchCount = num; } wasNight = Game.IsNight; ApplyVisuals(); } private void OnDestroy() { All.Remove(this); } private void Update() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (lit && (Object)(object)fireLight != (Object)null) { fireLight.intensity = 3f + Mathf.PerlinNoise(Time.time * 4f, 0f) * 1.5f; } Character localCharacter = Character.localCharacter; if (lit && (Object)(object)localCharacter != (Object)null && InZone(localCharacter.Center) && localCharacter.refs.afflictions.GetCurrentStatus((STATUSTYPE)2) > 0f) { localCharacter.refs.afflictions.SubtractStatus((STATUSTYPE)2, 0.05f * Time.deltaTime, false, false); } if (PhotonNetwork.IsMasterClient) { bool isNight = Game.IsNight; if (lit && wasNight && !isNight) { HostSetState(0, isLit: false); } wasNight = isNight; } } public bool InZone(Vector3 pos) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (lit) { return Vector3.Distance(pos, ((Component)this).transform.position) <= Settings.FireZoneRadius; } return false; } public static bool Warms(Vector3 pos) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) foreach (FirePit item in All) { if ((Object)(object)item != (Object)null && item.InZone(pos)) { return true; } } return false; } public static void HostPlaceBranch(Vector3 pos, Quaternion rot) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) FirePit firePit = null; float num = 2.5f; foreach (FirePit item in All) { float num2 = Vector3.Distance(((Component)item).transform.position, pos); if (num2 < num) { num = num2; firePit = item; } } if ((Object)(object)firePit != (Object)null) { if (!firePit.lit) { firePit.HostSetState(Mathf.Min(firePit.branchCount + 1, Needed), isLit: false); } } else { Quaternion val = Quaternion.Euler(0f, ((Quaternion)(ref rot)).eulerAngles.y, 0f); PhotonNetwork.InstantiateRoomObject("NC_FirePit", pos, val, (byte)0, new object[1] { 1 }); } } private void HostSetState(int count, bool isLit) { PhotonNetwork.RemoveRPCs(((MonoBehaviourPun)this).photonView); ((MonoBehaviourPun)this).photonView.RPC("NC_State", (RpcTarget)3, new object[2] { count, isLit }); } [PunRPC] private void NC_State(int count, bool isLit) { branchCount = count; lit = isLit; ApplyVisuals(); } [PunRPC] private void NC_RequestAddBranch() { if (PhotonNetwork.IsMasterClient && !lit && branchCount < Needed) { HostSetState(branchCount + 1, isLit: false); } } [PunRPC] private void NC_RequestLight() { if (PhotonNetwork.IsMasterClient && !lit && branchCount >= Needed) { HostSetState(branchCount, isLit: true); } } private void ApplyVisuals() { for (int i = 0; i < branchVisuals.Length; i++) { branchVisuals[i].SetActive(i < branchCount); } if (lit && (Object)(object)fire == (Object)null) { CreateFire(); } if ((Object)(object)fire != (Object)null) { fire.SetActive(lit); } } private void CreateFire() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Expected O, but got Unknown //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) fire = new GameObject("Fire"); fire.transform.SetParent(((Component)this).transform, false); fire.transform.localPosition = new Vector3(0f, 0.1f, 0f); Campfire val = FindSourceCampfire(); if ((Object)(object)val != (Object)null) { GameObject val2 = new GameObject("staging"); val2.SetActive(false); GameObject val3 = Object.Instantiate<GameObject>(val.enableWhenLit, val2.transform); for (int i = 0; i < 4; i++) { MonoBehaviour[] componentsInChildren = val3.GetComponentsInChildren<MonoBehaviour>(true); for (int j = 0; j < componentsInChildren.Length; j++) { Object.DestroyImmediate((Object)(object)componentsInChildren[j]); } } Collider[] componentsInChildren2 = val3.GetComponentsInChildren<Collider>(true); for (int j = 0; j < componentsInChildren2.Length; j++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[j]); } Light[] componentsInChildren3 = val3.GetComponentsInChildren<Light>(true); for (int j = 0; j < componentsInChildren3.Length; j++) { ((Behaviour)componentsInChildren3[j]).enabled = false; } val3.transform.SetParent(fire.transform, false); val3.transform.localPosition = Vector3.zero; val3.transform.localRotation = Quaternion.identity; val3.transform.localScale = val.enableWhenLit.transform.lossyScale * 0.45f; val3.SetActive(true); ParticleSystem[] componentsInChildren4 = val3.GetComponentsInChildren<ParticleSystem>(true); for (int j = 0; j < componentsInChildren4.Length; j++) { componentsInChildren4[j].Play(); } AudioSource[] componentsInChildren5 = val3.GetComponentsInChildren<AudioSource>(true); foreach (AudioSource val4 in componentsInChildren5) { if ((Object)(object)val4.clip != (Object)null && val4.loop) { val4.Play(); } } Object.Destroy((Object)(object)val2); } GameObject val5 = new GameObject("Light"); val5.transform.SetParent(fire.transform, false); val5.transform.localPosition = new Vector3(0f, 0.7f, 0f); fireLight = val5.AddComponent<Light>(); fireLight.type = (LightType)2; fireLight.color = new Color(1f, 0.55f, 0.2f); fireLight.range = Settings.FireZoneRadius * 1.5f; fireLight.intensity = 3f; } private static Campfire FindSourceCampfire() { try { Campfire val = (MapHandler.Exists ? MapHandler.CurrentCampfire : null); if ((Object)(object)val != (Object)null && (Object)(object)val.enableWhenLit != (Object)null) { return val; } } catch (Exception) { } foreach (Campfire aLL_CAMPFIRE in Campfire.ALL_CAMPFIRES) { if ((Object)(object)aLL_CAMPFIRE != (Object)null && (Object)(object)aLL_CAMPFIRE.enableWhenLit != (Object)null) { return aLL_CAMPFIRE; } } return null; } private static bool Holding(Character c) { if ((Object)(object)c != (Object)null) { return ItemRegistry.IsBranches(c.data.currentItem); } return false; } private static bool HoldingFood(Character c) { if ((Object)(object)c != (Object)null && (Object)(object)c.data.currentItem != (Object)null && (Object)(object)c.data.currentItem.cooking != (Object)null) { return c.data.currentItem.cooking.canBeCooked; } return false; } public bool IsInteractible(Character interactor) { return true; } public void Interact(Character interactor) { if (lit && HoldingFood(interactor)) { cooking = interactor.data.currentItem; cooking.cooking.StartCookingVisuals(); Cozy.Roasting = true; } } public void HoverEnter() { } public void HoverExit() { } public Vector3 Center() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) return ((Component)this).transform.position + Vector3.up * 0.35f; } public Transform GetTransform() { return ((Component)this).transform; } public string GetName() { if (!lit) { return "Branch pile"; } return "Campfire"; } public string GetInteractionText() { if (lit) { if (!HoldingFood(Character.localCharacter)) { return "Burning - safe until morning"; } return LocalizedText.GetText("COOK", true); } if (branchCount < Needed) { if (!Holding(Character.localCharacter)) { return $"Needs {Needed - branchCount} more branches ({branchCount}/{Needed})"; } return $"Add branches ({branchCount}/{Needed})"; } return "Light fire"; } public bool IsConstantlyInteractable(Character interactor) { if (!lit) { if (branchCount < Needed) { return Holding(interactor); } return true; } return HoldingFood(interactor); } public float GetInteractTime(Character interactor) { if (!lit) { if (branchCount < Needed) { return 0.75f; } return 3f; } return 5f; } public void Interact_CastFinished(Character interactor) { if (lit) { if ((Object)(object)cooking != (Object)null) { cooking.cooking.FinishCooking(); Cozy.OnRoastFinished(); } cooking = null; Cozy.Roasting = false; } else if (branchCount < Needed && Holding(interactor)) { if (ConsumeHeldItem(interactor)) { ((MonoBehaviourPun)this).photonView.RPC("NC_RequestAddBranch", (RpcTarget)2, Array.Empty<object>()); } } else if (branchCount >= Needed) { ((MonoBehaviourPun)this).photonView.RPC("NC_RequestLight", (RpcTarget)2, Array.Empty<object>()); } } public void CancelCast(Character interactor) { if ((Object)(object)cooking != (Object)null) { cooking.cooking.CancelCookingVisuals(); } cooking = null; Cozy.Roasting = false; } public void ReleaseInteract(Character interactor) { } private static bool ConsumeHeldItem(Character c) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) CharacterItems items = c.refs.items; if (items.currentSelectedSlot.IsNone) { return false; } ItemSlot itemSlot = c.player.GetItemSlot(items.currentSelectedSlot.Value); if (itemSlot == null || itemSlot.IsEmpty()) { return false; } c.player.EmptySlot(items.currentSelectedSlot, true); if (items.currentSelectedSlot.IsSome && items.currentSelectedSlot.Value == 250) { ((MonoBehaviourPun)c).photonView.RPC("DestroyHeldItemRpc", (RpcTarget)0, Array.Empty<object>()); } else { items.EquipSlot(Optionable<byte>.None); } c.refs.afflictions.UpdateWeight(); return true; } } internal class PlacedTent : MonoBehaviourPun, IInteractibleConstant, IInteractible { public static readonly List<PlacedTent> All = new List<PlacedTent>(); public bool InZone => SafeZones.IsInSafeZone(((Component)this).transform.position); public bool holdOnFinish => false; private void Awake() { All.Add(this); } private void OnDestroy() { All.Remove(this); } public bool IsInteractible(Character interactor) { return !SleepManager.IsSleeping; } public void Interact(Character interactor) { } public void HoverEnter() { } public void HoverExit() { } public Vector3 Center() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) return ((Component)this).transform.position + Vector3.up; } public Transform GetTransform() { return ((Component)this).transform; } public string GetName() { return "Tent"; } public string GetInteractionText() { if (!Game.IsNightish) { return "Pack up tent"; } if (!InZone) { return "Can't sleep - tent must be next to a lit campfire"; } return "Sleep"; } public bool IsConstantlyInteractable(Character interactor) { if (Game.IsNightish) { return InZone; } return true; } public float GetInteractTime(Character interactor) { if (!Game.IsNightish) { return 2f; } return 1.5f; } public void Interact_CastFinished(Character interactor) { if (Game.IsNightish) { if (InZone) { SleepManager.StartSleeping(this); } } else { ((MonoBehaviourPun)this).photonView.RPC("NC_RequestPackUp", (RpcTarget)2, Array.Empty<object>()); } } public void CancelCast(Character interactor) { } public void ReleaseInteract(Character interactor) { } [PunRPC] private void NC_RequestPackUp() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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) if (PhotonNetwork.IsMasterClient && !Game.IsNightish) { GameObject val = PhotonNetwork.InstantiateItemRoom("NC_Tent", ((Component)this).transform.position + Vector3.up * 0.5f, ((Component)this).transform.rotation, true); val.GetComponent<PhotonView>().RPC("SetKinematicRPC", (RpcTarget)0, new object[3] { false, val.transform.position, val.transform.rotation }); PhotonNetwork.Destroy(((Component)this).gameObject); } } } internal static class Structures { private const float TentWidth = 2f; private const float TentLength = 2.4f; private const float TentHeight = 1.5f; private const float TentLongestSide = 3f; private const float LogLength = 1f; public static void Build(Transform holder, Backpack tent, Item branches) { BuildPlacedTent(holder, tent); BuildFirePit(holder, branches); } private static void BuildPlacedTent(Transform holder, Backpack tent) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) GameObject val = NewNetworked(holder, "NC_PlacedTent"); if (ModelLibrary.TentPitched != null) { GlbModel tentPitched = ModelLibrary.TentPitched; ModelLibrary.FitStanding(tentPitched.CreateInstance(val.transform, "Tent"), tentPitched, 3f); Bounds val2 = Visuals.LocalBounds(val.transform); BoxCollider obj = val.AddComponent<BoxCollider>(); ((Collider)obj).isTrigger = true; obj.center = ((Bounds)(ref val2)).center; obj.size = ((Bounds)(ref val2)).size; val.AddComponent<PlacedTent>(); ItemRegistry.RegisterNetworkPrefab(((Object)val).name, val); } else { Material sharedMaterial = ((Component)tent).GetComponentInChildren<Renderer>(true).sharedMaterial; Visuals.MeshObject(val.transform, "Tent", Visuals.TentMesh(2f, 2.4f, 1.5f), sharedMaterial).transform.localPosition = Vector3.zero; Material material = Visuals.Tinted(sharedMaterial, new Color(0.25f, 0.1f, 0.04f)); Visuals.MeshObject(val.transform, "Door", Visuals.TriangleMesh(new Vector3(-0.36f, 0f, 0f), new Vector3(0.36f, 0f, 0f), new Vector3(0f, 0.97499996f, 0f)), material).transform.localPosition = new Vector3(0f, 0.01f, 1.21f); BoxCollider obj2 = val.AddComponent<BoxCollider>(); ((Collider)obj2).isTrigger = true; obj2.center = new Vector3(0f, 0.75f, 0f); obj2.size = new Vector3(2f, 1.5f, 2.4f); val.AddComponent<PlacedTent>(); ItemRegistry.RegisterNetworkPrefab(((Object)val).name, val); } } private static void BuildFirePit(Transform holder, Item branches) { //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) GameObject val = NewNetworked(holder, "NC_FirePit"); int num = Mathf.Max(1, Settings.BranchesToBuild); for (int i = 0; i < num; i++) { float num2 = (float)i * 180f / (float)num; if (ModelLibrary.Branch != null) { Transform transform = new GameObject("Branch_" + i).transform; transform.SetParent(val.transform, false); transform.localPosition = new Vector3(0f, 0.05f + (float)i * 0.08f, 0f); transform.localRotation = Quaternion.Euler(0f, num2, 0f) * Quaternion.Euler(90f, 0f, 0f); GameObject val2 = ModelLibrary.Branch.CreateInstance(transform, "Log"); Bounds bounds = ModelLibrary.Branch.Bounds; float num3 = 1f / Mathf.Max(new float[4] { ((Bounds)(ref bounds)).size.x, ((Bounds)(ref bounds)).size.y, ((Bounds)(ref bounds)).size.z, 0.0001f }); val2.transform.localScale = Vector3.one * num3; val2.transform.localPosition = -((Bounds)(ref bounds)).center * num3; } else { GameObject obj = Visuals.CopyMeshes(((Component)branches).gameObject, val.transform, "Branch_" + i); obj.transform.localRotation = Quaternion.Euler(0f, num2 * 2f, 0f); obj.transform.localPosition = Quaternion.Euler(0f, num2 * 2f, 0f) * new Vector3(0f, 0.05f, 0.3f); } } SphereCollider obj2 = val.AddComponent<SphereCollider>(); ((Collider)obj2).isTrigger = true; obj2.radius = 0.7f; obj2.center = new Vector3(0f, 0.35f, 0f); val.AddComponent<FirePit>(); ItemRegistry.RegisterNetworkPrefab(((Object)val).name, val); } private static GameObject NewNetworked(Transform holder, string name) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown GameObject val = new GameObject(name); val.transform.SetParent(holder, false); val.layer = 0; PhotonView obj = val.AddComponent<PhotonView>(); obj.Synchronization = (ViewSynchronization)0; obj.ObservedComponents = new List<Component>(); obj.OwnershipTransfer = (OwnershipOption)0; return val; } } internal static class Visuals { private class MeshBuilder { private readonly List<Vector3> verts = new List<Vector3>(); private readonly List<int> tris = new List<int>(); public void Quad(Vector3 a, Vector3 b, Vector3 c, Vector3 d) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) Tri(a, b, c); Tri(a, c, d); } public void Tri(Vector3 a, Vector3 b, Vector3 c) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) Add(a, b, c); Add(a, c, b); } private void Add(Vector3 a, Vector3 b, Vector3 c) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) int count = verts.Count; verts.Add(a); verts.Add(b); verts.Add(c); tris.Add(count); tris.Add(count + 1); tris.Add(count + 2); } public Mesh Build(string name) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0049: Expected O, but got Unknown Mesh val = new Mesh { name = name }; val.SetVertices(verts); val.SetTriangles(tris, 0); val.SetUVs(0, (Vector2[])(object)new Vector2[verts.Count]); val.RecalculateNormals(); val.RecalculateBounds(); return val; } } private static readonly string[] ColorProps = new string[4] { "_BaseColor", "_Color", "_Tint", "_MainColor" }; public static void Tint(GameObject root, Color color) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { Material[] sharedMaterials = val.sharedMaterials; for (int j = 0; j < sharedMaterials.Length; j++) { if ((Object)(object)sharedMaterials[j] != (Object)null) { sharedMaterials[j] = Tinted(sharedMaterials[j], color); } } val.sharedMaterials = sharedMaterials; } } public static Bounds LocalBounds(Transform root) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) bool flag = false; Bounds result = default(Bounds); ((Bounds)(ref result))..ctor(Vector3.zero, Vector3.zero); Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<Renderer>(true); MeshFilter val6 = default(MeshFilter); foreach (Renderer val in componentsInChildren) { Renderer val2 = val; MeshRenderer val3 = (MeshRenderer)(object)((val2 is MeshRenderer) ? val2 : null); Mesh val5; if (val3 == null) { SkinnedMeshRenderer val4 = (SkinnedMeshRenderer)(object)((val2 is SkinnedMeshRenderer) ? val2 : null); if (val4 == null) { goto IL_0068; } val5 = val4.sharedMesh; } else { if (!((Component)val3).TryGetComponent<MeshFilter>(ref val6)) { goto IL_0068; } val5 = val6.sharedMesh; } goto IL_006b; IL_0068: val5 = null; goto IL_006b; IL_006b: Mesh val7 = val5; if (!((Object)(object)val7 == (Object)null)) { Bounds bounds = val7.bounds; Matrix4x4 val8 = root.worldToLocalMatrix * ((Component)val).transform.localToWorldMatrix; for (int i = 0; i < 8; i++) { Vector3 val9 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((i & 1) != 0) ? 1 : (-1)), (float)(((i & 2) != 0) ? 1 : (-1)), (float)(((i & 4) != 0) ? 1 : (-1)))); Vector3 val10 = ((Matrix4x4)(ref val8)).MultiplyPoint3x4(val9); if (!flag) { ((Bounds)(ref result))..ctor(val10, Vector3.zero); flag = true; } else { ((Bounds)(ref result)).Encapsulate(val10); } } } } return result; } public static Material Tinted(Material source, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(source); string[] colorProps = ColorProps; foreach (string text in colorProps) { if (val.HasProperty(text)) { val.SetColor(text, color); } } return val; } public static GameObject MeshObject(Transform parent, string name, Mesh mesh, Material material) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.AddComponent<MeshFilter>().sharedMesh = mesh; ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = material; return val; } public static Mesh TentMesh(float width, float length, float height) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) float num = width / 2f; float num2 = length / 2f; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f - num, 0f, 0f - num2); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(num, 0f, 0f - num2); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(0f - num, 0f, num2); Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(num, 0f, num2); Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(0f, height, 0f - num2); Vector3 val6 = default(Vector3); ((Vector3)(ref val6))..ctor(0f, height, num2); MeshBuilder meshBuilder = new MeshBuilder(); meshBuilder.Quad(val, val3, val6, val5); meshBuilder.Quad(val4, val2, val5, val6); meshBuilder.Tri(val3, val4, val6); meshBuilder.Tri(val2, val, val5); return meshBuilder.Build("NC_TentMesh"); } public static Mesh TriangleMesh(Vector3 a, Vector3 b, Vector3 c) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) MeshBuilder meshBuilder = new MeshBuilder(); meshBuilder.Tri(a, b, c); return meshBuilder.Build("NC_Triangle"); } public static GameObject CopyMeshes(GameObject src, Transform parent, string name) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); Matrix4x4 worldToLocalMatrix = src.transform.worldToLocalMatrix; Renderer[] componentsInChildren = src.GetComponentsInChildren<Renderer>(true); MeshFilter val7 = default(MeshFilter); foreach (Renderer val2 in componentsInChildren) { Renderer val3 = val2; MeshRenderer val4 = (MeshRenderer)(object)((val3 is MeshRenderer) ? val3 : null); Mesh val6; if (val4 == null) { SkinnedMeshRenderer val5 = (SkinnedMeshRenderer)(object)((val3 is SkinnedMeshRenderer) ? val3 : null); if (val5 == null) { goto IL_0075; } val6 = val5.sharedMesh; } else { if (!((Component)val4).TryGetComponent<MeshFilter>(ref val7)) { goto IL_0075; } val6 = val7.sharedMesh; } goto IL_0078; IL_0075: val6 = null; goto IL_0078; IL_0078: Mesh val8 = val6; if (!((Object)(object)val8 == (Object)null)) { GameObject val9 = new GameObject(((Object)val2).name); val9.transform.SetParent(val.transform, false); Matrix4x4 val10 = worldToLocalMatrix * ((Component)val2).transform.localToWorldMatrix; val9.transform.localPosition = Vector4.op_Implicit(((Matrix4x4)(ref val10)).GetColumn(3)); val9.transform.localRotation = ((Matrix4x4)(ref val10)).rotation; val9.transform.localScale = ((Matrix4x4)(ref val10)).lossyScale; val9.AddComponent<MeshFilter>().sharedMesh = val8; ((Renderer)val9.AddComponent<MeshRenderer>()).sharedMaterials = val2.sharedMaterials; } } return val; } } } namespace NightCamp.Systems { internal static class BranchScatter { private const float MinSpacing = 12f; private const int PlentyToSearch = 200; private const float StockDelay = 2f; private static int sceneHandle = -1; private static float sceneTime; private static bool tentChecked; private static readonly HashSet<int> stockedSegments = new HashSet<int>(); private static readonly HashSet<int> pendingCampfireTents = new HashSet<int>(); private static float segmentActiveSince = -1f; public static void Tick() { TrackScene(); if (!PhotonNetwork.IsMasterClient || !Game.InLevel) { return; } sceneTime += Time.deltaTime; if (!tentChecked && sceneTime > 8f) { tentChecked = true; if (Settings.TentAtRunStart && !AnyTentExists()) { SpawnItemNear(Character.localCharacter, "NC_Tent", 2f); } } TryStockCurrentSegment(); TrySpawnCampfireTents(); } private static void TrySpawnCampfireTents() { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) if (!tentChecked || pendingCampfireTents.Count == 0 || !MapHandler.Exists) { return; } MapHandler instance = Singleton<MapHandler>.Instance; RaycastHit val3 = default(RaycastHit); foreach (int item in pendingCampfireTents.ToList()) { Campfire val = null; try { GameObject segmentCampfire = instance.segments[item].segmentCampfire; if ((Object)(object)segmentCampfire != (Obje