using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("FreshPolakke_BloodMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FreshPolakke_BloodMod")]
[assembly: AssemblyTitle("FreshPolakke_BloodMod")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace FreshPolakke_BloodMod
{
[BepInPlugin("FreshPolakke_BloodMod", "Blood Mod", "1.1.0")]
public class BloodPlugin : BaseUnityPlugin
{
private sealed class PlayerState
{
public float lastHealth;
public bool dead;
}
private sealed class PendingSplat
{
public float time;
public Vector3 point;
public Vector3 normal;
public float size;
public Transform parent;
public Vector3 stretch;
public bool puddle;
public float growTime;
}
private sealed class SplatRecord
{
public Transform transform;
public MeshRenderer renderer;
public float size;
public float aspect;
public float born;
public float growTime;
public MeshFilter filter;
}
private sealed class PendingBlood
{
public float due;
public Component player;
public float damage;
public bool bypass;
}
private sealed class HitInfo
{
public Vector3 toSource;
public float time;
}
internal static ManualLogSource Log;
internal static BloodPlugin Instance;
private ConfigEntry<bool> enabled;
private ConfigEntry<float> intensity;
private ConfigEntry<float> minDamage;
private ConfigEntry<int> maxParticles;
private ConfigEntry<float> heightOffset;
private ConfigEntry<bool> deathBurst;
private ConfigEntry<float> sizeMultiplier;
private ConfigEntry<bool> collisionEnabled;
private ConfigEntry<bool> localInFront;
private ConfigEntry<bool> sprayTowardsAttacker;
private ConfigEntry<bool> floorBlood;
private ConfigEntry<int> maxSplats;
private ConfigEntry<float> splatLifetime;
private ConfigEntry<float> splatSize;
private ConfigEntry<bool> puddles;
private ConfigEntry<float> puddleSize;
private ConfigEntry<bool> verboseLogging;
private ConfigEntry<bool> dumpMembers;
private const float PollInterval = 0.05f;
private const float RefreshInterval = 1f;
private const int MaxSystems = 12;
private static readonly Color BloodDark = new Color(0.35f, 0f, 0f, 1f);
private static readonly Color BloodLight = new Color(0.75f, 0.02f, 0.02f, 1f);
private static readonly Color SplatDark = new Color(0.22f, 0f, 0f, 1f);
private static readonly Color SplatLight = new Color(0.5f, 0.01f, 0.01f, 1f);
private static readonly Color PuddleDark = new Color(0.16f, 0f, 0f, 1f);
private static readonly Color PuddleLight = new Color(0.34f, 0f, 0f, 1f);
private static readonly string[] HealthPaths = new string[3] { "data.health", "health", "Health" };
private static readonly string[] DeadPaths = new string[4] { "data.dead", "dead", "isDead", "IsDead" };
private static readonly string[] ShaderNames = new string[4] { "Universal Render Pipeline/Lit", "Universal Render Pipeline/Simple Lit", "Sprites/Default", "Universal Render Pipeline/Unlit" };
private Type playerType;
private readonly List<Component> players = new List<Component>();
private readonly Dictionary<int, PlayerState> states = new Dictionary<int, PlayerState>();
private string healthPath;
private string deadPath;
private bool warnedNoHealth;
private float nextPoll;
private float nextRefresh;
private float nextTypeSearch;
private Transform poolRoot;
private readonly List<ParticleSystem> pool = new List<ParticleSystem>();
private int reuseIndex;
private Material bloodMaterial;
private Mesh chunkMesh;
private MaterialPropertyBlock propertyBlock;
private Transform decalRoot;
private readonly List<Mesh> blobMeshes = new List<Mesh>();
private readonly List<PendingSplat> pending = new List<PendingSplat>();
private readonly List<SplatRecord> splats = new List<SplatRecord>();
private int splatCounter;
private int puddleCounter;
private readonly List<SplatRecord> growing = new List<SplatRecord>();
private readonly List<Mesh> puddleMeshes = new List<Mesh>();
private readonly List<PendingBlood> pendingBlood = new List<PendingBlood>();
private static readonly Dictionary<int, HitInfo> hits = new Dictionary<int, HitInfo>();
private bool patched;
private readonly Dictionary<int, float> lastSpawn = new Dictionary<int, float>();
private const BindingFlags Flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
private static readonly Dictionary<string, MemberInfo> memberCache = new Dictionary<string, MemberInfo>();
private static void Dbg(string message)
{
if ((Object)(object)Instance != (Object)null && Instance.verboseLogging != null && Instance.verboseLogging.Value)
{
Log.LogInfo((object)message);
}
}
private void Awake()
{
//IL_0286: Unknown result type (might be due to invalid IL or missing references)
//IL_0290: Expected O, but got Unknown
//IL_0295: Unknown result type (might be due to invalid IL or missing references)
//IL_029b: Expected O, but got Unknown
//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
//IL_02b9: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Instance = this;
enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable or disable the blood effect.");
intensity = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Intensity", 1f, "Multiplier for the amount of blood (0 = off).");
minDamage = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MinDamage", 1f, "Minimum damage that triggers blood.");
maxParticles = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxParticlesPerHit", 120, "Maximum number of blood chunks per hit.");
heightOffset = ((BaseUnityPlugin)this).Config.Bind<float>("General", "HeightOffset", 1.2f, "Fallback height above the player origin where blood spawns.");
deathBurst = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DeathBurst", true, "Extra blood burst on death.");
sizeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SizeMultiplier", 1f, "Size of the blood chunks.");
collisionEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ParticleCollision", true, "Blood chunks bounce off the map.");
localInFront = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "LocalBloodInFront", true, "When you take damage, blood spawns near your camera.");
sprayTowardsAttacker = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SprayTowardsAttacker", true, "Blood sprays towards the side the damage came from. Off = blood sprays in the direction of the hit.");
floorBlood = ((BaseUnityPlugin)this).Config.Bind<bool>("Floor", "FloorBlood", true, "Leave blood splats on floors and walls.");
maxSplats = ((BaseUnityPlugin)this).Config.Bind<int>("Floor", "MaxBloodSplats", 400, "Maximum number of blood splats at once.");
splatLifetime = ((BaseUnityPlugin)this).Config.Bind<float>("Floor", "SplatLifetimeMinutes", 15f, "How long blood splats stay, in minutes (0 = forever).");
splatSize = ((BaseUnityPlugin)this).Config.Bind<float>("Floor", "SplatSize", 1f, "Size of the blood splats.");
puddles = ((BaseUnityPlugin)this).Config.Bind<bool>("Floor", "BloodPuddles", true, "Leave large blood puddles on the floor that grow over a few seconds.");
puddleSize = ((BaseUnityPlugin)this).Config.Bind<float>("Floor", "PuddleSize", 1f, "Size of the blood puddles.");
verboseLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "VerboseLogging", false, "Log every blood effect and internal details (for troubleshooting).");
dumpMembers = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "DumpPlayerMembers", false, "Write all fields of the Player class to the log once (for troubleshooting).");
propertyBlock = new MaterialPropertyBlock();
GameObject val = new GameObject("BloodPool");
Object.DontDestroyOnLoad((Object)(object)val);
poolRoot = val.transform;
GameObject val2 = new GameObject("BloodDecals");
Object.DontDestroyOnLoad((Object)(object)val2);
decalRoot = val2.transform;
SceneManager.sceneLoaded += OnSceneLoaded;
Log.LogInfo((object)"Blood Mod loaded.");
}
private void OnDestroy()
{
Instance = null;
SceneManager.sceneLoaded -= OnSceneLoaded;
ClearSplats();
if ((Object)(object)decalRoot != (Object)null)
{
Object.Destroy((Object)(object)((Component)decalRoot).gameObject);
}
if ((Object)(object)poolRoot != (Object)null)
{
Object.Destroy((Object)(object)((Component)poolRoot).gameObject);
}
if ((Object)(object)bloodMaterial != (Object)null)
{
Object.Destroy((Object)(object)bloodMaterial);
}
if ((Object)(object)chunkMesh != (Object)null)
{
Object.Destroy((Object)(object)chunkMesh);
}
foreach (Mesh blobMesh in blobMeshes)
{
if ((Object)(object)blobMesh != (Object)null)
{
Object.Destroy((Object)(object)blobMesh);
}
}
foreach (Mesh puddleMesh in puddleMeshes)
{
if ((Object)(object)puddleMesh != (Object)null)
{
Object.Destroy((Object)(object)puddleMesh);
}
}
}
private void Update()
{
UpdateSplats();
if (!enabled.Value)
{
return;
}
ProcessBlood();
float unscaledTime = Time.unscaledTime;
if (unscaledTime < nextPoll)
{
return;
}
nextPoll = unscaledTime + 0.05f;
if (playerType == null)
{
if (unscaledTime < nextTypeSearch)
{
return;
}
nextTypeSearch = unscaledTime + 5f;
playerType = FindPlayerType();
if (playerType == null)
{
return;
}
Dbg("Player type found: " + playerType.FullName);
PatchPlayer();
}
if (unscaledTime >= nextRefresh)
{
nextRefresh = unscaledTime + 1f;
RefreshPlayers();
}
PollPlayers();
}
private static Type FindPlayerType()
{
Type type = null;
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
Type type2 = assembly.GetType("Player");
if (!(type2 == null) && typeof(Component).IsAssignableFrom(type2))
{
if (assembly.GetName().Name == "Assembly-CSharp")
{
return type2;
}
if (type == null)
{
type = type2;
}
}
}
return type;
}
private void RefreshPlayers()
{
players.Clear();
Object[] array = Object.FindObjectsOfType(playerType);
HashSet<int> hashSet = new HashSet<int>();
Object[] array2 = array;
foreach (Object val in array2)
{
Component val2 = (Component)(object)((val is Component) ? val : null);
if (!((Object)(object)val2 == (Object)null))
{
players.Add(val2);
hashSet.Add(((Object)val2).GetInstanceID());
}
}
List<int> list = new List<int>();
foreach (int key in states.Keys)
{
if (!hashSet.Contains(key))
{
list.Add(key);
}
}
foreach (int item in list)
{
states.Remove(item);
lastSpawn.Remove(item);
}
if (list.Count > 0)
{
Dbg("Removed " + list.Count + " stale player entries.");
}
List<int> list2 = new List<int>();
foreach (KeyValuePair<int, HitInfo> hit in hits)
{
if (Time.unscaledTime - hit.Value.time > 5f)
{
list2.Add(hit.Key);
}
}
foreach (int item2 in list2)
{
hits.Remove(item2);
}
if (dumpMembers.Value && players.Count > 0)
{
DumpMembers(players[0], "Player");
object obj = ReadPath(players[0], "data");
if (obj != null)
{
DumpMembers(obj, "Player.data");
}
dumpMembers.Value = false;
}
}
private void PollPlayers()
{
foreach (Component player in players)
{
if ((Object)(object)player == (Object)null)
{
continue;
}
if (!TryReadHealth(player, out var health))
{
if (!warnedNoHealth)
{
warnedNoHealth = true;
Log.LogWarning((object)"Could not read player health. Set [Debug] DumpPlayerMembers = true in the config and check the log.");
}
continue;
}
bool flag = ReadDead(player);
int instanceID = ((Object)player).GetInstanceID();
if (!states.TryGetValue(instanceID, out PlayerState value))
{
states[instanceID] = new PlayerState
{
lastHealth = health,
dead = flag
};
continue;
}
float num = value.lastHealth - health;
if (flag && !value.dead && deathBurst.Value)
{
QueueBlood(player, Mathf.Max(num, 20f) * 1.5f, 0.15f, bypass: true);
}
else if (num >= minDamage.Value)
{
QueueBlood(player, num, 0.15f, bypass: false);
}
value.lastHealth = health;
value.dead = flag;
}
}
private bool IsLocal(Component p)
{
if (playerType == null)
{
return false;
}
try
{
object obj = null;
FieldInfo field = playerType.GetField("localPlayer", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null)
{
obj = field.GetValue(null);
}
if (obj == null)
{
PropertyInfo property = playerType.GetProperty("localPlayer", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
if (property != null)
{
obj = property.GetValue(null, null);
}
}
Component val = (Component)((obj is Component) ? obj : null);
return (Object)(object)val != (Object)null && (Object)(object)val == (Object)(object)p;
}
catch
{
return false;
}
}
private Vector3 BodyPosition(Component p)
{
//IL_0005: 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_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_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_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: 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_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
bool flag = false;
Bounds val = default(Bounds);
Renderer[] componentsInChildren = p.GetComponentsInChildren<Renderer>();
foreach (Renderer val2 in componentsInChildren)
{
if (!((Object)(object)val2 == (Object)null) && !(val2 is ParticleSystemRenderer))
{
if (!flag)
{
val = val2.bounds;
flag = true;
}
else
{
((Bounds)(ref val)).Encapsulate(val2.bounds);
}
}
}
if (flag)
{
Vector3 size = ((Bounds)(ref val)).size;
if (((Vector3)(ref size)).sqrMagnitude > 0.0001f)
{
size = ((Bounds)(ref val)).size;
if (((Vector3)(ref size)).magnitude < 10f)
{
return ((Bounds)(ref val)).center;
}
}
}
return p.transform.position + Vector3.up * heightOffset.Value;
}
private Vector3 GetSpawnPosition(Component p, Vector3 spray, bool hasDir)
{
//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_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: 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_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: 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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
Camera main = Camera.main;
if (localInFront.Value && (Object)(object)main != (Object)null && IsLocal(p))
{
Vector3 val = (hasDir ? spray : ((Component)main).transform.forward);
return ((Component)main).transform.position + val * 0.8f + Vector3.down * 0.15f;
}
Vector3 val2 = BodyPosition(p);
return hasDir ? (val2 + spray * 0.25f) : val2;
}
internal static void RecordHit(object instance, Vector3 force, bool hasPos, Vector3 pos)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: 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_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: 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_0072: 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)
Component val = (Component)((instance is Component) ? instance : null);
if ((Object)(object)val == (Object)null)
{
return;
}
Vector3 toSource = Vector3.zero;
if (((Vector3)(ref force)).sqrMagnitude > 0.0001f)
{
toSource = -((Vector3)(ref force)).normalized;
}
else if (hasPos)
{
Vector3 val2 = pos - val.transform.position;
if (((Vector3)(ref val2)).sqrMagnitude > 0.0001f)
{
toSource = ((Vector3)(ref val2)).normalized;
}
}
if (!(((Vector3)(ref toSource)).sqrMagnitude < 0.5f))
{
hits[((Object)val).GetInstanceID()] = new HitInfo
{
toSource = toSource,
time = Time.unscaledTime
};
}
}
internal static void PostfixForce(object __instance, float damage, Vector3 force)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
RecordHit(__instance, force, hasPos: false, Vector3.zero);
NotifyDamage(__instance, damage);
}
internal static void PostfixForcePos(object __instance, float damage, Vector3 force, Vector3 pos)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
RecordHit(__instance, force, hasPos: true, pos);
NotifyDamage(__instance, damage);
}
private static void NotifyDamage(object instance, float damage)
{
Component val = (Component)((instance is Component) ? instance : null);
if ((Object)(object)val != (Object)null && (Object)(object)Instance != (Object)null)
{
Instance.OnDamage(val, damage);
}
}
internal void OnDamage(Component victim, float damage)
{
if (enabled.Value && !(damage < minDamage.Value))
{
QueueBlood(victim, damage, 0f, bypass: false);
}
}
private void PatchPlayer()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
if (!patched && !(playerType == null))
{
patched = true;
Harmony harmony = new Harmony("FreshPolakke_BloodMod");
PatchMethod(harmony, "CallTakeDamageAndAddForceAndFall", "PostfixForce");
PatchMethod(harmony, "CallTakeDamageAndAddForceAndFallWithFallof", "PostfixForcePos");
PatchMethod(harmony, "RPCA_TakeDamageAndAddForceFallWithFallof", "PostfixForcePos");
}
}
private void PatchMethod(Harmony harmony, string methodName, string postfixName)
{
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Expected O, but got Unknown
try
{
MethodInfo methodInfo = null;
MethodInfo[] methods = playerType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
foreach (MethodInfo methodInfo2 in methods)
{
if (methodInfo2.Name == methodName)
{
methodInfo = methodInfo2;
break;
}
}
if (methodInfo == null)
{
Log.LogWarning((object)("Method not found: " + methodName + " (hit direction may be unavailable)."));
return;
}
MethodInfo method = typeof(BloodPlugin).GetMethod(postfixName, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(method), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Dbg("Hit direction hooked via: " + methodName);
}
catch (Exception ex)
{
Log.LogWarning((object)("Patch failed (" + methodName + "): " + ex.Message));
}
}
private bool TryGetHit(Component p, out Vector3 toSource)
{
//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_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)
toSource = Vector3.zero;
if (!hits.TryGetValue(((Object)p).GetInstanceID(), out HitInfo value))
{
return false;
}
if (Time.unscaledTime - value.time > 1f)
{
return false;
}
toSource = value.toSource;
return true;
}
private void QueueBlood(Component p, float damage, float delay, bool bypass)
{
pendingBlood.Add(new PendingBlood
{
due = Time.unscaledTime + delay,
player = p,
damage = damage,
bypass = bypass
});
}
private void ProcessBlood()
{
for (int num = this.pendingBlood.Count - 1; num >= 0; num--)
{
PendingBlood pendingBlood = this.pendingBlood[num];
if (!(Time.unscaledTime < pendingBlood.due))
{
this.pendingBlood.RemoveAt(num);
if (!((Object)(object)pendingBlood.player == (Object)null))
{
EmitBlood(pendingBlood.player, pendingBlood.damage, pendingBlood.bypass);
}
}
}
}
private void EmitBlood(Component p, float damage, bool bypass)
{
//IL_0050: 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_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)
//IL_0083: 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_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: 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)
int instanceID = ((Object)p).GetInstanceID();
if (bypass || !lastSpawn.TryGetValue(instanceID, out var value) || !(Time.unscaledTime - value < 0.3f))
{
lastSpawn[instanceID] = Time.unscaledTime;
Vector3 toSource;
bool flag = TryGetHit(p, out toSource);
Vector3 spray = Vector3.zero;
if (flag)
{
spray = (sprayTowardsAttacker.Value ? toSource : (-toSource));
}
Vector3 spawnPosition = GetSpawnPosition(p, spray, flag);
SpawnBlood(spawnPosition, damage, p, spray, flag);
}
}
private void SpawnBlood(Vector3 position, float damage, Component source, Vector3 spray, bool hasDir)
{
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: 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_00c5: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_020e: 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_0243: Unknown result type (might be due to invalid IL or missing references)
if (intensity.Value <= 0f)
{
return;
}
ParticleSystem val = RentSystem();
if (!((Object)(object)val == (Object)null))
{
int num = Mathf.Clamp(Mathf.RoundToInt(damage * 3f * intensity.Value), 10, Mathf.Max(10, maxParticles.Value));
((Component)val).gameObject.layer = PickLayer();
CollisionModule collision = val.collision;
((CollisionModule)(ref collision)).enabled = collisionEnabled.Value;
((CollisionModule)(ref collision)).collidesWith = LayerMask.op_Implicit(CollisionMask(source));
ParticleSystemRenderer component = ((Component)val).GetComponent<ParticleSystemRenderer>();
Color val2 = Color.Lerp(BloodDark, BloodLight, Random.value);
propertyBlock.Clear();
propertyBlock.SetColor("_BaseColor", val2);
propertyBlock.SetColor("_Color", val2);
((Renderer)component).SetPropertyBlock(propertyBlock);
Dbg("Blood: damage " + damage.ToString("F1") + ", " + num + " chunks at " + ((Vector3)(ref position)).ToString("F1") + (hasDir ? (", direction " + ((Vector3)(ref spray)).ToString("F2")) : ", no direction"));
ShapeModule shape = val.shape;
if (hasDir)
{
((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
((ShapeModule)(ref shape)).angle = 35f;
((ShapeModule)(ref shape)).radius = 0.12f;
((ShapeModule)(ref shape)).randomDirectionAmount = 0.15f;
((Component)val).transform.rotation = Quaternion.LookRotation(spray);
}
else
{
((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
((ShapeModule)(ref shape)).radius = 0.15f;
((ShapeModule)(ref shape)).randomDirectionAmount = 0f;
((Component)val).transform.rotation = Quaternion.identity;
}
((Component)val).transform.position = position;
val.Clear(true);
val.Play(true);
val.Emit(num);
if (floorBlood.Value)
{
ScheduleSplats(position, num, damage, source, spray, hasDir);
}
}
}
private void OnSceneLoaded(Scene scene, LoadSceneMode loadMode)
{
ClearSplats();
}
private void ClearSplats()
{
pending.Clear();
growing.Clear();
foreach (SplatRecord splat in splats)
{
if ((Object)(object)splat.transform != (Object)null)
{
Object.Destroy((Object)(object)((Component)splat.transform).gameObject);
}
}
splats.Clear();
}
private void ScheduleSplats(Vector3 origin, int particleCount, float damage, Component source, Vector3 spray, bool hasDir)
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: 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_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: 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_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_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: 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_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_02c4: 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_02e7: 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)
int num = Mathf.Clamp(particleCount / 5, 3, 16);
int num2 = CollisionMask(source);
float num3 = Mathf.Clamp(0.6f + damage / 30f, 0.6f, 2f) * splatSize.Value;
if (puddles.Value)
{
Vector3 val = (((Object)(object)source != (Object)null) ? BodyPosition(source) : origin);
RaycastHit val2 = default(RaycastHit);
if (Physics.Raycast(val, Vector3.down, ref val2, 6f, num2, (QueryTriggerInteraction)1) && ((RaycastHit)(ref val2)).normal.y > 0.5f)
{
float num4 = Mathf.Clamp(damage / 15f, 0.6f, 3.5f);
PendingSplat pendingSplat = new PendingSplat();
pendingSplat.puddle = true;
pendingSplat.time = Time.time + 0.4f + ((RaycastHit)(ref val2)).distance * 0.05f;
pendingSplat.point = ((RaycastHit)(ref val2)).point;
pendingSplat.normal = ((RaycastHit)(ref val2)).normal;
pendingSplat.size = Random.Range(0.8f, 1.1f) * num4 * puddleSize.Value;
pendingSplat.growTime = 2f + num4;
pendingSplat.parent = (((Object)(object)((RaycastHit)(ref val2)).rigidbody != (Object)null) ? ((Component)((RaycastHit)(ref val2)).collider).transform : null);
pending.Add(pendingSplat);
}
}
Vector3 val3 = default(Vector3);
RaycastHit val4 = default(RaycastHit);
for (int i = 0; i < num; i++)
{
bool flag = hasDir && Random.value < 0.6f;
bool flag2 = !flag && Random.value < 0.7f;
if (flag)
{
val3 = spray + new Vector3(Random.Range(-0.35f, 0.35f), Random.Range(-0.7f, 0.1f), Random.Range(-0.35f, 0.35f));
}
else if (flag2)
{
((Vector3)(ref val3))..ctor(Random.Range(-0.7f, 0.7f), -1f, Random.Range(-0.7f, 0.7f));
}
else
{
((Vector3)(ref val3))..ctor(Random.Range(-1f, 1f), Random.Range(-0.3f, 0.4f), Random.Range(-1f, 1f));
}
((Vector3)(ref val3)).Normalize();
float num5 = (flag ? 6f : (flag2 ? 5f : 3.5f));
if (Physics.Raycast(origin, val3, ref val4, num5, num2, (QueryTriggerInteraction)1))
{
PendingSplat pendingSplat2 = new PendingSplat();
pendingSplat2.time = Time.time + ((RaycastHit)(ref val4)).distance * 0.08f;
pendingSplat2.point = ((RaycastHit)(ref val4)).point;
pendingSplat2.normal = ((RaycastHit)(ref val4)).normal;
pendingSplat2.size = Random.Range(0.18f, 0.5f) * num3;
pendingSplat2.stretch = (flag ? spray : Vector3.zero);
pendingSplat2.parent = (((Object)(object)((RaycastHit)(ref val4)).rigidbody != (Object)null) ? ((Component)((RaycastHit)(ref val4)).collider).transform : null);
pending.Add(pendingSplat2);
}
}
}
private void UpdateSplats()
{
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
for (int num = pending.Count - 1; num >= 0; num--)
{
PendingSplat pendingSplat = pending[num];
if (!(Time.time < pendingSplat.time))
{
pending.RemoveAt(num);
PlaceSplat(pendingSplat);
}
}
for (int num2 = growing.Count - 1; num2 >= 0; num2--)
{
SplatRecord splatRecord = growing[num2];
if ((Object)(object)splatRecord.transform == (Object)null)
{
growing.RemoveAt(num2);
}
else
{
float num3 = Mathf.Clamp01((Time.time - splatRecord.born) / splatRecord.growTime);
float num4 = num3 * num3 * (3f - 2f * num3);
float num5 = Mathf.Lerp(0.1f, 1f, num4);
splatRecord.transform.localScale = new Vector3(splatRecord.size * num5, 1f, splatRecord.size * splatRecord.aspect * num5);
if (num3 >= 1f)
{
growing.RemoveAt(num2);
}
}
}
float num6 = splatLifetime.Value * 60f;
if (num6 <= 0f)
{
return;
}
num6 = Mathf.Max(num6, 5f);
int num7 = 0;
while (num7 < splats.Count)
{
SplatRecord splatRecord2 = splats[num7];
if ((Object)(object)splatRecord2.transform == (Object)null)
{
splats.RemoveAt(num7);
continue;
}
float num8 = Time.time - splatRecord2.born;
if (num8 < num6 - 3f)
{
break;
}
if (num8 >= num6)
{
Object.Destroy((Object)(object)((Component)splatRecord2.transform).gameObject);
splats.RemoveAt(num7);
}
else
{
float num9 = (num6 - num8) / 3f;
splatRecord2.transform.localScale = new Vector3(splatRecord2.size * num9, 1f, splatRecord2.size * splatRecord2.aspect * num9);
num7++;
}
}
}
private static bool HasUnitScale(Transform t)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
Vector3 lossyScale = t.lossyScale;
return Mathf.Abs(lossyScale.x - 1f) < 0.05f && Mathf.Abs(lossyScale.y - 1f) < 0.05f && Mathf.Abs(lossyScale.z - 1f) < 0.05f;
}
private SplatRecord CreateSplat()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
GameObject val = new GameObject("BloodSplat");
val.layer = PickLayer();
MeshFilter val2 = val.AddComponent<MeshFilter>();
val2.sharedMesh = GetBlobMesh(Random.Range(0, 4));
MeshRenderer val3 = val.AddComponent<MeshRenderer>();
((Renderer)val3).sharedMaterial = GetMaterial();
((Renderer)val3).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)val3).receiveShadows = false;
((Renderer)val3).allowOcclusionWhenDynamic = false;
return new SplatRecord
{
transform = val.transform,
renderer = val3,
filter = val2
};
}
private void PlaceSplat(PendingSplat s)
{
//IL_0145: 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_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: 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_011e: 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_0175: 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_0180: 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_01c7: 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_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_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: 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_025c: 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_026b: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_0289: 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)
SplatRecord splatRecord;
if (splats.Count >= Mathf.Max(10, maxSplats.Value))
{
splatRecord = splats[0];
splats.RemoveAt(0);
if ((Object)(object)splatRecord.transform == (Object)null)
{
splatRecord = CreateSplat();
}
}
else
{
splatRecord = CreateSplat();
}
growing.Remove(splatRecord);
Transform transform = splatRecord.transform;
splatRecord.filter.sharedMesh = (s.puddle ? GetPuddleMesh(Random.Range(0, 3)) : GetBlobMesh(Random.Range(0, 4)));
Transform val = (((Object)(object)s.parent != (Object)null && HasUnitScale(s.parent)) ? s.parent : decalRoot);
transform.SetParent(val, false);
if (s.puddle)
{
puddleCounter = (puddleCounter + 1) % 30;
transform.position = s.point + s.normal * (0.005f + (float)puddleCounter * 0.00015f);
}
else
{
splatCounter = (splatCounter + 1) % 30;
transform.position = s.point + s.normal * (0.01f + (float)splatCounter * 0.0004f);
}
Vector3 val2 = Vector3.ProjectOnPlane(s.stretch, s.normal);
float num = 1f;
if (((Vector3)(ref val2)).sqrMagnitude > 0.01f)
{
transform.rotation = Quaternion.LookRotation(((Vector3)(ref val2)).normalized, s.normal);
num = 1.6f;
}
else
{
transform.rotation = Quaternion.FromToRotation(Vector3.up, s.normal) * Quaternion.Euler(0f, Random.value * 360f, 0f);
}
float num2 = ((s.growTime > 0f) ? 0.1f : 1f);
transform.localScale = new Vector3(s.size * num2, 1f, s.size * num * num2);
Color val3 = (s.puddle ? Color.Lerp(PuddleDark, PuddleLight, Random.value) : Color.Lerp(SplatDark, SplatLight, Random.value));
propertyBlock.Clear();
propertyBlock.SetColor("_BaseColor", val3);
propertyBlock.SetColor("_Color", val3);
((Renderer)splatRecord.renderer).SetPropertyBlock(propertyBlock);
splatRecord.size = s.size;
splatRecord.aspect = num;
splatRecord.born = Time.time;
splatRecord.growTime = s.growTime;
if (s.growTime > 0f)
{
growing.Add(splatRecord);
}
((Component)transform).gameObject.SetActive(true);
splats.Add(splatRecord);
}
private Mesh GetBlobMesh(int index)
{
while (blobMeshes.Count < 4)
{
blobMeshes.Add(CreateBlobMesh(1000 + blobMeshes.Count * 37));
}
return blobMeshes[Mathf.Clamp(index, 0, blobMeshes.Count - 1)];
}
private Mesh GetPuddleMesh(int index)
{
while (puddleMeshes.Count < 3)
{
puddleMeshes.Add(CreatePuddleMesh(5000 + puddleMeshes.Count * 53));
}
return puddleMeshes[Mathf.Clamp(index, 0, puddleMeshes.Count - 1)];
}
private static Mesh CreatePuddleMesh(int seed)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Expected O, but got Unknown
Random random = new Random(seed);
List<Vector3> list = new List<Vector3>();
List<Vector3> list2 = new List<Vector3>();
List<int> list3 = new List<int>();
AddBlob(list, list2, list3, Vector3.zero, 0.5f, 28, random, 0.22f);
int num = 2 + random.Next(3);
for (int i = 0; i < num; i++)
{
float num2 = (float)(random.NextDouble() * Math.PI * 2.0);
float num3 = 0.18f + (float)random.NextDouble() * 0.15f;
float radius = 0.28f + (float)random.NextDouble() * 0.12f;
AddBlob(list, list2, list3, new Vector3(Mathf.Cos(num2) * num3, 0f, Mathf.Sin(num2) * num3), radius, 20, random, 0.2f);
}
Mesh val = new Mesh();
((Object)val).name = "BloodPuddle";
val.SetVertices(list);
val.SetNormals(list2);
val.uv = (Vector2[])(object)new Vector2[list.Count];
val.SetTriangles(list3, 0);
val.RecalculateBounds();
return val;
}
private static Mesh CreateBlobMesh(int seed)
{
//IL_001d: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Expected O, but got Unknown
Random random = new Random(seed);
List<Vector3> list = new List<Vector3>();
List<Vector3> list2 = new List<Vector3>();
List<int> list3 = new List<int>();
AddBlob(list, list2, list3, Vector3.zero, 0.5f, 16, random, 0.45f);
int num = 3 + random.Next(3);
for (int i = 0; i < num; i++)
{
float num2 = (float)(random.NextDouble() * Math.PI * 2.0);
float num3 = 0.55f + (float)random.NextDouble() * 0.35f;
float radius = 0.04f + (float)random.NextDouble() * 0.07f;
AddBlob(list, list2, list3, new Vector3(Mathf.Cos(num2) * num3, 0f, Mathf.Sin(num2) * num3), radius, 8, random, 0.25f);
}
Mesh val = new Mesh();
((Object)val).name = "BloodBlob";
val.SetVertices(list);
val.SetNormals(list2);
val.uv = (Vector2[])(object)new Vector2[list.Count];
val.SetTriangles(list3, 0);
val.RecalculateBounds();
return val;
}
private static void AddBlob(List<Vector3> verts, List<Vector3> norms, List<int> tris, Vector3 center, float radius, int segments, Random rng, float irregularity)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
int count = verts.Count;
verts.Add(center);
norms.Add(Vector3.up);
for (int i = 0; i < segments; i++)
{
float num = (float)i * MathF.PI * 2f / (float)segments;
float num2 = radius * (1f - irregularity + irregularity * (float)rng.NextDouble() * 1.4f);
if (i % 4 == 0)
{
num2 *= 1f + 0.35f * (float)rng.NextDouble();
}
verts.Add(center + new Vector3(Mathf.Cos(num) * num2, 0f, Mathf.Sin(num) * num2));
norms.Add(Vector3.up);
}
for (int j = 0; j < segments; j++)
{
int item = count + 1 + j;
int item2 = count + 1 + (j + 1) % segments;
tris.Add(count);
tris.Add(item2);
tris.Add(item);
}
}
private static int PickLayer()
{
Camera main = Camera.main;
int num = (((Object)(object)main != (Object)null) ? main.cullingMask : (-1));
if ((num & 1) != 0)
{
return 0;
}
for (int i = 0; i < 32; i++)
{
if ((num & (1 << i)) != 0)
{
return i;
}
}
return 0;
}
private static int CollisionMask(Component source)
{
if ((Object)(object)source == (Object)null)
{
return -1;
}
int num = 0;
Collider[] componentsInChildren = source.GetComponentsInChildren<Collider>();
foreach (Collider val in componentsInChildren)
{
num |= 1 << ((Component)val).gameObject.layer;
}
if ((num & 1) != 0)
{
return -1;
}
return ~num;
}
private ParticleSystem RentSystem()
{
pool.RemoveAll((ParticleSystem p) => (Object)(object)p == (Object)null);
foreach (ParticleSystem item in pool)
{
if (!item.IsAlive(true))
{
return item;
}
}
if (pool.Count < 12)
{
ParticleSystem val = CreateSystem();
if ((Object)(object)val != (Object)null)
{
pool.Add(val);
}
return val;
}
reuseIndex = (reuseIndex + 1) % pool.Count;
return pool[reuseIndex];
}
private ParticleSystem CreateSystem()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: 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_00d0: 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_0110: 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_0133: 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_0141: 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_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: 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_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0296: Expected O, but got Unknown
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("BloodSplatter");
val.transform.SetParent(poolRoot, false);
ParticleSystem val2 = val.AddComponent<ParticleSystem>();
val2.Stop(true, (ParticleSystemStopBehavior)0);
float value = sizeMultiplier.Value;
MainModule main = val2.main;
((MainModule)(ref main)).playOnAwake = false;
((MainModule)(ref main)).duration = 0.5f;
((MainModule)(ref main)).loop = false;
((MainModule)(ref main)).maxParticles = 400;
((MainModule)(ref main)).startLifetime = new MinMaxCurve(1f, 2.5f);
((MainModule)(ref main)).startSpeed = new MinMaxCurve(1.5f, 5f);
((MainModule)(ref main)).startSize = new MinMaxCurve(0.05f * value, 0.15f * value);
((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Color.white);
((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(1.5f);
((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
((MainModule)(ref main)).startRotation3D = true;
((MainModule)(ref main)).startRotationX = new MinMaxCurve(0f, 6.2832f);
((MainModule)(ref main)).startRotationY = new MinMaxCurve(0f, 6.2832f);
((MainModule)(ref main)).startRotationZ = new MinMaxCurve(0f, 6.2832f);
EmissionModule emission = val2.emission;
((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
ShapeModule shape = val2.shape;
((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
((ShapeModule)(ref shape)).radius = 0.15f;
CollisionModule collision = val2.collision;
((CollisionModule)(ref collision)).enabled = collisionEnabled.Value;
((CollisionModule)(ref collision)).type = (ParticleSystemCollisionType)1;
((CollisionModule)(ref collision)).mode = (ParticleSystemCollisionMode)0;
((CollisionModule)(ref collision)).quality = (ParticleSystemCollisionQuality)2;
((CollisionModule)(ref collision)).enableDynamicColliders = false;
((CollisionModule)(ref collision)).dampen = MinMaxCurve.op_Implicit(0.6f);
((CollisionModule)(ref collision)).lifetimeLoss = MinMaxCurve.op_Implicit(0.1f);
RotationOverLifetimeModule rotationOverLifetime = val2.rotationOverLifetime;
((RotationOverLifetimeModule)(ref rotationOverLifetime)).enabled = true;
((RotationOverLifetimeModule)(ref rotationOverLifetime)).separateAxes = true;
((RotationOverLifetimeModule)(ref rotationOverLifetime)).x = new MinMaxCurve(-4f, 4f);
((RotationOverLifetimeModule)(ref rotationOverLifetime)).y = new MinMaxCurve(-4f, 4f);
((RotationOverLifetimeModule)(ref rotationOverLifetime)).z = new MinMaxCurve(-4f, 4f);
SizeOverLifetimeModule sizeOverLifetime = val2.sizeOverLifetime;
((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3]
{
new Keyframe(0f, 1f),
new Keyframe(0.75f, 1f),
new Keyframe(1f, 0f)
}));
ParticleSystemRenderer component = ((Component)val2).GetComponent<ParticleSystemRenderer>();
component.renderMode = (ParticleSystemRenderMode)4;
component.mesh = GetChunkMesh();
((Renderer)component).sharedMaterial = GetMaterial();
((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)component).receiveShadows = false;
component.enableGPUInstancing = false;
((Renderer)component).allowOcclusionWhenDynamic = false;
return val2;
}
private Mesh GetChunkMesh()
{
if ((Object)(object)chunkMesh == (Object)null)
{
chunkMesh = CreateRoundedCube();
}
return chunkMesh;
}
private static Mesh CreateRoundedCube()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0084: 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_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_00b2: 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_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_00ca: 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_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_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_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_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_010d: 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_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0150: 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_015c: 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_0168: 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_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: 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_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0424: Unknown result type (might be due to invalid IL or missing references)
//IL_042b: Expected O, but got Unknown
//IL_0302: Unknown result type (might be due to invalid IL or missing references)
//IL_030a: Unknown result type (might be due to invalid IL or missing references)
//IL_030f: Unknown result type (might be due to invalid IL or missing references)
//IL_0317: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: 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_01ef: 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_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_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: 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_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: 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_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_0282: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: 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_02a8: Unknown result type (might be due to invalid IL or missing references)
//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
Vector3[] array = (Vector3[])(object)new Vector3[6]
{
new Vector3(4f, 0f, 0f),
new Vector3(0f, 0f, 0f),
new Vector3(0f, 4f, 0f),
new Vector3(0f, 0f, 0f),
new Vector3(0f, 0f, 4f),
new Vector3(0f, 0f, 0f)
};
Vector3[] array2 = (Vector3[])(object)new Vector3[6]
{
Vector3.up,
Vector3.up,
Vector3.right,
Vector3.right,
Vector3.right,
Vector3.right
};
Vector3[] array3 = (Vector3[])(object)new Vector3[6]
{
Vector3.forward,
Vector3.forward,
Vector3.forward,
Vector3.forward,
Vector3.up,
Vector3.up
};
Vector3[] array4 = (Vector3[])(object)new Vector3[6]
{
Vector3.right,
Vector3.left,
Vector3.up,
Vector3.down,
Vector3.forward,
Vector3.back
};
List<Vector3> list = new List<Vector3>();
List<Vector3> list2 = new List<Vector3>();
List<Vector2> list3 = new List<Vector2>();
List<int> list4 = new List<int>();
Vector3 val2 = default(Vector3);
for (int i = 0; i < 6; i++)
{
int count = list.Count;
for (int j = 0; j <= 4; j++)
{
for (int k = 0; k <= 4; k++)
{
Vector3 val = array[i] + array2[i] * (float)k + array3[i] * (float)j;
((Vector3)(ref val2))..ctor(Mathf.Clamp(val.x, 1f, 3f), Mathf.Clamp(val.y, 1f, 3f), Mathf.Clamp(val.z, 1f, 3f));
Vector3 val3 = val - val2;
Vector3 normalized = ((Vector3)(ref val3)).normalized;
list.Add((val2 + normalized * 1f) / 4f - new Vector3(0.5f, 0.5f, 0.5f));
list2.Add(normalized);
list3.Add(new Vector2((float)k / 4f, (float)j / 4f));
}
}
bool flag = Vector3.Dot(Vector3.Cross(array2[i], array3[i]), array4[i]) < 0f;
for (int l = 0; l < 4; l++)
{
for (int m = 0; m < 4; m++)
{
int num = count + l * 5 + m;
int item = num + 1;
int num2 = num + 4 + 1;
int item2 = num2 + 1;
if (!flag)
{
list4.Add(num);
list4.Add(item);
list4.Add(num2);
list4.Add(item);
list4.Add(item2);
list4.Add(num2);
}
else
{
list4.Add(num);
list4.Add(num2);
list4.Add(item);
list4.Add(item);
list4.Add(num2);
list4.Add(item2);
}
}
}
}
Mesh val4 = new Mesh();
((Object)val4).name = "BloodChunk";
val4.SetVertices(list);
val4.SetNormals(list2);
val4.SetUVs(0, list3);
val4.SetTriangles(list4, 0);
val4.RecalculateBounds();
return val4;
}
private Material GetMaterial()
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Expected O, but got Unknown
if ((Object)(object)bloodMaterial != (Object)null)
{
return bloodMaterial;
}
string[] shaderNames = ShaderNames;
foreach (string text in shaderNames)
{
Shader val = Shader.Find(text);
if (!((Object)(object)val == (Object)null))
{
bloodMaterial = new Material(val);
((Object)bloodMaterial).name = "BloodMaterial";
if (bloodMaterial.HasProperty("_BaseColor"))
{
bloodMaterial.SetColor("_BaseColor", BloodDark);
}
if (bloodMaterial.HasProperty("_Color"))
{
bloodMaterial.SetColor("_Color", BloodDark);
}
if (bloodMaterial.HasProperty("_Smoothness"))
{
bloodMaterial.SetFloat("_Smoothness", 0.7f);
}
if (bloodMaterial.HasProperty("_Metallic"))
{
bloodMaterial.SetFloat("_Metallic", 0f);
}
Dbg("Blood shader: " + text);
return bloodMaterial;
}
}
ParticleSystemRenderer[] array = Resources.FindObjectsOfTypeAll<ParticleSystemRenderer>();
foreach (ParticleSystemRenderer val2 in array)
{
if ((Object)(object)val2 != (Object)null && (Object)(object)((Renderer)val2).sharedMaterial != (Object)null)
{
bloodMaterial = new Material(((Renderer)val2).sharedMaterial);
Log.LogWarning((object)("No standard shader found, using game material: " + ((Object)((Renderer)val2).sharedMaterial).name));
return bloodMaterial;
}
}
Log.LogError((object)"No suitable shader found - blood may render pink.");
return null;
}
private static MemberInfo FindMember(Type t, string name)
{
string key = t.FullName + "." + name;
if (memberCache.TryGetValue(key, out MemberInfo value))
{
return value;
}
value = (MemberInfo)(((object)t.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) ?? ((object)t.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)));
memberCache[key] = value;
return value;
}
private static object ReadPath(object root, string path)
{
object obj = root;
string[] array = path.Split('.');
foreach (string name in array)
{
if (obj == null)
{
return null;
}
MemberInfo memberInfo = FindMember(obj.GetType(), name);
if (memberInfo == null)
{
return null;
}
try
{
FieldInfo fieldInfo = memberInfo as FieldInfo;
obj = ((fieldInfo != null) ? fieldInfo.GetValue(obj) : ((PropertyInfo)memberInfo).GetValue(obj, null));
}
catch
{
return null;
}
}
return obj;
}
private static bool ToFloat(object o, out float value)
{
value = 0f;
if (o is float)
{
value = (float)o;
return true;
}
if (o is double)
{
value = (float)(double)o;
return true;
}
if (o is int)
{
value = (int)o;
return true;
}
return false;
}
private bool TryReadHealth(Component p, out float health)
{
health = 0f;
if (healthPath != null && ToFloat(ReadPath(p, healthPath), out health))
{
return true;
}
string[] healthPaths = HealthPaths;
foreach (string text in healthPaths)
{
if (ToFloat(ReadPath(p, text), out health))
{
healthPath = text;
Dbg("Health read via: " + text);
return true;
}
}
return false;
}
private bool ReadDead(Component p)
{
if (deadPath != null)
{
object obj = ReadPath(p, deadPath);
return obj is bool && (bool)obj;
}
string[] deadPaths = DeadPaths;
foreach (string text in deadPaths)
{
object obj2 = ReadPath(p, text);
if (obj2 is bool)
{
deadPath = text;
Dbg("Death flag read via: " + text);
return (bool)obj2;
}
}
return false;
}
private static void DumpMembers(object obj, string label)
{
Type type = obj.GetType();
Log.LogInfo((object)("---- Members of " + label + " (" + type.FullName + ") ----"));
FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
foreach (FieldInfo fieldInfo in fields)
{
Log.LogInfo((object)(" Field " + fieldInfo.FieldType.Name + " " + fieldInfo.Name));
}
PropertyInfo[] properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
foreach (PropertyInfo propertyInfo in properties)
{
Log.LogInfo((object)(" Property " + propertyInfo.PropertyType.Name + " " + propertyInfo.Name));
}
}
}
}