using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using FistVR; using HarmonyLib; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")] [assembly: AssemblyCompany("BloodSystem")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+449acb6bb3a2ebf7106d764eb3f17bfa0ecf1d98")] [assembly: AssemblyProduct("BloodSystem")] [assembly: AssemblyTitle("BloodSystem")] [assembly: AssemblyVersion("1.0.0.0")] namespace BloodSystem; internal static class BloodThermal { private struct MatRef { public Material Mat; public MatKey Key; public bool Drip; public MatRef(Material mat, MatKey key, bool drip) { Mat = mat; Key = key; Drip = drip; } } private class Cohort { public int Id; public int CurveClass; public float StartTime; public float RetireTime; public int Step; public float NextEvent; public float AmbIntensity; public bool AmbSampled; public readonly List Mats = new List(); public readonly List Renderers = new List(); } private const int MAX_CLASSES = 20; private const string P_INTENSITY = "_ThermalIntensity"; private const string P_TRANSVIS = "_ThermalTransparentVisibility"; private const string P_NOALPHA = "_ThermalDisableAlphaBlend"; private const string P_HEATMAP = "_ThermalHeatMap"; private const string P_HEATMAPSCL = "_ThermalHeatMapScale"; private const string P_DISABLE = "_ThermalDisable"; private const string P_COLORALPHA = "_ThermalUseColorAlpha"; private const string P_VERTEXCOLOR = "_ThermalUseVertexColor"; internal static ConfigEntry CfgAnimate; private const float COOL_SECONDS = 8f; private const int STEPS = 80; private const float COHORT_WINDOW = 0.5f; private const int CLASSES = 4; private const float FRAGMENT_WEIGHT = 1f; private const bool STAGGER = true; private const bool STAGGER_OUTWARD = false; private const float DENSE_LINEARITY = 0.75f; private const float TAIL_LINEARITY = 0.3f; private const float SPARSE_COOL_MULT = 1.6f; private const float FRESH_INTENSITY = 27f; private const float START_TEMP_C = 36f; private const float AMBIENT_TEMP_C = 20f; private const bool USE_VOLUMES = true; private const int DENSITY_BLUR = 4; private const float DENSITY_BLUR_FRACTION = 0.03f; private const bool OPAQUE_IN_THERMAL = false; private const float HEATMAP_STRENGTH = 1f; private const bool SHAPE_VIA_HEATMAP = true; private const bool USE_PROPERTY_BLOCK = false; private const bool DEBUG_LOG = false; private const float DEBUG_FORCE = -1f; private const float AMBIENT_OVERRIDE = -1f; private static float[][] _stepTime; private static float[][] _heatFrac; private static int _classes = 1; private static int _steps = 1; private static float _quantum = 2.5f; private static float _hotOffset; private static bool _usePropertyBlock; private static bool _shapeViaHeatMap; private static bool _forced; private static float _forcedValue; private static bool _enabled; private static bool _keepWarm; internal const bool NormalizeDensity = true; internal const float FragmentWeight = 1f; internal const int DensityBlur = 4; internal const float DensityBlurFraction = 0.03f; private static readonly Dictionary _cohorts = new Dictionary(); private static readonly List _live = new List(); private static readonly List _done = new List(); private static readonly List _retire = new List(); private static float _nextEvent = float.MaxValue; private static bool _armed; private static MaterialPropertyBlock _mpb; private static readonly HashSet _diagLoggedScenes = new HashSet(); private static int _dbgSteps; private static int _dbgWrites; private static readonly Dictionary _heatMasks = new Dictionary(); internal static int Classes => _classes; internal static int ActiveClasses { get { if (!_armed) { return 1; } return _classes; } } internal static bool Enabled => _enabled; internal static void BindConfig(ConfigFile cfg) { CfgAnimate = cfg.Bind("Thermal", "Animate Cooldown", true, "Whether blood cools down on thermal optics. On: blood leaves the body hot and fades to the temperature of its surroundings over about eight seconds, thicker pooled areas holding their heat longer than scattered spray. Off: blood still shows up on thermal at body temperature but stays there for as long as the decal lasts, and none of the cooling machinery runs at all."); } internal static void Init() { _enabled = true; _keepWarm = !CfgAnimate.Value; _usePropertyBlock = false; _shapeViaHeatMap = true; _forcedValue = -1f; _forced = _forcedValue >= 0f; _classes = (_keepWarm ? 1 : Mathf.Clamp(4, 1, 20)); _steps = Mathf.Clamp(80, 2, 160); _hotOffset = 27f; float num = 16f; float num2 = 16f; _hotOffset = ((Mathf.Abs(num) < 0.01f) ? 27f : (27f * (num2 / num))); BuildStepTables(); _quantum = Mathf.Max(0.25f, 0.5f); _cohorts.Clear(); _live.Clear(); _done.Clear(); _nextEvent = float.MaxValue; _armed = false; BloodSystemPlugin.Log.LogInfo((object)("[BloodSystem] Thermal: enabled=" + _enabled + " classes=" + _classes + " steps=" + _steps + " quantum=" + _quantum.ToString("F2") + "s hotOffset=" + _hotOffset.ToString("F1") + " mode=" + (_usePropertyBlock ? "PropertyBlock" : "Material") + (_keepWarm ? " KEEP-WARM" : "") + (_forced ? (" FORCED=" + _forcedValue.ToString("F1")) : ""))); } internal static void LogThermalDiagnostics(Camera cam) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) try { Scene activeScene = SceneManager.GetActiveScene(); string name = ((Scene)(ref activeScene)).name; Material decalSourceMat = BloodSystemPlugin._decalSourceMat; string item = name + "|" + ((decalSourceMat == null) ? "none" : ((Object)decalSourceMat.shader).name); if (_diagLoggedScenes.Add(item)) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("[BloodSystem] THERMAL DIAG scene='").Append(name).Append("'"); FXM instance = ManagerSingleton.Instance; if ((Object)(object)instance == (Object)null) { stringBuilder.Append(" | FXM=MISSING (no thermal shader available)"); } else { Shader thermalShader = instance.ThermalShader; stringBuilder.Append(" | FXM=ok ThermalShader=").Append((thermalShader == null) ? "NULL" : ((Object)thermalShader).name).Append((thermalShader == null) ? "" : (thermalShader.isSupported ? " (supported)" : " (NOT SUPPORTED)")); } if (cam != null) { stringBuilder.Append(" | cam='").Append(((Object)cam).name).Append("'") .Append(" clear=") .Append(cam.clearFlags) .Append(" bg=") .Append(cam.backgroundColor) .Append(" path=") .Append(cam.actualRenderingPath); } stringBuilder.Append(" | ObjectTemperatures=").Append((ObjectTemperature.allTemperatureObjects == null) ? (-1) : ObjectTemperature.allTemperatureObjects.Count); stringBuilder.Append(" TemperatureVolumes=").Append((TemperatureVolume.volumes == null) ? (-1) : TemperatureVolume.volumes.Count); Material decalSourceMat2 = BloodSystemPlugin._decalSourceMat; stringBuilder.Append(" | decalSrc=").Append((decalSourceMat2 == null) ? "none" : (((Object)decalSourceMat2.shader).name + " RenderType=" + decalSourceMat2.GetTag("RenderType", false, ""))); stringBuilder.Append(" | ambientLight=").Append(RenderSettings.ambientLight).Append(" ambientIntensity=") .Append(RenderSettings.ambientIntensity.ToString("F2")); BloodSystemPlugin.Log.LogInfo((object)stringBuilder.ToString()); } } catch (Exception ex) { BloodSystemPlugin.Log.LogWarning((object)("[BloodSystem] THERMAL DIAG failed: " + ex.Message)); } } internal static void DebugNoteChunks(int chunkCount, int dotCount) { } private static void BuildStepTables() { _stepTime = new float[_classes][]; _heatFrac = new float[_classes][]; float num = Mathf.Max(0.25f, 8f); for (int i = 0; i < _classes; i++) { float num2 = ((_classes == 1) ? 0f : ((float)i / (float)(_classes - 1))); float num3 = Mathf.Clamp01(0.75f); float num4 = Mathf.Clamp01(0.3f); float linearity = Mathf.Lerp(num4, Mathf.Max(num3, num4), 1f - num2); float num5 = num / Mathf.Lerp(1f, Mathf.Max(0.05f, 1.6f), num2); float k = 4f / num5; float num6 = 0f; if (_classes > 1) { int num7 = i; num6 = num5 / (float)(_steps - 1) * (float)num7 / (float)_classes; } _stepTime[i] = new float[_steps]; _heatFrac[i] = new float[_steps]; for (int j = 0; j < _steps; j++) { float num8 = 1f - (float)j / (float)(_steps - 1); _heatFrac[i][j] = num8; _stepTime[i][j] = ((j == 0) ? 0f : (SolveTime(num8, k, num5, linearity) + num6)); } } } private static float CoolCurve(float t, float k, float tau, float linearity) { if (t >= tau) { return 0f; } float num = Mathf.Lerp(Mathf.Exp((0f - k) * t), Mathf.Max(0f, 1f - t / tau), linearity); float num2 = Mathf.Lerp(Mathf.Exp((0f - k) * tau), 0f, linearity); return Mathf.Clamp01((num - num2) / Mathf.Max(0.0001f, 1f - num2)); } private static float SolveTime(float targetFrac, float k, float tau, float linearity) { if (targetFrac <= 0f) { return tau; } float num = 0f; float num2 = tau; for (int i = 0; i < 40; i++) { float num3 = (num + num2) * 0.5f; if (CoolCurve(num3, k, tau, linearity) > targetFrac) { num = num3; } else { num2 = num3; } } return (num + num2) * 0.5f; } internal static int CurrentCohort(int curveClass) { if (!_enabled) { return 0; } if (curveClass < 0) { curveClass = 0; } if (curveClass >= _classes) { curveClass = _classes - 1; } int num = Mathf.FloorToInt(Time.time / _quantum); int num2 = num * 20 + curveClass; if (!_cohorts.TryGetValue(num2, out var value)) { value = new Cohort { Id = num2, CurveClass = curveClass, StartTime = (float)num * _quantum, Step = 0, AmbSampled = false }; value.RetireTime = value.StartTime + _quantum + BloodSystemPlugin.CfgLifetime.Value + 1f; value.NextEvent = ((_keepWarm || _forced) ? value.RetireTime : (value.StartTime + _stepTime[curveClass][1])); _cohorts[num2] = value; _live.Add(value); if (value.NextEvent < _nextEvent) { _nextEvent = value.NextEvent; } } return num2; } internal static void RegisterMaterial(Material m, MatKey key, bool drip) { if (!_enabled || m == null) { return; } ApplyShapeProps(m); if (_cohorts.TryGetValue(key.Cohort, out var value)) { value.Mats.Add(new MatRef(m, key, drip)); if (_forced) { WriteHeat(m, _forcedValue, value.AmbIntensity); } else if (_armed || _keepWarm) { WriteHeat(m, IntensityAt(value, value.Step), value.AmbIntensity); } } } internal static void MarkAlwaysHot(Material m) { if (_enabled && m != null) { ApplyShapeProps(m); WriteHeat(m, _forced ? _forcedValue : _hotOffset, 0f); } } internal static void RegisterHeatMask(Texture visible, Texture heat) { if (visible != null && heat != null) { _heatMasks[visible] = heat; } } private static Texture HeatMaskFor(Texture visible) { if (visible == null) { return null; } if (!_heatMasks.TryGetValue(visible, out var value)) { return visible; } return value; } private static void ApplyShapeProps(Material m) { Texture val = HeatMaskFor(m.mainTexture); bool flag = val != null; m.SetFloat("_ThermalTransparentVisibility", 1f); m.SetFloat("_ThermalDisableAlphaBlend", 0f); m.SetFloat("_ThermalDisable", 0f); m.SetFloat("_ThermalUseColorAlpha", 0f); m.SetFloat("_ThermalUseVertexColor", 0f); m.SetTexture("_ThermalHeatMap", (Texture)(flag ? ((object)val) : ((object)Texture2D.whiteTexture))); if (!_shapeViaHeatMap) { m.SetFloat("_ThermalHeatMapScale", flag ? Mathf.Max(0f, 1f) : 0f); } } private static void WriteHeat(Material m, float v, float amb) { if (_shapeViaHeatMap) { m.SetFloat("_ThermalIntensity", amb); m.SetFloat("_ThermalHeatMapScale", (v - amb) * Mathf.Max(0f, 1f)); } else { m.SetFloat("_ThermalIntensity", v); } } internal static void RegisterRenderer(Renderer r, int cohortId, Vector3 worldPos) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (!_enabled || r == null) { return; } NoteSpawnPosition(cohortId, worldPos); if (_usePropertyBlock && _cohorts.TryGetValue(cohortId, out var value)) { value.Renderers.Add(r); if (_forced) { ApplyToRenderer(r, _forcedValue, value.AmbIntensity); } else if (_armed || _keepWarm) { ApplyToRenderer(r, IntensityAt(value, value.Step), value.AmbIntensity); } } } internal static void NoteSpawnPosition(int cohortId, Vector3 worldPos) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (_enabled && _cohorts.TryGetValue(cohortId, out var value) && !value.AmbSampled) { SampleAmbient(value, worldPos); } } private static void SampleAmbient(Cohort co, Vector3 worldPos) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_00a3: 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) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) co.AmbSampled = true; co.AmbIntensity = 0f; List volumes = TemperatureVolume.volumes; if (volumes == null || volumes.Count == 0) { return; } float num = 0f; for (int i = 0; i < volumes.Count; i++) { TemperatureVolume val = volumes[i]; if (val != null) { Vector3 val2 = worldPos - ((Component)val).transform.position; bool flag; if (val.spherical) { float num2 = Mathf.Max(val.size.x, Mathf.Max(val.size.y, val.size.z)) + val.blendDistance; flag = ((Vector3)(ref val2)).sqrMagnitude <= num2 * num2; } else { flag = Mathf.Abs(val2.x) <= val.size.x + val.blendDistance && Mathf.Abs(val2.y) <= val.size.y + val.blendDistance && Mathf.Abs(val2.z) <= val.size.z + val.blendDistance; } if (flag && Mathf.Abs(val.thermalIntensity) > Mathf.Abs(num)) { num = val.thermalIntensity; } } } co.AmbIntensity = num; } private static float IntensityAt(Cohort co, int step) { if (step >= _steps) { step = _steps - 1; } return co.AmbIntensity + _hotOffset * _heatFrac[co.CurveClass][step]; } internal static void OnSceneChanged() { _armed = false; for (int num = _live.Count - 1; num >= 0; num--) { Retire(_live[num]); } for (int num2 = _done.Count - 1; num2 >= 0; num2--) { Retire(_done[num2]); } _live.Clear(); _done.Clear(); _cohorts.Clear(); _nextEvent = float.MaxValue; } internal static void Arm() { if (!_armed && _enabled) { _armed = true; BloodSystemPlugin.Log.LogInfo((object)"[BloodSystem] Thermal armed - a thermal camera rendered in this scene, blood heat is now being applied."); for (int i = 0; i < _live.Count; i++) { ApplyCohort(_live[i]); } for (int j = 0; j < _done.Count; j++) { ApplyCohort(_done[j]); } } } internal static void Tick() { if (!_enabled) { return; } float time = Time.time; if (time < _nextEvent) { return; } float num = float.MaxValue; _retire.Clear(); for (int num2 = _live.Count - 1; num2 >= 0; num2--) { Cohort cohort = _live[num2]; if (time >= cohort.RetireTime) { _live.RemoveAt(num2); _retire.Add(cohort); } else { bool flag = false; while (cohort.Step < _steps - 1 && time >= cohort.NextEvent) { cohort.Step++; flag = true; cohort.NextEvent = ((cohort.Step < _steps - 1) ? (cohort.StartTime + _stepTime[cohort.CurveClass][cohort.Step + 1]) : cohort.RetireTime); } if (flag && _armed) { ApplyCohort(cohort); } if (cohort.Step >= _steps - 1) { _live.RemoveAt(num2); _done.Add(cohort); if (cohort.RetireTime < num) { num = cohort.RetireTime; } } else if (cohort.NextEvent < num) { num = cohort.NextEvent; } } } while (_done.Count > 0 && time >= _done[0].RetireTime) { _retire.Add(_done[0]); _done.RemoveAt(0); } if (_done.Count > 0 && _done[0].RetireTime < num) { num = _done[0].RetireTime; } for (int i = 0; i < _retire.Count; i++) { Retire(_retire[i]); } _retire.Clear(); _nextEvent = num; } private static void ApplyCohort(Cohort co) { float v = (_forced ? _forcedValue : IntensityAt(co, co.Step)); if (_usePropertyBlock) { for (int num = co.Renderers.Count - 1; num >= 0; num--) { Renderer val = co.Renderers[num]; if ((Object)(object)val == (Object)null) { co.Renderers.RemoveAt(num); } else { ApplyToRenderer(val, v, co.AmbIntensity); _dbgWrites++; } } return; } for (int i = 0; i < co.Mats.Count; i++) { Material mat = co.Mats[i].Mat; if (mat != null) { WriteHeat(mat, v, co.AmbIntensity); _dbgWrites++; } } } private static void ApplyToRenderer(Renderer r, float v, float amb) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown Material sharedMaterial = r.sharedMaterial; Texture val = ((sharedMaterial == null) ? null : HeatMaskFor(sharedMaterial.mainTexture)); bool flag = val != null; if (_mpb == null) { _mpb = new MaterialPropertyBlock(); } _mpb.Clear(); r.GetPropertyBlock(_mpb); _mpb.SetFloat("_ThermalTransparentVisibility", 1f); _mpb.SetFloat("_ThermalDisableAlphaBlend", 0f); _mpb.SetFloat("_ThermalDisable", 0f); _mpb.SetFloat("_ThermalUseColorAlpha", 0f); _mpb.SetFloat("_ThermalUseVertexColor", 0f); _mpb.SetTexture("_ThermalHeatMap", (Texture)(flag ? ((object)val) : ((object)Texture2D.whiteTexture))); if (_shapeViaHeatMap && flag) { _mpb.SetFloat("_ThermalIntensity", amb); _mpb.SetFloat("_ThermalHeatMapScale", (v - amb) * Mathf.Max(0f, 1f)); } else { _mpb.SetFloat("_ThermalIntensity", v); _mpb.SetFloat("_ThermalHeatMapScale", flag ? Mathf.Max(0f, 1f) : 0f); } r.SetPropertyBlock(_mpb); } private static void Retire(Cohort co) { for (int i = 0; i < co.Mats.Count; i++) { MatRef matRef = co.Mats[i]; if (matRef.Drip) { BloodSystemPlugin._dripMatCache.Remove(matRef.Key); } else { BloodSystemPlugin._matCache.Remove(matRef.Key); } if (matRef.Mat != null) { Object.Destroy((Object)(object)matRef.Mat); } } co.Mats.Clear(); co.Renderers.Clear(); _cohorts.Remove(co.Id); _live.Remove(co); _done.Remove(co); } } internal struct MatKey : IEquatable { public readonly Color Col; public readonly int Cohort; public MatKey(Color col, int cohort) { //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) Col = col; Cohort = cohort; } public bool Equals(MatKey o) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (Cohort == o.Cohort) { return ((object)Col/*cast due to .constrained prefix*/).Equals((object?)o.Col); } return false; } public override bool Equals(object o) { if (o is MatKey) { return Equals((MatKey)o); } return false; } public override int GetHashCode() { //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) return (((object)Col/*cast due to .constrained prefix*/).GetHashCode() * 397) ^ Cohort; } } internal struct DotData { public Vector3 Pos; public Vector3 Norm; public float R; public float Dark; public float Bright; public Vector3 TanNorm; public Vector3 ElongDir; public float Elongation; public float Dist; public byte CurveClass; public DotData(Vector3 pos, Vector3 norm, float r, float dark, float bright, Vector3 tanNorm, Vector3 elongDir, float elongation, float dist, byte curveClass) { //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_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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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) Pos = pos; Norm = norm; R = r; Dark = dark; Bright = bright; TanNorm = tanNorm; ElongDir = elongDir; Elongation = elongation; Dist = dist; CurveClass = curveClass; } } [BepInPlugin("h3vr.invent60.bloodsystem", "Blood System", "3.4.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class BloodSystemPlugin : BaseUnityPlugin { [StructLayout(LayoutKind.Sequential, Size = 1)] internal struct RhByDist : IComparer { public int Compare(RaycastHit a, RaycastHit b) { return ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance); } } internal static ManualLogSource Log; internal static BloodSystemPlugin _instance; internal static ConfigEntry CfgEnabled; internal static ConfigEntry CfgLifetime; internal static ConfigEntry CfgRayCount; internal static ConfigEntry CfgConeAngle; internal static ConfigEntry CfgDotSize; internal static ConfigEntry CfgRange; internal static ConfigEntry CfgProjectionMode; internal static ConfigEntry CfgSpeedRatio; internal static ConfigEntry CfgSpeedBias; internal static ConfigEntry CfgDotScaleMax; internal static ConfigEntry CfgDotScaleRange; internal static ConfigEntry CfgGibRayCount; internal static ConfigEntry CfgColorOverride; internal static ConfigEntry CfgColorOverrideMode; internal static ConfigEntry CfgSplashOnHumans; public static float ExternalBloodScale = 1f; internal static ConfigEntry CfgSplatterEnabled; internal static ConfigEntry CfgSprayEnabled; internal static ConfigEntry CfgVanillaStainEnabled; internal static ConfigEntry CfgDripStainsEnabled; internal static readonly Color _mustardFallback = new Color(0.9f, 0.8f, 0f, 1f); internal static readonly Dictionary _matCache = new Dictionary(); internal static readonly Dictionary _dripMatCache = new Dictionary(); private static int _nextShotId; private static readonly Dictionary> _shotGroups = new Dictionary>(); private static readonly Queue _shotQueue = new Queue(); private static readonly Queue _dripQueue = new Queue(); internal static ConfigEntry CfgMaxShots; internal static ConfigEntry CfgMaxDrips; private static Shader _bloodShader; private static bool _bloodShaderSearched; internal static Material _decalSourceMat; internal static bool _decalSourceSearched; internal static bool _dbgDotLogged; internal static bool _dbgDecalLogged; private static Texture2D _decalTex; private static Texture2D _hardCircleTex; private static Texture2D _firstBloodTex; private static Texture2D _normalMapTex; private static Texture2D _noiseMapTex; private static readonly Dictionary _coloredTexCache = new Dictionary(); private static Vector2[] _splatterUVs; private static float[] _cumWeights; private static float[] _splatterDarks; private static float[] _splatterBrights; private static Vector3[] _splatterNormals; private static byte[] _splatterClasses; private static readonly Vector3 _tanLight; internal static readonly float[] BRIGHT_LEVELS; private static readonly float[] _brightLevels; private static ParticleSystem _pelletPS; private static ParticleSystem _fogPS; private static ParticleSystem _jetPS; private static Material _fogMat; private static Material _pelletMat; private static Material _dotBaseMat; private static Mesh _dotQuadMesh; private static ParticleSystem _flyingDotPS; private static Particle[] _flyBuf; private static Particle[] _flyMergeBuf; internal static readonly RaycastHit[] _rayBuf; internal static readonly RhByDist _rhCompare; private static bool _ngaChecked; private static bool _ngaKetchup; private static Color _ngaColor; internal static bool _alloyGrabPending; private static Shader _fallbackDecalShader; private static bool _fallbackDecalShaderSearched; private const int GIB_BATCH = 50; private static bool _dbgDropLogged; private static bool _growingStainLoggedOnce; private static string AlloyMatCachePath => Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "alloy_mat.cache"); private static Color BrightTint(Color col) { //IL_0014: 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_0024: 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_0032: Unknown result type (might be due to invalid IL or missing references) float num = _brightLevels[Random.Range(0, _brightLevels.Length)]; return new Color(col.r * num, col.g * num, col.b * num, col.a); } private void Awake() { //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Expected O, but got Unknown //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Unknown result type (might be due to invalid IL or missing references) //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_04e8: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Expected O, but got Unknown //IL_04fd: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_050a: Unknown result type (might be due to invalid IL or missing references) //IL_051b: Unknown result type (might be due to invalid IL or missing references) //IL_052c: Unknown result type (might be due to invalid IL or missing references) //IL_0561: 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_0585: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Expected O, but got Unknown //IL_0676: Unknown result type (might be due to invalid IL or missing references) //IL_067b: Unknown result type (might be due to invalid IL or missing references) //IL_068b: Unknown result type (might be due to invalid IL or missing references) //IL_069b: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; _instance = this; CfgEnabled = ((BaseUnityPlugin)this).Config.Bind("Blood", "Enabled", true, "Toggle all blood effects."); CfgLifetime = ((BaseUnityPlugin)this).Config.Bind("Blood", "Lifetime seconds", 60f, "How long splash and drip stains last before despawning. Long enough that blood is still around to look at on thermal well after it has finished cooling."); CfgRayCount = ((BaseUnityPlugin)this).Config.Bind("Blood", "Max rays per shot", 3000, "Maximum splash ray count. Capped to the actual number of image pixels if fewer."); CfgConeAngle = ((BaseUnityPlugin)this).Config.Bind("Blood", "Cone half-angle", 10f, "Half-angle in degrees of the splash cone."); CfgDotSize = ((BaseUnityPlugin)this).Config.Bind("Blood", "Dot base radius", 0.008f, "Base radius of each splash dot in metres. Scales to Dot Max Scale at Dot Scale Range distance."); CfgRange = ((BaseUnityPlugin)this).Config.Bind("Blood", "Range metres", 40f, "Maximum splash distance in metres."); CfgProjectionMode = ((BaseUnityPlugin)this).Config.Bind("Blood", "Projection Mode", "Animated", "How splash dots appear. Animated: dots fly from wound to wall in real-time (best visuals, most FPS cost). Delayed: dots appear all at once after a timed delay with no animation (moderate). Immediate: dots appear instantly with no delay and no animation (cheapest, best for low-end systems)."); CfgSpeedRatio = ((BaseUnityPlugin)this).Config.Bind("Blood", "Projection Speed Ratio", 2f, "Multiplies bullet exit speed to calculate how fast splash dots travel toward the wall. Higher = faster animation, less time spread between near and far dots. Default 2."); CfgSpeedBias = ((BaseUnityPlugin)this).Config.Bind("Blood", "Projection Speed Bias", 10f, "Flat metres-per-second added to projection speed after the ratio multiply. Prevents dots from moving too slowly for low-velocity bullets. Default 10."); CfgDotScaleMax = ((BaseUnityPlugin)this).Config.Bind("Blood", "Dot Max Scale", 5f, "Maximum size multiplier applied to splash dots at Dot Scale Range distance. 5 means dots at full range are 5x the base radius. Default 5."); CfgDotScaleRange = ((BaseUnityPlugin)this).Config.Bind("Blood", "Dot Scale Range metres", 50f, "Distance in metres at which splash dots reach their maximum size (Dot Max Scale). Dots near the wound start at Dot Base Radius and grow linearly to this range. Default 30."); CfgGibRayCount = ((BaseUnityPlugin)this).Config.Bind("Blood", "Gib Ray Count", 200, "Number of rays fired in random 360-degree directions when a segment explodes. Lower values improve FPS in gib-heavy fights. Capped by image pixel count. Default 200."); CfgMaxShots = ((BaseUnityPlugin)this).Config.Bind("Blood", "Max shot groups", 20, "Maximum number of shots whose splash and drip decals stay visible. When exceeded, the oldest shot's decals are all deleted together."); CfgMaxDrips = ((BaseUnityPlugin)this).Config.Bind("Blood", "Max drip stains", 400, "Maximum drip stains from particle detection (VanillaDripStainer). Oldest deleted when exceeded."); CfgColorOverride = ((BaseUnityPlugin)this).Config.Bind("Blood", "Color Override", "#8C1A1A", "Hex color (e.g. #8C1A1A) used for blood when Color Override Mode is set to Soft or Hard. Ignored when mode is Unset."); CfgSplashOnHumans = ((BaseUnityPlugin)this).Config.Bind("Blood", "Splash On Human-mod Humans", false, "Whether the LinkExplodes splash/spray/gib burst plays on Sosigs controlled by the Human mod (invent60's puppeteer AI). Default off - that mod calls LinkExplodes on every ordinary kill, not just real grenade/gib bursts."); CfgColorOverrideMode = ((BaseUnityPlugin)this).Config.Bind("Blood", "Color Override Mode", "0", "Type 1 for Soft Override: replaces normal blood color, but sosigs with a color specifically set via NGA SosigIntegrityConfigs (e.g. zombies) keep their own color. Type 2 for Hard Override: replaces blood color for every sosig, no exceptions. Any other value = Unset: no override, vanilla per-sosig color behavior."); CfgSplatterEnabled = ((BaseUnityPlugin)this).Config.Bind("Blood", "Splatter Enabled", true, "Projected blood splash dots on walls/floor/props from the bullet wound. The main splatter effect."); CfgSprayEnabled = ((BaseUnityPlugin)this).Config.Bind("Blood", "Spray Enabled", true, "Blood particles that scatter outward from the wound in a wide cone/sphere, not just along the bullet path. Off by default - many players found this looked like an unintended splatter-sphere."); CfgVanillaStainEnabled = ((BaseUnityPlugin)this).Config.Bind("Blood", "Vanilla Particle Staining Enabled", true, "Whether vanilla sosig bleed-out particles get intercepted and made to leave a stain when they land. When off, vanilla bleed particles behave as in unmodded H3VR (fall/bounce, no stain)."); CfgDripStainsEnabled = ((BaseUnityPlugin)this).Config.Bind("Blood", "Blood Drip Stains Enabled", true, "Our own dripping-wound blood drops that fall from the wound over time and stain the floor."); BloodThermal.BindConfig(((BaseUnityPlugin)this).Config); BloodThermal.Init(); SceneManager.sceneLoaded += delegate { BloodThermal.OnSceneChanged(); }; _decalTex = MakeSoftCircle(96); _hardCircleTex = MakeHardCircle(64); BloodThermal.RegisterHeatMask((Texture)(object)_decalTex, (Texture)(object)MakeHeatMask(_decalTex)); BloodThermal.RegisterHeatMask((Texture)(object)_hardCircleTex, (Texture)(object)MakeHeatMask(_hardCircleTex)); TryLoadFromBundle(); Shader val = Shader.Find("Sprites/Default"); if (val != null) { _dotBaseMat = new Material(val); _dotBaseMat.mainTexture = (Texture)(object)_decalTex; } _dotQuadMesh = new Mesh(); _dotQuadMesh.vertices = (Vector3[])(object)new Vector3[4] { new Vector3(-0.5f, -0.5f, 0f), new Vector3(0.5f, -0.5f, 0f), new Vector3(0.5f, 0.5f, 0f), new Vector3(-0.5f, 0.5f, 0f) }; _dotQuadMesh.uv = (Vector2[])(object)new Vector2[4] { new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(0f, 1f) }; _dotQuadMesh.normals = (Vector3[])(object)new Vector3[4] { Vector3.forward, Vector3.forward, Vector3.forward, Vector3.forward }; _dotQuadMesh.triangles = new int[6] { 0, 2, 3, 0, 1, 2 }; _dotQuadMesh.RecalculateBounds(); GameObject val2 = new GameObject("FlyingDotPS"); Object.DontDestroyOnLoad((Object)val2); _flyingDotPS = val2.AddComponent(); MainModule main = _flyingDotPS.main; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.5f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.02f); ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).playOnAwake = false; ((MainModule)(ref main)).maxParticles = 8000; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0f); EmissionModule emission = _flyingDotPS.emission; ((EmissionModule)(ref emission)).enabled = false; ((EmissionModule)(ref emission)).rateOverTime = new MinMaxCurve(0f); ((Component)_flyingDotPS).GetComponent().renderMode = (ParticleSystemRenderMode)0; List list = LoadAllPngs(); if (list.Count > 0) { _firstBloodTex = list[0]; BuildSampleDataFromAll(list); Log.LogInfo((object)("[BloodSystem] " + list.Count + " PNG(s) loaded. CDF points=" + ((_splatterUVs != null) ? _splatterUVs.Length.ToString() : "0"))); } else { BuildFallbackGrid(200); Log.LogWarning((object)"[BloodSystem] No PNG found in plugin folder — using uniform fallback grid."); } _fogMat = BuildSprayMaterial(); _pelletMat = BuildSprayMaterial(); BloodThermal.MarkAlwaysHot(_fogMat); BloodThermal.MarkAlwaysHot(_pelletMat); if (_flyingDotPS != null && _pelletMat != null) { ((Renderer)((Component)_flyingDotPS).GetComponent()).material = _pelletMat; } BuildSprayPSes(); Harmony val3 = new Harmony("h3vr.invent60.bloodsystem"); val3.PatchAll(typeof(BloodSystemPatches)); val3.PatchAll(typeof(ThermalArmHook)); val3.PatchAll(typeof(BloodSystemPatches.WfxDecalMaterialGrab)); val3.PatchAll(typeof(BloodSystemPatches.OnslaughtNaturalDeathPatch)); Log.LogInfo((object)("[BloodSystem] 3.4.1 loaded. FieldsOK=" + BloodSystemPatches.Ok)); if (Chainloader.PluginInfos.ContainsKey("Aiyke.code_mod")) { Log.LogInfo((object)"[BloodSystem] Aiyke code mod pack detected - overriding its MoveBullet penetration patches so this mod's own splatter detection works."); TryOverrideAiykePenetration(); } } private void Update() { BloodThermal.Tick(); } private static void TryOverrideAiykePenetration() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown try { MethodInfo methodInfo = AccessTools.Method(typeof(BallisticProjectile), "MoveBullet", new Type[1] { typeof(float) }, (Type[])null); if ((object)methodInfo == null) { return; } Patches patchInfo = Harmony.GetPatchInfo((MethodBase)methodInfo); if (patchInfo == null || patchInfo.Prefixes == null) { return; } Harmony val = new Harmony("h3vr.invent60.bloodsystem"); int num = 0; foreach (Patch prefix in patchInfo.Prefixes) { if ((object)prefix.PatchMethod != null && (object)prefix.PatchMethod.DeclaringType != null && prefix.PatchMethod.DeclaringType.FullName == "plugin.code_mod") { val.Unpatch((MethodBase)methodInfo, prefix.PatchMethod); num++; } } Log.LogInfo((object)("[BloodSystem] Aiyke Compat Override: removed " + num + " Aiyke prefix patch(es) from BallisticProjectile.MoveBullet.")); } catch (Exception ex) { Log.LogWarning((object)("[BloodSystem] TryOverrideAiykePenetration: " + ex.Message)); } } internal static Material GetDripMat(Color col) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetDripMat(col, BloodThermal.CurrentCohort(BloodThermal.Classes - 1)); } internal static Material GetDripMat(Color col, int cohortId) { //IL_0002: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) MatKey key = new MatKey(col, cohortId); if (_dripMatCache.TryGetValue(key, out var value) && value != null) { return value; } Material bloodMat = GetBloodMat(col, cohortId); if (bloodMat == null) { if (_pelletMat == null) { return null; } value = new Material(_pelletMat); value.color = col; } else { value = new Material(bloodMat); } if (_hardCircleTex != null) { value.mainTexture = (Texture)(object)_hardCircleTex; } else if (_decalTex != null) { value.mainTexture = (Texture)(object)_decalTex; } value.SetOverrideTag("RenderType", "Transparent"); _dripMatCache[key] = value; BloodThermal.RegisterMaterial(value, key, drip: true); return value; } internal static List StartShotGroup() { int num = _nextShotId++; List list = new List(); _shotGroups[num] = list; _shotQueue.Enqueue(num); EvictOldShots(); return list; } private static void EvictOldShots() { while (_shotQueue.Count > CfgMaxShots.Value) { int key = _shotQueue.Dequeue(); if (!_shotGroups.TryGetValue(key, out var value)) { continue; } foreach (GameObject item in value) { if (item != null) { Object.Destroy((Object)(object)item); } } _shotGroups.Remove(key); } } internal static void TrackGO(GameObject go, List shotList) { if (shotList != null) { shotList.Add(go); return; } _dripQueue.Enqueue(go); while (_dripQueue.Count > CfgMaxDrips.Value) { GameObject val = _dripQueue.Dequeue(); if (val != null) { Object.Destroy((Object)(object)val); } } } private static List LoadAllPngs() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown List list = new List(); try { string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); List list2 = new List(Directory.GetFiles(directoryName, "*.png")); list2.AddRange(Directory.GetFiles(directoryName, "*.jpg")); list2.AddRange(Directory.GetFiles(directoryName, "*.jpeg")); foreach (string item in list2) { string text = Path.GetFileNameWithoutExtension(item).ToLower(); if (text == "icon") { continue; } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (val.LoadImage(File.ReadAllBytes(item))) { ((Texture)val).filterMode = (FilterMode)2; if (text.Contains("normal") || text.Contains("norm")) { _normalMapTex = val; Log.LogInfo((object)("[BloodSystem] NormalMap=" + Path.GetFileName(item))); } else if (text.Contains("noise")) { _noiseMapTex = NormalizeLumTex(val); Log.LogInfo((object)("[BloodSystem] NoiseTex=" + Path.GetFileName(item))); } else { list.Add(NormalizeLumTex(val, keepAlpha: true)); } } } } catch (Exception ex) { Log.LogWarning((object)("[BloodSystem] LoadAllPngs: " + ex.Message)); } return list; } private static Texture2D NormalizeLumTex(Texture2D src, bool keepAlpha = false) { //IL_001f: 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) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_0037: 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_0052: 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_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) Color[] pixels = src.GetPixels(); float num = float.MaxValue; float num2 = float.MinValue; Color[] array = pixels; foreach (Color val in array) { if (!keepAlpha || !(val.a < 0.02f)) { float num3 = val.r * 0.299f + val.g * 0.587f + val.b * 0.114f; if (num3 < num) { num = num3; } if (num3 > num2) { num2 = num3; } } } float num4 = num2 - num; Texture2D val2 = new Texture2D(((Texture)src).width, ((Texture)src).height, (TextureFormat)4, false); bool flag = num4 < 0.001f; for (int j = 0; j < pixels.Length; j++) { float num5 = ((!flag) ? ((pixels[j].r * 0.299f + pixels[j].g * 0.587f + pixels[j].b * 0.114f - num) / num4) : 1f); pixels[j] = new Color(num5, num5, num5, keepAlpha ? pixels[j].a : 1f); } val2.SetPixels(pixels); val2.Apply(); ((Texture)val2).filterMode = (FilterMode)2; return val2; } private static float LookupNoiseBright(Vector2 uv) { //IL_000d: 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_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) if (_noiseMapTex == null) { return 1f; } float num = uv.x * 0.5f + 0.5f; float num2 = uv.y * 0.5f + 0.5f; int num3 = Mathf.Clamp(Mathf.RoundToInt(num * (float)(((Texture)_noiseMapTex).width - 1)), 0, ((Texture)_noiseMapTex).width - 1); int num4 = Mathf.Clamp(Mathf.RoundToInt(num2 * (float)(((Texture)_noiseMapTex).height - 1)), 0, ((Texture)_noiseMapTex).height - 1); Color pixel = _noiseMapTex.GetPixel(num3, num4); float grayscale = ((Color)(ref pixel)).grayscale; return Mathf.Lerp(0.3f, 1f, grayscale); } private static Vector3 LookupNormal(Vector2 uv) { //IL_001c: 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_0095: 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_009b: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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) if (_normalMapTex == null) { return new Vector3(0f, 0f, 1f); } float num = uv.x * 0.5f + 0.5f; float num2 = uv.y * 0.5f + 0.5f; int num3 = Mathf.Clamp(Mathf.RoundToInt(num * (float)(((Texture)_normalMapTex).width - 1)), 0, ((Texture)_normalMapTex).width - 1); int num4 = Mathf.Clamp(Mathf.RoundToInt(num2 * (float)(((Texture)_normalMapTex).height - 1)), 0, ((Texture)_normalMapTex).height - 1); Color pixel = _normalMapTex.GetPixel(num3, num4); Vector3 val = new Vector3(pixel.r * 2f - 1f, pixel.g * 2f - 1f, Mathf.Abs(pixel.b * 2f - 1f)); return ((Vector3)(ref val)).normalized; } private static Texture2D MakeHeatMask(Texture2D src) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_004d: 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) if (src == null) { return null; } int width = ((Texture)src).width; int height = ((Texture)src).height; Texture2D val = new Texture2D(width, height, (TextureFormat)4, false); Color[] pixels = src.GetPixels(); Color[] array = (Color[])(object)new Color[pixels.Length]; for (int i = 0; i < pixels.Length; i++) { float a = pixels[i].a; array[i] = new Color(a, a, a, 1f); } val.SetPixels(array); val.Apply(); return val; } private static Texture2D MakeSoftCircle(int size) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_007d: 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) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false); float num = (float)(size - 1) * 0.5f; Color[] array = (Color[])(object)new Color[size * size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num2 = ((float)j - num) / num; float num3 = ((float)i - num) / num; float num4 = num2 * num2 + num3 * num3; float num5 = ((num4 > 1f) ? 0f : Mathf.Clamp01(Mathf.Exp((0f - num4) * 15f))); array[i * size + j] = new Color(1f, 1f, 1f, num5); } } val.SetPixels(array); val.Apply(); return val; } private static Texture2D MakeHardCircle(int size) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false); float num = (float)(size - 1) * 0.5f; Color[] array = (Color[])(object)new Color[size * size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num2 = ((float)j - num) / num; float num3 = ((float)i - num) / num; float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3); float num5 = Mathf.Clamp01((num4 - 0.6f) / 0.4f); float num6 = ((num4 > 1f) ? 0f : (1f - num5 * num5 * (3f - 2f * num5))); array[i * size + j] = new Color(1f, 1f, 1f, num6); } } val.SetPixels(array); val.Apply(); return val; } private static Texture2D MakeHemisphereNormalMap(int size) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //IL_0075: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false); float num = (float)(size - 1) * 0.5f; Color[] array = (Color[])(object)new Color[size * size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num2 = ((float)j - num) / num; float num3 = ((float)i - num) / num; float num4 = num2 * num2 + num3 * num3; Vector3 val3; if (!(num4 > 1f)) { Vector3 val2 = new Vector3(num2, num3, Mathf.Sqrt(1f - num4)); val3 = ((Vector3)(ref val2)).normalized; } else { val3 = Vector3.forward; } Vector3 val4 = val3; array[i * size + j] = new Color(val4.x * 0.5f + 0.5f, val4.y * 0.5f + 0.5f, val4.z * 0.5f + 0.5f, 1f); } } val.SetPixels(array); val.Apply(); return val; } private static Texture2D GetColoredTex(Color col) { //IL_0005: 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_0021: Expected O, but got Unknown //IL_00d3: 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_008c: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) if (_coloredTexCache.TryGetValue(col, out var value) && value != null) { return value; } int num = 96; value = new Texture2D(num, num, (TextureFormat)4, false); float num2 = (float)(num - 1) * 0.5f; Color[] array = (Color[])(object)new Color[num * num]; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { float num3 = ((float)j - num2) / num2; float num4 = ((float)i - num2) / num2; float num5 = num3 * num3 + num4 * num4; float num6 = ((num5 > 1f) ? 0f : Mathf.Clamp01(Mathf.Exp((0f - num5) * 8f))); array[i * num + j] = new Color(col.r, col.g, col.b, num6); } } value.SetPixels(array); value.Apply(); ((Texture)value).filterMode = (FilterMode)2; _coloredTexCache[col] = value; return value; } private static void BuildSampleDataFromAll(List textures) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) List list = new List(); List list2 = new List(); List list3 = new List(); List list4 = new List(); List list5 = new List(); List list6 = new List(); float num = 0f; foreach (Texture2D texture in textures) { int width = ((Texture)texture).width; int height = ((Texture)texture).height; Color[] pixels = texture.GetPixels(); float num2 = (float)width / (float)height; float[] array = BuildDensityMap(pixels, width, height); List list7 = new List(width * height / 4); List list8 = new List(width * height / 4); List list9 = new List(width * height / 4); List list10 = new List(width * height / 4); float num3 = 0f; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { Color val = pixels[i * width + j]; float num4 = val.r * 0.299f + val.g * 0.587f + val.b * 0.114f; float a = val.a; if (!(a < 0.02f)) { float num5; float num6; if (num2 >= 1f) { num5 = (float)j / (float)(width - 1) * 2f - 1f; num6 = ((float)i / (float)(height - 1) * 2f - 1f) / num2; } else { num5 = ((float)j / (float)(width - 1) * 2f - 1f) * num2; num6 = (float)i / (float)(height - 1) * 2f - 1f; } list7.Add(new Vector2(num5, num6)); list8.Add(1f - num4); list9.Add(a); list10.Add(array[i * width + j]); num3 += a; } } } if (!(num3 < 0.001f) && list7.Count != 0) { LogDensityStats(((Object)texture).name, list10); float[] array2 = list10.ToArray(); Array.Sort(array2); float num7 = array2[Mathf.Clamp((int)((float)array2.Length * 0.02f), 0, array2.Length - 1)]; float num8 = array2[Mathf.Clamp((int)((float)array2.Length * 0.98f), 0, array2.Length - 1)] - num7; for (int k = 0; k < list10.Count; k++) { list10[k] = ((num8 > 1E-05f) ? Mathf.Clamp01((list10[k] - num7) / num8) : 0f); } float num9 = 1f / num3; for (int l = 0; l < list7.Count; l++) { num += list9[l] * num9; list.Add(list7[l]); list2.Add(list8[l]); list3.Add(LookupNoiseBright(list7[l])); list4.Add(LookupNormal(list7[l])); list6.Add(list10[l]); list5.Add(num); } } } _splatterUVs = list.ToArray(); _splatterDarks = list2.ToArray(); _splatterBrights = list3.ToArray(); _splatterNormals = list4.ToArray(); _cumWeights = list5.ToArray(); _splatterClasses = BuildCurveClasses(list6); LogClassDistribution(list6); } private static void LogDensityStats(string name, List dens) { try { if (dens.Count != 0) { float[] array = dens.ToArray(); Array.Sort(array); int num = array.Length; Log.LogInfo((object)("[BloodSystem] Density '" + name + "' n=" + num + " min=" + array[0].ToString("F3") + " p05=" + array[num * 5 / 100].ToString("F3") + " p25=" + array[num * 25 / 100].ToString("F3") + " p50=" + array[num / 2].ToString("F3") + " p75=" + array[num * 75 / 100].ToString("F3") + " p95=" + array[num * 95 / 100].ToString("F3") + " max=" + array[num - 1].ToString("F3"))); } } catch (Exception ex) { Log.LogWarning((object)("[BloodSystem] LogDensityStats: " + ex.Message)); } } private static void LogClassDistribution(List densities) { try { int classes = BloodThermal.Classes; if (_splatterClasses == null || _splatterClasses.Length == 0) { return; } int[] array = new int[classes]; double[] array2 = new double[classes]; double[] array3 = new double[classes]; for (int i = 0; i < _splatterClasses.Length; i++) { int num = _splatterClasses[i]; if (num >= classes) { num = classes - 1; } array[num]++; array2[num] += ((Vector2)(ref _splatterUVs[i])).magnitude; array3[num] += densities[i]; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("[BloodSystem] Density classes (0=densest, cools slowest):"); for (int j = 0; j < classes; j++) { stringBuilder.Append("\n class ").Append(j).Append(": ") .Append(array[j]) .Append(" samples (") .Append((100f * (float)array[j] / (float)_splatterClasses.Length).ToString("F1")) .Append("%)"); if (array[j] > 0) { stringBuilder.Append(" meanDensity=").Append((array3[j] / (double)array[j]).ToString("F3")).Append(" meanRadius=") .Append((array2[j] / (double)array[j]).ToString("F3")); } } stringBuilder.Append("\n meanRadius should RISE with class index if the packed middle is class 0."); Log.LogInfo((object)stringBuilder.ToString()); } catch (Exception ex) { Log.LogWarning((object)("[BloodSystem] LogClassDistribution: " + ex.Message)); } } private static int AnimStepsForDistance(float dist) { if (dist <= 3f) { return 1; } if (dist <= 10f) { return Mathf.RoundToInt(Mathf.Lerp(1f, 2f, (dist - 3f) / 7f)); } if (dist <= 40f) { return Mathf.RoundToInt(Mathf.Lerp(2f, 5f, (dist - 10f) / 30f)); } return 5; } private static float[] BoxBlur(float[] src, int w, int h, int r) { float[] array = new float[w * h]; for (int i = 0; i < h; i++) { int num = i * w; float num2 = 0f; int num3 = 0; int num4 = Mathf.Min(w - 1, r); for (int j = 0; j <= num4; j++) { num2 += src[num + j]; num3++; } for (int k = 0; k < w; k++) { array[num + k] = num2 / (float)num3; int num5 = k + r + 1; int num6 = k - r; if (num5 < w) { num2 += src[num + num5]; num3++; } if (num6 >= 0) { num2 -= src[num + num6]; num3--; } } } float[] array2 = new float[w * h]; for (int l = 0; l < w; l++) { float num7 = 0f; int num8 = 0; int num9 = Mathf.Min(h - 1, r); for (int m = 0; m <= num9; m++) { num7 += array[m * w + l]; num8++; } for (int n = 0; n < h; n++) { array2[n * w + l] = num7 / (float)num8; int num10 = n + r + 1; int num11 = n - r; if (num10 < h) { num7 += array[num10 * w + l]; num8++; } if (num11 >= 0) { num7 -= array[num11 * w + l]; num8--; } } } return array2; } private static float[] BuildDensityMap(Color[] pixels, int w, int h) { int r = Mathf.Max(4, Mathf.RoundToInt((float)Mathf.Min(w, h) * 0.03f)); float num = Mathf.Clamp01(1f); float[] array = new float[w * h]; float[] array2 = new float[w * h]; for (int i = 0; i < array.Length; i++) { float num2 = (array[i] = pixels[i].a); array2[i] = num2 * num2; } float[] array3 = BoxBlur(array, w, h, r); float[] array4 = BoxBlur(array2, w, h, r); float[] array5 = new float[w * h]; for (int j = 0; j < array5.Length; j++) { float num3 = array3[j]; float num4 = Mathf.Max(0f, array4[j] - num3 * num3); float num5 = num3 * (1f - num3); float num6 = ((num5 > 1E-05f) ? Mathf.Clamp01(num4 / num5) : 0f); array5[j] = num3 * (1f - num * num6 * (1f - num3)); } return array5; } private static byte[] BuildCurveClasses(List densities) { int count = densities.Count; byte[] array = new byte[count]; int classes = BloodThermal.Classes; if (classes <= 1 || count == 0) { return array; } int[] array2 = new int[classes]; for (int i = 0; i < count; i++) { float num = Mathf.Clamp01((densities[i] - 0f) / 1f); int num2 = Mathf.Clamp((int)((1f - num) * (float)classes * 0.9999f), 0, classes - 1); array[i] = (byte)num2; array2[num2]++; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("[BloodSystem] Class bands over normalized density:"); for (int j = 0; j < classes; j++) { float num3 = 1f - 1f * (float)j / (float)classes; float num4 = 1f - 1f * (float)(j + 1) / (float)classes; stringBuilder.Append("\n class ").Append(j).Append(" density ") .Append(num4.ToString("F2")) .Append("-") .Append(num3.ToString("F2")) .Append(" -> ") .Append(array2[j]) .Append(" samples (") .Append((100f * (float)array2[j] / (float)count).ToString("F1")) .Append("%)"); } Log.LogInfo((object)stringBuilder.ToString()); return array; } private static void BuildFallbackGrid(int side) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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) List list = new List(side * side); List list2 = new List(side * side); List list3 = new List(side * side); List list4 = new List(side * side); Vector2 val = default(Vector2); for (int i = 0; i < side; i++) { for (int j = 0; j < side; j++) { ((Vector2)(ref val))..ctor((float)j / (float)(side - 1) * 2f - 1f, (float)i / (float)(side - 1) * 2f - 1f); list.Add(val); list2.Add(0.8f); list3.Add(LookupNoiseBright(val)); list4.Add(LookupNormal(val)); } } _splatterUVs = list.ToArray(); _splatterDarks = list2.ToArray(); _splatterBrights = list3.ToArray(); _splatterNormals = list4.ToArray(); _cumWeights = new float[0]; _splatterClasses = new byte[list.Count]; } private static void SampleSplatter(out Vector2 uv, out float dark, out float bright, out Vector3 tanNorm, out byte curveClass) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c6: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) if (_splatterUVs == null || _splatterUVs.Length == 0) { uv = new Vector2(Random.Range(-1f, 1f), Random.Range(-1f, 1f)); dark = 0.8f; bright = 1f; tanNorm = Vector3.forward; curveClass = 0; return; } int num; if (_cumWeights == null || _cumWeights.Length == 0) { num = Random.Range(0, _splatterUVs.Length); } else { float num2 = Random.Range(0f, _cumWeights[_cumWeights.Length - 1]); int num3 = 0; int num4 = _cumWeights.Length - 1; while (num3 < num4) { int num5 = num3 + num4 >> 1; if (_cumWeights[num5] < num2) { num3 = num5 + 1; } else { num4 = num5; } } num = num3; } uv = _splatterUVs[num]; dark = ((_splatterDarks != null && num < _splatterDarks.Length) ? _splatterDarks[num] : 0.8f); bright = ((_splatterBrights != null && num < _splatterBrights.Length) ? _splatterBrights[num] : 1f); tanNorm = ((_splatterNormals != null && num < _splatterNormals.Length) ? _splatterNormals[num] : Vector3.forward); curveClass = (byte)((_splatterClasses != null && num < _splatterClasses.Length) ? _splatterClasses[num] : 0); } private static void TryLoadFromBundle() { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown try { string alloyMatCachePath = AlloyMatCachePath; if (!File.Exists(alloyMatCachePath)) { return; } Dictionary dictionary = new Dictionary(); string[] array = File.ReadAllLines(alloyMatCachePath); foreach (string text in array) { int num = text.IndexOf('='); if (num >= 0) { dictionary[text.Substring(0, num).Trim()] = text.Substring(num + 1).Trim(); } } if (!dictionary.TryGetValue("shaderName", out var value)) { return; } Shader val = Shader.Find(value); if (val == null) { Log.LogWarning((object)("[BloodSystem] Cache shader not found: " + value)); return; } Material val2 = new Material(val); if (dictionary.TryGetValue("renderQueue", out var value2)) { val2.renderQueue = int.Parse(value2); } if (dictionary.TryGetValue("_SrcBlend", out value2) && val2.HasProperty("_SrcBlend")) { val2.SetInt("_SrcBlend", int.Parse(value2)); } if (dictionary.TryGetValue("_DstBlend", out value2) && val2.HasProperty("_DstBlend")) { val2.SetInt("_DstBlend", int.Parse(value2)); } if (dictionary.TryGetValue("_ZWrite", out value2) && val2.HasProperty("_ZWrite")) { val2.SetInt("_ZWrite", int.Parse(value2)); } if (dictionary.TryGetValue("_Mode", out value2) && val2.HasProperty("_Mode")) { val2.SetFloat("_Mode", float.Parse(value2)); } if (dictionary.TryGetValue("keywords", out value2) && !string.IsNullOrEmpty(value2)) { array = value2.Split(new char[1] { ',' }); foreach (string text2 in array) { if (!string.IsNullOrEmpty(text2.Trim())) { val2.EnableKeyword(text2.Trim()); } } } val2.SetInt("_Cull", 0); _decalSourceMat = val2; _decalSourceSearched = true; Log.LogInfo((object)("[BloodSystem] Cache loaded: " + value + " rq=" + val2.renderQueue)); } catch (Exception ex) { Log.LogWarning((object)("[BloodSystem] TryLoadFromCache: " + ex.Message)); } } internal static void SaveAlloyCacheToFile(Material mat) { try { List list = new List { "shaderName=" + ((Object)mat.shader).name, "renderQueue=" + mat.renderQueue, "keywords=" + string.Join(",", mat.shaderKeywords) }; string[] array = new string[3] { "_SrcBlend", "_DstBlend", "_ZWrite" }; foreach (string text in array) { if (mat.HasProperty(text)) { list.Add(text + "=" + mat.GetInt(text)); } } array = new string[2] { "_Mode", "_Cutoff" }; foreach (string text2 in array) { if (mat.HasProperty(text2)) { list.Add(text2 + "=" + mat.GetFloat(text2).ToString("F3")); } } File.WriteAllLines(AlloyMatCachePath, list.ToArray()); Log.LogInfo((object)("[BloodSystem] Cache saved: " + ((Object)mat.shader).name + " kws=" + string.Join(",", mat.shaderKeywords))); } catch (Exception ex) { Log.LogWarning((object)("[BloodSystem] SaveAlloyCache: " + ex.Message)); } } internal static IEnumerator TryGrabAlloyFromScene() { _alloyGrabPending = true; yield return null; if (_decalSourceMat != null) { _alloyGrabPending = false; yield break; } Renderer val = null; int num = -1; int num2 = 0; try { Renderer[] array = Object.FindObjectsOfType(); foreach (Renderer val2 in array) { if (val2 == null) { continue; } Material sharedMaterial = val2.sharedMaterial; if (sharedMaterial == null || sharedMaterial.shader == null) { continue; } string name = ((Object)sharedMaterial.shader).name; if (name.IndexOf("Alloy", StringComparison.OrdinalIgnoreCase) >= 0 && name.IndexOf("Additive", StringComparison.OrdinalIgnoreCase) < 0) { num2++; int num3 = 0; if (name == "Alloy/Core") { num3 += 100; } if (sharedMaterial.renderQueue > 2000) { num3 += 50; } Log.LogInfo((object)("[BloodSystem] Alloy candidate: shader=" + name + " rq=" + sharedMaterial.renderQueue + " score=" + num3 + " obj=" + ((Object)((Component)val2).gameObject).name)); if (num3 > num) { num = num3; val = val2; } } } } catch (Exception ex) { Log.LogWarning((object)("[BloodSystem] TryGrabAlloyFromScene: " + ex.Message)); } Log.LogInfo((object)("[BloodSystem] AlloyGrab: candidates=" + num2 + " bestScore=" + num)); if (val != null) { _decalSourceMat = new Material(val.sharedMaterial); _decalSourceMat.SetInt("_Cull", 0); _decalSourceSearched = true; _matCache.Clear(); _dripMatCache.Clear(); Log.LogInfo((object)("[BloodSystem] Alloy mat GRABBED: " + ((Object)_decalSourceMat.shader).name + " rq=" + _decalSourceMat.renderQueue)); SaveAlloyCacheToFile(_decalSourceMat); } else { Log.LogWarning((object)"[BloodSystem] No Alloy renderer found — shoot a wall, then a sosig."); } _alloyGrabPending = false; } internal static Material GetBloodMat(Color col) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return GetBloodMat(col, BloodThermal.CurrentCohort(BloodThermal.Classes - 1)); } internal static Material GetBloodMat(Color col, int cohortId) { //IL_0002: 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_009c: Expected O, but got Unknown //IL_00af: 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_0056: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) MatKey key = new MatKey(col, cohortId); if (_matCache.TryGetValue(key, out var value) && value != null) { return value; } Material decalSourceMat = _decalSourceMat; if (decalSourceMat == null) { if (!_fallbackDecalShaderSearched) { _fallbackDecalShaderSearched = true; _fallbackDecalShader = Shader.Find("Legacy Shaders/Transparent/Diffuse"); } if (_fallbackDecalShader == null) { return null; } value = new Material(_fallbackDecalShader); if (_decalTex != null) { value.mainTexture = (Texture)(object)_decalTex; } value.color = col; value.SetOverrideTag("RenderType", "Transparent"); _matCache[key] = value; BloodThermal.RegisterMaterial(value, key, drip: false); return value; } value = new Material(decalSourceMat); if (_decalTex != null) { value.mainTexture = (Texture)(object)_decalTex; } ApplyBloodProps(value, col); _matCache[key] = value; BloodThermal.RegisterMaterial(value, key, drip: false); return value; } private static void ApplyBloodProps(Material m, Color col) { //IL_0013: 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_0150: Unknown result type (might be due to invalid IL or missing references) if (m.HasProperty("_Color")) { m.SetColor("_Color", col); } if (m.HasProperty("_Metal")) { m.SetFloat("_Metal", 0f); } if (m.HasProperty("_Specularity")) { m.SetFloat("_Specularity", 0f); } if (m.HasProperty("_Roughness")) { m.SetFloat("_Roughness", 0.8f); } m.DisableKeyword("_RIM_ON"); if (m.HasProperty("_EmissionColor")) { m.SetColor("_EmissionColor", Color.black); } m.DisableKeyword("_EMISSION"); m.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)4; if (m.HasProperty("_SrcBlend")) { m.SetInt("_SrcBlend", 5); } if (m.HasProperty("_DstBlend")) { m.SetInt("_DstBlend", 10); } m.DisableKeyword("_ALPHAPREMULTIPLY_ON"); m.EnableKeyword("_ALPHABLEND_ON"); m.SetOverrideTag("RenderType", "Transparent"); if (m.HasProperty("_Metallic")) { m.SetFloat("_Metallic", 0f); } if (m.HasProperty("_Smoothness")) { m.SetFloat("_Smoothness", 0.1f); } if (m.HasProperty("_SpecColor")) { m.SetColor("_SpecColor", Color.black); } if (m.HasProperty("_Shininess")) { m.SetFloat("_Shininess", 0.05f); } } private static Material BuildSprayMaterial() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown Shader val = Shader.Find("Sprites/Default"); if (val == null) { val = Shader.Find("Particles/Additive"); } if (val == null) { return null; } Material val2 = new Material(val); if (_firstBloodTex != null) { val2.mainTexture = (Texture)(object)_firstBloodTex; } return val2; } private static void SetParticleFadeMode(Material mat) { mat.SetFloat("_Mode", 2f); mat.EnableKeyword("_ALPHABLEND_ON"); mat.DisableKeyword("_ALPHATEST_ON"); mat.DisableKeyword("_ALPHAPREMULTIPLY_ON"); mat.SetInt("_SrcBlend", 5); mat.SetInt("_DstBlend", 10); mat.SetInt("_ZWrite", 0); mat.renderQueue = 3000; } private void BuildSprayPSes() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //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_0025: 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_0034: 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_0050: Unknown result type (might be due to invalid IL or missing references) //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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_014d: 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) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0171: 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_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: 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_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Expected O, but got Unknown //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Expected O, but got Unknown //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: 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_0320: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: 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_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Expected O, but got Unknown //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Expected O, but got Unknown //IL_0441: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_04ad: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04fa: Unknown result type (might be due to invalid IL or missing references) //IL_04ff: Unknown result type (might be due to invalid IL or missing references) //IL_050e: Unknown result type (might be due to invalid IL or missing references) //IL_0513: Unknown result type (might be due to invalid IL or missing references) //IL_0524: Unknown result type (might be due to invalid IL or missing references) //IL_0533: Unknown result type (might be due to invalid IL or missing references) //IL_0538: Unknown result type (might be due to invalid IL or missing references) //IL_0567: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_0579: Unknown result type (might be due to invalid IL or missing references) Gradient val = new Gradient(); val.SetKeys((GradientColorKey[])(object)new GradientColorKey[2] { new GradientColorKey(Color.white, 0f), new GradientColorKey(Color.white, 1f) }, (GradientAlphaKey[])(object)new GradientAlphaKey[2] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(0f, 1f) }); GameObject val2 = new GameObject("BSFog"); Object.DontDestroyOnLoad((Object)(object)val2); val2.SetActive(false); _fogPS = val2.AddComponent(); MainModule main = _fogPS.main; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.25f, 0.4f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.3f, 1.2f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.01f, 0.03f); ((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f); ((MainModule)(ref main)).maxParticles = 2000; ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0.05f); ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).playOnAwake = false; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).duration = 0.5f; ((MainModule)(ref main)).startColor = new MinMaxGradient(_mustardFallback); EmissionModule emission = _fogPS.emission; ((EmissionModule)(ref emission)).enabled = true; ((EmissionModule)(ref emission)).rateOverTime = new MinMaxCurve(0f); ShapeModule shape = _fogPS.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)7; ((ShapeModule)(ref shape)).angle = 85f; ((ShapeModule)(ref shape)).radius = 0.02f; SizeOverLifetimeModule sizeOverLifetime = _fogPS.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0f, 0.5f), new Keyframe(1f, 2.5f) })); ColorOverLifetimeModule colorOverLifetime = _fogPS.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true; ((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val); ParticleSystemRenderer component = ((Component)_fogPS).GetComponent(); if ((Object)(object)component != (Object)null && _fogMat != null) { ((Renderer)component).material = _fogMat; } val2.SetActive(true); GameObject val3 = new GameObject("BSPellet"); Object.DontDestroyOnLoad((Object)(object)val3); val3.SetActive(false); _pelletPS = val3.AddComponent(); MainModule main2 = _pelletPS.main; ((MainModule)(ref main2)).startLifetime = new MinMaxCurve(0.3f, 0.5f); ((MainModule)(ref main2)).startSpeed = new MinMaxCurve(1.5f, 4f); ((MainModule)(ref main2)).startSize = new MinMaxCurve(0.04f, 0.12f); ((MainModule)(ref main2)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f); ((MainModule)(ref main2)).maxParticles = 2000; ((MainModule)(ref main2)).gravityModifier = MinMaxCurve.op_Implicit(0.35f); ((MainModule)(ref main2)).loop = false; ((MainModule)(ref main2)).playOnAwake = false; ((MainModule)(ref main2)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main2)).duration = 0.5f; ((MainModule)(ref main2)).startColor = new MinMaxGradient(_mustardFallback); EmissionModule emission2 = _pelletPS.emission; ((EmissionModule)(ref emission2)).enabled = true; ((EmissionModule)(ref emission2)).rateOverTime = new MinMaxCurve(0f); ShapeModule shape2 = _pelletPS.shape; ((ShapeModule)(ref shape2)).enabled = true; ((ShapeModule)(ref shape2)).shapeType = (ParticleSystemShapeType)4; ((ShapeModule)(ref shape2)).angle = 20f; ((ShapeModule)(ref shape2)).radius = 0.02f; SizeOverLifetimeModule sizeOverLifetime2 = _pelletPS.sizeOverLifetime; ((SizeOverLifetimeModule)(ref sizeOverLifetime2)).enabled = true; ((SizeOverLifetimeModule)(ref sizeOverLifetime2)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0f, 0.4f), new Keyframe(1f, 1.6f) })); ColorOverLifetimeModule colorOverLifetime2 = _pelletPS.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime2)).enabled = true; ((ColorOverLifetimeModule)(ref colorOverLifetime2)).color = new MinMaxGradient(val); ParticleSystemRenderer component2 = ((Component)_pelletPS).GetComponent(); if ((Object)(object)component2 != (Object)null && _pelletMat != null) { ((Renderer)component2).material = _pelletMat; } val3.SetActive(true); GameObject val4 = new GameObject("BSJet"); Object.DontDestroyOnLoad((Object)val4); val4.SetActive(false); _jetPS = val4.AddComponent(); MainModule main3 = _jetPS.main; ((MainModule)(ref main3)).startLifetime = new MinMaxCurve(0.3f, 0.5f); ((MainModule)(ref main3)).startSpeed = new MinMaxCurve(8f, 18f); ((MainModule)(ref main3)).startSize = new MinMaxCurve(0.012f, 0.03f); ((MainModule)(ref main3)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f); ((MainModule)(ref main3)).maxParticles = 1000; ((MainModule)(ref main3)).gravityModifier = MinMaxCurve.op_Implicit(1.2f); ((MainModule)(ref main3)).loop = false; ((MainModule)(ref main3)).playOnAwake = false; ((MainModule)(ref main3)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main3)).duration = 0.5f; ((MainModule)(ref main3)).startColor = new MinMaxGradient(_mustardFallback); EmissionModule emission3 = _jetPS.emission; ((EmissionModule)(ref emission3)).enabled = true; ((EmissionModule)(ref emission3)).rateOverTime = new MinMaxCurve(0f); ShapeModule shape3 = _jetPS.shape; ((ShapeModule)(ref shape3)).enabled = true; ((ShapeModule)(ref shape3)).shapeType = (ParticleSystemShapeType)4; ((ShapeModule)(ref shape3)).angle = 5f; ((ShapeModule)(ref shape3)).radius = 0.005f; ColorOverLifetimeModule colorOverLifetime3 = _jetPS.colorOverLifetime; ((ColorOverLifetimeModule)(ref colorOverLifetime3)).enabled = true; ((ColorOverLifetimeModule)(ref colorOverLifetime3)).color = new MinMaxGradient(val); ParticleSystemRenderer component3 = ((Component)_jetPS).GetComponent(); if ((Object)(object)component3 != (Object)null && _pelletMat != null) { ((Renderer)component3).material = _pelletMat; } val4.SetActive(true); } internal static void SpawnProjection(Vector3 exitPt, Vector3 projDir, Sosig srcSosig, float bulletSpeed, bool gib = false, List shotList = null, float rayCountScale = 1f) { //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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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) //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_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_00cf: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_00ec: 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_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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: 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_01e0: 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_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0273: 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_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0319: 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_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0334: 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_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_034f: 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) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_0482: 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_04a0: Unknown result type (might be due to invalid IL or missing references) //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_0931: Unknown result type (might be due to invalid IL or missing references) //IL_04cc: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: Unknown result type (might be due to invalid IL or missing references) //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: 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_054d: Unknown result type (might be due to invalid IL or missing references) //IL_0551: Unknown result type (might be due to invalid IL or missing references) //IL_05a6: Unknown result type (might be due to invalid IL or missing references) //IL_081f: Unknown result type (might be due to invalid IL or missing references) //IL_0907: Unknown result type (might be due to invalid IL or missing references) if (!CfgEnabled.Value || !CfgSplatterEnabled.Value) { return; } try { Color sosigBloodColor = GetSosigBloodColor(srcSosig); Vector3 normalized = ((Vector3)(ref projDir)).normalized; float num = Mathf.Tan(CfgConeAngle.Value * ((float)Math.PI / 180f)) * 0.8f; float value = CfgRange.Value; float num2 = Mathf.Max(1f, bulletSpeed * CfgSpeedRatio.Value) + CfgSpeedBias.Value; Vector3 val = Vector3.Cross((Mathf.Abs(Vector3.Dot(normalized, Vector3.up)) > 0.99f) ? Vector3.forward : Vector3.up, normalized); Vector3 normalized2 = ((Vector3)(ref val)).normalized; Vector3 val2 = Vector3.Cross(normalized, normalized2); float num3 = Random.Range(0f, (float)Math.PI * 2f); float num4 = Mathf.Cos(num3); float num5 = Mathf.Sin(num3); Vector3 val3 = normalized2 * num4 + val2 * num5; Vector3 val4 = val2 * num4 - normalized2 * num5; normalized2 = val3; val2 = val4; bool flag = string.Equals(CfgProjectionMode.Value, "Animated", StringComparison.OrdinalIgnoreCase); bool flag2 = string.Equals(CfgProjectionMode.Value, "Immediate", StringComparison.OrdinalIgnoreCase); float value2 = CfgDotScaleMax.Value; float num6 = (value2 - 1f) / Mathf.Max(0.1f, CfgDotScaleRange.Value); int num7 = ((_splatterUVs != null && _splatterUVs.Length != 0) ? _splatterUVs.Length : int.MaxValue); int num8 = (gib ? Mathf.Min(Mathf.Max(1, CfgGibRayCount.Value), num7) : Mathf.Min(Mathf.Max(1, CfgRayCount.Value), num7)); if (rayCountScale < 0.999f) { num8 = Mathf.Max(1, Mathf.RoundToInt((float)num8 * rayCountScale)); } if (gib) { ((MonoBehaviour)_instance).StartCoroutine(SpawnGibGradual(exitPt, num8, value, value2, num6, sosigBloodColor, srcSosig, shotList)); return; } int num9 = Physics.RaycastNonAlloc(exitPt + Vector3.up * 0.5f, Vector3.down, _rayBuf, 0.6f); Array.Sort(_rayBuf, 0, num9, _rhCompare); for (int i = 0; i < num9; i++) { RaycastHit val5 = _rayBuf[i]; if (!((Object)(object)((RaycastHit)(ref val5)).collider.attachedRigidbody != (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref val5)).collider).GetComponentInParent() != (Object)null) && !(((RaycastHit)(ref val5)).normal.y < 0.5f)) { exitPt = ((RaycastHit)(ref val5)).point + ((RaycastHit)(ref val5)).normal * 0.05f; break; } } Dictionary> dictionary = new Dictionary>(); Dictionary>> dictionary2 = new Dictionary>>(); List list = new List(); List list2 = new List(); float num10 = 0f; if (_flyBuf == null || _flyBuf.Length < num8) { _flyBuf = (Particle[])(object)new Particle[num8]; } int num11 = 0; Color32 startColor = Color32.op_Implicit(sosigBloodColor); for (int j = 0; j < num8; j++) { SampleSplatter(out var uv, out var dark, out var bright, out var tanNorm, out var curveClass); Vector3 val6; if (!gib) { val = normalized + normalized2 * uv.x * num + val2 * uv.y * num; val6 = ((Vector3)(ref val)).normalized; } else { val6 = Random.onUnitSphere; } Vector3 val7 = val6; int num12 = Physics.RaycastNonAlloc(exitPt - normalized * 0.15f, val7, _rayBuf, value); Array.Sort(_rayBuf, 0, num12, _rhCompare); RaycastHit val8 = default(RaycastHit); bool flag3 = false; for (int k = 0; k < num12; k++) { RaycastHit val9 = _rayBuf[k]; if (!IsSourceSosig(((RaycastHit)(ref val9)).collider, srcSosig) && !((Object)(object)((Component)((RaycastHit)(ref val9)).collider).GetComponentInParent() != (Object)null)) { val8 = val9; flag3 = true; break; } } if (flag3) { float num13 = CfgDotSize.Value * Mathf.Clamp(1f + ((RaycastHit)(ref val8)).distance * num6, 1f, value2); if (((RaycastHit)(ref val8)).distance > num10) { num10 = ((RaycastHit)(ref val8)).distance; } float num14 = Mathf.Abs(Vector3.Dot(val7, ((RaycastHit)(ref val8)).normal)); float elongation = Mathf.Clamp(1f / Mathf.Max(0.15f, num14), 1f, 8f); Vector3 elongDir = val7 - Vector3.Dot(val7, ((RaycastHit)(ref val8)).normal) * ((RaycastHit)(ref val8)).normal; if (((Vector3)(ref elongDir)).sqrMagnitude > 0.001f) { ((Vector3)(ref elongDir)).Normalize(); } else { elongDir = normalized2; } Rigidbody attachedRigidbody = ((RaycastHit)(ref val8)).collider.attachedRigidbody; Transform item = (((Object)(object)attachedRigidbody != (Object)null) ? ((Component)attachedRigidbody).transform : null); DotData item2 = new DotData(((RaycastHit)(ref val8)).point, ((RaycastHit)(ref val8)).normal, num13, dark, bright, tanNorm, elongDir, elongation, ((RaycastHit)(ref val8)).distance, curveClass); list.Add(item2); list2.Add(item); if (flag && _flyingDotPS != null && num11 < _flyBuf.Length) { float num15 = ((RaycastHit)(ref val8)).distance / num2; ((Particle)(ref _flyBuf[num11])).position = exitPt; ((Particle)(ref _flyBuf[num11])).velocity = val7 * num2; ((Particle)(ref _flyBuf[num11])).startLifetime = num15; ((Particle)(ref _flyBuf[num11])).remainingLifetime = num15; ((Particle)(ref _flyBuf[num11])).startSize = num13 * 2f; ((Particle)(ref _flyBuf[num11])).startColor = startColor; num11++; } } } int num16 = ((!flag || num10 < 3f) ? 1 : AnimStepsForDistance(num10)); float num17 = Mathf.Max(0.0001f, num10) / (float)num16; for (int l = 0; l < list.Count; l++) { DotData item3 = list[l]; Transform val10 = list2[l]; int key = Mathf.Clamp((int)(item3.Dist / num17), 0, num16 - 1); if ((Object)(object)val10 == (Object)null) { if (!dictionary.ContainsKey(key)) { dictionary[key] = new List(); } dictionary[key].Add(item3); continue; } if (!dictionary2.ContainsKey(key)) { dictionary2[key] = new Dictionary>(); } if (!dictionary2[key].ContainsKey(val10)) { dictionary2[key][val10] = new List(); } dictionary2[key][val10].Add(item3); } float binSize = num17 / num2; if (dictionary.Count == 0 && dictionary2.Count == 0) { return; } if (flag && _flyingDotPS != null && num11 > 0) { int particles = _flyingDotPS.GetParticles(_flyMergeBuf); int num18 = Mathf.Min(num11, _flyMergeBuf.Length - particles); if (num18 > 0) { Array.Copy(_flyBuf, 0, _flyMergeBuf, particles, num18); _flyingDotPS.SetParticles(_flyMergeBuf, particles + num18); if (!_flyingDotPS.isPlaying) { _flyingDotPS.Play(); } } } if (!_dbgDotLogged) { _dbgDotLogged = true; Log.LogInfo((object)("[BloodSystem] First projection: " + num11 + " particles speed=" + num2.ToString("F1") + " N=" + num8 + " mode=" + CfgProjectionMode.Value)); } if (flag2) { List list3 = new List(); foreach (KeyValuePair> item4 in dictionary) { list3.AddRange(item4.Value); } if (list3.Count > 0) { BuildDotMesh(list3, null, sosigBloodColor, shotList); } Dictionary> dictionary3 = new Dictionary>(); foreach (KeyValuePair>> item5 in dictionary2) { foreach (KeyValuePair> item6 in item5.Value) { if (!dictionary3.ContainsKey(item6.Key)) { dictionary3[item6.Key] = new List(); } dictionary3[item6.Key].AddRange(item6.Value); } } { foreach (KeyValuePair> item7 in dictionary3) { if (item7.Key != null && (Object)(object)item7.Key != (Object)null) { BuildDotMesh(item7.Value, item7.Key, sosigBloodColor, shotList); } } return; } } ((MonoBehaviour)_instance).StartCoroutine(DoDelayedSpawn(dictionary, dictionary2, sosigBloodColor, binSize, shotList)); } catch (Exception ex) { Log.LogError((object)("[BloodSystem] SpawnProjection: " + ex)); } } private static IEnumerator SpawnGibGradual(Vector3 pos, int N, float range, float scaleMax, float scaleSlope, Color col, Sosig srcSosig, List shotList) { //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_002b: 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) List staticDots = new List(); Dictionary> dynDots = new Dictionary>(); for (int i = 0; i < N; i++) { SampleSplatter(out var _, out var dark, out var bright, out var tanNorm, out var curveClass); Vector3 onUnitSphere = Random.onUnitSphere; int num = Physics.RaycastNonAlloc(pos, onUnitSphere, _rayBuf, range); Array.Sort(_rayBuf, 0, num, _rhCompare); RaycastHit val = default(RaycastHit); bool flag = false; for (int j = 0; j < num; j++) { RaycastHit val2 = _rayBuf[j]; if (!IsSourceSosig(((RaycastHit)(ref val2)).collider, srcSosig) && !((Object)(object)((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent() != (Object)null)) { val = val2; flag = true; break; } } if (flag) { float r = CfgDotSize.Value * Mathf.Clamp(1f + ((RaycastHit)(ref val)).distance * scaleSlope, 1f, scaleMax); float num2 = Mathf.Abs(Vector3.Dot(onUnitSphere, ((RaycastHit)(ref val)).normal)); float elongation = Mathf.Clamp(1f / Mathf.Max(0.15f, num2), 1f, 8f); Vector3 elongDir = onUnitSphere - Vector3.Dot(onUnitSphere, ((RaycastHit)(ref val)).normal) * ((RaycastHit)(ref val)).normal; if (((Vector3)(ref elongDir)).sqrMagnitude > 0.001f) { ((Vector3)(ref elongDir)).Normalize(); } else { elongDir = Vector3.right; } DotData item = new DotData(((RaycastHit)(ref val)).point, ((RaycastHit)(ref val)).normal, r, dark, bright, tanNorm, elongDir, elongation, ((RaycastHit)(ref val)).distance, curveClass); Rigidbody attachedRigidbody = ((RaycastHit)(ref val)).collider.attachedRigidbody; if ((Object)(object)attachedRigidbody == (Object)null) { staticDots.Add(item); } else { Transform transform = ((Component)attachedRigidbody).transform; if (!dynDots.ContainsKey(transform)) { dynDots[transform] = new List(); } dynDots[transform].Add(item); } } if ((i + 1) % 50 == 0) { yield return null; } } if (staticDots.Count > 0) { BuildDotMesh(staticDots, null, col, shotList); } foreach (KeyValuePair> item2 in dynDots) { if (item2.Key != null && (Object)(object)item2.Key != (Object)null) { BuildDotMesh(item2.Value, item2.Key, col, shotList); } } } private static IEnumerator DoDelayedSpawn(Dictionary> staticBins, Dictionary>> dynBins, Color col, float binSize, List shotList) { //IL_0015: 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) List list = new List(staticBins.Keys); foreach (int key in dynBins.Keys) { if (!list.Contains(key)) { list.Add(key); } } list.Sort(); float num = 0f; foreach (int b in list) { float t = (float)b * binSize; float num2 = t - num; if (num2 > 0.001f) { yield return (object)new WaitForSeconds(num2); num = t; } if (staticBins.TryGetValue(b, out var value) && value.Count > 0) { BuildDotMesh(value, null, col, shotList); } if (!dynBins.TryGetValue(b, out var value2)) { continue; } foreach (KeyValuePair> item in value2) { if (item.Key != null && (Object)(object)item.Key != (Object)null) { BuildDotMesh(item.Value, item.Key, col, shotList); } } } } internal static void SpawnBloodSpray(Vector3 pos, Vector3 fwd, Color col, bool explode = false, float speedScale = 1f, float burstFraction = 1f, Transform follow = null) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0023: 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) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!CfgEnabled.Value || !CfgSprayEnabled.Value) { return; } if (_instance != null) { if (explode) { SpraySprayImmediate(pos, fwd, col, explode, speedScale, burstFraction); return; } SpraySprayImmediate(pos, fwd, col, explode, speedScale, burstFraction, doFog: true, doPellet: true, doJet: false); ((MonoBehaviour)_instance).StartCoroutine(DoTrailingSpray(pos, fwd, col, explode, speedScale, burstFraction, follow, doFog: false, doPellet: false, doJet: true, 0.5f)); } else { SpraySprayImmediate(pos, fwd, col, explode, speedScale, burstFraction); } } private static IEnumerator DoTrailingSpray(Vector3 pos, Vector3 fwd, Color col, bool explode, float speedScale, float burstFraction, Transform follow, bool doFog, bool doPellet, bool doJet, float seconds) { //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_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_0015: 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) float wait = seconds / 6f; float trail = 0.1f; bool wasFollowing = (Object)(object)follow != (Object)null; for (int i = 0; i < 6 && (!(i > 0 && wasFollowing) || !((Object)(object)follow == (Object)null)); i++) { SpraySprayImmediate(((Object)(object)follow != (Object)null) ? follow.position : pos, fwd, col, explode, speedScale, burstFraction, doFog, doPellet, doJet, doStain: false, (i == 0) ? 0.5f : trail); yield return (object)new WaitForSeconds(wait); } } private static void SpraySprayImmediate(Vector3 pos, Vector3 fwd, Color col, bool explode, float speedScale, float burstFraction, bool doFog = true, bool doPellet = true, bool doJet = true, bool doStain = true, float countScale = 1f) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_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_0069: 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_0170: 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_018b: 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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0233: 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_0247: 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_01cc: 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_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: 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_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_0470: 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) //IL_047e: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: Unknown result type (might be due to invalid IL or missing references) //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0401: 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_0404: 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_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_051a: Unknown result type (might be due to invalid IL or missing references) //IL_051d: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_052b: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_054a: Unknown result type (might be due to invalid IL or missing references) //IL_054f: Unknown result type (might be due to invalid IL or missing references) //IL_0553: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_058d: Unknown result type (might be due to invalid IL or missing references) //IL_05d2: Unknown result type (might be due to invalid IL or missing references) //IL_05d5: Unknown result type (might be due to invalid IL or missing references) //IL_05da: Unknown result type (might be due to invalid IL or missing references) //IL_05e3: Unknown result type (might be due to invalid IL or missing references) //IL_05e8: Unknown result type (might be due to invalid IL or missing references) //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_05f6: Unknown result type (might be due to invalid IL or missing references) //IL_05fd: Unknown result type (might be due to invalid IL or missing references) //IL_0602: Unknown result type (might be due to invalid IL or missing references) //IL_0607: Unknown result type (might be due to invalid IL or missing references) //IL_060b: Unknown result type (might be due to invalid IL or missing references) //IL_0610: Unknown result type (might be due to invalid IL or missing references) //IL_0612: Unknown result type (might be due to invalid IL or missing references) //IL_0613: Unknown result type (might be due to invalid IL or missing references) //IL_0639: Unknown result type (might be due to invalid IL or missing references) //IL_0640: Unknown result type (might be due to invalid IL or missing references) //IL_0645: Unknown result type (might be due to invalid IL or missing references) Quaternion rotation = Quaternion.LookRotation(fwd); float num = (explode ? Mathf.Clamp(speedScale, 0.2f, 2.5f) : 1f); float num2 = Mathf.Clamp01(burstFraction); if (doFog && _fogPS != null) { ((Component)_fogPS).transform.position = pos; ((Component)_fogPS).transform.rotation = rotation; MainModule main = _fogPS.main; ((MainModule)(ref main)).startColor = new MinMaxGradient(col); if (explode) { ((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.4f * num, 0.8f * num); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.5f * num, 2f * num); ShapeModule shape = _fogPS.shape; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = 0.3f; _fogPS.Emit(Mathf.RoundToInt(500f * num2 * countScale)); } else { ((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.5f, 0.8f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.3f, 1.2f); ShapeModule shape2 = _fogPS.shape; ((ShapeModule)(ref shape2)).shapeType = (ParticleSystemShapeType)7; ((ShapeModule)(ref shape2)).angle = 85f; ((ShapeModule)(ref shape2)).radius = 0.02f; _fogPS.Emit(Mathf.RoundToInt(500f * countScale)); } } if (doPellet && _pelletPS != null) { ((Component)_pelletPS).transform.position = pos; ((Component)_pelletPS).transform.rotation = rotation; MainModule main2 = _pelletPS.main; ((MainModule)(ref main2)).startColor = new MinMaxGradient(col); if (explode) { ((MainModule)(ref main2)).startLifetime = new MinMaxCurve(0.4f * num, 0.8f * num); ((MainModule)(ref main2)).startSpeed = new MinMaxCurve(1.5f * num, 5f * num); ShapeModule shape3 = _pelletPS.shape; ((ShapeModule)(ref shape3)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape3)).radius = 0.05f; _pelletPS.Emit(Mathf.RoundToInt(600f * num2 * countScale)); } else { ((MainModule)(ref main2)).startLifetime = new MinMaxCurve(0.6f, 1f); ((MainModule)(ref main2)).startSpeed = new MinMaxCurve(1.5f, 4f); ShapeModule shape4 = _pelletPS.shape; ((ShapeModule)(ref shape4)).shapeType = (ParticleSystemShapeType)4; ((ShapeModule)(ref shape4)).angle = 20f; ((ShapeModule)(ref shape4)).radius = 0.02f; _pelletPS.Emit(Mathf.RoundToInt(400f * countScale)); } } if (doJet && _jetPS != null) { ((Component)_jetPS).transform.position = pos; ((Component)_jetPS).transform.rotation = rotation; MainModule main3 = _jetPS.main; ((MainModule)(ref main3)).startColor = new MinMaxGradient(col); if (explode) { ((MainModule)(ref main3)).startLifetime = new MinMaxCurve(0.4f * num, 0.8f * num); ((MainModule)(ref main3)).startSpeed = new MinMaxCurve(3f * num, 9f * num); ShapeModule shape5 = _jetPS.shape; ((ShapeModule)(ref shape5)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape5)).radius = 0.03f; _jetPS.Emit(Mathf.RoundToInt(300f * num2 * countScale)); } else { ((MainModule)(ref main3)).startLifetime = new MinMaxCurve(0.6f, 1f); ((MainModule)(ref main3)).startSpeed = new MinMaxCurve(8f, 18f); ShapeModule shape6 = _jetPS.shape; ((ShapeModule)(ref shape6)).shapeType = (ParticleSystemShapeType)4; ((ShapeModule)(ref shape6)).angle = 5f; ((ShapeModule)(ref shape6)).radius = 0.005f; _jetPS.Emit(Mathf.RoundToInt(200f * countScale)); } } if (!doStain) { return; } Vector3 val = ((Mathf.Abs(Vector3.Dot(fwd, Vector3.up)) > 0.9f) ? Vector3.forward : Vector3.up); Vector3 val2 = Vector3.Cross(val, fwd); val = ((Vector3)(ref val2)).normalized; Vector3 val3 = Vector3.Cross(fwd, val); if (explode) { RaycastHit val4 = default(RaycastHit); for (int i = 0; i < 20; i++) { Vector3 onUnitSphere = Random.onUnitSphere; if (Physics.Raycast(pos, onUnitSphere, ref val4, 4f) && (Object)(object)((RaycastHit)(ref val4)).collider.attachedRigidbody == (Object)null) { SpawnSprayDot(((RaycastHit)(ref val4)).point, ((RaycastHit)(ref val4)).normal, col); } } return; } RaycastHit val5 = default(RaycastHit); for (int j = 0; j < 8; j++) { float num3 = (float)j * ((float)Math.PI / 4f); val2 = fwd * 0.087f + (val * Mathf.Cos(num3) + val3 * Mathf.Sin(num3)) * 0.996f; Vector3 normalized = ((Vector3)(ref val2)).normalized; if (Physics.Raycast(pos, normalized, ref val5, 0.6f) && (Object)(object)((RaycastHit)(ref val5)).collider.attachedRigidbody == (Object)null) { SpawnSprayDot(((RaycastHit)(ref val5)).point, ((RaycastHit)(ref val5)).normal, col); } } RaycastHit val6 = default(RaycastHit); for (int k = 0; k < 8; k++) { float num4 = Random.Range(0f, (float)Math.PI * 2f); float num5 = Mathf.Sin(0.34906584f); float num6 = Mathf.Cos(0.34906584f); val2 = fwd * num6 + (val * Mathf.Cos(num4) + val3 * Mathf.Sin(num4)) * num5; Vector3 normalized2 = ((Vector3)(ref val2)).normalized; if (Physics.Raycast(pos, normalized2, ref val6, 2.5f) && (Object)(object)((RaycastHit)(ref val6)).collider.attachedRigidbody == (Object)null) { SpawnSprayDot(((RaycastHit)(ref val6)).point, ((RaycastHit)(ref val6)).normal, col); } } RaycastHit val7 = default(RaycastHit); for (int l = 0; l < 4; l++) { float num7 = Random.Range(0f, (float)Math.PI * 2f); float num8 = Mathf.Sin(0.08726646f); float num9 = Mathf.Cos(0.08726646f); val2 = fwd * num9 + (val * Mathf.Cos(num7) + val3 * Mathf.Sin(num7)) * num8; Vector3 normalized3 = ((Vector3)(ref val2)).normalized; if (Physics.Raycast(pos, normalized3, ref val7, 5f) && (Object)(object)((RaycastHit)(ref val7)).collider.attachedRigidbody == (Object)null) { SpawnSprayDot(((RaycastHit)(ref val7)).point, ((RaycastHit)(ref val7)).normal, col); } } } internal static void SpawnDripStain(Vector3 pos, Vector3 normal, Color col, float scale = 1f) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_003a: 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_0058: 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_005d: Unknown result type (might be due to invalid IL or missing references) //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_0064: 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_0083: 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_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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00b9: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00d6: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_00e6: 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_00ef: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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) //IL_0114: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_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_018b: 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_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: 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_01bf: 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) //IL_01c8: 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_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: 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_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: 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_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Expected O, but got Unknown //IL_0268: Unknown result type (might be due to invalid IL or missing references) col = BrightTint(col); int cohortId = BloodThermal.CurrentCohort(BloodThermal.Classes - 1); BloodThermal.NoteSpawnPosition(cohortId, pos); Material bloodMat = GetBloodMat(col, cohortId); if (bloodMat != null) { float num = Random.Range(0.015f, 0.04f) * scale; Vector3 val = ((Mathf.Abs(Vector3.Dot(normal, Vector3.up)) > 0.9f) ? Vector3.forward : Vector3.up); Quaternion val2 = Quaternion.LookRotation(-normal, val) * Quaternion.Euler(0f, 0f, Random.Range(0f, 360f)); Vector3 val3 = val2 * Vector3.right * num; Vector3 val4 = val2 * Vector3.up * num; Vector3 val5 = pos + normal * 0.003f; Mesh val6 = new Mesh(); val6.vertices = (Vector3[])(object)new Vector3[4] { val5 - val3 - val4, val5 + val3 - val4, val5 + val3 + val4, val5 - val3 + val4 }; val6.uv = (Vector2[])(object)new Vector2[4] { new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(0f, 1f) }; Vector3 normalized = ((Vector3)(ref normal)).normalized; val6.normals = (Vector3[])(object)new Vector3[4] { normalized, normalized, normalized, normalized }; val6.colors = (Color[])(object)new Color[4] { col, col, col, col }; val6.triangles = new int[6] { 0, 2, 3, 0, 1, 2 }; val6.RecalculateBounds(); GameObject val7 = new GameObject("DS"); val7.AddComponent().mesh = val6; MeshRenderer obj = val7.AddComponent(); ((Renderer)obj).sharedMaterial = bloodMat; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; Object.Destroy((Object)(object)val7, CfgLifetime.Value); BloodThermal.RegisterRenderer((Renderer)(object)obj, cohortId, pos); } } internal unsafe static void SpawnBloodDrops(Vector3 pos, Vector3 outward, Color col, int count, List shotList = null) { //IL_0038: 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_003d: 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_003f: 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_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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00a9: 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_00b4: 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_00cd: 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_00f9: 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_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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_0172: 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_0188: 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) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Expected O, but got Unknown //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: 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_01b7: Expected O, but got Unknown //IL_01b9: Unknown result type (might be due to invalid IL or missing references) if (CfgEnabled.Value && CfgDripStainsEnabled.Value && _instance != null) { Vector3 val = ((((Vector3)(ref outward)).sqrMagnitude > 0.001f) ? ((Vector3)(ref outward)).normalized : Vector3.up); Vector3 val2 = pos + val * 0.08f; if (!_dbgDropLogged) { _dbgDropLogged = true; ManualLogSource log = Log; string text = count.ToString(); Vector3 val3 = val2; log.LogInfo((object)("[BloodSystem] SpawnBloodDrops count=" + text + " pos=" + ((object)(*(Vector3*)(&val3))/*cast due to .constrained prefix*/).ToString())); } GameObject val4 = new GameObject("BDrp"); val4.transform.position = val2; val4.transform.rotation = Quaternion.LookRotation(val); ParticleSystem obj = val4.AddComponent(); MainModule main = obj.main; ((MainModule)(ref main)).startLifetime = new MinMaxCurve(1.5f, 3.5f); ((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.3f, 1.5f); ((MainModule)(ref main)).startSize = new MinMaxCurve(0.008f, 0.025f); ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(1f); ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).playOnAwake = false; ((MainModule)(ref main)).maxParticles = 64; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; ((MainModule)(ref main)).startColor = new MinMaxGradient(col); ShapeModule shape = obj.shape; ((ShapeModule)(ref shape)).enabled = true; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4; ((ShapeModule)(ref shape)).angle = 55f; ((ShapeModule)(ref shape)).radius = 0.02f; EmissionModule emission = obj.emission; ((EmissionModule)(ref emission)).enabled = true; ((EmissionModule)(ref emission)).rateOverTime = new MinMaxCurve(0f); ParticleSystemRenderer component = ((Component)obj).GetComponent(); if ((Object)(object)component != (Object)null && _pelletMat != null) { Material val5 = new Material(_pelletMat); val5.color = col; BloodThermal.MarkAlwaysHot(val5); ((Renderer)component).material = val5; } obj.Play(); obj.Emit(count); Object.Destroy((Object)val4, 6f); ((MonoBehaviour)_instance).StartCoroutine(DoDropStains(val2, col, count, shotList)); } } private static bool HasComponentInParentByName(Component c, string typeName) { Transform val = c.transform; while ((Object)(object)val != (Object)null) { if ((Object)(object)((Component)val).GetComponent(typeName) != (Object)null) { return true; } val = val.parent; } return false; } private static IEnumerator DoDropStains(Vector3 pos, Color col, int count, List shotList) { //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_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) int num = Physics.RaycastNonAlloc(pos + Vector3.up * 0.1f, Vector3.down, _rayBuf, 6f); Array.Sort(_rayBuf, 0, num, _rhCompare); RaycastHit floor = default(RaycastHit); bool flag = false; for (int i = 0; i < num; i++) { RaycastHit val = _rayBuf[i]; if (!((Object)(object)((RaycastHit)(ref val)).collider.attachedRigidbody != (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent() != (Object)null) && !HasComponentInParentByName((Component)(object)((RaycastHit)(ref val)).collider, "HumanLimbHitbox") && !(((RaycastHit)(ref val)).normal.y < 0.5f) && !((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent() != (Object)null) && ((Component)((RaycastHit)(ref val)).collider).gameObject.layer != 5) { floor = val; flag = true; break; } } if (flag) { float num2 = Mathf.Clamp(Mathf.Sqrt(2f * Mathf.Max(0.01f, ((RaycastHit)(ref floor)).distance) / 9.81f), 0.05f, 3.5f); yield return (object)new WaitForSeconds(num2); float num3 = Mathf.Sqrt(19.62f * Mathf.Max(0.01f, ((RaycastHit)(ref floor)).distance)); Vector3 worldVel = Vector3.down * num3; int num4 = Mathf.Min(count, 8); for (int j = 0; j < num4; j++) { Vector2 val2 = Random.insideUnitCircle * 0.15f; SpawnDripStainStreak(((RaycastHit)(ref floor)).point + new Vector3(val2.x, 0f, val2.y), worldVel, ((RaycastHit)(ref floor)).normal, col, shotList); } } } internal static IEnumerator DrippingWound(Vector3 woundPt, Sosig sosig, Color col) { //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_0015: 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) if (!CfgEnabled.Value || !CfgDripStainsEnabled.Value) { yield break; } int drips = Random.Range(4, 9); for (int i = 0; i < drips; i++) { yield return (object)new WaitForSeconds(Random.Range(1.5f, 3.5f)); if ((Object)(object)sosig == (Object)null) { break; } RaycastHit[] array = Physics.RaycastAll(woundPt + Vector3.up * 0.1f, Vector3.down, 6f); Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance)); RaycastHit[] array2 = array; for (int num = 0; num < array2.Length; num++) { RaycastHit val = array2[num]; if (!((Object)(object)((RaycastHit)(ref val)).collider.attachedRigidbody != (Object)null) && !((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent() != (Object)null) && !HasComponentInParentByName((Component)(object)((RaycastHit)(ref val)).collider, "HumanLimbHitbox") && !(((RaycastHit)(ref val)).normal.y < 0.5f) && !((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent() != (Object)null) && ((Component)((RaycastHit)(ref val)).collider).gameObject.layer != 5) { SpawnGrowingStain(((RaycastHit)(ref val)).point, ((RaycastHit)(ref val)).normal, col); break; } } } } internal unsafe static void SpawnGrowingStain(Vector3 pos, Vector3 normal, Color col) { //IL_0054: 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_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_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_0076: 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_0094: 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_0099: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00c4: 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_00cd: Expected O, but got Unknown //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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_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_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0170: 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_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: 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_01b6: 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_01be: 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_01c6: 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_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: 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_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: 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_0230: Expected O, but got Unknown //IL_0237: 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_023e: 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_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0268: 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) if (!_growingStainLoggedOnce) { _growingStainLoggedOnce = true; ManualLogSource log = Log; Vector3 val = pos; string? text = ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString(); val = normal; log.LogInfo((object)("[BloodSystem] SpawnGrowingStain pos=" + text + " normal=" + ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString())); } int cohortId = BloodThermal.CurrentCohort(BloodThermal.Classes - 1); BloodThermal.NoteSpawnPosition(cohortId, pos); Material dripMat = GetDripMat(col, cohortId); if (dripMat != null) { float num = Random.Range(0.001f, 0.007f); Vector3 val2 = ((Mathf.Abs(Vector3.Dot(normal, Vector3.up)) > 0.9f) ? Vector3.forward : Vector3.up); Quaternion rotation = Quaternion.LookRotation(normal, val2) * Quaternion.Euler(0f, 0f, Random.Range(0f, 360f)); Mesh val3 = new Mesh(); val3.vertices = (Vector3[])(object)new Vector3[4] { new Vector3(-1f, -1f, 0f), new Vector3(1f, -1f, 0f), new Vector3(1f, 1f, 0f), new Vector3(-1f, 1f, 0f) }; val3.uv = (Vector2[])(object)new Vector2[4] { new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(0f, 1f) }; val3.normals = (Vector3[])(object)new Vector3[4] { normal, normal, normal, normal }; val3.colors = (Color[])(object)new Color[4] { col, col, col, col }; val3.triangles = new int[6] { 0, 2, 3, 0, 1, 2 }; val3.RecalculateBounds(); GameObject val4 = new GameObject("GS"); val4.transform.position = pos + normal * 0.003f; val4.transform.rotation = rotation; val4.transform.localScale = Vector3.one * num; val4.AddComponent().mesh = val3; MeshRenderer obj = val4.AddComponent(); ((Renderer)obj).sharedMaterial = dripMat; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; Object.Destroy((Object)(object)val4, CfgLifetime.Value); BloodThermal.RegisterRenderer((Renderer)(object)obj, cohortId, pos); } } internal static void SpawnDripStainStreak(Vector3 origin, Vector3 worldVel, Vector3 hitNormal, Color col, List shotList = null, bool sprayStreak = false) { //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_0020: 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_0025: 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_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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0089: 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_00e1: 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_00e8: 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) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0132: 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_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_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_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0181: 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_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019c: 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_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: 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_01d0: 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_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Expected O, but got Unknown //IL_0218: Expected O, but got Unknown //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_015c: 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_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) Vector3 normalized = ((Vector3)(ref hitNormal)).normalized; float num = Mathf.Abs(Vector3.Dot((((Vector3)(ref worldVel)).sqrMagnitude > 0.001f) ? ((Vector3)(ref worldVel)).normalized : (-normalized), normalized)); float num2 = Mathf.Clamp(1f / Mathf.Max(0.15f, num), 1f, 6f); if (sprayStreak) { float num3 = Mathf.Round(Mathf.Clamp01((num2 - 1f) / 5f) * 4f) / 4f; ((Color)(ref col))..ctor(col.r, col.g, col.b, Mathf.Lerp(0.9f, 0.7f, num3)); } col = BrightTint(col); int cohortId = BloodThermal.CurrentCohort(BloodThermal.Classes - 1); BloodThermal.NoteSpawnPosition(cohortId, origin); Material dripMat = GetDripMat(col, cohortId); if (dripMat != null) { float num4 = Random.Range(0.008f, 0.024f); Vector3 val = worldVel - Vector3.Dot(worldVel, normalized) * normalized; if (((Vector3)(ref val)).sqrMagnitude > 0.001f) { ((Vector3)(ref val)).Normalize(); } else { Vector3 val2 = ((Mathf.Abs(Vector3.Dot(normalized, Vector3.up)) > 0.9f) ? Vector3.forward : Vector3.up); Vector3 val3 = Vector3.Cross(normalized, val2); val = ((Vector3)(ref val3)).normalized; } Vector3 val4 = Vector3.Cross(normalized, val); if (((Vector3)(ref val4)).sqrMagnitude < 0.001f) { val4 = Vector3.Cross(normalized, Vector3.forward); } ((Vector3)(ref val4)).Normalize(); GameObject val5 = new GameObject("DStr"); val5.transform.position = origin + normalized * 0.003f; val5.transform.rotation = Quaternion.LookRotation(normalized, val4); val5.transform.localScale = new Vector3(num4 * num2 * 2f, num4 * 2f, 1f); val5.AddComponent().sharedMesh = _dotQuadMesh; MeshRenderer val6 = val5.AddComponent(); ((Renderer)val6).sharedMaterial = dripMat; ((Renderer)val6).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val6).receiveShadows = false; Object.Destroy((Object)val5, CfgLifetime.Value); TrackGO(val5, shotList); BloodThermal.RegisterRenderer((Renderer)(object)val6, cohortId, origin); } } internal static void SpawnSprayDot(Vector3 pos, Vector3 normal, Color col) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) //IL_005d: 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_0062: 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_0064: 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_0083: 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_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_009f: 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_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_00b5: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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_011e: Expected O, but got Unknown //IL_0124: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) col = BrightTint(col); int cohortId = BloodThermal.CurrentCohort(BloodThermal.Classes - 1); BloodThermal.NoteSpawnPosition(cohortId, pos); Material bloodMat = GetBloodMat(col, cohortId); if (bloodMat != null && _dotQuadMesh != null) { float num = Random.Range(0.008f, 0.036f); Vector3 val = ((Mathf.Abs(Vector3.Dot(normal, Vector3.up)) > 0.9f) ? Vector3.forward : Vector3.up); Quaternion rotation = Quaternion.LookRotation(normal, val) * Quaternion.Euler(0f, 0f, Random.Range(0f, 360f)); GameObject val2 = new GameObject("SD"); val2.transform.position = pos + normal * 0.003f; val2.transform.rotation = rotation; val2.transform.localScale = Vector3.one * (num * 2f); val2.AddComponent().sharedMesh = _dotQuadMesh; MeshRenderer val3 = val2.AddComponent(); ((Renderer)val3).sharedMaterial = bloodMat; ((Renderer)val3).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val3).receiveShadows = false; Object.Destroy((Object)val2, CfgLifetime.Value); TrackGO(val2, null); BloodThermal.RegisterRenderer((Renderer)(object)val3, cohortId, pos); } } private unsafe static void BuildDotMesh(List dots, Transform parent, Color col, List shotList = null) { //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_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_023d: 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_0246: 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_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Expected O, but got Unknown //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Expected O, but got Unknown //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: 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_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: 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_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02df: 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_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: 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_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: 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_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_030c: 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_025f: Unknown result type (might be due to invalid IL or missing references) //IL_050c: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_0397: 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_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040a: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_054e: Unknown result type (might be due to invalid IL or missing references) //IL_0553: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Unknown result type (might be due to invalid IL or missing references) //IL_0558: 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_0572: Unknown result type (might be due to invalid IL or missing references) //IL_05a5: Unknown result type (might be due to invalid IL or missing references) //IL_05aa: Unknown result type (might be due to invalid IL or missing references) //IL_05e3: Unknown result type (might be due to invalid IL or missing references) //IL_05e8: Unknown result type (might be due to invalid IL or missing references) if (dots.Count == 0) { return; } int num = ((!BloodThermal.Enabled) ? 1 : BloodThermal.ActiveClasses); float[] bRIGHT_LEVELS = BRIGHT_LEVELS; List[] array = new List[bRIGHT_LEVELS.Length * num]; for (int i = 0; i < array.Length; i++) { array[i] = new List(); } for (int j = 0; j < dots.Count; j++) { DotData dotData = dots[j]; float num2 = Mathf.Lerp(0.4f, 1f, dotData.Dark); float num3 = Mathf.Lerp(0.55f, 1f, Mathf.Clamp01(Vector3.Dot(dotData.TanNorm, _tanLight))); float num4 = num2 * num3 * dotData.Bright; int num5 = 0; float num6 = Mathf.Abs(num4 - bRIGHT_LEVELS[0]); for (int k = 1; k < bRIGHT_LEVELS.Length; k++) { float num7 = Mathf.Abs(num4 - bRIGHT_LEVELS[k]); if (num7 < num6) { num6 = num7; num5 = k; } } int num8 = ((dotData.CurveClass < num) ? dotData.CurveClass : (num - 1)); array[num5 * num + num8].Add(j); } bool flag = _dbgDotLogged; int num9 = 0; for (int l = 0; l < array.Length; l++) { if (array[l].Count == 0) { continue; } num9++; int num10 = l / num; int curveClass = l % num; float num11 = bRIGHT_LEVELS[num10]; Color col2 = new Color(Mathf.Clamp01(col.r * num11), Mathf.Clamp01(col.g * num11), Mathf.Clamp01(col.b * num11), col.a); int cohortId = BloodThermal.CurrentCohort(curveClass); BloodThermal.NoteSpawnPosition(cohortId, dots[array[l][0]].Pos); Material bloodMat = GetBloodMat(col2, cohortId); if (bloodMat == null) { continue; } int count = array[l].Count; for (int m = 0; m < count; m += 16383) { int num12 = Mathf.Min(16383, count - m); Vector3[] array2 = (Vector3[])(object)new Vector3[num12 * 4]; Vector2[] array3 = (Vector2[])(object)new Vector2[num12 * 4]; Vector3[] array4 = (Vector3[])(object)new Vector3[num12 * 4]; int[] array5 = new int[num12 * 6]; for (int n = 0; n < num12; n++) { DotData dotData2 = dots[array[l][m + n]]; Vector3 norm = dotData2.Norm; float r = dotData2.R; Vector3 elongDir = dotData2.ElongDir; Vector3 val = Vector3.Cross(norm, elongDir); if (((Vector3)(ref val)).sqrMagnitude < 0.001f) { Vector3 val2 = ((Mathf.Abs(Vector3.Dot(norm, Vector3.up)) > 0.9f) ? Vector3.forward : Vector3.up); val = Vector3.Cross(norm, val2); } ((Vector3)(ref val)).Normalize(); Vector3 val3 = elongDir * (r * dotData2.Elongation); Vector3 val4 = val * r; Vector3 val5 = dotData2.Pos + norm * 0.003f; Vector3 val6 = val5 - val3 - val4; Vector3 val7 = val5 + val3 - val4; Vector3 val8 = val5 + val3 + val4; Vector3 val9 = val5 - val3 + val4; if ((Object)(object)parent != (Object)null) { val6 = parent.InverseTransformPoint(val6); val7 = parent.InverseTransformPoint(val7); val8 = parent.InverseTransformPoint(val8); val9 = parent.InverseTransformPoint(val9); } int num13 = n * 4; array2[num13] = val6; array2[num13 + 1] = val7; array2[num13 + 2] = val8; array2[num13 + 3] = val9; array4[num13] = norm; array4[num13 + 1] = norm; array4[num13 + 2] = norm; array4[num13 + 3] = norm; array3[num13] = new Vector2(0f, 0f); array3[num13 + 1] = new Vector2(1f, 0f); array3[num13 + 2] = new Vector2(1f, 1f); array3[num13 + 3] = new Vector2(0f, 1f); int num14 = n * 6; array5[num14] = num13; array5[num14 + 1] = num13 + 2; array5[num14 + 2] = num13 + 3; array5[num14 + 3] = num13; array5[num14 + 4] = num13 + 1; array5[num14 + 5] = num13 + 2; } Mesh val10 = new Mesh(); val10.vertices = array2; val10.uv = array3; val10.normals = array4; val10.triangles = array5; val10.RecalculateBounds(); GameObject val11 = new GameObject("BD"); if ((Object)(object)parent != (Object)null) { val11.transform.SetParent(parent, false); } val11.AddComponent().mesh = val10; MeshRenderer obj = val11.AddComponent(); ((Renderer)obj).sharedMaterial = bloodMat; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).receiveShadows = false; Object.Destroy((Object)(object)val11, CfgLifetime.Value); TrackGO(val11, shotList); BloodThermal.RegisterRenderer((Renderer)(object)obj, cohortId, dots[array[l][m]].Pos); if (!flag) { flag = true; _dbgDotLogged = true; DotData dotData3 = dots[array[l][m]]; Vector3 val12 = (((Object)(object)parent != (Object)null) ? parent.TransformPoint(array2[0]) : array2[0]); ManualLogSource log = Log; string[] obj2 = new string[12] { "[BloodSystem] DBG dot[0] worldPos=", null, null, null, null, null, null, null, null, null, null, null }; Vector3 val13 = val12; obj2[1] = ((object)(*(Vector3*)(&val13))/*cast due to .constrained prefix*/).ToString(); obj2[2] = " r="; obj2[3] = dotData3.R.ToString(); obj2[4] = " norm="; val13 = dotData3.Norm; obj2[5] = ((object)(*(Vector3*)(&val13))/*cast due to .constrained prefix*/).ToString(); obj2[6] = " matShader="; obj2[7] = ((Object)bloodMat.shader).name; obj2[8] = " matColor="; obj2[9] = ((object)bloodMat.GetColor("_Color")/*cast due to .constrained prefix*/).ToString(); obj2[10] = " hasTex="; obj2[11] = (bloodMat.mainTexture != null).ToString(); log.LogInfo((object)string.Concat(obj2)); } } } BloodThermal.DebugNoteChunks(num9, dots.Count); } internal unsafe static Color GetSosigBloodColor(Sosig s) { //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) if (!_ngaChecked) { _ngaChecked = true; try { if (Chainloader.PluginInfos.TryGetValue("NGA.SosigIntegrityConfigs", out var value) && value.Instance != null) { BaseUnityPlugin instance = value.Instance; if (instance != null) { ConfigEntry val = default(ConfigEntry); if (instance.Config.TryGetEntry("Sosig Body.Colour", "Ketchup", ref val) && val.Value) { _ngaKetchup = true; ConfigEntry val2 = default(ConfigEntry); if (instance.Config.TryGetEntry("Sosig Body.Colour", "Mustard Colour", ref val2)) { Color val3 = default(Color); _ngaColor = (ColorUtility.TryParseHtmlString(val2.Value, ref val3) ? val3 : _mustardFallback); } else { _ngaColor = _mustardFallback; } } ManualLogSource log = Log; string text = _ngaKetchup.ToString(); Color ngaColor = _ngaColor; log.LogInfo((object)("[BloodSystem] NGA ketchup=" + text + " col=" + ((object)(*(Color*)(&ngaColor))/*cast due to .constrained prefix*/).ToString())); } } else { Log.LogInfo((object)"[BloodSystem] NGA SosigIntegrityConfigs not present."); } } catch (Exception ex) { Log.LogWarning((object)("[BloodSystem] NGA check: " + ex.Message)); } } string text2 = (CfgColorOverrideMode.Value ?? "").Replace(" ", ""); bool flag = text2 == "2"; bool flag2 = text2 == "1"; Color result = default(Color); if (flag && ColorUtility.TryParseHtmlString(CfgColorOverride.Value, ref result)) { return result; } if (_ngaKetchup) { return _ngaColor; } Color result2 = default(Color); if (flag2 && ColorUtility.TryParseHtmlString(CfgColorOverride.Value, ref result2)) { return result2; } return _mustardFallback; } internal static IEnumerator TagGibsDeferred(Vector3 pos, Sosig src) { //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) yield return null; Collider[] array = Physics.OverlapSphere(pos, 8f); foreach (Collider val in array) { if ((Object)(object)((Component)val).GetComponentInParent() != (Object)null) { continue; } Rigidbody attachedRigidbody = val.attachedRigidbody; if (!((Object)(object)attachedRigidbody == (Object)null)) { SosigGibTag sosigGibTag = ((Component)attachedRigidbody).GetComponent(); if ((Object)(object)sosigGibTag == (Object)null) { sosigGibTag = ((Component)attachedRigidbody).gameObject.AddComponent(); } sosigGibTag.SourceSosig = src; } } } internal static bool IsSourceSosig(Collider col, Sosig src) { if ((Object)(object)col == (Object)null) { return false; } if ((Object)(object)src == (Object)null) { return false; } SosigLink componentInParent = ((Component)col).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.S != (Object)null && (Object)(object)componentInParent.S == (Object)(object)src) { return true; } if (((Component)col).transform.IsChildOf(((Component)src).transform)) { return true; } Rigidbody attachedRigidbody = col.attachedRigidbody; if ((Object)(object)attachedRigidbody != (Object)null) { SosigGibTag component = ((Component)attachedRigidbody).GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)component.SourceSosig == (Object)(object)src) { return true; } } return false; } static BloodSystemPlugin() { //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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007b: 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) Vector3 val = new Vector3(0.5f, 0.5f, 0.707f); _tanLight = ((Vector3)(ref val)).normalized; BRIGHT_LEVELS = new float[10] { 0.6f, 0.644f, 0.689f, 0.733f, 0.778f, 0.822f, 0.867f, 0.911f, 0.956f, 1f }; _brightLevels = BRIGHT_LEVELS; _flyBuf = (Particle[])(object)new Particle[4000]; _flyMergeBuf = (Particle[])(object)new Particle[8000]; _rayBuf = (RaycastHit[])(object)new RaycastHit[64]; _rhCompare = default(RhByDist); } } public class SosigGibTag : MonoBehaviour { public Sosig SourceSosig; } public class SplatterTracker : MonoBehaviour { public Vector3 LastBulletDir; public float LastBulletSpeed = 400f; public Collider PrevCollider; public SosigLink PrevHitLink; public Vector3 LastSosigLinkPos; public Sosig LastSosig; public bool PendingBlood; public Vector3 PendingExitPt; public Vector3 PendingStrikeDir; public Sosig PendingSrc; public Color PendingCol; public Vector3 PendingEntryPt; public SosigLink PendingWoundLink; public bool IsPlayerShot; public float PendingBloodScale = 1f; } public class VanillaDripStainer : MonoBehaviour { private ParticleSystem _ps; private Particle[] _buf; private Sosig _sosig; private int _skip; private bool _useParticleColor; private bool _sprayMode; private int _maxRaycast = 8; public void SetSosig(Sosig s) { _sosig = s; } public void SetUseParticleColor() { _useParticleColor = true; } public void SetSprayMode() { _sprayMode = true; } public void SetMaxRaycast(int n) { _maxRaycast = n; } private void Start() { //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) _ps = ((Component)this).GetComponent(); if ((Object)(object)_sosig == (Object)null) { _sosig = ((Component)this).GetComponentInParent(); } if ((Object)(object)_ps != (Object)null) { MainModule main = _ps.main; _buf = (Particle[])(object)new Particle[Mathf.Max(((MainModule)(ref main)).maxParticles, 64)]; } } private void Update() { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_006e: Invalid comparison between Unknown and I4 //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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_0196: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_021b: 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_0225: 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_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: 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_0385: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_ps == (Object)null || _buf == null || ++_skip < 4) { return; } _skip = 0; int particles = _ps.GetParticles(_buf); if (particles == 0) { return; } int num = Mathf.Min(particles, _maxRaycast); MainModule main = _ps.main; bool flag = (int)((MainModule)(ref main)).simulationSpace == 0; bool flag2 = false; for (int i = 0; i < num; i++) { Vector3 val = (flag ? ((Component)_ps).transform.TransformPoint(((Particle)(ref _buf[i])).position) : ((Particle)(ref _buf[i])).position); Vector3 val2 = (flag ? ((Component)_ps).transform.TransformDirection(((Particle)(ref _buf[i])).velocity) : ((Particle)(ref _buf[i])).velocity); if (!_useParticleColor && ((Particle)(ref _buf[i])).remainingLifetime >= ((Particle)(ref _buf[i])).startLifetime * 0.97f) { float num2 = Random.Range(0f, (float)Math.PI * 2f); Vector3 val3 = new Vector3(Mathf.Cos(num2), 0f, Mathf.Sin(num2)) * Random.Range(0.1f, 0.35f); ((Particle)(ref _buf[i])).velocity = ((Particle)(ref _buf[i])).velocity + val3; flag2 = true; } RaycastHit val4 = default(RaycastHit); bool flag3 = false; float magnitude = ((Vector3)(ref val2)).magnitude; float num3 = (_sprayMode ? Mathf.Max(0.05f, magnitude * Time.deltaTime * 5f) : Mathf.Clamp(magnitude * Time.deltaTime * 3f, 0.04f, 0.08f)); if (magnitude > 0.05f && Physics.Raycast(val, val2 / magnitude, ref val4, num3)) { flag3 = true; } if (!flag3 && Physics.Raycast(val + Vector3.up * 0.02f, Vector3.down, ref val4, 0.04f)) { flag3 = true; } if (!flag3 && !_useParticleColor && ((Particle)(ref _buf[i])).remainingLifetime < ((Particle)(ref _buf[i])).startLifetime * 0.08f) { if (magnitude > 0.05f) { Physics.Raycast(val, val2 / magnitude, ref val4, 0.08f); } if (((RaycastHit)(ref val4)).collider == null) { Physics.Raycast(val + Vector3.up * 0.04f, Vector3.down, ref val4, 0.06f); } } if (((RaycastHit)(ref val4)).collider == null || (Object)(object)((RaycastHit)(ref val4)).collider.attachedRigidbody != (Object)null || (Object)(object)((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent() != (Object)null || (Object)(object)((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent() != (Object)null || ((Component)((RaycastHit)(ref val4)).collider).gameObject.layer == 5) { continue; } Color col = (_useParticleColor ? Color32.op_Implicit(((Particle)(ref _buf[i])).GetCurrentColor(_ps)) : BloodSystemPlugin.GetSosigBloodColor(_sosig)); if (_sprayMode) { float value = Random.value; if (value < 0.8f) { BloodSystemPlugin.SpawnSprayDot(((RaycastHit)(ref val4)).point, ((RaycastHit)(ref val4)).normal, col); } else if (value >= 0.9f) { BloodSystemPlugin.SpawnDripStainStreak(((RaycastHit)(ref val4)).point, val2, ((RaycastHit)(ref val4)).normal, col, null, sprayStreak: true); } } else { BloodSystemPlugin.SpawnDripStainStreak(((RaycastHit)(ref val4)).point, val2, ((RaycastHit)(ref val4)).normal, col); } ((Particle)(ref _buf[i])).remainingLifetime = 0f; flag2 = true; } if (flag2) { _ps.SetParticles(_buf, particles); } } } [HarmonyPatch] internal static class ThermalArmHook { private static bool Prepare() { return (object)AccessTools.TypeByName("PIPScope") != null; } private static MethodBase TargetMethod() { Type type = AccessTools.TypeByName("PIPScope"); if ((object)type == null) { return null; } return AccessTools.Method(type, "ApplyCameraShader", (Type[])null, (Type[])null); } private static void Postfix(Camera cam, bool isThermal) { if (isThermal) { BloodThermal.Arm(); BloodThermal.LogThermalDiagnostics(cam); } } } internal static class BloodSystemPatches { [HarmonyPatch] internal static class WfxDecalMaterialGrab { private static bool _grabbed; private static readonly string[] DecalTypeNames = new string[3] { "FistVR.ImpactDecal", "ImpactDecal", "WFX_BulletHoleDecal" }; private static readonly string[] DecalMethodNames = new string[4] { "Start", "Awake", "OnEnable", "SetHeat" }; private static Type FindDecalType() { for (int i = 0; i < DecalTypeNames.Length; i++) { Type type = AccessTools.TypeByName(DecalTypeNames[i]); if ((object)type != null) { return type; } } return null; } private static MethodBase FindDecalMethod() { Type type = FindDecalType(); if ((object)type == null) { return null; } for (int i = 0; i < DecalMethodNames.Length; i++) { MethodInfo methodInfo = AccessTools.Method(type, DecalMethodNames[i], (Type[])null, (Type[])null); if ((object)methodInfo != null) { return methodInfo; } } return null; } private static bool Prepare() { return false; } private static MethodBase TargetMethod() { return FindDecalMethod(); } private static void Postfix(Component __instance) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown if (_grabbed) { return; } if (BloodSystemPlugin._decalSourceMat != null) { _grabbed = true; return; } try { Renderer component = __instance.GetComponent(); if (component != null && component.sharedMaterial != null) { Material decalSourceMat = BloodSystemPlugin._decalSourceMat; string text = ((decalSourceMat == null) ? "none" : (((Object)decalSourceMat.shader).name + " RenderType=" + decalSourceMat.GetTag("RenderType", false, ""))); BloodSystemPlugin._decalSourceMat = new Material(component.sharedMaterial); BloodSystemPlugin._decalSourceMat.SetInt("_Cull", 0); BloodSystemPlugin._decalSourceSearched = true; BloodSystemPlugin._matCache.Clear(); BloodSystemPlugin._dripMatCache.Clear(); _grabbed = true; BloodSystemPlugin.Log.LogInfo((object)("[BloodSystem] WFX mat grabbed on decal Start: " + ((Object)component.sharedMaterial.shader).name + " RenderType=" + component.sharedMaterial.GetTag("RenderType", false, "") + " (replaced: " + text + ")")); } } catch (Exception ex) { BloodSystemPlugin.Log.LogWarning((object)("[BloodSystem] WFxDecalGrab: " + ex.Message)); } } } [HarmonyPatch] internal static class OnslaughtNaturalDeathPatch { private static bool Prepare() { return (object)AccessTools.TypeByName("localpcnerd.OnslaughtMode.OnslaughtManager") != null; } private static MethodBase TargetMethod() { Type type = AccessTools.TypeByName("localpcnerd.OnslaughtMode.OnslaughtManager"); if ((object)type == null) { return null; } return AccessTools.Method(type, "Update", (Type[])null, (Type[])null); } private static void Prefix(object __instance) { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Invalid comparison between Unknown and I4 try { Type type = __instance.GetType(); FieldInfo fieldInfo = AccessTools.Field(type, "spawnedSosigs"); IList list = (((object)fieldInfo != null) ? (fieldInfo.GetValue(__instance) as IList) : null); if (list == null) { return; } FieldInfo fieldInfo2 = AccessTools.Field(type, "kills"); int num = (((object)fieldInfo2 != null) ? ((int)fieldInfo2.GetValue(__instance)) : 0); Type type2 = null; FieldInfo fieldInfo3 = null; for (int num2 = list.Count - 1; num2 >= 0; num2--) { object obj = list[num2]; if (obj == null) { list.RemoveAt(num2); } else { if ((object)type2 == null) { type2 = obj.GetType(); fieldInfo3 = AccessTools.Field(type2, "sosig"); } if ((object)fieldInfo3 != null) { object? value = fieldInfo3.GetValue(obj); Sosig val = (Sosig)((value is Sosig) ? value : null); if ((Object)(object)val == (Object)null) { list.RemoveAt(num2); } else if ((int)val.BodyState == 3) { val.TickDownToClear(3f); list.RemoveAt(num2); num++; } } } } fieldInfo2?.SetValue(__instance, num); } catch (Exception ex) { BloodSystemPlugin.Log.LogWarning((object)("[BloodSystem] OnslaughtNaturalDeath: " + ex.Message)); } } } private static bool _bloodFiredOnce; private static readonly FieldInfo FLastColliderHit = typeof(BallisticProjectile).GetField("m_lastColliderHit", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo FVelocity = typeof(BallisticProjectile).GetField("m_velocity", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo FHit = typeof(BallisticProjectile).GetField("m_hit", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo FBleedingEvents = typeof(Sosig).GetField("m_bleedingEvents", BindingFlags.Instance | BindingFlags.NonPublic); private static readonly FieldInfo FPlayerIFF = typeof(FVRPlayerBody).GetField("m_playerIFF", BindingFlags.Instance | BindingFlags.NonPublic); private static int _playerIFF = -1; private static readonly Dictionary _strikeDir = new Dictionary(); private static readonly Dictionary _strikeSpeed = new Dictionary(); private static SplatterTracker _activeBulletTracker; private static bool _sosigStartLoggedOnce; private static bool _dbgDamageClassLogged; internal static bool Ok { get { if ((object)FLastColliderHit != null && (object)FVelocity != null) { return (object)FHit != null; } return false; } } internal static bool IsPlayerBullet(BallisticProjectile bp) { if (_playerIFF < 0) { if ((Object)(object)GM.CurrentPlayerBody == (Object)null || (object)FPlayerIFF == null) { return true; } try { _playerIFF = (int)FPlayerIFF.GetValue(GM.CurrentPlayerBody); } catch { return true; } } return bp.Source_IFF == _playerIFF; } [HarmonyPatch(typeof(Sosig), "Start")] [HarmonyPostfix] private static void OnSosigStart(Sosig __instance) { try { if (BloodSystemPlugin._decalSourceMat == null && !BloodSystemPlugin._alloyGrabPending) { ((MonoBehaviour)BloodSystemPlugin._instance).StartCoroutine(BloodSystemPlugin.TryGrabAlloyFromScene()); } } catch (Exception ex) { BloodSystemPlugin.Log.LogWarning((object)("[BloodSystem] SosigStart: " + ex.Message)); } } [HarmonyPatch(typeof(Sosig), "BleedingUpdate")] [HarmonyPostfix] private static void OnBleedingUpdate(Sosig __instance) { if ((object)FBleedingEvents == null || !BloodSystemPlugin.CfgEnabled.Value || !BloodSystemPlugin.CfgVanillaStainEnabled.Value) { return; } try { if (!(FBleedingEvents.GetValue(__instance) is List { Count: not 0 } list)) { return; } for (int i = 0; i < list.Count; i++) { BleedingEvent val = list[i]; if (val != null && !((Object)(object)val.m_system == (Object)null) && !((Object)(object)((Component)val.m_system).GetComponent() != (Object)null)) { VanillaDripStainer vanillaDripStainer = ((Component)val.m_system).gameObject.AddComponent(); vanillaDripStainer.SetSosig(__instance); vanillaDripStainer.SetMaxRaycast(8); } } } catch { } } [HarmonyPatch(typeof(BallisticProjectile), "MoveBullet", new Type[] { typeof(float) })] [HarmonyPrefix] private static void PreMove(BallisticProjectile __instance) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (Ok) { SplatterTracker splatterTracker = ((Component)__instance).GetComponent(); if ((Object)(object)splatterTracker == (Object)null) { splatterTracker = ((Component)__instance).gameObject.AddComponent(); } splatterTracker.PendingBlood = false; splatterTracker.IsPlayerShot = IsPlayerBullet(__instance); _activeBulletTracker = (splatterTracker.IsPlayerShot ? splatterTracker : null); ref Collider prevCollider = ref splatterTracker.PrevCollider; object? value = FLastColliderHit.GetValue(__instance); prevCollider = (Collider)((value is Collider) ? value : null); Vector3 val = (Vector3)FVelocity.GetValue(__instance); if (((Vector3)(ref val)).magnitude > 0.01f) { splatterTracker.LastBulletDir = ((Vector3)(ref val)).normalized; splatterTracker.LastBulletSpeed = ((Vector3)(ref val)).magnitude; } } } [HarmonyPatch(typeof(BallisticProjectile), "MoveBullet", new Type[] { typeof(float) })] [HarmonyPostfix] private unsafe static void PostMove(BallisticProjectile __instance) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_0155: 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_0141: 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_014d: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: 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_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0241: 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_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0261: 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) _activeBulletTracker = null; if (!Ok) { return; } SplatterTracker component = ((Component)__instance).GetComponent(); if ((Object)(object)component == (Object)null) { return; } object? value = FLastColliderHit.GetValue(__instance); Collider val = (Collider)((value is Collider) ? value : null); if (val != component.PrevCollider && val != null && (Object)(object)val != (Object)null && component.IsPlayerShot) { SosigLink componentInParent = ((Component)val).GetComponentInParent(); Sosig val2 = (((Object)(object)componentInParent != (Object)null) ? componentInParent.S : ((Component)val).GetComponentInParent()); if (!((Object)(object)val2 == (Object)null)) { RaycastHit val3 = (RaycastHit)FHit.GetValue(__instance); float num = Vector3.Dot(((Component)__instance).transform.position - ((RaycastHit)(ref val3)).point, ((RaycastHit)(ref val3)).normal); if (!(num >= 0f)) { Vector3 val4 = ((((Vector3)(ref component.LastBulletDir)).sqrMagnitude > 0.01f) ? component.LastBulletDir : ((Component)__instance).transform.forward); float bulletSpeed = ((component.LastBulletSpeed > 1f) ? component.LastBulletSpeed : 400f); Sosig val5 = val2; Color sosigBloodColor = BloodSystemPlugin.GetSosigBloodColor(val5); bool pendingBlood = component.PendingBlood; Vector3 pos = (pendingBlood ? component.PendingEntryPt : ((RaycastHit)(ref val3)).point); Vector3 val6 = (pendingBlood ? component.PendingExitPt : (((RaycastHit)(ref val3)).point + val4 * 0.35f)); float num2 = (pendingBlood ? component.PendingBloodScale : 1f); component.PendingBlood = false; component.PendingBloodScale = 1f; if (!_bloodFiredOnce) { _bloodFiredOnce = true; ManualLogSource log = BloodSystemPlugin.Log; string[] obj = new string[6] { "[BloodSystem] First blood (dot=", num.ToString("F2"), ") exitPt=", null, null, null }; Vector3 val7 = val6; obj[3] = ((object)(*(Vector3*)(&val7))/*cast due to .constrained prefix*/).ToString(); obj[4] = " vel="; obj[5] = bulletSpeed.ToString("F0"); log.LogInfo((object)string.Concat(obj)); } List shotList = BloodSystemPlugin.StartShotGroup(); BloodSystemPlugin.SpawnProjection(val6, val4, val5, bulletSpeed, gib: false, shotList, num2); Transform follow = ((pendingBlood && (Object)(object)component.PendingWoundLink != (Object)null) ? ((Component)component.PendingWoundLink).transform : null); BloodSystemPlugin.SpawnBloodSpray(val6, val4, sosigBloodColor, explode: false, 1f, num2, follow); BloodSystemPlugin.SpawnBloodDrops(val6, val4, sosigBloodColor, Mathf.Max(1, Mathf.RoundToInt(10f * num2)), shotList); BloodSystemPlugin.SpawnBloodDrops(pos, -val4, sosigBloodColor, Mathf.Max(1, Mathf.RoundToInt(8f * num2)), shotList); } } } if (BloodSystemPlugin._decalSourceMat == null && !BloodSystemPlugin._alloyGrabPending && val != null && (Object)(object)val != (Object)null && (Object)(object)val.attachedRigidbody == (Object)null && (Object)(object)((Component)val).GetComponentInParent() == (Object)null) { ((MonoBehaviour)BloodSystemPlugin._instance).StartCoroutine(BloodSystemPlugin.TryGrabAlloyFromScene()); } } [HarmonyPatch(typeof(SosigLink), "Damage")] [HarmonyPostfix] private unsafe static void OnSosigLinkDamage(SosigLink __instance, Damage d) { //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: 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_0096: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: 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_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: 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_0141: 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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0260: 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_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) try { if (!BloodSystemPlugin.CfgEnabled.Value || _activeBulletTracker == null) { return; } Vector3 val; if (!_dbgDamageClassLogged) { _dbgDamageClassLogged = true; ManualLogSource log = BloodSystemPlugin.Log; string[] obj = new string[10] { "[BloodSystem] SosigLink.Damage class=", ((object)Unsafe.As(ref d.Class)/*cast due to .constrained prefix*/).ToString(), " kinetic=", d.Dam_TotalKinetic.ToString(), " strikeDir=", null, null, null, null, null }; val = d.strikeDir; obj[5] = ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString(); obj[6] = " sourcePoint="; val = d.Source_Point; obj[7] = ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString(); obj[8] = " point="; val = d.point; obj[9] = ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString(); log.LogInfo((object)string.Concat(obj)); } Vector3 val2; if (((Vector3)(ref d.strikeDir)).sqrMagnitude > 0.001f) { val2 = ((Vector3)(ref d.strikeDir)).normalized; } else if (((Vector3)(ref _activeBulletTracker.LastBulletDir)).sqrMagnitude > 0.001f) { val2 = _activeBulletTracker.LastBulletDir; } else { val = d.point - d.Source_Point; if (((Vector3)(ref val)).sqrMagnitude > 0.001f) { val = d.point - d.Source_Point; val2 = ((Vector3)(ref val)).normalized; } else { val2 = Vector3.forward; } } _strikeDir[__instance] = val2; _strikeSpeed[__instance] = _activeBulletTracker.LastBulletSpeed; Sosig s = __instance.S; Color sosigBloodColor = BloodSystemPlugin.GetSosigBloodColor(s); Vector3 val3 = d.point + val2 * 0.35f; RaycastHit val4 = default(RaycastHit); if (Physics.Raycast(d.point, val2, ref val4, 2f)) { SosigLink componentInParent = ((Component)((RaycastHit)(ref val4)).collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && componentInParent.S == __instance.S) { val3 = ((RaycastHit)(ref val4)).point + val2 * 0.02f; } } Vector3 val5 = d.point + Vector3.up * 0.35f; val = val3 - val5; float num = ((Vector3)(ref val)).magnitude + 0.1f; int num2 = Physics.RaycastNonAlloc(val5, val2, BloodSystemPlugin._rayBuf, num); Array.Sort(BloodSystemPlugin._rayBuf, 0, num2, BloodSystemPlugin._rhCompare); for (int i = 0; i < num2; i++) { RaycastHit val6 = BloodSystemPlugin._rayBuf[i]; if (!((Object)(object)((Component)((RaycastHit)(ref val6)).collider).GetComponentInParent() != (Object)null) && !((Object)(object)((RaycastHit)(ref val6)).collider.attachedRigidbody != (Object)null) && !(((RaycastHit)(ref val6)).normal.y < 0.5f)) { val3 = ((RaycastHit)(ref val6)).point + ((RaycastHit)(ref val6)).normal * 0.05f; break; } } if (!BloodSystemPlugin._dbgDecalLogged) { BloodSystemPlugin._dbgDecalLogged = true; try { StringBuilder stringBuilder = new StringBuilder("[BloodSystem] DBG decal types: "); HashSet hashSet = new HashSet(); MonoBehaviour[] array = Object.FindObjectsOfType(); foreach (MonoBehaviour val7 in array) { if (!((Object)(object)val7 == (Object)null)) { string name = ((object)val7).GetType().Name; if ((name.IndexOf("Decal", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Hole", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("WFX", StringComparison.OrdinalIgnoreCase) >= 0) && hashSet.Add(name)) { stringBuilder.Append(name).Append(' '); } } } BloodSystemPlugin.Log.LogInfo((object)stringBuilder.ToString()); } catch { } } float externalBloodScale = BloodSystemPlugin.ExternalBloodScale; BloodSystemPlugin.ExternalBloodScale = 1f; SplatterTracker activeBulletTracker = _activeBulletTracker; activeBulletTracker.PendingBlood = true; activeBulletTracker.PendingExitPt = val3; activeBulletTracker.PendingStrikeDir = val2; activeBulletTracker.PendingSrc = s; activeBulletTracker.PendingCol = sosigBloodColor; activeBulletTracker.PendingEntryPt = d.point; activeBulletTracker.PendingWoundLink = __instance; activeBulletTracker.PendingBloodScale = externalBloodScale; } catch (Exception ex) { BloodSystemPlugin.Log.LogWarning((object)("[BloodSystem] OnSosigLinkDamage: " + ex.Message)); } } [HarmonyPatch(typeof(SosigLink), "LinkExplodes")] [HarmonyPostfix] private unsafe static void OnLinkExplodes(SosigLink __instance, DamageClass damClass) { //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_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_006a: 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_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Invalid comparison between Unknown and I4 //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_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0174: 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_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) try { if (!BloodSystemPlugin.CfgEnabled.Value || (Object)(object)__instance == (Object)null) { return; } Vector3 position = ((Component)__instance).transform.position; Sosig s = __instance.S; if ((s == null || !((Object)(object)((Component)s).GetComponent("HumanMarker") != (Object)null) || BloodSystemPlugin.CfgSplashOnHumans.Value) && (int)damClass != 0) { Color sosigBloodColor = BloodSystemPlugin.GetSosigBloodColor(s); bool flag = true; if (!_strikeDir.TryGetValue(__instance, out var value) || ((Vector3)(ref value)).sqrMagnitude < 0.001f) { value = Vector3.up; } _strikeDir.Remove(__instance); if (!_strikeSpeed.TryGetValue(__instance, out var value2)) { value2 = 300f; } _strikeSpeed.Remove(__instance); float bulletSpeed = 400f; float speedScale = Mathf.Clamp(value2 / 300f, 0.5f, 2.5f); if (!_bloodFiredOnce) { _bloodFiredOnce = true; ManualLogSource log = BloodSystemPlugin.Log; string[] obj = new string[6] { "[BloodSystem] First blood via LinkExplodes gib pos=", null, null, null, null, null }; Vector3 val = position; obj[1] = ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString(); obj[2] = " entrySpd="; obj[3] = value2.ToString("F0"); obj[4] = " scale="; obj[5] = speedScale.ToString("F2"); log.LogInfo((object)string.Concat(obj)); } float rayCountScale = (((int)damClass == 2) ? 0.2f : 1f); List shotList = BloodSystemPlugin.StartShotGroup(); BloodSystemPlugin.SpawnProjection(position, value, s, bulletSpeed, flag, shotList, rayCountScale); BloodSystemPlugin.SpawnBloodSpray(position, value, sosigBloodColor, flag, speedScale); BloodSystemPlugin.SpawnBloodDrops(position, value, sosigBloodColor, 10, shotList); if (s != null) { ((MonoBehaviour)BloodSystemPlugin._instance).StartCoroutine(BloodSystemPlugin.TagGibsDeferred(position, s)); } } } catch (Exception ex) { BloodSystemPlugin.Log.LogWarning((object)("[BloodSystem] OnLinkExplodes: " + ex.Message)); } } }