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 Footprints v0.1.1
Footprints.dll
Decompiled an hour agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using ModMenu; using UnityEngine; using UnityEngine.Rendering.HighDefinition; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Footprints")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.1.0")] [assembly: AssemblyInformationalVersion("0.1.1+7580bc23ef579f194089ab813cc8dfc65404bab2")] [assembly: AssemblyProduct("Footprints")] [assembly: AssemblyTitle("Footprints")] [assembly: AssemblyVersion("0.1.1.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Footprints { internal static class MenuHooks { internal const string ModMenuGuid = "daniel.lethalcompany.modmenu"; private const string Tab = "Footprints"; [MethodImpl(MethodImplOptions.NoInlining)] internal static void Register() { MenuApi.Button("Footprints", "Clear all prints", (Func<string>)delegate { Pool.Clear("Mod Menu"); return "cleared the footprints"; }, false, false, (Func<string>)null, "every print on this moon and in the ship, on your game"); MenuApi.Toggle("Footprints", "Hide prints", (Func<bool>)(() => Pool.Hidden), (Func<bool, string>)delegate(bool on) { Pool.SetHidden(on); return (!on) ? "footprints shown" : "footprints hidden"; }, false, false, (Func<string>)null, "they keep being made and fading, just not drawn; until you switch it off or restart"); Switch("Eyeless Dog tracks", Plugin.TrackDogs); Switch("Forest Giant tracks", Plugin.TrackGiants); Switch("Baboon Hawk tracks", Plugin.TrackHawks); Switch("Masked tracks", Plugin.TrackMasked); Switch("Mud prints on terrain", Plugin.MudOnTerrain); } private static void Switch(string label, ConfigEntry<bool> e) { MenuApi.Toggle("Footprints", label, (Func<bool>)(() => e.Value), (Func<bool, string>)delegate(bool on) { e.Value = on; return label + ": " + (on ? "on" : "off"); }, false, false, (Func<string>)null, (string)null); } } public static class Monsters { public enum Type { Dog, Giant, Hawk, Masked } private class Walker { public bool Has; public bool Left; public Vector3 Last; public int Blood; public Type Type; } public const int OwnerBase = 100; private static readonly Dictionary<EnemyAI, Walker> _w = new Dictionary<EnemyAI, Walker>(); private static readonly List<EnemyAI> _gone = new List<EnemyAI>(); private static float _nextPrune; private static readonly List<EnemyAI> _masked = new List<EnemyAI>(); public static void AddMasked(EnemyAI e) { if ((Object)(object)e != (Object)null && !_masked.Contains(e)) { _masked.Add(e); } } public static PrintShape ShapeOf(Type t) { return t switch { Type.Hawk => PrintShape.Claw, Type.Giant => PrintShape.Giant, Type.Dog => PrintShape.Paw, _ => PrintShape.Boot, }; } public static float StrideOf(Type t) { return t switch { Type.Hawk => 0.9f, Type.Giant => 3.4f, Type.Dog => 1.6f, _ => Plugin.Stride.Value, }; } private static bool Tracked(EnemyAI e, out Type t) { t = Type.Dog; if (e is MouthDogAI) { t = Type.Dog; return Plugin.TrackDogs.Value; } if (e is ForestGiantAI) { t = Type.Giant; return Plugin.TrackGiants.Value; } if (e is BaboonBirdAI) { t = Type.Hawk; return Plugin.TrackHawks.Value; } if (e is MaskedPlayerEnemy) { t = Type.Masked; return Plugin.TrackMasked.Value; } return false; } public static int BloodLeft(EnemyAI e) { if (!((Object)(object)e != (Object)null) || !_w.TryGetValue(e, out var value)) { return 0; } return value.Blood; } public static void Update() { StartOfRound instance = StartOfRound.Instance; RoundManager instance2 = RoundManager.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance2 == (Object)null || instance.inShipPhase || instance2.SpawnedEnemies == null) { if (_w.Count > 0) { _w.Clear(); } return; } List<EnemyAI> spawnedEnemies = instance2.SpawnedEnemies; for (int i = 0; i < spawnedEnemies.Count; i++) { Visit(spawnedEnemies[i]); } _masked.RemoveAll((EnemyAI m) => (Object)(object)m == (Object)null); for (int num = 0; num < _masked.Count; num++) { if (!spawnedEnemies.Contains(_masked[num])) { Visit(_masked[num]); } } if (!(Time.time > _nextPrune)) { return; } _nextPrune = Time.time + 5f; _gone.Clear(); foreach (EnemyAI key in _w.Keys) { if ((Object)(object)key == (Object)null) { _gone.Add(key); } } foreach (EnemyAI item in _gone) { _w.Remove(item); } } private static void Visit(EnemyAI e) { //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_0083: 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_007c: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)e == (Object)null || !Tracked(e, out var t)) { return; } if (!_w.TryGetValue(e, out var value)) { value = new Walker { Type = t }; _w[e] = value; } if (e.isEnemyDead || !((Component)e).gameObject.activeInHierarchy) { value.Has = false; value.Blood = 0; return; } Vector3 position = ((Component)e).transform.position; if (!value.Has) { value.Has = true; value.Last = position; return; } Vector3 val = position - value.Last; val.y = 0f; float magnitude = ((Vector3)(ref val)).magnitude; float num = StrideOf(t); if (!(magnitude < num)) { Vector3 last = value.Last; value.Last = position; if (!(magnitude > num * 4f)) { value.Left = !value.Left; Step(e, value, last, position, val / magnitude); } } } private static void Step(EnemyAI e, Walker w, Vector3 from, Vector3 pos, Vector3 heading) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; RaycastHit hit = default(RaycastHit); if (Physics.Raycast(pos + Vector3.up * 0.6f, Vector3.down, ref hit, 1.2f, instance.walkableSurfacesMask, (QueryTriggerInteraction)1) && !(((RaycastHit)(ref hit)).distance > 0.85f)) { int owner = (int)(100 + w.Type); PrintShape shape = ShapeOf(w.Type); bool isInsidePlayerShip = e.isInsidePlayerShip; Transform parent = (isInsidePlayerShip ? instance.elevatorTransform : null); if (Plugin.BloodSteps.Value > 0 && Blood.Near(from, pos)) { w.Blood = Plugin.BloodSteps.Value; } if (w.Blood > 0) { Tracker.Bloody(ref w.Blood, hit, heading, w.Left, owner, shape, parent); } else if (!isInsidePlayerShip) { Tracker.OnSurface(hit, heading, w.Left, owner, shape, e.isOutside, e.isOutside); } } } } [HarmonyPatch] internal static class Patches { [HarmonyPatch(typeof(StartOfRound), "InstantiateFootprintsPooledObjects")] [HarmonyPrefix] private static bool NoVanillaPool() { return false; } [HarmonyPatch(typeof(PlayerControllerB), "DropBlood")] [HarmonyPrefix] private static void NoVanillaPrint(ref bool leaveFootprint) { leaveFootprint = false; } [HarmonyPatch(typeof(StartOfRound), "ResetPooledObjects")] [HarmonyPostfix] private static void ClearOnReset(bool destroy) { Pool.Clear(destroy ? "ResetPooledObjects (ship reset)" : "ResetPooledObjects", !destroy); } [HarmonyPatch(typeof(MaskedPlayerEnemy), "Start")] [HarmonyPostfix] private static void TrackMasked(MaskedPlayerEnemy __instance) { Monsters.AddMasked((EnemyAI)(object)__instance); } [HarmonyPatch(typeof(StartOfRound), "ShipHasLeft")] [HarmonyPostfix] private static void ClearOnLeave() { Pool.Clear("ShipHasLeft", keepShip: true); } } public static class PluginInfo { public const string Guid = "daniel.lethalcompany.footprints"; public const string Name = "Footprints"; public const string Version = "0.1.1"; } [BepInPlugin("daniel.lethalcompany.footprints", "Footprints", "0.1.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static ConfigEntry<int> PoolSize; internal static ConfigEntry<float> DrawDistance; internal static ConfigEntry<float> Stride; internal static ConfigEntry<float> SnowFull; internal static ConfigEntry<float> SnowGone; internal static ConfigEntry<float> BlizzardFull; internal static ConfigEntry<float> BlizzardGone; internal static ConfigEntry<string> BlizzardWeathers; internal static ConfigEntry<float> MudFull; internal static ConfigEntry<float> MudGone; internal static ConfigEntry<float> BloodFull; internal static ConfigEntry<float> BloodGone; internal static ConfigEntry<float> MudSheen; internal static ConfigEntry<float> MudEdgeLow; internal static ConfigEntry<float> MudEdgeHigh; internal static ConfigEntry<string> WetWeathers; internal static ConfigEntry<string> MudTags; internal static ConfigEntry<string> PuddleTags; internal static ConfigEntry<bool> MudOnTerrain; internal static ConfigEntry<int> BloodSteps; internal static ConfigEntry<float> BloodStepFade; internal static ConfigEntry<float> BloodReach; internal static ConfigEntry<Color> MudColor; internal static ConfigEntry<Color> BloodColor; internal static ConfigEntry<Color> BloodDryColor; internal static ConfigEntry<bool> TrackDogs; internal static ConfigEntry<bool> TrackGiants; internal static ConfigEntry<bool> TrackHawks; internal static ConfigEntry<bool> TrackMasked; internal static ConfigEntry<bool> VerboseLog; private readonly Harmony _harmony = new Harmony("daniel.lethalcompany.footprints"); private void Awake() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Expected O, but got Unknown //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Expected O, but got Unknown //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Expected O, but got Unknown //IL_0360: 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_03ac: Expected O, but got Unknown //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Expected O, but got Unknown //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Expected O, but got Unknown //IL_044f: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_0570: Unknown result type (might be due to invalid IL or missing references) //IL_0575: Unknown result type (might be due to invalid IL or missing references) //IL_057b: Expected O, but got Unknown //IL_057b: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; PoolSize = ((BaseUnityPlugin)this).Config.Bind<int>("Performance", "PoolSize", 400, new ConfigDescription("Prints that can be on the ground at once, shared by everyone. When it runs out the oldest print is reused (vanilla keeps 250 snow prints). Takes effect on the next moon.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(50, 1000), Array.Empty<object>())); DrawDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Performance", "DrawDistance", 40f, new ConfigDescription("Prints further away than this (metres) are not drawn.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 200f), Array.Empty<object>())); Stride = ((BaseUnityPlugin)this).Config.Bind<float>("Prints", "Stride", 0.8f, new ConfigDescription("Metres walked between two prints (left, right, left...).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.4f, 2f), Array.Empty<object>())); SnowFull = ((BaseUnityPlugin)this).Config.Bind<float>("Fade", "SnowFullMinutes", 2f, "Snow prints stay sharp for this long (minutes)..."); SnowGone = ((BaseUnityPlugin)this).Config.Bind<float>("Fade", "SnowGoneMinutes", 6f, "...then fill in and are gone at this age (minutes)."); BlizzardFull = ((BaseUnityPlugin)this).Config.Bind<float>("Fade", "BlizzardFullMinutes", 1f, "In a blizzard, snow prints stay sharp for this long (minutes)..."); BlizzardGone = ((BaseUnityPlugin)this).Config.Bind<float>("Fade", "BlizzardGoneMinutes", 3f, "...and are gone at this age (minutes)."); BlizzardWeathers = ((BaseUnityPlugin)this).Config.Bind<string>("Fade", "BlizzardWeathers", "Blizzard, Snowfall", "Weather names (comma-separated, any case) that count as a blizzard. Vanilla has no blizzard weather; these are the names modded weathers use."); MudFull = ((BaseUnityPlugin)this).Config.Bind<float>("Fade", "MudFullMinutes", 1f, "Mud prints stay sharp for this long (minutes)..."); MudGone = ((BaseUnityPlugin)this).Config.Bind<float>("Fade", "MudGoneMinutes", 4f, "...and are gone at this age (minutes)."); BloodFull = ((BaseUnityPlugin)this).Config.Bind<float>("Fade", "BloodFullMinutes", 1f, "Blood prints stay fresh for this long (minutes), then dry to brown..."); BloodGone = ((BaseUnityPlugin)this).Config.Bind<float>("Fade", "BloodGoneMinutes", 5f, "...and are gone at this age (minutes)."); WetWeathers = ((BaseUnityPlugin)this).Config.Bind<string>("Mud", "WetWeathers", "Rainy, Stormy, Flooded", "Weather names (comma-separated, any case) that turn the ground to mud. Modded weathers can be added by name."); MudTags = ((BaseUnityPlugin)this).Config.Bind<string>("Mud", "MudTags", "Grass, Gravel", "Footstep surface tags (comma-separated) that take mud prints in wet weather, besides terrain."); MudOnTerrain = ((BaseUnityPlugin)this).Config.Bind<bool>("Mud", "MudOnTerrain", true, "Terrain takes mud prints in wet weather."); PuddleTags = ((BaseUnityPlugin)this).Config.Bind<string>("Mud", "PuddleTags", "Puddle", "Tags that always take mud prints, in any weather and inside."); BloodSteps = ((BaseUnityPlugin)this).Config.Bind<int>("Blood", "BloodSteps", 12, new ConfigDescription("Prints left after stepping in blood or next to a body.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 50), Array.Empty<object>())); BloodStepFade = ((BaseUnityPlugin)this).Config.Bind<float>("Blood", "BloodStepFade", 0.08f, new ConfigDescription("How much fainter each bloody print is than the one before (0.08 = 8%).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.2f), Array.Empty<object>())); BloodReach = ((BaseUnityPlugin)this).Config.Bind<float>("Blood", "BloodReach", 0.6f, new ConfigDescription("A foot this close (metres) to a blood pool or a body picks up blood.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 2f), Array.Empty<object>())); MudColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Colours", "Mud", new Color(0.045f, 0.03f, 0.02f, 1f), "Tint of mud prints (dark wet mud, so it shows on brown dirt)."); MudSheen = ((BaseUnityPlugin)this).Config.Bind<float>("Mud", "MudSheen", 0.85f, new ConfigDescription("Wet gloss of mud prints (decal smoothness; 0 = matt).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); MudEdgeLow = ((BaseUnityPlugin)this).Config.Bind<float>("Mud", "MudEdgeLow", 0.35f, new ConfigDescription("Mud prints: print-texture alpha below this is cut away (with MudEdgeHigh, makes crisp sole edges).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); MudEdgeHigh = ((BaseUnityPlugin)this).Config.Bind<float>("Mud", "MudEdgeHigh", 0.6f, new ConfigDescription("Mud prints: print-texture alpha above this is full strength.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); BloodColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Colours", "Blood", new Color(0.38f, 0.02f, 0.02f, 1f), "Tint of fresh blood prints."); BloodDryColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Colours", "BloodDry", new Color(0.22f, 0.09f, 0.05f, 1f), "Tint of blood prints once they start to fade."); TrackDogs = ((BaseUnityPlugin)this).Config.Bind<bool>("Monsters", "EyelessDogs", true, "Eyeless Dogs leave paw prints."); TrackGiants = ((BaseUnityPlugin)this).Config.Bind<bool>("Monsters", "ForestGiants", true, "Forest Giants leave huge bare footprints."); TrackHawks = ((BaseUnityPlugin)this).Config.Bind<bool>("Monsters", "BaboonHawks", true, "Baboon Hawks leave three-toed claw prints."); TrackMasked = ((BaseUnityPlugin)this).Config.Bind<bool>("Monsters", "Masked", true, "The Masked leave ordinary crew boot prints, like a player's."); VerboseLog = ((BaseUnityPlugin)this).Config.Bind<bool>("Testing", "VerboseLog", false, "Log every print placed (very chatty; for testing)."); _harmony.PatchAll(typeof(Plugin).Assembly); if (Chainloader.PluginInfos.ContainsKey("daniel.lethalcompany.modmenu")) { MenuHooks.Register(); } GameObject val = new GameObject("Footprints.Runner"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; val.AddComponent<Runner>(); Log.LogInfo((object)"Footprints 0.1.1 loaded."); } } public enum PrintKind { Snow, Mud, Blood } public enum PrintShape { Boot, Paw, Giant, Claw } public static class Pool { public const float TickSeconds = 0.5f; private const float Lift = 0.45f; private const float SideStep = 0.11f; public static DecalProjector[] Projectors = (DecalProjector[])(object)new DecalProjector[0]; public static float[] Born = new float[0]; public static float[] Full = new float[0]; public static float[] Gone = new float[0]; public static float[] Strength = new float[0]; public static int[] Owner = new int[0]; public static bool[] Live = new bool[0]; public static bool[] OnShip = new bool[0]; public static bool[] Dried = new bool[0]; public static PrintKind[] Kind = new PrintKind[0]; public static PrintShape[] Shape = new PrintShape[0]; public static int Placed; public static int Recycled; private static GameObject _root; private static int _next; private static float _nextTick; private static readonly Material[,] _mats = new Material[4, 4]; private static Material _vanilla; private static Vector3 _baseSize; public static bool Hidden { get; private set; } public static Vector3 BaseSize => _baseSize; public static int Capacity => Projectors.Length; public static int LiveCount { get { int num = 0; for (int i = 0; i < Live.Length; i++) { if (Live[i]) { num++; } } return num; } } public static float FadeAt(float age, float full, float gone) { if (age <= full) { return 1f; } if (age >= gone) { return 0f; } return 1f - (age - full) / (gone - full); } private static bool Intact() { if ((Object)(object)_root == (Object)null || Projectors.Length != Plugin.PoolSize.Value) { return false; } for (int i = 0; i < Projectors.Length; i++) { if ((Object)(object)Projectors[i] == (Object)null) { return false; } } return true; } private static bool Ensure() { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) if (Intact()) { return true; } int value = Plugin.PoolSize.Value; StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance.footprintDecal == (Object)null) { return false; } DecalProjector[] projectors = Projectors; foreach (DecalProjector val in projectors) { if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } } if ((Object)(object)_root != (Object)null) { Object.Destroy((Object)(object)_root); } _root = new GameObject("Footprints.Pool"); Object.DontDestroyOnLoad((Object)(object)_root); Projectors = (DecalProjector[])(object)new DecalProjector[value]; Born = new float[value]; Full = new float[value]; Gone = new float[value]; Strength = new float[value]; Owner = new int[value]; Live = new bool[value]; OnShip = new bool[value]; Dried = new bool[value]; Kind = new PrintKind[value]; Shape = new PrintShape[value]; for (int j = 0; j < value; j++) { GameObject obj = Object.Instantiate<GameObject>(instance.footprintDecal, _root.transform); ((Object)obj).name = "Print" + j; DecalProjector component = obj.GetComponent<DecalProjector>(); ((Behaviour)component).enabled = false; component.drawDistance = Plugin.DrawDistance.Value; component.fadeFactor = 1f; Projectors[j] = component; } if ((Object)(object)_vanilla == (Object)null) { _vanilla = Projectors[0].material; _baseSize = Projectors[0].size; } _next = 0; Placed = 0; Recycled = 0; Plugin.Log.LogInfo((object)$"pool: {value} prints from {((Object)instance.footprintDecal).name}, draw distance {Plugin.DrawDistance.Value} m"); return true; } private static Material Tinted(Material src, string name, Color c) { //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_0019: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)src == (Object)null) { return null; } Material val = new Material(src) { name = name }; if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", c); } else { ManualLogSource log = Plugin.Log; string[] obj = new string[5] { "pool: ", null, null, null, null }; Shader shader = src.shader; obj[1] = ((shader != null) ? ((Object)shader).name : null); obj[2] = " has no _BaseColor; "; obj[3] = name; obj[4] = " keeps the snow colour"; log.LogWarning((object)string.Concat(obj)); } return val; } public static Material MaterialFor(PrintKind k, bool dried = false) { return MaterialFor(k, PrintShape.Boot, dried); } public static Material MaterialFor(PrintKind k, PrintShape shape, bool dried) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00d5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_vanilla == (Object)null) { return null; } int num = k switch { PrintKind.Blood => dried ? 3 : 2, PrintKind.Mud => 1, _ => 0, }; Material val = _mats[(int)shape, num]; if ((Object)(object)val != (Object)null) { return val; } Material val2 = _mats[(int)shape, 0]; if ((Object)(object)val2 == (Object)null) { val2 = ((shape == PrintShape.Boot) ? _vanilla : Shapes.MakeMaterial(_vanilla, shape)); _mats[(int)shape, 0] = val2; } Color value; switch (num) { case 0: return val2; default: value = Plugin.BloodDryColor.Value; break; case 2: value = Plugin.BloodColor.Value; break; case 1: value = Plugin.MudColor.Value; break; } Color c = value; val = Tinted(val2, string.Format("Footprints.{0}.{1}", shape, num switch { 2 => "Blood", 1 => "Mud", _ => "BloodDry", }), c); if (num == 1) { Wet.Apply(val); } _mats[(int)shape, num] = val; return val; } public static int Place(Vector3 point, Vector3 normal, Vector3 heading, bool left, float full, float gone, float strength, int owner) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return Place(PrintKind.Snow, point, normal, heading, left, full, gone, strength, owner, null); } public static int Place(PrintKind kind, Vector3 point, Vector3 normal, Vector3 heading, bool left, float full, float gone, float strength, int owner, Transform parent) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) return Place(kind, PrintShape.Boot, point, normal, heading, left, full, gone, strength, owner, parent); } public static int Place(PrintKind kind, PrintShape shape, Vector3 point, Vector3 normal, Vector3 heading, bool left, float full, float gone, float strength, int owner, Transform parent) { //IL_0076: 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_0079: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_0107: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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) //IL_0140: 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_026d: Unknown result type (might be due to invalid IL or missing references) if (!Ensure()) { return -1; } int next = _next; _next = (_next + 1) % Projectors.Length; if (Live[next]) { Recycled++; } DecalProjector val = Projectors[next]; Transform transform = ((Component)val).transform; Transform val2 = (((Object)(object)parent != (Object)null) ? parent : _root.transform); if ((Object)(object)transform.parent != (Object)(object)val2) { transform.SetParent(val2, false); } Vector3 val3 = Vector3.ProjectOnPlane(heading, normal); if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f) { val3 = Vector3.ProjectOnPlane(Vector3.forward, normal); } ((Vector3)(ref val3)).Normalize(); Vector3 val4 = Vector3.Cross(normal, val3); float num = Shapes.Scale(shape); val.size = new Vector3(_baseSize.x * num, _baseSize.y * num, _baseSize.z); transform.SetPositionAndRotation(point + normal * 0.45f + val4 * (left ? (-0.11f) : 0.11f) * num, Quaternion.LookRotation(-normal, val3)); val.uvScale = new Vector2(left ? (-1f) : 1f, 1f); val.uvBias = new Vector2(left ? 1f : 0f, 0f); val.drawDistance = Plugin.DrawDistance.Value; Material val5 = MaterialFor(kind, shape, dried: false); if ((Object)(object)val5 != (Object)null && (Object)(object)val.material != (Object)(object)val5) { val.material = val5; } Born[next] = Time.time; Full[next] = full; Gone[next] = gone; Strength[next] = strength; Owner[next] = owner; Kind[next] = kind; Shape[next] = shape; OnShip[next] = (Object)(object)parent != (Object)null; Dried[next] = false; Live[next] = true; val.fadeFactor = strength; ((Behaviour)val).enabled = !Hidden; Placed++; if (Plugin.VerboseLog.Value) { Plugin.Log.LogInfo((object)string.Format("print {0} {1} {2} owner {3} at {4} strength {5:F2}{6} (full {7:F0} s, gone {8:F0} s)", next, kind, shape, owner, point, strength, ((Object)(object)parent != (Object)null) ? " on the ship" : "", full, gone)); } return next; } public static void Tick() { if (Time.time < _nextTick) { return; } _nextTick = Time.time + 0.5f; if ((Object)(object)StartOfRound.Instance == (Object)null) { if (LiveCount > 0) { Clear("no StartOfRound", keepShip: false); } return; } float time = Time.time; for (int i = 0; i < Live.Length; i++) { if (!Live[i]) { continue; } DecalProjector val = Projectors[i]; if ((Object)(object)val == (Object)null) { Live[i] = false; continue; } float num = time - Born[i]; float num2 = FadeAt(num, Full[i], Gone[i]); if (num2 <= 0f) { Live[i] = false; ((Behaviour)val).enabled = false; continue; } val.fadeFactor = num2 * Strength[i]; if (Kind[i] == PrintKind.Blood && !Dried[i] && num > Full[i]) { Dried[i] = true; Material val2 = MaterialFor(PrintKind.Blood, Shape[i], dried: true); if ((Object)(object)val2 != (Object)null) { val.material = val2; } } } } public static void SetHidden(bool hidden) { Hidden = hidden; for (int i = 0; i < Projectors.Length; i++) { if ((Object)(object)Projectors[i] != (Object)null) { ((Behaviour)Projectors[i]).enabled = Live[i] && !hidden; } } } public static void Clear(string why, bool keepShip) { int num = 0; for (int i = 0; i < Projectors.Length; i++) { if (Live[i] && (!keepShip || !OnShip[i])) { num++; Live[i] = false; if ((Object)(object)Projectors[i] != (Object)null) { ((Behaviour)Projectors[i]).enabled = false; } } } if (num > 0) { Plugin.Log.LogInfo((object)$"pool: cleared {num} prints ({why})"); } } public static void Clear(string why) { Clear(why, keepShip: false); } } public static class Shapes { private const int W = 256; private const int H = 512; private static readonly Vector2 UpperRight = new Vector2(0.69f, 0.7f); private static readonly Vector2 LowerLeft = new Vector2(0.27f, 0.27f); private const float Unit = 30f; public static float Scale(PrintShape s) { return s switch { PrintShape.Claw => 0.9f, PrintShape.Giant => 1.9f, PrintShape.Paw => 1.5f, _ => 1f, }; } public static Material MakeMaterial(Material vanilla, PrintShape shape) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(vanilla) { name = "Footprints." + shape }; Make(shape, out var albedo, out var normal, Stretch(Pool.BaseSize)); if (val.HasProperty("_BaseColorMap")) { val.SetTexture("_BaseColorMap", (Texture)(object)albedo); } else { ManualLogSource log = Plugin.Log; Shader shader = vanilla.shader; log.LogWarning((object)$"shapes: {((shader != null) ? ((Object)shader).name : null)} has no _BaseColorMap; {shape} prints look like boots"); } if (val.HasProperty("_NormalMap")) { val.SetTexture("_NormalMap", (Texture)(object)normal); } return val; } public static float Stretch(Vector3 decalSize) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_002c: Unknown result type (might be due to invalid IL or missing references) if (!(decalSize.x > 0f) || !(decalSize.y > 0f)) { return 1.294f; } return decalSize.x / 256f / (decalSize.y / 512f); } public static void Make(PrintShape shape, out Texture2D albedo, out Texture2D normal, float stretch = 1.294f) { //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: 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_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_033f: 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_00c3: Unknown result type (might be due to invalid IL or missing references) float num = 30f * stretch; float[] array = new float[131072]; Vector2 val2 = default(Vector2); for (int i = 0; i < 512; i++) { for (int j = 0; j < 256; j++) { float num2 = 0f; Vector2[] array2 = (Vector2[])(object)new Vector2[2] { UpperRight, LowerLeft }; foreach (Vector2 val in array2) { ((Vector2)(ref val2))..ctor(((float)j + 0.5f - val.x * 256f) / 30f, ((float)i + 0.5f - val.y * 512f) / num); if (!(Mathf.Abs(val2.x) > 1.6f) && !(Mathf.Abs(val2.y) > 3f)) { num2 = Mathf.Max(num2, Depth(shape, val2)); } } float num3 = Mathf.Sin((float)j * 0.11f + Mathf.Sin((float)i * 0.05f) * 2.5f) * Mathf.Sin((float)i * 0.09f + Mathf.Sin((float)j * 0.06f) * 2.5f); array[i * 256 + j] = num2 * (0.86f + 0.14f * num3); } } albedo = new Texture2D(256, 512, (TextureFormat)4, true, false) { name = "Footprints." + shape, wrapMode = (TextureWrapMode)1 }; normal = new Texture2D(256, 512, (TextureFormat)4, true, true) { name = "Footprints." + shape.ToString() + "Normal", wrapMode = (TextureWrapMode)1 }; Color32[] array3 = (Color32[])(object)new Color32[131072]; Color32[] array4 = (Color32[])(object)new Color32[131072]; for (int l = 0; l < 512; l++) { for (int m = 0; m < 256; m++) { float num4 = array[l * 256 + m]; array3[l * 256 + m] = new Color32((byte)214, (byte)226, (byte)240, (byte)(Mathf.Clamp01(num4 * 1.15f) * 255f)); float num5 = array[l * 256 + Mathf.Min(m + 1, 255)] - array[l * 256 + Mathf.Max(m - 1, 0)]; float num6 = array[Mathf.Min(l + 1, 511) * 256 + m] - array[Mathf.Max(l - 1, 0) * 256 + m]; Vector3 val3 = new Vector3(num5 * 6f, num6 * 6f, 1f); Vector3 normalized = ((Vector3)(ref val3)).normalized; byte b = (byte)((normalized.x * 0.5f + 0.5f) * 255f); byte b2 = (byte)((normalized.y * 0.5f + 0.5f) * 255f); array4[l * 256 + m] = new Color32(b, b2, (byte)((normalized.z * 0.5f + 0.5f) * 255f), byte.MaxValue); } } albedo.SetPixels32(array3); albedo.Apply(true, true); normal.SetPixels32(array4); normal.Apply(true, true); } private static float Depth(PrintShape s, Vector2 p) { //IL_001f: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_0070: 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_008a: 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_00a6: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_0146: 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_016d: 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_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: 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) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_020d: 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_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0238: 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_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: 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_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) float result = 0f; switch (s) { case PrintShape.Paw: result = Blob(p, new Vector2(0f, -0.45f), new Vector2(0.62f, 0.48f)); result = Mathf.Max(result, Blob(p, new Vector2(-0.7f, 0.3f), new Vector2(0.22f, 0.27f))); result = Mathf.Max(result, Blob(p, new Vector2(-0.25f, 0.7f), new Vector2(0.23f, 0.29f))); result = Mathf.Max(result, Blob(p, new Vector2(0.25f, 0.7f), new Vector2(0.23f, 0.29f))); result = Mathf.Max(result, Blob(p, new Vector2(0.7f, 0.3f), new Vector2(0.22f, 0.27f))); result = Mathf.Max(result, 0.7f * Stick(p, new Vector2(-0.78f, 0.55f), new Vector2(-0.86f, 0.78f), 0.07f)); result = Mathf.Max(result, 0.7f * Stick(p, new Vector2(-0.27f, 1f), new Vector2(-0.29f, 1.22f), 0.07f)); result = Mathf.Max(result, 0.7f * Stick(p, new Vector2(0.27f, 1f), new Vector2(0.29f, 1.22f), 0.07f)); result = Mathf.Max(result, 0.7f * Stick(p, new Vector2(0.78f, 0.55f), new Vector2(0.86f, 0.78f), 0.07f)); break; case PrintShape.Giant: result = Blob(p, new Vector2(0.05f, -1.75f), new Vector2(0.62f, 0.72f)); result = Mathf.Max(result, Blob(p, new Vector2(0.3f, -0.55f), new Vector2(0.5f, 0.95f))); result = Mathf.Max(result, Blob(p, new Vector2(-0.15f, -0.9f), new Vector2(0.42f, 0.6f))); result = Mathf.Max(result, Blob(p, new Vector2(0f, 0.85f), new Vector2(0.88f, 0.62f))); result = Mathf.Max(result, Blob(p, new Vector2(-0.55f, 1.95f), new Vector2(0.3f, 0.36f))); result = Mathf.Max(result, Blob(p, new Vector2(-0.05f, 2.05f), new Vector2(0.2f, 0.24f))); result = Mathf.Max(result, Blob(p, new Vector2(0.32f, 1.92f), new Vector2(0.18f, 0.22f))); result = Mathf.Max(result, Blob(p, new Vector2(0.62f, 1.7f), new Vector2(0.16f, 0.2f))); result = Mathf.Max(result, Blob(p, new Vector2(0.85f, 1.42f), new Vector2(0.14f, 0.18f))); break; case PrintShape.Claw: { Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, -0.35f); result = Blob(p, val, new Vector2(0.38f, 0.36f)); result = Mathf.Max(result, Toe(p, val, new Vector2(-0.45f, 0.55f), new Vector2(-0.85f, 1.4f), 0.2f)); result = Mathf.Max(result, Toe(p, val, new Vector2(0f, 0.75f), new Vector2(0f, 1.8f), 0.21f)); result = Mathf.Max(result, Toe(p, val, new Vector2(0.45f, 0.55f), new Vector2(0.85f, 1.4f), 0.2f)); result = Mathf.Max(result, Toe(p, val, new Vector2(0f, -0.85f), new Vector2(0f, -1.35f), 0.18f)); break; } } return result; } private static float Blob(Vector2 p, Vector2 c, Vector2 r) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor((p.x - c.x) / r.x, (p.y - c.y) / r.y); return Edge(((Vector2)(ref val)).magnitude); } private static float Stick(Vector2 p, Vector2 a, Vector2 b, float r) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_002f: 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) //IL_0036: 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) Vector2 val = b - a; float num = Mathf.Clamp01(Vector2.Dot(p - a, val) / Mathf.Max(((Vector2)(ref val)).sqrMagnitude, 1E-06f)); Vector2 val2 = p - (a + val * num); return Edge(((Vector2)(ref val2)).magnitude / r); } private static float Toe(Vector2 p, Vector2 root, Vector2 mid, Vector2 tip, float r) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: 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_0010: 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 Mathf.Max(Stick(p, root, mid, r), 0.9f * Stick(p, mid, tip, r * 0.6f)); } private static float Edge(float d) { if (!(d >= 1f)) { if (!(d <= 0.75f)) { return 1f - (d - 0.75f) / 0.25f; } return 1f; } return 0f; } } public static class Tracker { private struct Walker { public bool Has; public bool Left; public Vector3 Last; public int Blood; } private static Walker[] _w = new Walker[0]; public static bool? ForceBlizzard; public static bool? ForceWet; public static int BloodLeft(int slot) { if (slot < 0 || slot >= _w.Length) { return 0; } return _w[slot].Blood; } public static void Update() { //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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null || instance.allPlayerScripts == null || instance.inShipPhase) { Reset(); return; } PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; if (_w.Length != allPlayerScripts.Length) { _w = new Walker[allPlayerScripts.Length]; } float value = Plugin.Stride.Value; for (int i = 0; i < allPlayerScripts.Length; i++) { PlayerControllerB val = allPlayerScripts[i]; if ((Object)(object)val == (Object)null || !val.isPlayerControlled || val.isPlayerDead || val.isClimbingLadder || val.inVehicleAnimation || (Object)(object)val.physicsParent != (Object)null) { _w[i].Has = false; if ((Object)(object)val == (Object)null || !val.isPlayerControlled || val.isPlayerDead) { _w[i].Blood = 0; } continue; } Vector3 position = ((Component)val).transform.position; if (!_w[i].Has) { _w[i].Has = true; _w[i].Last = position; continue; } Vector3 val2 = position - _w[i].Last; val2.y = 0f; float magnitude = ((Vector3)(ref val2)).magnitude; if (!(magnitude < value)) { Vector3 last = _w[i].Last; _w[i].Last = position; if (!(magnitude > value * 4f)) { _w[i].Left = !_w[i].Left; Step(ref _w[i], val, last, position, val2 / magnitude); } } } } private static void Reset() { for (int i = 0; i < _w.Length; i++) { _w[i].Has = false; _w[i].Blood = 0; } } private static void Step(ref Walker w, PlayerControllerB p, Vector3 from, Vector3 pos, Vector3 heading) { //IL_000e: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; int owner = (int)p.playerClientId; RaycastHit hit = default(RaycastHit); if (Physics.Raycast(pos + Vector3.up * 0.6f, Vector3.down, ref hit, 1.2f, instance.walkableSurfacesMask, (QueryTriggerInteraction)1) && !(((RaycastHit)(ref hit)).distance > 0.85f)) { bool flag = p.isInHangarShipRoom || p.isInElevator; Transform parent = (flag ? instance.elevatorTransform : null); if (Plugin.BloodSteps.Value > 0 && Blood.Near(from, pos)) { w.Blood = Plugin.BloodSteps.Value; } if (w.Blood > 0) { Bloody(ref w.Blood, hit, heading, w.Left, owner, PrintShape.Boot, parent); } else if (!flag) { OnSurface(hit, heading, w.Left, owner, PrintShape.Boot, !p.isInsideFactory, puddles: true); } } } internal static void OnSurface(RaycastHit hit, Vector3 heading, bool left, int owner, PrintShape shape, bool outside, bool puddles) { //IL_0000: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0071: Unknown result type (might be due to invalid IL or missing references) Surface surface = Surfaces.Classify(hit); if (surface == Surface.Puddle) { if (puddles) { Mud(hit, heading, left, owner, shape); } } else { if (!outside) { return; } switch (surface) { case Surface.Snow: { bool num = ForceBlizzard ?? Weather.IsBlizzard(); ConfigEntry<float> val = (num ? Plugin.BlizzardFull : Plugin.SnowFull); ConfigEntry<float> gone = (num ? Plugin.BlizzardGone : Plugin.SnowGone); Pool.Place(PrintKind.Snow, shape, ((RaycastHit)(ref hit)).point, ((RaycastHit)(ref hit)).normal, heading, left, val.Value * 60f, Gone(val, gone), 1f, owner, null); break; } case Surface.MudWhenWet: if (ForceWet ?? Weather.IsWet()) { Mud(hit, heading, left, owner, shape); } break; } } } internal static void Bloody(ref int blood, RaycastHit hit, Vector3 heading, bool left, int owner, PrintShape shape, Transform parent) { //IL_003a: 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_0046: Unknown result type (might be due to invalid IL or missing references) int num = Plugin.BloodSteps.Value - blood; blood--; float num2 = Mathf.Clamp01(1f - Plugin.BloodStepFade.Value * (float)num); if (num2 > 0.01f) { Pool.Place(PrintKind.Blood, shape, ((RaycastHit)(ref hit)).point, ((RaycastHit)(ref hit)).normal, heading, left, Plugin.BloodFull.Value * 60f, Gone(Plugin.BloodFull, Plugin.BloodGone), num2, owner, parent); } } private static void Mud(RaycastHit hit, Vector3 heading, bool left, int owner, PrintShape shape) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) Pool.Place(PrintKind.Mud, shape, ((RaycastHit)(ref hit)).point, ((RaycastHit)(ref hit)).normal, heading, left, Plugin.MudFull.Value * 60f, Gone(Plugin.MudFull, Plugin.MudGone), 1f, owner, null); } private static float Gone(ConfigEntry<float> full, ConfigEntry<float> gone) { return Mathf.Max(gone.Value * 60f, full.Value * 60f + 1f); } } public static class Blood { public static bool Near(Vector3 from, Vector3 to) { //IL_005e: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) StartOfRound instance = StartOfRound.Instance; float value = Plugin.BloodReach.Value; float r = value * value; PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val == (Object)null) { continue; } List<GameObject> playerBloodPooledObjects = val.playerBloodPooledObjects; if (playerBloodPooledObjects != null) { for (int j = 0; j < playerBloodPooledObjects.Count; j++) { GameObject val2 = playerBloodPooledObjects[j]; if (!((Object)(object)val2 == (Object)null) && val2.activeSelf && Close(from, to, val2.transform.position, r, 0.45f)) { return true; } } } DeadBodyInfo deadBody = val.deadBody; if (!val.isPlayerDead || !((Object)(object)deadBody != (Object)null) || deadBody.deactivated || !((Component)deadBody).gameObject.activeInHierarchy || deadBody.bodyParts == null) { continue; } Rigidbody[] bodyParts = deadBody.bodyParts; foreach (Rigidbody val3 in bodyParts) { if ((Object)(object)val3 != (Object)null && Close(from, to, val3.position, r, 0.2f)) { return true; } } } return false; } private static bool Close(Vector3 a, Vector3 b, Vector3 at, float r2, float lift) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_0065: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) float num = at.y - lift - b.y; if (num < -1f || num > 1f) { return false; } float num2 = b.x - a.x; float num3 = b.z - a.z; float num4 = num2 * num2 + num3 * num3; float num5 = ((num4 > 1E-06f) ? Mathf.Clamp01(((at.x - a.x) * num2 + (at.z - a.z) * num3) / num4) : 1f); float num6 = at.x - (a.x + num2 * num5); float num7 = at.z - (a.z + num3 * num5); return num6 * num6 + num7 * num7 <= r2; } } public enum Surface { None, Snow, Puddle, MudWhenWet, Other } public static class Surfaces { private static string _mudKey; private static string _puddleKey; private static readonly HashSet<string> _mud = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private static readonly HashSet<string> _puddle = new HashSet<string>(StringComparer.OrdinalIgnoreCase); public static Surface Classify(RaycastHit hit) { Collider collider = ((RaycastHit)(ref hit)).collider; if ((Object)(object)collider == (Object)null) { return Surface.None; } Refresh(); if (collider is TerrainCollider) { if (!Plugin.MudOnTerrain.Value) { return Surface.Other; } return Surface.MudWhenWet; } string tag = ((Component)collider).tag; if (tag == "Snow") { return Surface.Snow; } if (_puddle.Contains(tag)) { return Surface.Puddle; } if (_mud.Contains(tag)) { return Surface.MudWhenWet; } return Surface.Other; } private static void Refresh() { if (_mudKey != Plugin.MudTags.Value) { _mudKey = Plugin.MudTags.Value; Fill(_mud, _mudKey); } if (_puddleKey != Plugin.PuddleTags.Value) { _puddleKey = Plugin.PuddleTags.Value; Fill(_puddle, _puddleKey); } } private static void Fill(HashSet<string> set, string list) { set.Clear(); string[] array = list.Split(','); foreach (string text in array) { if (text.Trim().Length > 0) { set.Add(text.Trim()); } } } } public static class Weather { private static float _checked = -10f; private static bool _blizzard; private static bool _wet; private static Func<string> _wrName; private static bool _wrLooked; public static string Name() { if (!_wrLooked) { _wrLooked = true; MethodInfo m = AccessTools.TypeByName("WeatherRegistry.WeatherManager")?.GetMethod("GetCurrentLevelWeather", Type.EmptyTypes); if (m != null) { _wrName = delegate { object obj2 = m.Invoke(null, null); return obj2?.GetType().GetProperty("Name")?.GetValue(obj2) as string; }; } } if (_wrName != null) { try { string text = _wrName(); if (!string.IsNullOrEmpty(text)) { return text; } } catch { } } SelectableLevel val = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.currentLevel : null); if (!((Object)(object)val != (Object)null)) { return ""; } return ((object)Unsafe.As<LevelWeatherType, LevelWeatherType>(ref val.currentWeather)/*cast due to .constrained prefix*/).ToString(); } public static bool IsBlizzard() { Refresh(); return _blizzard; } public static bool IsWet() { Refresh(); return _wet; } private static void Refresh() { if (!(Time.time - _checked < 2f)) { _checked = Time.time; string n = Name().Trim(); _blizzard = InList(Plugin.BlizzardWeathers.Value, n); _wet = InList(Plugin.WetWeathers.Value, n); } } private static bool InList(string list, string n) { string[] array = list.Split(','); foreach (string text in array) { if (text.Trim().Length > 0 && string.Equals(text.Trim(), n, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } } internal class Runner : MonoBehaviour { private void Update() { try { Tracker.Update(); Monsters.Update(); Pool.Tick(); } catch (Exception ex) { Plugin.Log.LogError((object)("update: " + ex)); ((Behaviour)this).enabled = false; } } } public static class Wet { public static string LastReport = ""; public static void Apply(Material m) { if (!((Object)(object)m == (Object)null)) { byte[] sole = null; try { sole = Sharpen(m); } catch (Exception ex) { Plugin.Log.LogWarning((object)("wet: could not sharpen " + ((Object)m).name + ": " + ex.Message)); } try { Sheen(m, sole); } catch (Exception ex2) { Plugin.Log.LogWarning((object)("wet: could not add sheen to " + ((Object)m).name + ": " + ex2.Message)); } LastReport = ((Object)m).name + ": keywords [" + string.Join(" ", m.shaderKeywords) + "]" + Prop(m, "_AffectSmoothness") + Prop(m, "_Smoothness") + Prop(m, "_SmoothnessRemapMax") + Prop(m, "_MaskBlendSrc") + Prop(m, "_DecalMaskMapBlueScale") + Prop(m, "_DecalBlend") + Prop(m, "_DecalColorMask2") + " _MaskMap " + ((m.HasProperty("_MaskMap") && (Object)(object)m.GetTexture("_MaskMap") != (Object)null) ? ((Object)m.GetTexture("_MaskMap")).name : "-"); Plugin.Log.LogInfo((object)("wet: " + LastReport)); } } private static string Prop(Material m, string p) { if (!m.HasProperty(p)) { return " " + p + " -"; } return $" {p} {m.GetFloat(p):0.##}"; } private static void Set(Material m, string p, float v) { if (m.HasProperty(p)) { m.SetFloat(p, v); } } private static void Sheen(Material m, byte[] sole) { //IL_003f: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //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) float value = Plugin.MudSheen.Value; if (!(value <= 0f) && sole != null && m.HasProperty("_MaskMap")) { Texture texture = m.GetTexture("_BaseColorMap"); Texture2D val = new Texture2D(texture.width, texture.height, (TextureFormat)4, true, true) { name = ((Object)m).name + ".WetMask", wrapMode = (TextureWrapMode)1 }; Color32[] array = (Color32[])(object)new Color32[sole.Length]; for (int i = 0; i < array.Length; i++) { array[i] = new Color32((byte)0, byte.MaxValue, sole[i], byte.MaxValue); } val.SetPixels32(array); val.Apply(true, true); string[] shaderKeywords = m.shaderKeywords; m.SetTexture("_MaskMap", (Texture)(object)val); Set(m, "_AffectSmoothness", 1f); Set(m, "_AffectMetal", 0f); Set(m, "_AffectAO", 0f); Set(m, "_Smoothness", value); Set(m, "_SmoothnessRemapMin", value); Set(m, "_SmoothnessRemapMax", value); Set(m, "_MetallicRemapMin", 0f); Set(m, "_MetallicRemapMax", 0f); Set(m, "_AORemapMin", 1f); Set(m, "_AORemapMax", 1f); Set(m, "_MaskBlendSrc", 1f); Set(m, "_DecalMaskMapBlueScale", 1f); HDMaterial.ValidateMaterial(m); string[] array2 = shaderKeywords; foreach (string text in array2) { m.EnableKeyword(text); } m.EnableKeyword("_MASKMAP"); m.EnableKeyword("_MATERIAL_AFFECTS_MASKMAP"); } } private static byte[] Sharpen(Material m) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if (!m.HasProperty("_BaseColorMap")) { return null; } Texture texture = m.GetTexture("_BaseColorMap"); if ((Object)(object)texture == (Object)null) { return null; } float value = Plugin.MudEdgeLow.Value; float num = Mathf.Max(value + 0.01f, Plugin.MudEdgeHigh.Value); int width = texture.width; int height = texture.height; RenderTexture temporary = RenderTexture.GetTemporary(width, height, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2); Graphics.Blit(texture, temporary); RenderTexture active = RenderTexture.active; RenderTexture.active = temporary; Texture2D val = new Texture2D(width, height, (TextureFormat)4, true, false) { name = ((Object)m).name + ".Sharp", wrapMode = (TextureWrapMode)1 }; val.ReadPixels(new Rect(0f, 0f, (float)width, (float)height), 0, 0, false); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); Color32[] pixels = val.GetPixels32(); byte[] array = new byte[pixels.Length]; for (int i = 0; i < pixels.Length; i++) { float num2 = Mathf.Clamp01(((float)(int)pixels[i].a / 255f - value) / (num - value)); pixels[i].a = (array[i] = (byte)(num2 * num2 * (3f - 2f * num2) * 255f)); } val.SetPixels32(pixels); val.Apply(true, true); m.SetTexture("_BaseColorMap", (Texture)(object)val); return array; } } }