Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Odd Company v0.4.0
BepInEx/plugins/OddCompany/OddCompany.dll
Decompiled 19 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using GameNetcodeStuff; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.AI; using UnityEngine.Rendering; [assembly: AssemblyFileVersion("0.4.0.0")] [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.4.0.0")] namespace OddCompany; public static class Balance { public const int Protocol = 4; public static readonly string[] Names = new string[6] { "pligga", "Hushloom", "Backstitch", "Tollbud", "Foldback", "The Last Passenger" }; public static readonly string[] Advice = new string[6] { "Tongue winds up: step sideways or get behind cover.", "Sprinting feeds its pulse. Walk until it settles.", "Walk across the cyan stitches; sprinting snags you.", "Stand still in its amber ring for two seconds to pass.", "It follows your old footsteps. Avoid doubling back.", "Do not stare. Its mark returns at takeoff. The curse is fatal." }; public static int Damage(int health, int requested, bool gentle) { return Math.Max(0, Math.Min(requested, gentle ? (health - 20) : health)); } public static bool InTongue(float forward, float sideways, float height) { if (forward >= 0f && forward <= 6f && Math.Abs(sideways) <= 0.75f) { return Math.Abs(height) < 2f; } return false; } public static bool CanSpawn(float distance, bool visible, bool pathComplete) { if (distance >= 14f && distance <= 65f && !visible) { return pathComplete; } return false; } public static float RemainingStamina(float current, float drain) { return Math.Min(current, Math.Max(0.15f, current - drain)); } public static bool OutsideRoll(double roll, float chance) { return roll < (double)chance; } public static bool ZoneMatches(bool insideFactory, bool outside) { return insideFactory != outside; } public static bool CanMark(float distance, float angle, bool clear, bool looking, bool sameZone) { if (distance <= 22f && angle <= 65f && clear && looking) { return sameZone; } return false; } } public sealed class SightingGate { private readonly bool[] seen = new bool[6]; private float nextAllowed; public void Reset() { Array.Clear(seen, 0, seen.Length); nextAllowed = 0f; } public static bool Visible(float distance, bool inView, bool clearLine, bool eligible) { if (eligible && distance <= 12f && inView) { return clearLine; } return false; } public bool Consume(int kind, float now, bool attack, bool enabled) { if (kind < 0 || kind >= seen.Length || seen[kind]) { return false; } seen[kind] = true; if (!enabled || attack || now < nextAllowed) { return false; } nextAllowed = now + 45f; return true; } } public static class CurseRules { public const float GazeSeconds = 0.6f; public const float VisionSeconds = 3.5f; public const float SnapSeconds = 2.4f; public const float FinishSeconds = 6f; public static int Next(int stage, float elapsed, bool leaving, bool victimAlive) { if ((stage == 1 || stage == 2) && !victimAlive) { return 4; } if ((stage == 1 || stage == 2) && leaving) { return 3; } if (stage == 1 && elapsed >= 3.5f) { return 2; } if (stage == 3 && elapsed >= 6f) { return 4; } return stage; } public static bool ShouldKill(int stage, float elapsed, bool localVictim, bool alreadyKilled) { if (stage == 3 && elapsed >= 2.4f && elapsed < 6f && localVictim) { return !alreadyKilled; } return false; } } [BepInPlugin("local.oddcompany.five", "Odd Company", "0.4.0")] public sealed class Plugin : BaseUnityPlugin { private const string Channel = "OddCompany.v1"; internal static Plugin Instance; private readonly Dictionary<int, Creature> creatures = new Dictionary<int, Creature>(); private readonly Dictionary<ulong, float> peers = new Dictionary<ulong, float>(); private readonly Dictionary<ulong, Signal> signals = new Dictionary<ulong, Signal>(); private readonly Dictionary<ulong, float> hurtUntil = new Dictionary<ulong, float>(); private readonly Dictionary<ulong, float> hitUntil = new Dictionary<ulong, float>(); private ConfigEntry<bool> enabledMod; private ConfigEntry<bool> gentle; private ConfigEntry<bool> testMode; private ConfigEntry<bool> hints; private ConfigEntry<int> maxAlive; private ConfigEntry<int> maxPerDay; private ConfigEntry<int> testKind; private ConfigEntry<float> spawnDelay; private ConfigEntry<float> spawnInterval; private ConfigEntry<float> spawnChance; private ConfigEntry<float> outsideChance; private ConfigEntry<float> passengerChance; private ConfigEntry<float> curseShake; private ConfigEntry<float> curseFlicker; private ConfigEntry<float> curseDistortion; private bool? pendingOutside; private bool passengerSpawned; internal PassengerCurse Curse; private ConfigEntry<float> ambienceVolume; private ConfigEntry<float> warningVolume; private ConfigEntry<bool> sightingScares; private ConfigEntry<float> sightingVolume; internal readonly SightingGate Sightings = new SightingGate(); private ConfigEntry<bool>[] enabledKinds = new ConfigEntry<bool>[6]; private NetworkManager network; private CustomMessagingManager messages; private bool active; private bool acknowledged; private bool warnedPeers; private float nextSend; private float nextSpawn; private float activeSince; private float localHurtUntil; private int spawned; private int nextId = 1; private int sequence; private readonly List<int> bag = new List<int>(); private Random random = new Random(); internal Texture2D Face; internal AudioClip[,] Sounds = new AudioClip[6, 5]; internal AudioClip[] CurseSounds = (AudioClip[])(object)new AudioClip[3]; private readonly HashSet<int> shownHints = new HashSet<int>(); internal float CurseShake => curseShake.Value; internal float CurseFlicker => curseFlicker.Value; internal float CurseDistortion => curseDistortion.Value; internal bool SightingScares => sightingScares.Value; internal float SightingVolume => sightingVolume.Value; internal float AmbienceVolume => ambienceVolume.Value; internal float WarningVolume => warningVolume.Value; internal bool Host { get { if ((Object)(object)network != (Object)null) { return network.IsServer; } return false; } } internal bool Gentle => gentle.Value; internal IEnumerable<Creature> Creatures => creatures.Values; internal static PlayerControllerB LocalPlayer { get { if (!((Object)(object)GameNetworkManager.Instance == (Object)null)) { return GameNetworkManager.Instance.localPlayerController; } return null; } } internal static int WallMask { get { if (!((Object)(object)StartOfRound.Instance != (Object)null)) { return LayerMask.GetMask(new string[3] { "Default", "Room", "Colliders" }); } return StartOfRound.Instance.collidersAndRoomMask; } } private void Awake() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Expected O, but got Unknown //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Expected O, but got Unknown //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Expected O, but got Unknown //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Expected O, but got Unknown //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Expected O, but got Unknown //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Expected O, but got Unknown //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Expected O, but got Unknown //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Expected O, but got Unknown //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Expected O, but got Unknown //IL_0472: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Expected O, but got Unknown Instance = this; enabledMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Host: enable added encounters."); gentle = ((BaseUnityPlugin)this).Config.Bind<bool>("Balance", "GentleDamage", true, "Host: normal added attacks cannot lower health below 20. The Last Passenger's takeoff curse is an explicitly fatal exception."); maxAlive = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "MaxAlive", 1, new ConfigDescription("Host: simultaneous added monsters.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 3), new object[0])); maxPerDay = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", "MaxPerDay", 3, new ConfigDescription("Host: encounter limit per moon landing.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 12), new object[0])); spawnDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Spawning", "FirstSpawnDelay", 75f, new ConfigDescription("Host: seconds after landing.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 600f), new object[0])); spawnInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Spawning", "SpawnInterval", 75f, new ConfigDescription("Host: seconds between spawn attempts.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(15f, 600f), new object[0])); spawnChance = ((BaseUnityPlugin)this).Config.Bind<float>("Spawning", "SpawnChance", 0.65f, new ConfigDescription("Host: probability per attempt.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); outsideChance = ((BaseUnityPlugin)this).Config.Bind<float>("Spawning", "OutdoorChance", 0.2f, new ConfigDescription("Host: chance each new encounter is assigned outdoors. Failed placement keeps its roll until a suitable player/point is available.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); passengerChance = ((BaseUnityPlugin)this).Config.Bind<float>("Spawning", "LastPassengerChance", 0.12f, new ConfigDescription("Host: rare creature chance per successful encounter; at most once per landing. TestMode cycles it explicitly.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); curseShake = ((BaseUnityPlugin)this).Config.Bind<float>("Effects", "CurseShake", 0.7f, new ConfigDescription("Local: curse tremor intensity; zero disables camera shake.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); curseFlicker = ((BaseUnityPlugin)this).Config.Bind<float>("Effects", "CurseFlicker", 0.75f, new ConfigDescription("Local: curse light flicker depth; zero disables flickering.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); curseDistortion = ((BaseUnityPlugin)this).Config.Bind<float>("Effects", "CurseDistortion", 0.65f, new ConfigDescription("Local: temporary listener audio distortion; zero disables filtering.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); hints = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowHints", true, "Local: show each creature's counter once per landing."); ambienceVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "EncounterVolume", 0.45f, new ConfigDescription("Local: spatial creature soundscape volume. Zero disables ambience, not attack warnings.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); warningVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "WarningVolume", 0.75f, new ConfigDescription("Local: distinctive warning and attack sound volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); sightingScares = ((BaseUnityPlugin)this).Config.Bind<bool>("Audio", "FirstSightingScares", true, "Local: short sting on first clear sight of each species per landing. Shared 45-second cooldown; no camera effects."); sightingVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Audio", "SightingVolume", 0.55f, new ConfigDescription("Local: first-sighting sting volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0])); testMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Testing", "TestMode", false, "Host: first encounter after 15 seconds; cycles all enabled monsters, one at a time. Use a disposable LAN save."); testKind = ((BaseUnityPlugin)this).Config.Bind<int>("Testing", "FirstMonster", 0, new ConfigDescription("Host: 0 pligga, 1 Hushloom, 2 Backstitch, 3 Tollbud, 4 Foldback, 5 The Last Passenger (fatal takeoff curse).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 5), new object[0])); for (int i = 0; i < 6; i++) { enabledKinds[i] = ((BaseUnityPlugin)this).Config.Bind<bool>("Monsters", Balance.Names[i], true, "Host: allow this monster to spawn."); } using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("OddCompany.Pligga.png")) { if (stream != null) { byte[] array = new byte[stream.Length]; int num; for (int j = 0; j < array.Length; j += num) { if ((num = stream.Read(array, j, array.Length - j)) <= 0) { break; } } Face = new Texture2D(2, 2, (TextureFormat)4, false); ImageConversion.LoadImage(Face, array); } } for (int k = 0; k < 6; k++) { for (int l = 0; l < 5; l++) { float[] array2 = HorrorAudio.Render(k, l); AudioClip val = AudioClip.Create("OddCompany_" + k + "_" + l, array2.Length, 1, 22050, false); val.SetData(array2, 0); Sounds[k, l] = val; } } for (int m = 0; m < 3; m++) { float[] array3 = HorrorAudio.RenderCurse(m); CurseSounds[m] = AudioClip.Create("LastPassenger_Event_" + m, array3.Length, 1, 22050, false); CurseSounds[m].SetData(array3, 0); } Curse = ((Component)this).gameObject.AddComponent<PassengerCurse>(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Odd Company 0.4.0 loaded. Last Passenger curse is fatal. All players need this version."); } private void Update() { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton != (Object)(object)network || ((Object)(object)network != (Object)null && !network.IsListening)) { Unbind(); if ((Object)(object)singleton != (Object)null && singleton.IsListening && singleton.CustomMessagingManager != null) { network = singleton; messages = singleton.CustomMessagingManager; messages.RegisterNamedMessageHandler("OddCompany.v1", new HandleNamedMessageDelegate(Receive)); nextSend = 0f; } } if ((Object)(object)network == (Object)null) { return; } StartOfRound instance = StartOfRound.Instance; if (!((Object)(object)instance != (Object)null) || !instance.shipHasLanded || instance.inShipPhase || instance.allPlayersDead) { if (active) { Clear(); } active = false; } else if (!active) { active = true; activeSince = Time.time; nextSpawn = Time.time + (testMode.Value ? 15f : spawnDelay.Value); spawned = 0; shownHints.Clear(); Sightings.Reset(); bag.Clear(); pendingOutside = null; passengerSpawned = false; if (Host) { Curse.Reset(); } random = new Random(instance.randomMapSeed ^ 0x3084B); } if (!(Time.time >= nextSend)) { return; } nextSend = Time.time + 0.2f; if (Host) { RecordSignal(network.LocalClientId, LocalSignal()); if (active) { HostTick(); } Curse.HostTick(enabledMod.Value && AllPeersReady()); BroadcastSnapshot(); } else { Send(new Packet { op = 1, version = 4, signal = LocalSignal() }, 0uL); } } private Signal LocalSignal() { //IL_0061: 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_0073: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB localPlayer = LocalPlayer; Signal signal = new Signal(); signal.sprint = (Object)(object)localPlayer != (Object)null && localPlayer.isSprinting; signal.crouch = (Object)(object)localPlayer != (Object)null && localPlayer.isCrouching; signal.witness = WitnessInView(localPlayer); signal.look = (((Object)(object)localPlayer != (Object)null && (Object)(object)localPlayer.gameplayCamera != (Object)null) ? ((Component)localPlayer.gameplayCamera).transform.forward : Vector3.forward); return signal; } private int WitnessInView(PlayerControllerB player) { //IL_0061: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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) if (!Eligible(player) || (Object)(object)player.gameplayCamera == (Object)null) { return 0; } foreach (Creature value in creatures.Values) { if (!((Object)(object)value == (Object)null) && value.Kind == 5 && value.EligibleFor(player)) { Vector3 val = ((Component)value).transform.position + Vector3.up * 2.2f; Vector3 val2 = player.gameplayCamera.WorldToViewportPoint(val); if (val2.z > 0f && val2.x > 0.04f && val2.x < 0.96f && val2.y > 0.04f && val2.y < 0.96f && Vector3.Distance(val, ((Component)player.gameplayCamera).transform.position) <= 22f && ClearLine(((Component)player.gameplayCamera).transform.position, val)) { return value.Id; } } } return 0; } internal Signal GetSignal(PlayerControllerB player) { //IL_0037: 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) if (signals.TryGetValue(player.actualClientId, out var value) && Time.time - value.received < 1.5f) { return value; } Signal signal = new Signal(); signal.look = ((Component)player).transform.forward; return signal; } private void RecordSignal(ulong sender, Signal value) { //IL_005b: 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_0060: Unknown result type (might be due to invalid IL or missing references) if (value != null && Finite(value.look.x) && Finite(value.look.y) && Finite(value.look.z)) { value.look = ((((Vector3)(ref value.look)).sqrMagnitude > 0.01f) ? ((Vector3)(ref value.look)).normalized : Vector3.forward); value.received = Time.time; signals[sender] = value; } } private static bool Finite(float value) { if (!float.IsNaN(value)) { return !float.IsInfinity(value); } return false; } private void Receive(ulong sender, FastBufferReader reader) { try { if (((FastBufferReader)(ref reader)).Length > 24000) { return; } string text = default(string); ((FastBufferReader)(ref reader)).ReadValueSafe(ref text, false); Packet packet = JsonUtility.FromJson<Packet>(text); if (packet == null || packet.version != 4) { return; } if (Host) { if (sender != network.LocalClientId) { if (packet.op == 1) { peers[sender] = Time.time; RecordSignal(sender, packet.signal); } else if (packet.op == 4) { HostHit(sender, packet.id); } } } else if (sender == 0) { if (packet.op == 2) { acknowledged = true; ApplySnapshot(packet); } else if (packet.op == 3) { ApplyEffect(packet); } } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Ignored invalid Odd Company packet: " + ex.Message)); } } private unsafe void Send(Packet packet, ulong client) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) if (messages == null || (Object)(object)network == (Object)null || !network.IsListening) { return; } packet.version = 4; string text = JsonUtility.ToJson((object)packet); FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(text.Length * 4 + 64, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe(text, false); messages.SendNamedMessage("OddCompany.v1", client, val, (NetworkDelivery)4); } finally { ((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose(); } } private bool AllPeersReady() { foreach (ulong connectedClientsId in network.ConnectedClientsIds) { if (connectedClientsId != network.LocalClientId && (!peers.TryGetValue(connectedClientsId, out var value) || Time.time - value > 6f)) { return false; } } return true; } private void HostTick() { if (!enabledMod.Value || !AllPeersReady()) { Clear(); if (!warnedPeers && enabledMod.Value && Time.time - activeSince > 12f) { warnedPeers = true; Tip("Odd Company paused", "Every player needs Odd Company 0.4.0. Added monsters are paused until everyone responds."); ((BaseUnityPlugin)this).Logger.LogWarning((object)"Missing client handshake: added monsters paused."); } return; } warnedPeers = false; foreach (Creature item in new List<Creature>(creatures.Values)) { if ((Object)(object)item == (Object)null || Time.time - item.Born > (float)(testMode.Value ? 65 : 160)) { if ((Object)(object)item != (Object)null) { Remove(item.Id); } } else { item.Tick(); } } int num = (testMode.Value ? 1 : maxAlive.Value); int num2 = (testMode.Value ? 6 : maxPerDay.Value); if (creatures.Count < num && spawned < num2 && !(Time.time < nextSpawn)) { nextSpawn = Time.time + (testMode.Value ? 8f : spawnInterval.Value); if (testMode.Value || !(random.NextDouble() > (double)spawnChance.Value)) { TrySpawn(); } } } private void TrySpawn() { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00d2: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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_0160: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019b: 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) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Expected O, but got Unknown //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_026f: 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_0283: Invalid comparison between Unknown and I4 //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) if (!pendingOutside.HasValue) { pendingOutside = Balance.OutsideRoll(random.NextDouble(), outsideChance.Value); } bool value = pendingOutside.Value; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; List<PlayerControllerB> list = new List<PlayerControllerB>(); PlayerControllerB[] array = allPlayerScripts; foreach (PlayerControllerB val in array) { if (Eligible(val) && Balance.ZoneMatches(val.isInsideFactory, value)) { list.Add(val); } } if (list.Count == 0 && !value) { return; } Vector3 val2 = ((list.Count > 0) ? ((Component)list[random.Next(list.Count)]).transform.position : StartOfRound.Instance.groundOutsideShipSpawnPosition.position); NavMeshHit val3 = default(NavMeshHit); if (!NavMesh.SamplePosition(val2, ref val3, 4f, -1)) { return; } val2 = ((NavMeshHit)(ref val3)).position; GameObject[] array2 = (value ? RoundManager.Instance.outsideAINodes : RoundManager.Instance.insideAINodes); if (array2 == null || array2.Length == 0) { return; } NavMeshHit val5 = default(NavMeshHit); for (int j = 0; j < 45; j++) { GameObject val4 = array2[random.Next(array2.Length)]; if ((Object)(object)val4 == (Object)null) { continue; } Vector3 position = val4.transform.position; if (!NavMesh.SamplePosition(position, ref val5, 2f, -1)) { continue; } position = ((NavMeshHit)(ref val5)).position; if (value && Vector3.Distance(position, StartOfRound.Instance.elevatorTransform.position) < 20f) { continue; } float num = ((list.Count == 0) ? Vector3.Distance(position, val2) : float.MaxValue); bool visible = false; foreach (PlayerControllerB item in list) { num = Mathf.Min(num, Vector3.Distance(position, ((Component)item).transform.position)); if (CanSee(item, position + Vector3.up)) { visible = true; } } if (value) { PlayerControllerB[] array3 = allPlayerScripts; foreach (PlayerControllerB val6 in array3) { if ((Object)(object)val6 != (Object)null && val6.isPlayerControlled && !val6.isPlayerDead && !val6.isInsideFactory && CanSee(val6, position + Vector3.up)) { visible = true; } } } NavMeshPath val7 = new NavMeshPath(); bool pathComplete = NavMesh.CalculatePath(position, val2, -1, val7) && (int)val7.status == 0; if (!Balance.CanSpawn(num, visible, pathComplete)) { continue; } int num2 = PickKind(); if (num2 >= 0) { Creature creature = Create(nextId++, num2, position, value); creature.Home = position; if (num2 == 5) { passengerSpawned = true; } pendingOutside = null; spawned++; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Spawned " + Balance.Names[num2] + " (" + creature.Id + ") " + (value ? "outside" : "inside") + " at " + position)); if (testMode.Value) { Tip("Test encounter: " + Balance.Names[num2], Balance.Advice[num2] + (value ? " Look outside away from the ship." : " Look deeper inside.")); } } break; } } private int PickKind() { if (testMode.Value) { for (int i = 0; i < 6; i++) { int num = (testKind.Value + spawned + i) % 6; if (enabledKinds[num].Value) { return num; } } return -1; } if (enabledKinds[5].Value && !passengerSpawned && random.NextDouble() < (double)passengerChance.Value) { return 5; } if (bag.Count == 0) { for (int j = 0; j < 5; j++) { if (enabledKinds[j].Value) { bag.Add(j); } } } if (bag.Count == 0) { return -1; } int index = random.Next(bag.Count); int result = bag[index]; bag.RemoveAt(index); return result; } private Creature Create(int id, int kind, Vector3 point, bool outside) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("OddCompany_" + Balance.Names[kind]); val.transform.position = point; Creature creature = val.AddComponent<Creature>(); creature.Initialize(id, kind, Host, outside); creatures.Add(id, creature); return creature; } internal void Remove(int id) { if (creatures.TryGetValue(id, out var value)) { if ((Object)(object)value != (Object)null) { Object.Destroy((Object)(object)((Component)value).gameObject); } creatures.Remove(id); } } private void Clear() { foreach (Creature value in creatures.Values) { if ((Object)(object)value != (Object)null) { Object.Destroy((Object)(object)((Component)value).gameObject); } } creatures.Clear(); hurtUntil.Clear(); hitUntil.Clear(); } private void BroadcastSnapshot() { List<CreatureState> list = new List<CreatureState>(); foreach (Creature value in creatures.Values) { if ((Object)(object)value != (Object)null) { list.Add(value.State()); } } Packet packet = new Packet(); packet.op = 2; packet.serial = ++sequence; packet.monsters = list.ToArray(); packet.curse = Curse.Snapshot(); Packet packet2 = packet; foreach (ulong connectedClientsId in network.ConnectedClientsIds) { if (connectedClientsId != network.LocalClientId && peers.ContainsKey(connectedClientsId)) { Send(packet2, connectedClientsId); } } } private void ApplySnapshot(Packet packet) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) if (packet.serial <= sequence || packet.monsters == null || packet.monsters.Length > 3) { return; } sequence = packet.serial; if (packet.curse != null) { Curse.Apply(packet.curse); } HashSet<int> hashSet = new HashSet<int>(); CreatureState[] monsters = packet.monsters; foreach (CreatureState creatureState in monsters) { if (creatureState.kind >= 0 && creatureState.kind <= 5) { if (!creatures.TryGetValue(creatureState.id, out var value)) { value = Create(creatureState.id, creatureState.kind, creatureState.position, creatureState.outside); } value.Apply(creatureState); hashSet.Add(creatureState.id); } } foreach (int item in new List<int>(creatures.Keys)) { if (!hashSet.Contains(item)) { Remove(item); } } } internal bool Hurt(PlayerControllerB player, int damage, float stamina, int kind) { if (!Host || !Eligible(player)) { return false; } if (hurtUntil.TryGetValue(player.actualClientId, out var value) && Time.time < value) { return false; } hurtUntil[player.actualClientId] = Time.time + 4f; Packet packet = new Packet(); packet.op = 3; packet.damage = damage; packet.stamina = stamina; packet.gentle = gentle.Value; packet.kind = kind; Packet packet2 = packet; if (player.actualClientId == network.LocalClientId) { ApplyEffect(packet2); } else { Send(packet2, player.actualClientId); } return true; } private void ApplyEffect(Packet packet) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB localPlayer = LocalPlayer; if (active && Eligible(localPlayer) && !(Time.time < localHurtUntil)) { localHurtUntil = Time.time + 3.8f; int num = Balance.Damage(localPlayer.health, Mathf.Clamp(packet.damage, 0, 20), packet.gentle); if (num > 0) { localPlayer.DamagePlayer(num, true, true, (CauseOfDeath)6, 0, false, Vector3.zero); } localPlayer.sprintMeter = Balance.RemainingStamina(localPlayer.sprintMeter, Mathf.Clamp(packet.stamina, 0f, 0.25f)); } } internal void RequestHit(int id, PlayerControllerB player) { if (!((Object)(object)player == (Object)null) && !((Object)(object)player != (Object)(object)LocalPlayer)) { if (Host) { HostHit(network.LocalClientId, id); } else if (acknowledged) { Send(new Packet { op = 4, id = id }, 0uL); } } } private void HostHit(ulong sender, int id) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_008b: 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_009b: Unknown result type (might be due to invalid IL or missing references) //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) if (!active || !creatures.TryGetValue(id, out var value)) { return; } PlayerControllerB val = null; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val2 in allPlayerScripts) { if ((Object)(object)val2 != (Object)null && val2.actualClientId == sender) { val = val2; break; } } if (Eligible(val) && !(Vector3.Distance(((Component)val).transform.position, ((Component)value).transform.position) > 4.5f) && ClearLine(((Component)val).transform.position + Vector3.up, ((Component)value).transform.position + Vector3.up) && (val.currentlyHeldObjectServer is Shovel || val.currentlyHeldObjectServer is KnifeItem || val.currentlyHeldObject is Shovel || val.currentlyHeldObject is KnifeItem) && (!hitUntil.TryGetValue(sender, out var value2) || !(Time.time < value2))) { hitUntil[sender] = Time.time + 0.65f; value.TakeHit(); } } internal static bool Eligible(PlayerControllerB player) { if ((Object)(object)player != (Object)null && player.isPlayerControlled && !player.isPlayerDead && !player.isInHangarShipRoom && !player.inSpecialInteractAnimation) { return !player.isClimbingLadder; } return false; } internal static bool ClearLine(Vector3 from, Vector3 to) { //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) return !Physics.Linecast(from, to, WallMask, (QueryTriggerInteraction)1); } internal bool CanSee(PlayerControllerB player, Vector3 point) { //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) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)player).transform.position + Vector3.up * 1.5f; if (Vector3.Angle(GetSignal(player).look, point - val) < 75f) { return ClearLine(val, point); } return false; } internal void EncounterHint(int kind, Vector3 point) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB localPlayer = LocalPlayer; if (hints.Value && !shownHints.Contains(kind) && Eligible(localPlayer) && !(Vector3.Distance(((Component)localPlayer).transform.position, point) > 12f) && ClearLine(((Component)localPlayer).transform.position + Vector3.up, point + Vector3.up)) { shownHints.Add(kind); Tip(Balance.Names[kind], Balance.Advice[kind]); } } private static void Tip(string title, string body) { if ((Object)(object)HUDManager.Instance != (Object)null) { HUDManager.Instance.DisplayTip(title, body, false, false, "OddCompany"); } } private void Unbind() { if (messages != null) { messages.UnregisterNamedMessageHandler("OddCompany.v1"); } messages = null; network = null; acknowledged = false; active = false; peers.Clear(); signals.Clear(); shownHints.Clear(); sequence = 0; localHurtUntil = 0f; Sightings.Reset(); if ((Object)(object)Curse != (Object)null) { Curse.Reset(); } Clear(); } private void OnDestroy() { Unbind(); if ((Object)(object)Face != (Object)null) { Object.Destroy((Object)(object)Face); } AudioClip[,] sounds = Sounds; foreach (AudioClip val in sounds) { if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } } AudioClip[] curseSounds = CurseSounds; foreach (AudioClip val2 in curseSounds) { if ((Object)(object)val2 != (Object)null) { Object.Destroy((Object)(object)val2); } } if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } [Serializable] public sealed class Signal { public bool sprint; public bool crouch; public int witness; public Vector3 look; [NonSerialized] public float received; } [Serializable] public sealed class Packet { public int op; public int version; public int serial; public int id; public int kind; public int damage; public float stamina; public bool gentle; public Signal signal; public CreatureState[] monsters; public CurseState curse; } [Serializable] public sealed class CreatureState { public int id; public int kind; public int phase; public int cue; public int mood; public int cueRole; public bool outside; public Vector3 position; public Vector3 aim; public float yaw; public float charge; public Vector3[] marks; } public sealed class Creature : MonoBehaviour, IHittable { private struct Mark { public Vector3 point; public float time; public Mark(Vector3 position, float when) { //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) point = position; time = when; } } public int Id; public int Kind; public float Born; public Vector3 Home; public bool Outside; private readonly Dictionary<ulong, float> gaze = new Dictionary<ulong, float>(); private bool host; private NavMeshAgent agent; private Visuals visual; private CreatureState remote; private int phase; private int cue; private int mood; private int cueRole = 1; private int health = 3; private float deadline; private float cooldown; private float charge; private float nextMark; private float nextRoam; private float stunnedUntil; private float alertUntil; private Vector3 aim; private Vector3 roam; private readonly List<Mark> marks = new List<Mark>(); private readonly Queue<Mark> footsteps = new Queue<Mark>(); private readonly Dictionary<ulong, float> stillness = new Dictionary<ulong, float>(); private readonly Dictionary<ulong, float> passes = new Dictionary<ulong, float>(); private readonly Dictionary<ulong, Vector3> lastPosition = new Dictionary<ulong, Vector3>(); private ulong trailOwner = ulong.MaxValue; private Vector3 previousTrail; private float trailTick; public int Mood => mood; public void Initialize(int id, int kind, bool isHost, bool outside) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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) //IL_0097: Unknown result type (might be due to invalid IL or missing references) Outside = outside; Id = id; Kind = kind; host = isHost; Born = Time.time; Home = ((Component)this).transform.position; aim = ((Component)this).transform.position + ((Component)this).transform.forward * 5f; int num = LayerMask.NameToLayer("Enemies"); ((Component)this).gameObject.layer = ((num >= 0) ? num : 19); CapsuleCollider val = ((Component)this).gameObject.AddComponent<CapsuleCollider>(); ((Collider)val).isTrigger = true; val.center = Vector3.up; val.height = 2f; val.radius = 0.65f; visual = new Visuals(((Component)this).transform, kind); if (host) { agent = ((Component)this).gameObject.AddComponent<NavMeshAgent>(); agent.radius = 0.35f; agent.height = 1.8f; agent.speed = 1.5f; agent.angularSpeed = 180f; agent.acceleration = 6f; agent.stoppingDistance = 0.5f; agent.autoTraverseOffMeshLink = false; nextMark = Time.time + 5f; } } private void Update() { //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_006c: 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_00a1: 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_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_0100: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_0120: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Plugin.Instance == (Object)null) { return; } if (!host && remote != null) { ((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, remote.position, 1f - Mathf.Exp(-12f * Time.deltaTime)); ((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, Quaternion.Euler(0f, remote.yaw, 0f), 1f - Mathf.Exp(-12f * Time.deltaTime)); } if (host && (Object)(object)agent != (Object)null && agent.isOnNavMesh) { Vector3 desiredVelocity = agent.desiredVelocity; if (((Vector3)(ref desiredVelocity)).sqrMagnitude > 0.01f) { Vector3 val = ((Component)this).transform.position + Vector3.up; Vector3 desiredVelocity2 = agent.desiredVelocity; if (!Plugin.ClearLine(val, val + ((Vector3)(ref desiredVelocity2)).normalized * 0.85f)) { agent.isStopped = true; } } } visual.Animate(phase, mood, charge, aim, Points(), Time.time - Born); Plugin.Instance.EncounterHint(Kind, ((Component)this).transform.position); } public CreatureState State() { //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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) CreatureState creatureState = new CreatureState(); creatureState.id = Id; creatureState.kind = Kind; creatureState.position = ((Component)this).transform.position; creatureState.yaw = ((Component)this).transform.eulerAngles.y; creatureState.phase = phase; creatureState.cue = cue; creatureState.mood = mood; creatureState.cueRole = cueRole; creatureState.outside = Outside; creatureState.charge = charge; creatureState.aim = aim; creatureState.marks = Points(); return creatureState; } public void Apply(CreatureState state) { //IL_005d: 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_0097: Unknown result type (might be due to invalid IL or missing references) if (state.cue > cue) { visual.Sound(state.cueRole); } cue = state.cue; phase = state.phase; mood = state.mood; cueRole = state.cueRole; charge = state.charge; aim = state.aim; remote = state; marks.Clear(); if (state.marks != null) { for (int i = 0; i < Mathf.Min(12, state.marks.Length); i++) { marks.Add(new Mark(state.marks[i], Time.time)); } } } private Vector3[] Points() { //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) Vector3[] array = (Vector3[])(object)new Vector3[marks.Count]; for (int i = 0; i < marks.Count; i++) { ref Vector3 reference = ref array[i]; reference = marks[i].point; } return array; } private void Cue(int role = 1) { cue++; cueRole = role; visual.Sound(role); } private void Stop() { if ((Object)(object)agent != (Object)null && agent.isOnNavMesh) { agent.isStopped = true; } } private void Move(Vector3 destination, float speed) { //IL_0015: 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_0054: 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) if (Outside && (Object)(object)StartOfRound.Instance != (Object)null && Vector3.Distance(destination, StartOfRound.Instance.elevatorTransform.position) < 12f) { Stop(); } else if (!((Object)(object)agent == (Object)null) && agent.isOnNavMesh) { NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(destination, ref val, 2f, -1)) { Stop(); return; } agent.isStopped = false; agent.speed = speed; agent.SetDestination(((NavMeshHit)(ref val)).position); } } private void Roam() { //IL_001a: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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) mood = 0; if (Time.time >= nextRoam || Vector3.Distance(((Component)this).transform.position, roam) < 1.5f) { nextRoam = Time.time + 9f; GameObject[] array = (((Object)(object)RoundManager.Instance == (Object)null) ? null : (Outside ? RoundManager.Instance.outsideAINodes : RoundManager.Instance.insideAINodes)); roam = Home; if (array != null && array.Length > 0) { for (int i = 0; i < 10; i++) { GameObject val = array[Random.Range(0, array.Length)]; if ((Object)(object)val != (Object)null && Vector3.Distance(val.transform.position, ((Component)this).transform.position) < 22f) { roam = val.transform.position; break; } } } } Move(roam, 1.2f); } private PlayerControllerB Nearest(float range, bool requireSight) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB result = null; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (EligibleFor(val)) { float num = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position); if (!(num >= range) && (!requireSight || Sees(val))) { range = num; result = val; } } } return result; } private bool Sees(PlayerControllerB player) { //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) //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) return Plugin.ClearLine(((Component)this).transform.position + Vector3.up, ((Component)player).transform.position + Vector3.up); } public bool EligibleFor(PlayerControllerB player) { if (Plugin.Eligible(player)) { return Balance.ZoneMatches(player.isInsideFactory, Outside); } return false; } private float Distance(PlayerControllerB player) { //IL_0006: 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) return Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position); } private void Face(Vector3 point) { //IL_0000: 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_000c: 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_0032: 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) Vector3 val = point - ((Component)this).transform.position; val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 0.01f) { ((Component)this).transform.rotation = Quaternion.LookRotation(val); } } public void Tick() { if (!host || (Object)(object)agent == (Object)null || !agent.isOnNavMesh) { return; } mood = 0; if (Kind == 5) { Passenger(); return; } if (Time.time - Born < 6f || Time.time < stunnedUntil) { mood = 4; Stop(); return; } switch (Kind) { case 0: Pligga(); break; case 1: Hushloom(); break; case 2: Backstitch(); break; case 3: Tollbud(); break; case 4: Foldback(); break; } } private void Pligga() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_008d: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_00e8: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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) if (phase == 1) { mood = 2; Stop(); Face(aim); charge = 1f - Mathf.Clamp01((deadline - Time.time) / 1.8f); if (Time.time < deadline) { return; } phase = 2; mood = 3; deadline = Time.time + 0.4f; Cue(2); Vector3 val = aim - ((Component)this).transform.position; val.y = 0f; ((Vector3)(ref val)).Normalize(); Vector3 val2 = Vector3.Cross(Vector3.up, val); PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val3 in allPlayerScripts) { if (EligibleFor(val3)) { Vector3 val4 = ((Component)val3).transform.position - ((Component)this).transform.position; if (Balance.InTongue(Vector3.Dot(val4, val), Vector3.Dot(val4, val2), val4.y) && Sees(val3)) { Plugin.Instance.Hurt(val3, 10, 0.18f, Kind); } } } return; } if (phase == 2) { mood = 3; if (Time.time < deadline) { return; } phase = 0; charge = 0f; cooldown = Time.time + 7f; } PlayerControllerB val5 = Nearest(26f, requireSight: true); if ((Object)(object)val5 == (Object)null) { Roam(); return; } mood = 1; if (Distance(val5) < 6f && Time.time >= cooldown) { aim = ((Component)val5).transform.position; phase = 1; mood = 2; deadline = Time.time + 1.8f; Stop(); Face(aim); Cue(); } else if (Distance(val5) > 3f) { Move(((Component)val5).transform.position, 1.4f); } else { Stop(); } } private void Hushloom() { //IL_01e6: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = null; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val2 in allPlayerScripts) { if (EligibleFor(val2) && Distance(val2) < 11f && Sees(val2) && Plugin.Instance.GetSignal(val2).sprint) { val = val2; break; } } if (phase == 1) { mood = 2; Stop(); if (Time.time < deadline) { return; } if ((Object)(object)val != (Object)null) { PlayerControllerB[] allPlayerScripts2 = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB player in allPlayerScripts2) { if (EligibleFor(player) && Distance(player) < 7f && Sees(player) && Plugin.Instance.GetSignal(player).sprint) { Plugin.Instance.Hurt(player, 8, 0.22f, Kind); } } } phase = 2; mood = 3; deadline = Time.time + 0.6f; Cue(2); return; } if (phase == 2) { mood = 3; if (Time.time < deadline) { return; } phase = 0; charge = 0f; cooldown = Time.time + 6f; } charge = Mathf.Clamp01(charge + (((Object)(object)val == (Object)null) ? (-0.09f) : 0.12f)); if (charge >= 1f && Time.time >= cooldown) { phase = 1; mood = 2; deadline = Time.time + 2f; Stop(); Cue(); } else if ((Object)(object)val != (Object)null) { mood = 1; Move(((Component)val).transform.position, 1.8f); } else { mood = 0; Roam(); } } private void Backstitch() { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0184: 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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) Roam(); for (int num = marks.Count - 1; num >= 0; num--) { if (Time.time - marks[num].time > 12f) { marks.RemoveAt(num); } } if (Time.time >= nextMark) { nextMark = Time.time + 2.5f; if (marks.Count == 0 || Vector3.Distance(marks[marks.Count - 1].point, ((Component)this).transform.position) > 1f) { marks.Add(new Mark(((Component)this).transform.position, Time.time)); Cue(2); if (marks.Count > 5) { marks.RemoveAt(0); } } } PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!EligibleFor(val) || !Plugin.Instance.GetSignal(val).sprint) { continue; } foreach (Mark mark in marks) { if (Time.time - mark.time > 1.5f && Vector3.Distance(((Component)val).transform.position, mark.point) < 1.1f && Plugin.ClearLine(mark.point + Vector3.up * 0.5f, ((Component)val).transform.position + Vector3.up)) { alertUntil = Time.time + 2f; if (Plugin.Instance.Hurt(val, 6, 0.2f, Kind)) { Cue(2); } break; } } } phase = ((marks.Count > 0) ? 1 : 0); if (Time.time < alertUntil) { mood = 1; } } private void Tollbud() { //IL_0076: 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_003f: 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) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = Nearest(5.5f, requireSight: true); if ((Object)(object)val == (Object)null) { phase = 0; charge = 0f; stillness.Clear(); if (Vector3.Distance(((Component)this).transform.position, Home) > 0.8f) { Move(Home, 1f); } else { Stop(); } return; } Stop(); Face(((Component)val).transform.position); mood = 2; bool flag = true; PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val2 in allPlayerScripts) { if (!EligibleFor(val2) || Distance(val2) > 5.5f || !Sees(val2)) { continue; } ulong actualClientId = val2.actualClientId; Vector3 value; bool flag2 = lastPosition.TryGetValue(actualClientId, out value); lastPosition[actualClientId] = ((Component)val2).transform.position; if (!passes.TryGetValue(actualClientId, out var value2) || !(Time.time < value2)) { flag = false; stillness.TryGetValue(actualClientId, out var value3); value3 = ((flag2 && Vector3.Distance(value, ((Component)val2).transform.position) < 0.12f) ? (value3 + 0.2f) : 0f); stillness[actualClientId] = value3; if (value3 >= 2f) { passes[actualClientId] = Time.time + 20f; stillness[actualClientId] = 0f; } else if (phase == 1 && Time.time >= deadline && Distance(val2) < 3.2f) { Plugin.Instance.Hurt(val2, 8, 0.12f, Kind); } } } if (flag) { phase = 2; mood = 0; charge = 0f; return; } if (phase != 1) { phase = 1; deadline = Time.time + 3f; Cue(); } charge = 1f - Mathf.Clamp01((deadline - Time.time) / 3f); if (Time.time >= deadline) { mood = 3; deadline = Time.time + 3f; Cue(2); } } private void Foldback() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_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) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB val = Nearest(30f, requireSight: true); if ((Object)(object)val == (Object)null) { footsteps.Clear(); marks.Clear(); trailOwner = ulong.MaxValue; phase = 0; Roam(); return; } mood = 1; if (val.actualClientId != trailOwner) { footsteps.Clear(); marks.Clear(); trailOwner = val.actualClientId; previousTrail = ((Component)val).transform.position; phase = 0; cooldown = Time.time + 7f; Cue(); } if (Time.time >= trailTick) { trailTick = Time.time + 0.6f; footsteps.Enqueue(new Mark(((Component)val).transform.position, Time.time)); while (footsteps.Count > 20) { footsteps.Dequeue(); } } if (footsteps.Count > 0 && Time.time - footsteps.Peek().time >= 6f) { Mark mark = footsteps.Dequeue(); if (Vector3.Distance(previousTrail, mark.point) > 10f) { footsteps.Clear(); marks.Clear(); phase = 0; mood = 0; cooldown = Time.time + 7f; Stop(); return; } previousTrail = mark.point; aim = mark.point; Move(aim, 2.4f); phase = 1; } else if (phase == 0) { Stop(); } marks.Clear(); int num = 0; foreach (Mark footstep in footsteps) { if (num++ % 2 == 0 && marks.Count < 6) { marks.Add(footstep); } } charge = Mathf.Clamp01((Time.time - Born) / 7f); if (phase != 1 || !(Time.time >= cooldown)) { return; } PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB player in allPlayerScripts) { if (EligibleFor(player) && Distance(player) < 1.4f && Sees(player) && Plugin.Instance.Hurt(player, 10, 0.08f, Kind)) { mood = 3; Cue(2); } } } private void Passenger() { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_010f: Unknown result type (might be due to invalid IL or missing references) Stop(); if (Plugin.Instance.Curse.Marked) { mood = 2; return; } PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if (!((Object)(object)val == (Object)null)) { Signal signal = Plugin.Instance.GetSignal(val); Vector3 val2 = ((Component)this).transform.position + Vector3.up * 2.2f - (((Component)val).transform.position + Vector3.up * 1.5f); bool flag = Balance.CanMark(((Vector3)(ref val2)).magnitude, Vector3.Angle(signal.look, val2), Sees(val), signal.witness == Id, EligibleFor(val)); gaze.TryGetValue(val.actualClientId, out var value); value = (flag ? (value + 0.2f) : 0f); gaze[val.actualClientId] = value; if (flag) { Face(((Component)val).transform.position); mood = 1; } if (value >= 0.6f && Plugin.Instance.Curse.Mark(val, Id)) { mood = 2; Cue(); break; } } } } public bool Hit(int force, Vector3 hitDirection, PlayerControllerB playerWhoHit, bool playHitSFX, int hitID) { if ((Object)(object)Plugin.Instance != (Object)null && force > 0) { Plugin.Instance.RequestHit(Id, playerWhoHit); } return true; } public void TakeHit() { if (Kind != 5) { health--; stunnedUntil = Time.time + 2.5f; phase = 0; charge = 0f; cooldown = Time.time + 5f; mood = 4; Stop(); Cue(2); if (health <= 0) { Plugin.Instance.Remove(Id); } } } private void OnDestroy() { if (visual != null) { visual.Dispose(); } } } public sealed class Visuals { private readonly Transform root; private readonly Transform body; private readonly int kind; private readonly List<Material> materials = new List<Material>(); private readonly List<Mesh> meshes = new List<Mesh>(); private readonly List<Transform> limbs = new List<Transform>(); private readonly List<Quaternion> restRotations = new List<Quaternion>(); private readonly List<Vector3> restPositions = new List<Vector3>(); private readonly List<LineRenderer> marks = new List<LineRenderer>(); private readonly AudioSource sound; private readonly AudioSource ambience; private readonly AudioSource pursuit; private readonly AudioSource sighting; private readonly AudioLowPassFilter soundFilter; private readonly AudioLowPassFilter ambienceFilter; private readonly AudioLowPassFilter pursuitFilter; private float nextOcclusion; private float occlusion = 1f; private float mix; private float chaseMix; private float sightTime; private float gait; private float speed; private float strikeAt = -10f; private Vector3 lastPosition; private Quaternion headRest; private Vector3 headScale; private readonly Material main; private readonly Material bright; private readonly Material dark; private LineRenderer ring; private LineRenderer tongue; private LineRenderer guide; private Transform head; private static readonly Color[] Colors = (Color[])(object)new Color[6] { new Color(0.39f, 0.31f, 0.27f), new Color(0.29f, 0.28f, 0.25f), new Color(0.25f, 0.3f, 0.27f), new Color(0.33f, 0.25f, 0.15f), new Color(0.47f, 0.46f, 0.38f), new Color(0.32f, 0.045f, 0.04f) }; public Visuals(Transform parent, int creatureKind) { //IL_0072: 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_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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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_017e: 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) //IL_01b5: 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_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Expected O, but got Unknown //IL_04b3: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) root = parent; kind = creatureKind; body = new GameObject("Body").transform; body.SetParent(root, false); main = Material(Colors[kind], glow: false); Color[] array = (Color[])(object)new Color[6] { new Color(0.43f, 0.17f, 0.14f), new Color(0.4f, 0.37f, 0.49f), new Color(0.25f, 0.53f, 0.48f), new Color(0.65f, 0.42f, 0.16f), new Color(0.54f, 0.55f, 0.39f), new Color(0.29f, 0.025f, 0.022f) }; bright = Material(array[kind], glow: true); dark = Material(new Color(0.045f, 0.047f, 0.043f), glow: false); switch (kind) { case 0: BuildPligga(); break; case 1: BuildHushloom(); break; case 2: BuildBackstitch(); break; case 3: BuildTollbud(); break; case 4: BuildFoldback(); break; case 5: BuildPassenger(); break; } if (kind == 0 || kind == 4 || kind == 5) { RigHead(); } headRest = head.localRotation; headScale = head.localScale; lastPosition = root.position; foreach (Transform limb in limbs) { restRotations.Add(limb.localRotation); restPositions.Add(limb.localPosition); } ring = Line("Warning ring", bright, 0.045f, loop: true); tongue = Line("Tongue", main, 0.13f, loop: false); guide = Line("Trail guide", bright, 0.028f, loop: false); for (int i = 0; i < 6; i++) { marks.Add(Line("Trail " + i, bright, 0.04f, loop: true)); } sound = Audio("Warning voice", loop: false); ambience = Audio("Encounter bed", loop: true); pursuit = Audio("Pursuit bed", loop: true); sighting = Audio("First sighting", loop: false); sighting.spatialBlend = 0f; sighting.priority = 100; soundFilter = ((Component)sound).gameObject.AddComponent<AudioLowPassFilter>(); ambienceFilter = ((Component)ambience).gameObject.AddComponent<AudioLowPassFilter>(); pursuitFilter = ((Component)pursuit).gameObject.AddComponent<AudioLowPassFilter>(); soundFilter.lowpassResonanceQ = (ambienceFilter.lowpassResonanceQ = 1f); ambience.clip = Plugin.Instance.Sounds[kind, 0]; ambience.volume = 0f; ambience.Play(); pursuit.clip = Plugin.Instance.Sounds[kind, 3]; pursuit.volume = 0f; pursuit.Play(); GameObject val = new GameObject("ScanNode"); val.transform.SetParent(root, false); val.transform.localPosition = Vector3.up * 1.2f; int num2 = LayerMask.NameToLayer("ScanNode"); val.layer = ((num2 >= 0) ? num2 : 22); BoxCollider val2 = val.AddComponent<BoxCollider>(); ((Collider)val2).isTrigger = true; val2.size = Vector3.one; ScanNodeProperties val3 = val.AddComponent<ScanNodeProperties>(); val3.headerText = Balance.Names[kind]; val3.subText = Balance.Advice[kind]; val3.minRange = 0; val3.maxRange = 18; val3.requiresLineOfSight = true; val3.nodeType = 1; val3.creatureScanID = -1; } private Material Material(Color color, bool glow) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_0057: 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_0089: 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_00c2: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find(glow ? "HDRP/Unlit" : "HDRP/Lit"); if ((Object)(object)val == (Object)null) { val = Shader.Find("HDRP/Unlit"); } if ((Object)(object)val == (Object)null) { val = Shader.Find("Unlit/Color"); } Material val2 = new Material(val); if (val2.HasProperty("_BaseColor")) { val2.SetColor("_BaseColor", color); } if (val2.HasProperty("_UnlitColor")) { val2.SetColor("_UnlitColor", color); } if (val2.HasProperty("_Color")) { val2.SetColor("_Color", color); } if (val2.HasProperty("_Smoothness")) { val2.SetFloat("_Smoothness", 0.08f); } if (val2.HasProperty("_EmissiveColor")) { val2.SetColor("_EmissiveColor", glow ? color : Color.black); } val2.enableInstancing = true; materials.Add(val2); return val2; } private void RigHead() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) Transform transform = new GameObject("Head pivot").transform; transform.SetParent(body, false); transform.localPosition = head.localPosition; for (int num = body.childCount - 1; num >= 0; num--) { Transform child = body.GetChild(num); if ((Object)(object)child == (Object)(object)head || ((Object)child).name == "Photo face" || ((Object)child).name == "Mask seam" || ((Object)child).name == "Tongue tip" || ((Object)child).name == "Eye slit" || ((Object)child).name.StartsWith("Passenger face")) { child.SetParent(transform, true); } } head = transform; } private Transform Shape(string name, PrimitiveType type, Vector3 position, Vector3 scale, Material material) { //IL_0000: 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_0032: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive(type); ((Object)val).name = name; val.transform.SetParent(body, false); val.transform.localPosition = position; val.transform.localScale = scale; Collider component = val.GetComponent<Collider>(); component.enabled = false; Object.Destroy((Object)(object)component); val.GetComponent<Renderer>().sharedMaterial = material; return val.transform; } private Transform Bone(string name, Vector3 from, Vector3 to, float width, Material material) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_001d: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) Vector3 position = (from + to) * 0.5f; Vector3 val = to - from; Transform val2 = Shape(name, (PrimitiveType)2, position, new Vector3(width, ((Vector3)(ref val)).magnitude * 0.5f, width), material); val2.localRotation = Quaternion.FromToRotation(Vector3.up, to - from); return val2; } private Transform Sheet(string name, Vector3[] vertices, Material material) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown Mesh val = new Mesh(); ((Object)val).name = name; Vector3[] array = (Vector3[])(object)new Vector3[vertices.Length * 2]; Array.Copy(vertices, 0, array, 0, vertices.Length); Array.Copy(vertices, 0, array, vertices.Length, vertices.Length); int[] array2 = new int[(vertices.Length - 2) * 6]; for (int i = 0; i < vertices.Length - 2; i++) { int num = i * 6; array2[num] = 0; array2[num + 1] = i + 1; array2[num + 2] = i + 2; array2[num + 3] = vertices.Length; array2[num + 4] = vertices.Length + i + 2; array2[num + 5] = vertices.Length + i + 1; } val.vertices = array; val.triangles = array2; val.RecalculateNormals(); val.RecalculateBounds(); meshes.Add(val); GameObject val2 = new GameObject(name); val2.transform.SetParent(body, false); val2.AddComponent<MeshFilter>().sharedMesh = val; ((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = material; return val2.transform; } private AudioSource Audio(string name, bool loop) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(root, false); val.transform.localPosition = Vector3.up; AudioSource val2 = val.AddComponent<AudioSource>(); val2.playOnAwake = false; val2.spatialBlend = 1f; val2.rolloffMode = (AudioRolloffMode)1; val2.minDistance = 2f; val2.maxDistance = (loop ? 21 : 24); val2.dopplerLevel = 0f; val2.loop = loop; val2.volume = 0f; val2.priority = (loop ? 180 : 80); PlayerControllerB localPlayer = Plugin.LocalPlayer; if ((Object)(object)localPlayer != (Object)null && (Object)(object)localPlayer.movementAudio != (Object)null) { val2.outputAudioMixerGroup = localPlayer.movementAudio.outputAudioMixerGroup; } return val2; } private void MixAudio(int mood, float charge) { //IL_0035: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0086: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB localPlayer = Plugin.LocalPlayer; bool flag = Plugin.Eligible(localPlayer); if (Time.time >= nextOcclusion) { nextOcclusion = Time.time + 0.2f; occlusion = ((flag && !Plugin.ClearLine(root.position + Vector3.up, ((Component)localPlayer).transform.position + Vector3.up)) ? 0.28f : 1f); } float num = (flag ? 1 : 0); if (flag) { float num2 = Vector3.Distance(root.position, ((Component)localPlayer).transform.position); foreach (Creature creature in Plugin.Instance.Creatures) { if ((Object)(object)creature != (Object)null && (Object)(object)((Component)creature).transform != (Object)(object)root && Vector3.Distance(((Component)creature).transform.position, ((Component)localPlayer).transform.position) + 1f < num2) { num *= 0.35f; break; } } if (num2 > 24f) { num = 0f; } } mix = Mathf.MoveTowards(mix, num, Time.deltaTime * 0.8f); chaseMix = Mathf.MoveTowards(chaseMix, (float)((mood >= 1 && mood <= 3) ? 1 : 0), Time.deltaTime * 1.5f); float num3 = mix * Plugin.Instance.AmbienceVolume * occlusion; float num4 = (sound.isPlaying ? 0.4f : 1f); ambience.volume = num3 * (1f - chaseMix) * num4; pursuit.volume = num3 * chaseMix * num4; sound.volume = (flag ? (Plugin.Instance.WarningVolume * Mathf.Max(0.5f, occlusion)) : 0f); float num5 = ((occlusion < 0.5f) ? 1200 : 16000); ambienceFilter.cutoffFrequency = Mathf.Lerp(ambienceFilter.cutoffFrequency, num5, Time.deltaTime * 6f); pursuitFilter.cutoffFrequency = Mathf.Lerp(pursuitFilter.cutoffFrequency, num5, Time.deltaTime * 6f); soundFilter.cutoffFrequency = Mathf.Lerp(soundFilter.cutoffFrequency, (float)((occlusion < 0.5f) ? 2400 : 18000), Time.deltaTime * 6f); if (!flag) { sighting.Stop(); } } private void CheckSighting(int mood) { //IL_0035: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) PlayerControllerB localPlayer = Plugin.LocalPlayer; if (!Plugin.Eligible(localPlayer) || (Object)(object)localPlayer.gameplayCamera == (Object)null) { sightTime = 0f; return; } Camera gameplayCamera = localPlayer.gameplayCamera; Vector3 val = root.position + Vector3.up * 1.35f; Vector3 val2 = gameplayCamera.WorldToViewportPoint(val); bool inView = val2.z > 0f && val2.x > 0.12f && val2.x < 0.88f && val2.y > 0.08f && val2.y < 0.92f; bool flag = SightingGate.Visible(Vector3.Distance(((Component)gameplayCamera).transform.position, val), inView, Plugin.ClearLine(((Component)gameplayCamera).transform.position, val), eligible: true); sightTime = (flag ? (sightTime + Time.deltaTime) : 0f); if (sightTime < 0.25f) { return; } bool attack = sound.isPlaying; foreach (Creature creature in Plugin.Instance.Creatures) { if ((Object)(object)creature != (Object)null && creature.Mood >= 2 && creature.Mood <= 3 && Vector3.Distance(((Component)creature).transform.position, ((Component)localPlayer).transform.position) < 12f) { attack = true; } } if (Plugin.Instance.Sightings.Consume(kind, Time.time, attack, Plugin.Instance.SightingScares && Plugin.Instance.SightingVolume > 0f)) { sighting.clip = Plugin.Instance.Sounds[kind, 4]; sighting.volume = Plugin.Instance.SightingVolume; sighting.Play(); } } private void BuildPligga() { //IL_0016: 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_0049: 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) //IL_007e: 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) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Expected O, but got Unknown //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_04fc: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) Shape("Collapsed work coat", (PrimitiveType)1, new Vector3(0f, 0.86f, -0.13f), new Vector3(0.88f, 0.6f, 0.67f), dark).localRotation = Quaternion.Euler(15f, 0f, -7f); head = Shape("Round bald head", (PrimitiveType)0, new Vector3(0f, 1.7f, 0f), new Vector3(1.45f, 1.4f, 0.9f), main); Material val = Material(new Color(0.64f, 0.61f, 0.53f), glow: false); if (val.HasProperty("_BaseColorMap")) { val.SetTexture("_BaseColorMap", (Texture)(object)Plugin.Instance.Face); val.EnableKeyword("_BASECOLORMAP"); } if (val.HasProperty("_UnlitColorMap")) { val.SetTexture("_UnlitColorMap", (Texture)(object)Plugin.Instance.Face); val.EnableKeyword("_UNLIT_COLOR_MAP"); } if (val.HasProperty("_MainTex")) { val.SetTexture("_MainTex", (Texture)(object)Plugin.Instance.Face); } if (val.HasProperty("_EmissiveColorMap")) { val.SetTexture("_EmissiveColorMap", (Texture)(object)Plugin.Instance.Face); val.SetColor("_EmissiveColor", Color.black); val.EnableKeyword("_EMISSIVE_COLOR_MAP"); } Mesh val2 = new Mesh(); ((Object)val2).name = "Pligga oval mask"; Vector3[] array = (Vector3[])(object)new Vector3[49]; Vector2[] array2 = (Vector2[])(object)new Vector2[49]; int[] array3 = new int[144]; ref Vector3 reference = ref array[0]; reference = new Vector3(0f, 1.7f, 0.5f); ref Vector2 reference2 = ref array2[0]; reference2 = new Vector2(0.5f, 0.42f); for (int i = 0; i < 48; i++) { float num = (float)i * (float)Math.PI * 2f / 48f; ref Vector3 reference3 = ref array[i + 1]; reference3 = new Vector3(Mathf.Cos(num) * 0.69f, 1.7f + Mathf.Sin(num) * 0.66f, 0.35f); ref Vector2 reference4 = ref array2[i + 1]; reference4 = new Vector2(0.5f + Mathf.Cos(num) * 0.39f, 0.42f + Mathf.Sin(num) * 0.34f); array3[i * 3] = 0; array3[i * 3 + 1] = i + 1; array3[i * 3 + 2] = (i + 1) % 48 + 1; } val2.vertices = array; val2.uv = array2; val2.triangles = array3; val2.RecalculateNormals(); val2.RecalculateBounds(); meshes.Add(val2); GameObject val3 = new GameObject("Photo face"); val3.transform.SetParent(body, false); val3.AddComponent<MeshFilter>().sharedMesh = val2; ((Renderer)val3.AddComponent<MeshRenderer>()).sharedMaterial = val; for (int j = -1; j <= 1; j += 2) { limbs.Add(Shape("Dragging boot", (PrimitiveType)1, new Vector3((float)j * 0.29f, 0.2f, -0.12f), new Vector3(0.22f, 0.21f, 0.48f), dark)); Transform val4 = Shape("Too-long forearm", (PrimitiveType)1, new Vector3((float)j * 0.62f, 0.67f, 0.02f), new Vector3(0.13f, 0.53f, 0.14f), main); val4.localRotation = Quaternion.Euler(-12f, 0f, (float)(j * 12)); limbs.Add(val4); for (int k = 0; k < 3; k++) { Bone("Dragging finger", new Vector3((float)j * 0.62f + (float)k * 0.04f, 0.2f, 0.08f), new Vector3((float)j * 0.67f + (float)k * 0.04f, 0.07f, 0.31f), 0.027f, main).SetParent(val4, true); } for (int l = 0; l < 5; l++) { Bone("Mask seam", new Vector3((float)j * 0.6f, 1.3f + (float)l * 0.17f, 0.37f), new Vector3((float)j * 0.7f, 1.36f + (float)l * 0.17f, 0.29f), 0.018f, dark); } } for (int m = 0; m < 4; m++) { Shape("Coat tear", (PrimitiveType)3, new Vector3(0.08f, 0.67f + (float)m * 0.13f, 0.22f), new Vector3(0.45f, 0.025f, 0.03f), main).localRotation = Quaternion.Euler(0f, 0f, -14f); } Shape("Tongue tip", (PrimitiveType)0, new Vector3(0.03f, 1.35f, 0.56f), new Vector3(0.22f, 0.12f, 0.18f), main); } private void BuildHushloom() { //IL_0017: 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) //IL_0056: 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) //IL_00aa: 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_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_00f2: 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) //IL_0116: 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_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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) head = Shape("Hollow throat", (PrimitiveType)1, new Vector3(0f, 1.3f, 0f), new Vector3(0.24f, 0.71f, 0.3f), dark); Shape("Dim throat slit", (PrimitiveType)3, new Vector3(0f, 1.65f, 0.17f), new Vector3(0.055f, 0.4f, 0.025f), bright); for (int i = -1; i <= 1; i += 2) { Transform val = Sheet("Torn membrane", (Vector3[])(object)new Vector3[7] { new Vector3((float)i * 0.13f, 1.6f, 0f), new Vector3((float)i * 0.6f, 2.15f, -0.12f), new Vector3((float)i * 1.04f, 1.78f, -0.08f), new Vector3((float)i * 0.83f, 0.96f, 0.06f), new Vector3((float)i * 0.62f, 1.3f, 0f), new Vector3((float)i * 0.5f, 0.71f, 0.04f), new Vector3((float)i * 0.33f, 1.17f, 0f) }, main); Transform transform = new GameObject("Wing hinge").transform; transform.SetParent(body, false); transform.localPosition = new Vector3((float)i * 0.13f, 1.6f, 0f); val.SetParent(transform, true); limbs.Add(transform); Bone("Bent antenna", new Vector3((float)i * 0.08f, 1.93f, 0f), new Vector3((float)i * 0.32f, 2.38f, -0.15f), 0.025f, dark); for (int j = 0; j < 4; j++) { Bone("Membrane vein", new Vector3((float)i * 0.14f, 1.6f, 0.015f), new Vector3((float)i * (0.4f + (float)j * 0.17f), 1f + (float)j * 0.22f, -0.04f), 0.016f, dark).SetParent(transform, true); } Bone("Dangling leg", new Vector3((float)i * 0.1f, 1f, 0f), new Vector3((float)i * 0.29f, 0.34f, 0.2f), 0.029f, main); } } private void BuildBackstitch() { //IL_0017: 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) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) head = Shape("Corroded spindle", (PrimitiveType)2, new Vector3(0f, 0.8f, 0f), new Vector3(0.55f, 0.45f, 0.55f), main); for (int i = 0; i < 2; i++) { Shape("Spool rim", (PrimitiveType)2, new Vector3(0f, 0.45f + (float)i * 0.7f, 0f), new Vector3(1.1f, 0.055f, 1.1f), dark); } Vector3 val = default(Vector3); for (int j = 0; j < 6; j++) { float num = (float)j * (float)Math.PI / 3f; ((Vector3)(ref val))..ctor(Mathf.Cos(num) * 0.76f, 0.48f, Mathf.Sin(num) * 0.76f); Bone("Bent steel femur", new Vector3(Mathf.Cos(num) * 0.25f, 0.88f, Mathf.Sin(num) * 0.25f), val, 0.065f, dark); Transform item = Bone("Needle leg", val, new Vector3(Mathf.Cos(num) * 0.94f, 0.03f, Mathf.Sin(num) * 0.94f), 0.035f, main); limbs.Add(item); } for (int k = 0; k < 12; k++) { Shape("Wound wire", (PrimitiveType)2, new Vector3(0f, 0.48f + (float)k * 0.052f, 0f), new Vector3(0.6f, 0.012f, 0.6f), dark); } Shape("Thread eye", (PrimitiveType)0, new Vector3(0f, 0.9f, 0.33f), new Vector3(0.22f, 0.045f, 0.055f), bright); } private void BuildTollbud() { //IL_0017: 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) //IL_0056: 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) //IL_00b5: 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_00ed: 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) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_017a: 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_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) head = Shape("Rusted timeclock", (PrimitiveType)3, new Vector3(0f, 1.2f, 0f), new Vector3(0.46f, 0.91f, 0.4f), dark); Shape("Approval slot", (PrimitiveType)3, new Vector3(0f, 1.35f, 0.28f), new Vector3(0.45f, 0.08f, 0.03f), bright); for (int i = 0; i < 4; i++) { float num = (float)i * (float)Math.PI / 2f; Transform val = Shape("Split steel jaw", (PrimitiveType)3, new Vector3(Mathf.Cos(num) * 0.38f, 1.5f, Mathf.Sin(num) * 0.38f), new Vector3(0.19f, 1.05f, 0.07f), main); val.localRotation = Quaternion.Euler(0f, (float)(90 - i * 90), 25f); limbs.Add(val); Shape("Root foot", (PrimitiveType)1, new Vector3(Mathf.Cos(num) * 0.3f, 0.4f, Mathf.Sin(num) * 0.3f), new Vector3(0.14f, 0.42f, 0.14f), dark); } for (int j = 0; j < 6; j++) { Shape("Staple tooth", (PrimitiveType)3, new Vector3(-0.18f + (float)j * 0.07f, 1.27f, 0.29f), new Vector3(0.022f, 0.1f, 0.04f), main); } Shape("Hanging receipt", (PrimitiveType)3, new Vector3(0.035f, 0.95f, 0.27f), new Vector3(0.14f