using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("Berserkir")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Berserkir")]
[assembly: AssemblyTitle("Berserkir")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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]
[Microsoft.CodeAnalysis.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 Berserkir
{
[Serializable]
public class BerserkData
{
private const string SaveKey = "Berserkir_v1";
public float RageProgress;
public int RageCheckpoint;
public bool IsUnlocked;
public int ZerkCharges;
public float RageFloor => (float)RageCheckpoint * 20f;
public int FilledSegments => Mathf.FloorToInt(RageProgress / 20f);
public float CurrentSegmentFill => RageProgress % 20f / 20f;
public string Serialize()
{
return JsonUtility.ToJson((object)this);
}
public static BerserkData Load(Player player)
{
if ((Object)(object)player == (Object)null)
{
return new BerserkData();
}
if (player.m_customData.TryGetValue("Berserkir_v1", out var value))
{
try
{
BerserkData berserkData = JsonUtility.FromJson<BerserkData>(value);
if (berserkData != null)
{
return berserkData;
}
}
catch (Exception ex)
{
BerserkPlugin.Log.LogWarning((object)("[Berserkir] Failed to parse save data: " + ex.Message));
}
}
return new BerserkData();
}
public void Save(Player player)
{
if (!((Object)(object)player == (Object)null))
{
player.m_customData["Berserkir_v1"] = Serialize();
}
}
}
public class BerserkHUD : MonoBehaviour
{
private BerserkData _data = new BerserkData();
private Player? _trackedPlayer;
private bool _isBerserking;
private float _berserkTimer;
private float _holdTimer;
private float _lastCombatTime = -999f;
private float _lastFatigueMsg = -999f;
private bool _showInfoWindow;
private float _flashAlpha;
private float[] _circleFlashTimers = new float[5];
private float _allCirclesFlash;
private const float RagePerKill = 0.75f;
private const float RageDrainRate = 0.083f;
private const float CombatTimeout = 6f;
private const float ChargeChance = 0.05f;
private const float HoldThreshold = 1f;
private const float AnchorX = 85f;
private const float AnchorY = 998f;
private int _zerkCirclesLeft;
private float _zerkElapsed;
public static float ShakeMag;
private bool _zerkFadingOut;
private float _zerkFadeTimer;
private bool _stylesReady;
private int _lastScreenH;
private GUIStyle? _styleTitle;
private GUIStyle? _styleBody;
private GUIStyle? _styleCentered;
private GUIStyle? _styleQE;
private Texture2D? _texDark;
private Texture2D? _texPink;
private Texture2D? _texBorder;
private Texture2D? _texSegEmpty;
private Texture2D? _texCircleRing;
private Texture2D? _texCircleFill;
private Texture2D? _texCircleWhite;
private Texture2D? _texFlash;
private Sprite? _iconSprite;
private bool _iconLoaded;
public static BerserkHUD? Instance { get; private set; }
public bool IsBerserking => _isBerserking;
public static event Action? OnCircleFaded;
private void Awake()
{
Instance = this;
}
private void OnDestroy()
{
if ((Object)(object)Instance == (Object)(object)this)
{
Instance = null;
}
}
private void EnsurePlayer()
{
Player localPlayer = Player.m_localPlayer;
if ((Object)(object)localPlayer == (Object)null)
{
_trackedPlayer = null;
}
else if (!((Object)(object)_trackedPlayer == (Object)(object)localPlayer))
{
_trackedPlayer = localPlayer;
_data = BerserkData.Load(localPlayer);
}
}
public void SaveData()
{
_data?.Save(_trackedPlayer);
}
public void AdminFill()
{
EnsurePlayer();
if (!((Object)(object)_trackedPlayer == (Object)null))
{
_data.RageProgress = 100f;
_data.RageCheckpoint = 5;
_data.IsUnlocked = true;
_data.ZerkCharges = 5;
_data.Save(_trackedPlayer);
_allCirclesFlash = 1f;
SpawnGPEffect(_trackedPlayer);
}
}
public static void TriggerShake(float mag)
{
ShakeMag = mag;
}
public void OnMonsterKilled(Character monster)
{
EnsurePlayer();
if ((Object)(object)_trackedPlayer == (Object)null)
{
return;
}
_lastCombatTime = Time.time;
if (!_data.IsUnlocked)
{
_data.RageProgress = Mathf.Min(100f, _data.RageProgress + 0.75f);
int num = Mathf.FloorToInt(_data.RageProgress / 20f);
if (num > _data.RageCheckpoint)
{
_data.RageCheckpoint = Mathf.Min(5, num);
}
if (_data.RageProgress >= 100f)
{
_data.IsUnlocked = true;
_data.ZerkCharges = 5;
_showInfoWindow = false;
_allCirclesFlash = 1f;
SpawnGPEffect(_trackedPlayer);
}
}
else if (!_isBerserking && _data.ZerkCharges < 5 && Random.value < 0.05f)
{
_data.ZerkCharges++;
_circleFlashTimers[_data.ZerkCharges - 1] = 0.6f;
if (_data.ZerkCharges >= 5)
{
_allCirclesFlash = 1f;
SpawnGPEffect(_trackedPlayer);
}
}
_data.Save(_trackedPlayer);
}
private void SpawnGPEffect(Player player)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0029: 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_0070: 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)
if ((Object)(object)player == (Object)null)
{
return;
}
Vector3 position = ((Component)player).transform.position + Vector3.up * 0.5f;
ZNetScene instance = ZNetScene.instance;
GameObject val = ((instance != null) ? instance.GetPrefab("fx_GP_Player") : null);
if (!((Object)(object)val == (Object)null))
{
GameObject val2 = new GameObject("_gpHolder");
val2.SetActive(false);
GameObject val3 = Object.Instantiate<GameObject>(val, val2.transform);
val3.transform.position = position;
val3.transform.rotation = Quaternion.identity;
ZNetView[] componentsInChildren = val3.GetComponentsInChildren<ZNetView>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
}
ZSyncTransform[] componentsInChildren2 = val3.GetComponentsInChildren<ZSyncTransform>(true);
for (int i = 0; i < componentsInChildren2.Length; i++)
{
Object.DestroyImmediate((Object)(object)componentsInChildren2[i]);
}
ZSyncAnimation[] componentsInChildren3 = val3.GetComponentsInChildren<ZSyncAnimation>(true);
for (int i = 0; i < componentsInChildren3.Length; i++)
{
Object.DestroyImmediate((Object)(object)componentsInChildren3[i]);
}
val3.transform.SetParent((Transform)null);
Object.DestroyImmediate((Object)(object)val2);
val3.SetActive(true);
Object.Destroy((Object)(object)val3, 5f);
}
}
private static void ShowMsg(string msg)
{
MessageHud instance = MessageHud.instance;
if (instance != null)
{
instance.ShowMessage((MessageType)1, msg, 0, (Sprite)null, false);
}
}
private void Update()
{
EnsurePlayer();
if ((Object)(object)_trackedPlayer == (Object)null)
{
return;
}
TryLoadIcon();
HandleRageDrain();
HandleKeyInput();
HandleBerserkCountdown();
if (_flashAlpha > 0f)
{
_flashAlpha = Mathf.Max(0f, _flashAlpha - Time.deltaTime * 3f);
}
for (int i = 0; i < 5; i++)
{
if (_circleFlashTimers[i] > 0f)
{
_circleFlashTimers[i] = Mathf.Max(0f, _circleFlashTimers[i] - Time.deltaTime * 2.5f);
}
}
if (_allCirclesFlash > 0f)
{
_allCirclesFlash = Mathf.Max(0f, _allCirclesFlash - Time.deltaTime * 1.8f);
}
if (_zerkFadingOut)
{
_zerkFadeTimer = Mathf.Max(0f, _zerkFadeTimer - Time.deltaTime);
if (_zerkFadeTimer <= 0f)
{
_zerkFadingOut = false;
}
}
if (ShakeMag > 0f)
{
ShakeMag = Mathf.Max(0f, ShakeMag - Time.deltaTime * 5f);
}
}
private void TryLoadIcon()
{
if (!_iconLoaded && !((Object)(object)ObjectDB.instance == (Object)null))
{
GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("TrophyBjorn");
ItemDrop val = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null);
if (val != null && val.m_itemData?.m_shared?.m_icons?.Length > 0)
{
_iconSprite = val.m_itemData.m_shared.m_icons[0];
}
_iconLoaded = true;
}
}
private void HandleRageDrain()
{
if (!_data.IsUnlocked && !_isBerserking && !(Time.time - _lastCombatTime < 6f))
{
float rageFloor = _data.RageFloor;
if (_data.RageProgress > rageFloor)
{
_data.RageProgress = Mathf.Max(rageFloor, _data.RageProgress - 0.083f * Time.deltaTime);
}
}
}
private void HandleKeyInput()
{
bool key = Input.GetKey((KeyCode)113);
bool key2 = Input.GetKey((KeyCode)101);
if (!_data.IsUnlocked)
{
if (key && key2)
{
if (_holdTimer >= 0f)
{
_holdTimer += Time.deltaTime;
if (_holdTimer >= 0.3f)
{
_showInfoWindow = !_showInfoWindow;
_holdTimer = -9999f;
}
}
}
else
{
_holdTimer = 0f;
}
}
else if (_isBerserking || _data.ZerkCharges < 5)
{
_holdTimer = 0f;
}
else if (SE_Fatigue.HasFatigue((Character?)(object)_trackedPlayer))
{
_holdTimer = 0f;
if (key && key2 && Time.time - _lastFatigueMsg > 3f)
{
_lastFatigueMsg = Time.time;
MessageHud instance = MessageHud.instance;
if (instance != null)
{
instance.ShowMessage((MessageType)2, "<color=#888888>You are too exhausted to rage...</color>", 0, (Sprite)null, false);
}
}
}
else if (key && key2)
{
_holdTimer += Time.deltaTime;
if (_holdTimer >= 1f)
{
ActivateBerserk();
_holdTimer = 0f;
}
}
else
{
_holdTimer = 0f;
}
}
private void HandleBerserkCountdown()
{
if (!_isBerserking)
{
return;
}
_berserkTimer -= Time.deltaTime;
_zerkElapsed += Time.deltaTime;
int num = 5 - Mathf.FloorToInt(_zerkElapsed / 12f);
num = Mathf.Clamp(num, 0, 5);
if (num < _zerkCirclesLeft)
{
_zerkCirclesLeft = num;
for (int i = 0; i < _zerkCirclesLeft; i++)
{
_circleFlashTimers[i] = 0.5f;
}
BerserkHUD.OnCircleFaded?.Invoke();
}
bool flag = ((Character)_trackedPlayer).GetSEMan().HaveStatusEffect(SE_Berserk.EffectHash);
if (_berserkTimer <= 0f || !flag)
{
EndBerserk();
}
}
private void ActivateBerserk()
{
_isBerserking = true;
_berserkTimer = 60f;
_zerkCirclesLeft = 5;
_zerkElapsed = 0f;
_data.ZerkCharges = 0;
_data.Save(_trackedPlayer);
_flashAlpha = 0.85f;
_allCirclesFlash = 1f;
ObjectDB instance = ObjectDB.instance;
StatusEffect val = ((instance != null) ? instance.GetStatusEffect(SE_Berserk.EffectHash) : null);
if ((Object)(object)val != (Object)null)
{
((Character)_trackedPlayer).GetSEMan().AddStatusEffect(val, true, 0, 0f);
}
else
{
BerserkPlugin.Log.LogError((object)"[Berserkir] SE_Berserk not found in ObjectDB!");
}
}
private void EndBerserk()
{
_isBerserking = false;
_zerkFadingOut = true;
_zerkFadeTimer = 2.2f;
if (((Character)_trackedPlayer).GetSEMan().HaveStatusEffect(SE_Berserk.EffectHash))
{
((Character)_trackedPlayer).GetSEMan().RemoveStatusEffect(SE_Berserk.EffectHash, false);
}
}
private void OnGUI()
{
//IL_00ae: 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_00de: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_trackedPlayer == (Object)null))
{
if (!_stylesReady || Screen.height != _lastScreenH)
{
InitStyles();
}
float num = (float)Screen.height / 1080f;
float num2 = 85f * num;
float num3 = 998f * num;
if (!_data.IsUnlocked)
{
DrawPreUnlock(num2, num3, num);
}
else
{
DrawPostUnlock(num2, num3, num);
}
if (_showInfoWindow && !_data.IsUnlocked)
{
DrawInfoWindow(num2, num3, num);
}
if (_flashAlpha > 0.001f)
{
GUI.color = new Color(1f, 0.35f, 0.05f, _flashAlpha * 0.55f);
GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)_texFlash);
GUI.color = Color.white;
}
}
}
private void DrawPreUnlock(float x, float y, float s)
{
//IL_0069: 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_0057: 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_007a: 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)
float num = 54f * s;
float num2 = 54f * s;
float num3 = y - num2 * 0.5f;
Rect val = default(Rect);
((Rect)(ref val))..ctor(x, num3, num, num2);
if ((Object)(object)_iconSprite != (Object)null)
{
GUI.color = new Color(1f, 0.2f, 0.2f, 1f);
DrawSprite(_iconSprite, val);
GUI.color = Color.white;
}
else
{
GUI.Label(val, "<color=#CC2222><size=36>☠</size></color>", _styleCentered);
}
if (GUI.Button(val, GUIContent.none, GUIStyle.none))
{
_showInfoWindow = !_showInfoWindow;
}
GUI.Label(new Rect(x - 6f * s, num3 + num2 + 2f * s, num + 12f * s, 18f * s), "Q + E", _styleQE);
}
private void DrawPostUnlock(float x, float y, float s)
{
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: 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_01bb: Unknown result type (might be due to invalid IL or missing references)
float num = 22f * s;
float num2 = 4f * s;
float num3 = 5f * num + 4f * num2;
float num4 = y - num3;
for (int i = 0; i < 5; i++)
{
float num5 = num4 + (float)i * (num + num2);
bool flag = (_isBerserking ? (i < _zerkCirclesLeft) : (i < _data.ZerkCharges));
float flash = Mathf.Max(_circleFlashTimers[i], _allCirclesFlash);
DrawCircle(new Rect(x, num5, num, num), flag, flash, _isBerserking && flag);
}
if (!_isBerserking && _data.ZerkCharges >= 5)
{
float num6 = num4 + 5f * (num + num2) + 3f * s;
GUI.Label(new Rect(x - 6f * s, num6, num + 12f * s, 18f * s), "Q + E", _styleQE);
}
if (!_isBerserking && _holdTimer > 0f && _data.ZerkCharges >= 5)
{
float num7 = Mathf.Clamp01(_holdTimer / 1f);
float num8 = num4 + 5f * (num + num2) + 22f * s;
GUI.color = new Color(0.06f, 0.03f, 0.03f, 0.85f);
GUI.DrawTexture(new Rect(x, num8, num, 4f * s), (Texture)(object)_texDark);
GUI.color = new Color(0.75f, 0.07f, 0.1f, 1f);
GUI.DrawTexture(new Rect(x, num8, num * num7, 4f * s), (Texture)(object)_texPink);
GUI.color = Color.white;
}
}
private void DrawInfoWindow(float anchorX, float anchorY, float s)
{
//IL_0036: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
float num = 470f * s;
float num2 = 360f * s;
float num3 = anchorY - num2 - 70f * s;
num3 = Mathf.Max(4f, num3);
Rect r = default(Rect);
((Rect)(ref r))..ctor(anchorX, num3, num, num2);
DrawWoodPanel(r, border: true);
float num4 = 16f * s;
float num5 = ((Rect)(ref r)).x + num4;
float num6 = ((Rect)(ref r)).y + num4;
float num7 = num - num4 * 2f;
if (GUI.Button(new Rect(((Rect)(ref r)).xMax - 28f * s, ((Rect)(ref r)).y + 6f * s, 22f * s, 20f * s), "✕", _styleBody))
{
_showInfoWindow = false;
}
GUI.Label(new Rect(num5, num6, num7, 38f * s), "Berserkir", _styleTitle);
num6 += 44f * s;
string text = "Fill rage by killing monsters. Once you kill enough monsters, the bar will fill.\n\nWind down — the bar will fade until the checkpoint mark.\n\nFill all 5 bars to unlock Berserkir mode.\n\nActivate by holding <color=#FFD400><b>Q + E</b></color> at the same time.";
GUI.Label(new Rect(num5, num6, num7, 170f * s), text, _styleBody);
num6 += 175f * s;
DrawRageBar(num5, num6, num7, 28f * s, s);
}
private void DrawRageBar(float x, float y, float w, float h, float s)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: 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_0137: 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_0160: 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_0098: 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)
GUI.color = Color.white;
GUI.DrawTexture(new Rect(x, y, w, h), (Texture)(object)_texDark);
float num = Mathf.Clamp01(_data.RageProgress / 100f) * w;
if (num >= 1f)
{
GUI.DrawTexture(new Rect(x, y, num, h), (Texture)(object)_texPink);
}
float num2 = 3f * s;
for (int i = 1; i <= 4; i++)
{
float num3 = x + w / 5f * (float)i - num2 * 0.5f;
if (_data.RageCheckpoint >= i)
{
GUI.color = new Color(0.9f, 0.65f, 0.1f, 1f);
}
else
{
GUI.color = new Color(0.75f, 0.73f, 0.71f, 1f);
}
GUI.DrawTexture(new Rect(num3, y, num2, h), (Texture)(object)_texBorder);
}
float num4 = 2f * s;
GUI.color = new Color(0.72f, 0.48f, 0.08f, 1f);
GUI.DrawTexture(new Rect(x, y, w, num4), (Texture)(object)_texBorder);
GUI.DrawTexture(new Rect(x, y + h - num4, w, num4), (Texture)(object)_texBorder);
GUI.DrawTexture(new Rect(x, y, num4, h), (Texture)(object)_texBorder);
GUI.DrawTexture(new Rect(x + w - num4, y, num4, h), (Texture)(object)_texBorder);
GUI.color = Color.white;
}
private void DrawWoodPanel(Rect r, bool border = false)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: 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_009a: 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_00e8: 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)
GUI.color = new Color(0.12f, 0.07f, 0.04f, 0.92f);
GUI.DrawTexture(r, (Texture)(object)_texDark);
GUI.color = Color.white;
if (border)
{
float num = 2f;
GUI.color = new Color(0.72f, 0.48f, 0.08f, 0.92f);
GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, num), (Texture)(object)_texBorder);
GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - num, ((Rect)(ref r)).width, num), (Texture)(object)_texBorder);
GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, num, ((Rect)(ref r)).height), (Texture)(object)_texBorder);
GUI.DrawTexture(new Rect(((Rect)(ref r)).xMax - num, ((Rect)(ref r)).y, num, ((Rect)(ref r)).height), (Texture)(object)_texBorder);
GUI.color = Color.white;
}
}
private void DrawCircle(Rect r, bool filled, float flash = 0f, bool zerkGlow = false)
{
//IL_003e: 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_006c: 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_009e: 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_00f8: 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_0126: 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_014e: 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_01c6: 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_01f0: 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_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_0288: Unknown result type (might be due to invalid IL or missing references)
float num = ((Rect)(ref r)).width * 0.05f;
Rect val = new Rect(((Rect)(ref r)).x + num, ((Rect)(ref r)).y + num, ((Rect)(ref r)).width - num * 2f, ((Rect)(ref r)).height - num * 2f);
GUI.color = new Color(0.04f, 0.02f, 0.02f, 0.28f);
GUI.DrawTexture(val, (Texture)(object)_texCircleFill);
GUI.color = Color.white;
GUI.color = new Color(0.72f, 0.48f, 0.08f, filled ? 1f : 0.4f);
GUI.DrawTexture(r, (Texture)(object)_texCircleRing);
GUI.color = Color.white;
if (filled)
{
float num2 = ((Rect)(ref r)).width * 0.18f;
Rect val2 = new Rect(((Rect)(ref r)).x + num2, ((Rect)(ref r)).y + num2, ((Rect)(ref r)).width - num2 * 2f, ((Rect)(ref r)).height - num2 * 2f);
GUI.color = new Color(0.8f, 0.05f, 0.08f, 1f);
GUI.DrawTexture(val2, (Texture)(object)_texCircleFill);
GUI.color = Color.white;
GUI.color = new Color(1f, 0.4f, 0.1f, 0.55f);
GUI.DrawTexture(r, (Texture)(object)_texCircleRing);
GUI.color = Color.white;
}
if (zerkGlow)
{
float num3 = 0.55f + Mathf.Sin(Time.time * 3.5f) * 0.2f;
float num4 = ((Rect)(ref r)).width * 0.18f;
Rect val3 = new Rect(((Rect)(ref r)).x - num4, ((Rect)(ref r)).y - num4, ((Rect)(ref r)).width + num4 * 2f, ((Rect)(ref r)).height + num4 * 2f);
GUI.color = new Color(1f, 0.2f, 0.05f, num3);
GUI.DrawTexture(val3, (Texture)(object)_texCircleWhite);
GUI.color = Color.white;
}
if (flash > 0.01f)
{
float num5 = Mathf.Clamp01(flash) * 0.9f;
float num6 = ((Rect)(ref r)).width * 0.25f * Mathf.Clamp01(flash);
Rect val4 = new Rect(((Rect)(ref r)).x - num6, ((Rect)(ref r)).y - num6, ((Rect)(ref r)).width + num6 * 2f, ((Rect)(ref r)).height + num6 * 2f);
GUI.color = new Color(1f, 0.95f, 0.8f, num5);
GUI.DrawTexture(val4, (Texture)(object)_texCircleWhite);
GUI.color = Color.white;
}
}
private static void DrawSprite(Sprite sprite, Rect rect)
{
//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_000e: 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)
Rect textureRect = sprite.textureRect;
Texture2D texture = sprite.texture;
GUI.DrawTextureWithTexCoords(rect, (Texture)(object)texture, new Rect(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height));
}
private void InitStyles()
{
//IL_002d: 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_0075: 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_00c0: 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_00fa: 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_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_01da: 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_01e8: 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_01fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Expected O, but got Unknown
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0249: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: 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_0261: Expected O, but got Unknown
//IL_0281: 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_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: 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_02a3: Unknown result type (might be due to invalid IL or missing references)
//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02bc: Expected O, but got Unknown
//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0301: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: 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_0324: Unknown result type (might be due to invalid IL or missing references)
//IL_0333: Expected O, but got Unknown
_lastScreenH = Screen.height;
float num = (float)Screen.height / 1080f;
_texDark = MakeSolid(new Color(0.12f, 0.07f, 0.04f, 1f));
_texPink = MakeSolid(new Color(0.75f, 0.07f, 0.1f, 1f));
_texBorder = MakeSolid(new Color(0.72f, 0.48f, 0.08f, 1f));
_texSegEmpty = MakeSolid(new Color(0.72f, 0.7f, 0.68f, 1f));
_texCircleRing = MakeCircle(64, filled: false, new Color(0.72f, 0.48f, 0.08f, 0.95f));
_texCircleFill = MakeCircle(64, filled: true, new Color(0.85f, 0.08f, 0.22f, 1f));
_texCircleWhite = MakeCircle(64, filled: true, Color.white);
_texFlash = MakeSolid(new Color(0.7f, 0.05f, 0.05f, 1f));
Font val = ((IEnumerable<Font>)Resources.FindObjectsOfTypeAll<Font>()).FirstOrDefault((Func<Font, bool>)((Font f) => ((Object)f).name.Equals("Norsebold", StringComparison.OrdinalIgnoreCase) || ((Object)f).name.Equals("Norse Bold", StringComparison.OrdinalIgnoreCase)));
Color textColor = default(Color);
((Color)(ref textColor))..ctor(0.83f, 0.53f, 0.16f);
Color textColor2 = default(Color);
((Color)(ref textColor2))..ctor(0.78f, 0.66f, 0.51f);
Color textColor3 = default(Color);
((Color)(ref textColor3))..ctor(0.91f, 0.75f, 0.25f);
int fontSize = Mathf.RoundToInt(24f * num);
int fontSize2 = Mathf.RoundToInt(17f * num);
Mathf.RoundToInt(17f * num);
GUIStyle val2 = new GUIStyle(GUI.skin.label)
{
fontSize = fontSize,
fontStyle = (FontStyle)1,
richText = true,
wordWrap = false,
alignment = (TextAnchor)3
};
val2.normal.textColor = textColor;
_styleTitle = val2;
if ((Object)(object)val != (Object)null)
{
_styleTitle.font = val;
}
GUIStyle val3 = new GUIStyle(GUI.skin.label)
{
fontSize = fontSize2,
fontStyle = (FontStyle)0,
richText = true,
wordWrap = true,
alignment = (TextAnchor)0
};
val3.normal.textColor = textColor2;
_styleBody = val3;
if ((Object)(object)val != (Object)null)
{
_styleBody.font = val;
}
GUIStyle val4 = new GUIStyle(GUI.skin.label)
{
fontSize = fontSize2,
fontStyle = (FontStyle)1,
richText = true,
wordWrap = false,
alignment = (TextAnchor)4
};
val4.normal.textColor = textColor3;
_styleCentered = val4;
if ((Object)(object)val != (Object)null)
{
_styleCentered.font = val;
}
GUIStyle val5 = new GUIStyle(GUI.skin.label)
{
fontSize = Mathf.RoundToInt(12f * num),
fontStyle = (FontStyle)1,
richText = true,
wordWrap = false,
alignment = (TextAnchor)4
};
val5.normal.textColor = new Color(1f, 0.85f, 0.1f);
_styleQE = val5;
_stylesReady = true;
}
private static Texture2D MakeSolid(Color c)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Expected O, but got Unknown
//IL_0018: 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)
Texture2D val = new Texture2D(4, 4, (TextureFormat)4, false);
Color[] array = (Color[])(object)new Color[16];
for (int i = 0; i < 16; i++)
{
array[i] = c;
}
val.SetPixels(array);
val.Apply();
return val;
}
private static Texture2D MakeCircle(int size, bool filled, Color c)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Expected O, but got Unknown
//IL_0083: 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)
Texture2D val = new Texture2D(size, size, (TextureFormat)4, false);
float num = (float)size * 0.5f;
float num2 = num - 1.5f;
float num3 = num2 - 6f;
for (int i = 0; i < size; i++)
{
for (int j = 0; j < size; j++)
{
float num4 = (float)j - num + 0.5f;
float num5 = (float)i - num + 0.5f;
float num6 = Mathf.Sqrt(num4 * num4 + num5 * num5);
bool flag = (filled ? (num6 <= num2) : (num6 <= num2 && num6 >= num3));
val.SetPixel(j, i, flag ? c : Color.clear);
}
}
val.Apply();
return val;
}
}
public static class BerserkParticle
{
private static Material? _mat;
public static void SpawnHitSplash(Vector3 worldPos, Vector3 hitDir)
{
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Expected O, but got Unknown
//IL_023b: 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_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0274: Unknown result type (might be due to invalid IL or missing references)
//IL_028d: Unknown result type (might be due to invalid IL or missing references)
//IL_02d7: 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_033a: Unknown result type (might be due to invalid IL or missing references)
//IL_0353: 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_0255: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Expected O, but got Unknown
//IL_0075: 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_0089: 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_0082: 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_00a8: 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_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_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_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: 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_0188: 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_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_01b2: 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_01cc: 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_01d8: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)ZNetScene.instance != (Object)null)
{
string[] array = new string[4] { "vfx_BloodHit", "vfx_BloodDeath", "fx_bloodweapon_hit", "fx_TickBloodHit" };
foreach (string text in array)
{
GameObject prefab = ZNetScene.instance.GetPrefab(text);
if ((Object)(object)prefab == (Object)null)
{
continue;
}
try
{
GameObject val = new GameObject("_bloodHolder");
val.SetActive(false);
Quaternion rotation = ((hitDir != Vector3.zero) ? Quaternion.LookRotation(hitDir) : Quaternion.identity);
GameObject val2 = Object.Instantiate<GameObject>(prefab, val.transform);
val2.transform.position = worldPos;
val2.transform.rotation = rotation;
ZNetView[] componentsInChildren = val2.GetComponentsInChildren<ZNetView>(true);
for (int j = 0; j < componentsInChildren.Length; j++)
{
Object.DestroyImmediate((Object)(object)componentsInChildren[j]);
}
ZSyncTransform[] componentsInChildren2 = val2.GetComponentsInChildren<ZSyncTransform>(true);
for (int j = 0; j < componentsInChildren2.Length; j++)
{
Object.DestroyImmediate((Object)(object)componentsInChildren2[j]);
}
val2.transform.SetParent((Transform)null);
Object.DestroyImmediate((Object)(object)val);
val2.SetActive(true);
ParticleSystem[] componentsInChildren3 = val2.GetComponentsInChildren<ParticleSystem>(true);
for (int j = 0; j < componentsInChildren3.Length; j++)
{
MainModule main = componentsInChildren3[j].main;
MinMaxGradient startColor = ((MainModule)(ref main)).startColor;
Color colorMin = ((MinMaxGradient)(ref startColor)).colorMin;
startColor = ((MainModule)(ref main)).startColor;
Color colorMax = ((MinMaxGradient)(ref startColor)).colorMax;
((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(Mathf.Max(colorMin.r, 0.8f), colorMin.g * 0.15f, colorMin.b * 0.1f, colorMin.a), new Color(Mathf.Max(colorMax.r, 0.95f), colorMax.g * 0.2f, colorMax.b * 0.1f, colorMax.a));
}
Object.Destroy((Object)(object)val2, 1.5f);
return;
}
catch
{
}
}
}
EnsureMaterial();
if (!((Object)(object)_mat == (Object)null))
{
GameObject val3 = new GameObject("BerkHit");
val3.transform.position = worldPos;
if (hitDir != Vector3.zero)
{
val3.transform.rotation = Quaternion.LookRotation(hitDir);
}
ParticleSystem ps = AddBurst(val3, new Color(1f, 0.05f, 0.18f, 0.9f), new Color(0.8f, 0f, 0.32f, 1f), 12, 3f, 6f, 0.07f, 0.2f, 0.2f, 0.4f, 100f, 2f);
ParticleSystem ps2 = AddBurst(val3, new Color(1f, 0.35f, 0.55f, 0.85f), new Color(1f, 0.1f, 0.28f, 0.9f), 20, 4f, 9f, 0.02f, 0.08f, 0.12f, 0.26f, 130f, 1.4f);
ParticleSystem ps3 = AddBurst(val3, new Color(0.9f, 0.08f, 0.22f, 0.4f), new Color(1f, 0.03f, 0.38f, 0.55f), 6, 0.6f, 1.8f, 0.18f, 0.42f, 0.28f, 0.55f, 360f, 0.08f);
ApplyMaterial(ps, (ParticleSystemRenderMode)1, 0.15f, 1.5f);
ApplyMaterial(ps2, (ParticleSystemRenderMode)1, 0.1f, 1.2f);
ApplyMaterial(ps3, (ParticleSystemRenderMode)0);
Object.Destroy((Object)(object)val3, 0.7f);
}
}
private static ParticleSystem AddBurst(GameObject parent, Color col1, Color col2, int count, float speed, float maxSpeed, float size, float maxSize, float lifetime, float maxLifetime, float spread, float gravity)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_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_004b: 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_006b: 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_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: 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_00a9: 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_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_00dd: 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_0107: 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_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Expected O, but got Unknown
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: 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_013f: 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_015b: 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_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_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a5: Expected O, but got Unknown
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("L");
val.transform.SetParent(parent.transform, false);
ParticleSystem val2 = val.AddComponent<ParticleSystem>();
MainModule main = val2.main;
((MainModule)(ref main)).loop = false;
((MainModule)(ref main)).playOnAwake = true;
((MainModule)(ref main)).duration = 0.05f;
((MainModule)(ref main)).startLifetime = new MinMaxCurve(lifetime, maxLifetime);
((MainModule)(ref main)).startSpeed = new MinMaxCurve(speed, maxSpeed);
((MainModule)(ref main)).startSize = new MinMaxCurve(size, maxSize);
((MainModule)(ref main)).startColor = new MinMaxGradient(col1, col2);
((MainModule)(ref main)).gravityModifier = new MinMaxCurve(gravity);
((MainModule)(ref main)).maxParticles = count + 4;
((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
EmissionModule emission = val2.emission;
((EmissionModule)(ref emission)).enabled = true;
((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
((EmissionModule)(ref emission)).SetBurst(0, new Burst(0f, MinMaxCurve.op_Implicit((float)count)));
ShapeModule shape = val2.shape;
((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
((ShapeModule)(ref shape)).angle = spread * 0.5f;
((ShapeModule)(ref shape)).radius = 0.04f;
ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
Gradient val3 = new Gradient();
val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
{
new GradientColorKey(col1, 0f),
new GradientColorKey(col2, 1f)
}, (GradientAlphaKey[])(object)new GradientAlphaKey[2]
{
new GradientAlphaKey(1f, 0f),
new GradientAlphaKey(0f, 1f)
});
((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val3);
SizeOverLifetimeModule sizeOverLifetime = val2.sizeOverLifetime;
((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
AnimationCurve val4 = new AnimationCurve();
val4.AddKey(0f, 1f);
val4.AddKey(1f, 0.08f);
((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, val4);
return val2;
}
private static void ApplyMaterial(ParticleSystem ps, ParticleSystemRenderMode mode, float vScale = 0f, float lScale = 1f)
{
//IL_0013: 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_001b: Invalid comparison between Unknown and I4
ParticleSystemRenderer component = ((Component)ps).GetComponent<ParticleSystemRenderer>();
((Renderer)component).material = _mat;
component.renderMode = mode;
if ((int)mode == 1)
{
component.velocityScale = vScale;
component.lengthScale = lScale;
}
((Renderer)component).sortingOrder = 5;
}
private static void EnsureMaterial()
{
//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_0051: Expected O, but got Unknown
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Expected O, but got Unknown
if ((Object)(object)_mat != (Object)null)
{
return;
}
ParticleSystem[] array = Object.FindObjectsByType<ParticleSystem>((FindObjectsSortMode)0);
for (int i = 0; i < array.Length; i++)
{
ParticleSystemRenderer component = ((Component)array[i]).GetComponent<ParticleSystemRenderer>();
if (!((Object)(object)((component != null) ? ((Renderer)component).sharedMaterial : null) == (Object)null))
{
_mat = new Material(((Renderer)component).sharedMaterial)
{
name = "BerkHitMat"
};
return;
}
}
string[] array2 = new string[4] { "Custom/Particle", "Particles/Standard Unlit", "Legacy Shaders/Particles/Additive", "Sprites/Default" };
for (int i = 0; i < array2.Length; i++)
{
Shader val = Shader.Find(array2[i]);
if (!((Object)(object)val == (Object)null))
{
_mat = new Material(val)
{
name = "BerkHitMat"
};
_mat.SetInt("_SrcBlend", 5);
_mat.SetInt("_DstBlend", 1);
_mat.SetInt("_ZWrite", 0);
_mat.renderQueue = 3000;
break;
}
}
}
}
public class BerserkSwirl : MonoBehaviour
{
private ParticleSystem? _ring;
private ParticleSystem? _halo;
private ParticleSystem? _embers;
private float _time;
private Material? _mat;
public static BerserkSwirl Attach(Character c)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("BerkAura");
val.transform.SetParent(((Component)c).transform, false);
val.transform.localPosition = Vector3.zero;
BerserkSwirl berserkSwirl = val.AddComponent<BerserkSwirl>();
berserkSwirl.Build();
return berserkSwirl;
}
private void Build()
{
_mat = MakeGlowMat();
_ring = MakeGroundRing(((Component)this).transform, _mat);
_halo = MakeBodyHalo(((Component)this).transform, _mat);
_embers = MakeEmbers(((Component)this).transform, _mat);
}
private void OnDestroy()
{
if ((Object)(object)_mat != (Object)null)
{
Object.Destroy((Object)(object)_mat);
}
}
private void Update()
{
//IL_0026: 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_0050: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
_time += Time.deltaTime;
if ((Object)(object)_halo != (Object)null)
{
EmissionModule emission = _halo.emission;
((EmissionModule)(ref emission)).rateOverTime = new MinMaxCurve(8f + Mathf.Abs(Mathf.Sin(_time * 2.8f)) * 28f);
}
if ((Object)(object)_ring != (Object)null)
{
float num = Mathf.Pow(Mathf.Abs(Mathf.Sin(_time * 1.4f)), 3f);
EmissionModule emission2 = _ring.emission;
((EmissionModule)(ref emission2)).rateOverTime = new MinMaxCurve(3f + num * 35f);
}
}
private static Material MakeGlowMat()
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//IL_0118: 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)
Shader val = Shader.Find("Particles/Additive");
if ((Object)(object)val == (Object)null)
{
val = Shader.Find("Mobile/Particles/Additive");
}
if ((Object)(object)val == (Object)null)
{
val = Shader.Find("Legacy Shaders/Particles/Additive");
}
Material val2 = new Material(val ?? Shader.Find("Sprites/Default"));
Texture2D val3 = new Texture2D(64, 64, (TextureFormat)4, false);
float num = 32f;
for (int i = 0; i < 64; i++)
{
for (int j = 0; j < 64; j++)
{
float num2 = ((float)j - num + 0.5f) / num;
float num3 = ((float)i - num + 0.5f) / num;
float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3);
float num5 = Mathf.Clamp01(1f - num4);
num5 *= num5;
val3.SetPixel(j, i, new Color(1f, 1f, 1f, num5));
}
}
val3.Apply();
((Texture)val3).wrapMode = (TextureWrapMode)1;
val2.mainTexture = (Texture)(object)val3;
if (val2.HasProperty("_TintColor"))
{
val2.SetColor("_TintColor", new Color(0.9f, 0.1f, 0f, 0.6f));
}
return val2;
}
private static ParticleSystem MakeGroundRing(Transform parent, Material mat)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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_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_005e: 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_008a: 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_00c3: 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_00d9: 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_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("AuraRing");
val.transform.SetParent(parent, false);
val.transform.localPosition = new Vector3(0f, 0.05f, 0f);
ParticleSystem obj = val.AddComponent<ParticleSystem>();
MainModule main = obj.main;
((MainModule)(ref main)).loop = true;
((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.5f, 0.9f);
((MainModule)(ref main)).startSpeed = new MinMaxCurve(1.5f, 3f);
((MainModule)(ref main)).startSize = new MinMaxCurve(0.14f, 0.26f);
((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(1f, 0.1f, 0f, 1f), new Color(0.8f, 0f, 0f, 0.8f));
((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0.3f);
((MainModule)(ref main)).maxParticles = 250;
((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)0;
EmissionModule emission = obj.emission;
((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(10f);
ShapeModule shape = obj.shape;
((ShapeModule)(ref shape)).enabled = true;
((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)10;
((ShapeModule)(ref shape)).radius = 0.05f;
((ShapeModule)(ref shape)).radiusThickness = 1f;
((ShapeModule)(ref shape)).rotation = new Vector3(-90f, 0f, 0f);
ApplyFade(obj, new Color(1f, 0.1f, 0f), new Color(0.4f, 0f, 0f));
ParticleSystemRenderer component = ((Component)obj).GetComponent<ParticleSystemRenderer>();
component.renderMode = (ParticleSystemRenderMode)0;
((Renderer)component).sharedMaterial = mat;
obj.Play();
return obj;
}
private static ParticleSystem MakeBodyHalo(Transform parent, Material mat)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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_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_005e: 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_008a: 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_00c3: 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_00d9: 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_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: 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_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("AuraHalo");
val.transform.SetParent(parent, false);
val.transform.localPosition = new Vector3(0f, 1f, 0f);
ParticleSystem obj = val.AddComponent<ParticleSystem>();
MainModule main = obj.main;
((MainModule)(ref main)).loop = true;
((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.7f, 1.5f);
((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.5f, 1.4f);
((MainModule)(ref main)).startSize = new MinMaxCurve(0.1f, 0.24f);
((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(1f, 0.1f, 0f, 0.9f), new Color(0.8f, 0f, 0f, 0.7f));
((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.05f);
((MainModule)(ref main)).maxParticles = 180;
((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)0;
EmissionModule emission = obj.emission;
((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(18f);
ShapeModule shape = obj.shape;
((ShapeModule)(ref shape)).enabled = true;
((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
((ShapeModule)(ref shape)).radius = 0.65f;
((ShapeModule)(ref shape)).radiusThickness = 0f;
VelocityOverLifetimeModule velocityOverLifetime = obj.velocityOverLifetime;
((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
((VelocityOverLifetimeModule)(ref velocityOverLifetime)).radial = new MinMaxCurve(1.2f);
ApplyFade(obj, new Color(1f, 0.05f, 0f), new Color(0.3f, 0f, 0f));
ParticleSystemRenderer component = ((Component)obj).GetComponent<ParticleSystemRenderer>();
component.renderMode = (ParticleSystemRenderMode)0;
((Renderer)component).sharedMaterial = mat;
obj.Play();
return obj;
}
private static ParticleSystem MakeEmbers(Transform parent, Material mat)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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_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_005e: 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_008a: 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_00c3: 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_00d9: 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_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("AuraEmbers");
val.transform.SetParent(parent, false);
val.transform.localPosition = new Vector3(0f, 0.1f, 0f);
ParticleSystem obj = val.AddComponent<ParticleSystem>();
MainModule main = obj.main;
((MainModule)(ref main)).loop = true;
((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
((MainModule)(ref main)).startLifetime = new MinMaxCurve(1f, 2.2f);
((MainModule)(ref main)).startSpeed = new MinMaxCurve(1.5f, 3.5f);
((MainModule)(ref main)).startSize = new MinMaxCurve(0.04f, 0.1f);
((MainModule)(ref main)).startColor = new MinMaxGradient(new Color(1f, 0.15f, 0f, 1f), new Color(0.8f, 0f, 0f, 0.8f));
((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-1.8f);
((MainModule)(ref main)).maxParticles = 130;
((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)0;
EmissionModule emission = obj.emission;
((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(22f);
ShapeModule shape = obj.shape;
((ShapeModule)(ref shape)).enabled = true;
((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)10;
((ShapeModule)(ref shape)).radius = 0.3f;
((ShapeModule)(ref shape)).radiusThickness = 1f;
((ShapeModule)(ref shape)).rotation = new Vector3(-90f, 0f, 0f);
ApplyFade(obj, new Color(1f, 0.1f, 0f), new Color(0.3f, 0f, 0f));
ParticleSystemRenderer component = ((Component)obj).GetComponent<ParticleSystemRenderer>();
component.renderMode = (ParticleSystemRenderMode)0;
((Renderer)component).sharedMaterial = mat;
obj.Play();
return obj;
}
private static void ApplyFade(ParticleSystem ps, Color from, Color to)
{
//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_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
//IL_001e: 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_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: 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_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_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_0090: Unknown result type (might be due to invalid IL or missing references)
ColorOverLifetimeModule colorOverLifetime = ps.colorOverLifetime;
((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
Gradient val = new Gradient();
val.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
{
new GradientColorKey(from, 0f),
new GradientColorKey(to, 1f)
}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
{
new GradientAlphaKey(1f, 0f),
new GradientAlphaKey(0.4f, 0.6f),
new GradientAlphaKey(0f, 1f)
});
((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val);
}
}
public class BoneSync : MonoBehaviour
{
private struct WeaponClone
{
public MeshRenderer OriginalRenderer;
public GameObject Clone;
public Transform PlayerHand;
public Transform ModelHand;
}
[CompilerGenerated]
private sealed class <Setup>d__13 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public BoneSync <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Setup>d__13(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
int num = <>1__state;
BoneSync boneSync = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = null;
<>1__state = 1;
return true;
case 1:
{
<>1__state = -1;
if ((Object)(object)boneSync._playerRoot == (Object)null || (Object)(object)boneSync._modelRoot == (Object)null)
{
return false;
}
boneSync._playerAnimator = ((Component)boneSync._playerRoot).GetComponentInChildren<Animator>();
boneSync._modelAnimator = ((Component)boneSync._modelRoot).GetComponentInChildren<Animator>();
if ((Object)(object)boneSync._playerAnimator == (Object)null)
{
BerserkPlugin.Log.LogError((object)"[BoneSync] Player animator not found!");
return false;
}
if (boneSync._isDemonMode)
{
if ((Object)(object)boneSync._modelAnimator != (Object)null)
{
if ((Object)(object)boneSync._modelAnimator.runtimeAnimatorController != (Object)null)
{
AnimationClip[] animationClips = boneSync._modelAnimator.runtimeAnimatorController.animationClips;
foreach (AnimationClip val in animationClips)
{
string text = ((Object)val).name.ToLower();
if (text.Contains("idle") && !text.Contains("combat"))
{
boneSync._demonIdleAnims.Add(((Object)val).name);
}
else if (text.Contains("attack") || text.Contains("combat") || text.Contains("slash") || text.Contains("hit"))
{
boneSync._demonAttackAnims.Add(((Object)val).name);
}
else if (text.Contains("run") || text.Contains("walk") || text.Contains("move"))
{
boneSync._demonMoveAnims.Add(((Object)val).name);
}
}
}
AnimatorControllerParameter[] parameters = boneSync._modelAnimator.parameters;
for (int i = 0; i < parameters.Length; i++)
{
_ = parameters[i];
}
((Behaviour)boneSync._modelAnimator).enabled = true;
boneSync._modelAnimator.applyRootMotion = false;
boneSync._modelAnimator.cullingMode = (AnimatorCullingMode)0;
boneSync._modelAnimator.speed = 1f;
if (!boneSync.TryPlayAnim("idlecombat00") && !boneSync.TryPlayAnim("idle00"))
{
boneSync.PlayDemonAnim(boneSync._demonIdleAnims, "idle");
}
}
}
else if ((Object)(object)boneSync._modelAnimator != (Object)null)
{
((Behaviour)boneSync._modelAnimator).enabled = true;
boneSync._modelAnimator.runtimeAnimatorController = boneSync._playerAnimator.runtimeAnimatorController;
boneSync._modelAnimator.applyRootMotion = false;
}
SkinnedMeshRenderer[] componentsInChildren = ((Component)boneSync._modelRoot).GetComponentsInChildren<SkinnedMeshRenderer>(true);
for (int i = 0; i < componentsInChildren.Length; i++)
{
componentsInChildren[i].updateWhenOffscreen = true;
}
boneSync._playerBones = new Dictionary<string, Transform>(StringComparer.OrdinalIgnoreCase);
Transform[] componentsInChildren2 = ((Component)boneSync._playerRoot).GetComponentsInChildren<Transform>(true);
foreach (Transform val2 in componentsInChildren2)
{
if (!boneSync._playerBones.ContainsKey(((Object)val2).name))
{
boneSync._playerBones[((Object)val2).name] = val2;
}
}
boneSync._modelBones = new Dictionary<string, Transform>(StringComparer.OrdinalIgnoreCase);
componentsInChildren2 = ((Component)boneSync._modelRoot).GetComponentsInChildren<Transform>(true);
foreach (Transform val3 in componentsInChildren2)
{
if (!boneSync._modelBones.ContainsKey(((Object)val3).name))
{
boneSync._modelBones[((Object)val3).name] = val3;
}
}
if (!boneSync._isDemonMode)
{
boneSync.RefreshWeaponClones();
}
boneSync._ready = true;
return false;
}
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private Transform? _playerRoot;
private Transform? _modelRoot;
private Animator? _playerAnimator;
private Animator? _modelAnimator;
private bool _ready;
private bool _isDemonMode;
private List<WeaponClone> _weaponClones = new List<WeaponClone>();
private Dictionary<string, Transform> _modelBones = new Dictionary<string, Transform>();
private Dictionary<string, Transform> _playerBones = new Dictionary<string, Transform>();
private float _refreshTimer;
private const float RefreshInterval = 0.3f;
private List<string> _demonIdleAnims = new List<string>();
private List<string> _demonAttackAnims = new List<string>();
private List<string> _demonMoveAnims = new List<string>();
private int _attackAnimIndex;
private float _attackAnimEndTime;
private bool _isPlayingAttack;
private bool _isCharging;
private bool _wasMoving;
private bool _wasRunning;
private float _animRefreshTimer;
public void Init(Transform playerRoot, Transform modelRoot)
{
_playerRoot = playerRoot;
_modelRoot = modelRoot;
_isDemonMode = (Object)(object)BerserkPlugin.DemonPrefab != (Object)null && ((Object)modelRoot).name.Contains("Demon");
((MonoBehaviour)this).StartCoroutine(Setup());
}
[IteratorStateMachine(typeof(<Setup>d__13))]
private IEnumerator Setup()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Setup>d__13(0)
{
<>4__this = this
};
}
private void PlayDemonAnim(List<string> anims, string fallbackPattern)
{
if ((Object)(object)_modelAnimator == (Object)null || TryPlayAnim(fallbackPattern + "00") || TryPlayAnim(fallbackPattern + "01") || TryPlayAnim(fallbackPattern))
{
return;
}
foreach (string anim in anims)
{
if (TryPlayAnim(anim))
{
break;
}
}
}
private bool TryPlayAnim(string animName, bool useBlend = true)
{
if ((Object)(object)_modelAnimator == (Object)null)
{
return false;
}
int num = Animator.StringToHash(animName);
if (_modelAnimator.HasState(0, num))
{
if (useBlend)
{
_modelAnimator.CrossFadeInFixedTime(num, 0.15f, 0);
}
else
{
_modelAnimator.Play(num, 0, 0f);
}
return true;
}
int num2 = Animator.StringToHash("Base Layer." + animName);
if (_modelAnimator.HasState(0, num2))
{
if (useBlend)
{
_modelAnimator.CrossFadeInFixedTime(num2, 0.15f, 0);
}
else
{
_modelAnimator.Play(num2, 0, 0f);
}
return true;
}
return false;
}
public void PlayAttackAnimation(float speedMult = 1f)
{
if ((Object)(object)_modelAnimator == (Object)null || !_isDemonMode)
{
return;
}
_isPlayingAttack = true;
_attackAnimEndTime = Time.time + 0.7f / speedMult;
_modelAnimator.speed = speedMult;
string[] array = new string[3] { "attack00", "attack01", "attack02" };
_attackAnimIndex = (_attackAnimIndex + 1) % array.Length;
if (TryPlayAnim(array[_attackAnimIndex]))
{
return;
}
string[] array2 = array;
foreach (string animName in array2)
{
if (TryPlayAnim(animName))
{
break;
}
}
}
public void PlaySlamAnimation()
{
if (!((Object)(object)_modelAnimator == (Object)null) && _isDemonMode)
{
_isPlayingAttack = true;
_attackAnimEndTime = Time.time + 1.2f;
if (!TryPlayAnim("attack02") && !TryPlayAnim("attack01"))
{
TryPlayAnim("attack00");
}
}
}
public void PlayChargeAnimation()
{
if ((Object)(object)_modelAnimator == (Object)null || !_isDemonMode)
{
return;
}
_isPlayingAttack = true;
_attackAnimEndTime = Time.time + 30f;
_isCharging = true;
int num = Animator.StringToHash("attack01");
if (_modelAnimator.HasState(0, num))
{
_modelAnimator.Play(num, 0, 0f);
_modelAnimator.speed = 0.1f;
return;
}
num = Animator.StringToHash("attack00");
if (_modelAnimator.HasState(0, num))
{
_modelAnimator.Play(num, 0, 0f);
_modelAnimator.speed = 0.1f;
}
}
public void StopChargeAnimation()
{
_isPlayingAttack = false;
_attackAnimEndTime = 0f;
_isCharging = false;
if ((Object)(object)_modelAnimator != (Object)null)
{
_modelAnimator.speed = 1f;
}
}
private string? FindHandNameInParents(Transform t)
{
Transform parent = t.parent;
int num = 0;
while (num < 10 && (Object)(object)parent != (Object)null)
{
string text = ((Object)parent).name.ToLowerInvariant();
if (text.Contains("righthand") || text.Contains("lefthand"))
{
return ((Object)parent).name;
}
num++;
parent = parent.parent;
}
return null;
}
private void RefreshWeaponClones()
{
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Expected O, but got Unknown
if ((Object)(object)_playerRoot == (Object)null || (Object)(object)_modelRoot == (Object)null)
{
return;
}
for (int num = _weaponClones.Count - 1; num >= 0; num--)
{
WeaponClone weaponClone = _weaponClones[num];
if ((Object)(object)weaponClone.OriginalRenderer == (Object)null || !((Component)weaponClone.OriginalRenderer).gameObject.activeInHierarchy)
{
if ((Object)(object)weaponClone.OriginalRenderer != (Object)null)
{
((Renderer)weaponClone.OriginalRenderer).enabled = true;
}
if ((Object)(object)weaponClone.Clone != (Object)null)
{
Object.Destroy((Object)(object)weaponClone.Clone);
}
_weaponClones.RemoveAt(num);
}
}
MeshRenderer[] componentsInChildren = ((Component)_playerRoot).GetComponentsInChildren<MeshRenderer>(true);
foreach (MeshRenderer val in componentsInChildren)
{
if (!((Component)val).gameObject.activeInHierarchy)
{
continue;
}
bool flag = false;
foreach (WeaponClone weaponClone2 in _weaponClones)
{
if ((Object)(object)weaponClone2.OriginalRenderer == (Object)(object)val)
{
flag = true;
break;
}
}
if (flag)
{
continue;
}
string text = FindHandNameInParents(((Component)val).transform);
if (text != null && _modelBones.TryGetValue(text, out Transform value) && _playerBones.TryGetValue(text, out Transform value2))
{
GameObject val2 = new GameObject("WeaponClone_" + ((Object)val).name);
MeshFilter val3 = val2.AddComponent<MeshFilter>();
MeshRenderer obj = val2.AddComponent<MeshRenderer>();
MeshFilter component = ((Component)val).GetComponent<MeshFilter>();
if ((Object)(object)component != (Object)null)
{
val3.sharedMesh = component.sharedMesh;
}
((Renderer)obj).sharedMaterials = ((Renderer)val).sharedMaterials;
_weaponClones.Add(new WeaponClone
{
OriginalRenderer = val,
Clone = val2,
PlayerHand = value2,
ModelHand = value
});
((Renderer)val).enabled = false;
}
}
}
private void LateUpdate()
{
//IL_0031: 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_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: 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_020b: Expected I4, but got Unknown
//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
//IL_038c: Unknown result type (might be due to invalid IL or missing references)
//IL_0398: Unknown result type (might be due to invalid IL or missing references)
//IL_039d: 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_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_03b5: 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_03c5: Unknown result type (might be due to invalid IL or missing references)
//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
//IL_03db: Unknown result type (might be due to invalid IL or missing references)
//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0406: Unknown result type (might be due to invalid IL or missing references)
//IL_040b: Unknown result type (might be due to invalid IL or missing references)
//IL_040d: Unknown result type (might be due to invalid IL or missing references)
//IL_0412: Unknown result type (might be due to invalid IL or missing references)
//IL_042f: Unknown result type (might be due to invalid IL or missing references)
//IL_0434: 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_0458: Unknown result type (might be due to invalid IL or missing references)
if (!_ready || (Object)(object)_playerRoot == (Object)null || (Object)(object)_modelRoot == (Object)null)
{
return;
}
_modelRoot.position = _playerRoot.position;
_modelRoot.rotation = _playerRoot.rotation;
if (_isDemonMode)
{
if (_isPlayingAttack)
{
if (!(Time.time > _attackAnimEndTime))
{
return;
}
_isPlayingAttack = false;
if ((Object)(object)_modelAnimator != (Object)null)
{
_modelAnimator.speed = 1f;
}
}
if (!((Object)(object)_playerAnimator != (Object)null) || _isPlayingAttack)
{
return;
}
float num = 0f;
try
{
num = _playerAnimator.GetFloat("forward_speed");
}
catch
{
}
bool flag = Mathf.Abs(num) > 0.1f;
bool flag2 = Mathf.Abs(num) > 3f;
_animRefreshTimer -= Time.deltaTime;
bool flag3 = _animRefreshTimer <= 0f;
if (flag3)
{
_animRefreshTimer = 2f;
}
if (flag2 && (!_wasRunning || flag3))
{
TryPlayAnim("run00");
_wasMoving = true;
_wasRunning = true;
}
else if (flag && !flag2 && (!_wasMoving || flag3))
{
TryPlayAnim("run00");
_wasMoving = true;
_wasRunning = false;
}
else if (!flag && (_wasMoving || flag3))
{
if (!TryPlayAnim("idlecombat00"))
{
TryPlayAnim("idle00");
}
_wasMoving = false;
_wasRunning = false;
}
}
else
{
if ((Object)(object)_playerAnimator == (Object)null || (Object)(object)_modelAnimator == (Object)null)
{
return;
}
AnimatorControllerParameter[] parameters = _playerAnimator.parameters;
foreach (AnimatorControllerParameter val in parameters)
{
try
{
AnimatorControllerParameterType type = val.type;
switch (type - 1)
{
case 0:
_modelAnimator.SetFloat(val.nameHash, _playerAnimator.GetFloat(val.nameHash));
break;
case 2:
_modelAnimator.SetInteger(val.nameHash, _playerAnimator.GetInteger(val.nameHash));
break;
case 3:
_modelAnimator.SetBool(val.nameHash, _playerAnimator.GetBool(val.nameHash));
break;
case 1:
break;
}
}
catch
{
}
}
for (int j = 0; j < _playerAnimator.layerCount; j++)
{
AnimatorStateInfo currentAnimatorStateInfo = _playerAnimator.GetCurrentAnimatorStateInfo(j);
_modelAnimator.Play(((AnimatorStateInfo)(ref currentAnimatorStateInfo)).fullPathHash, j, ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime);
}
_modelAnimator.speed = _playerAnimator.speed;
_refreshTimer -= Time.deltaTime;
if (_refreshTimer <= 0f)
{
_refreshTimer = 0.3f;
RefreshWeaponClones();
}
foreach (WeaponClone weaponClone in _weaponClones)
{
if (!((Object)(object)weaponClone.Clone == (Object)null) && !((Object)(object)weaponClone.OriginalRenderer == (Object)null) && !((Object)(object)weaponClone.PlayerHand == (Object)null) && !((Object)(object)weaponClone.ModelHand == (Object)null))
{
Vector3 val2 = ((Component)weaponClone.OriginalRenderer).transform.position - weaponClone.PlayerHand.position;
Vector3 val3 = Quaternion.Inverse(weaponClone.PlayerHand.rotation) * val2;
Quaternion val4 = Quaternion.Inverse(weaponClone.PlayerHand.rotation) * ((Component)weaponClone.OriginalRenderer).transform.rotation;
weaponClone.Clone.transform.position = weaponClone.ModelHand.position + weaponClone.ModelHand.rotation * val3;
weaponClone.Clone.transform.rotation = weaponClone.ModelHand.rotation * val4;
weaponClone.Clone.transform.localScale = ((Component)weaponClone.OriginalRenderer).transform.lossyScale;
}
}
}
}
private void OnDestroy()
{
foreach (WeaponClone weaponClone in _weaponClones)
{
if ((Object)(object)weaponClone.OriginalRenderer != (Object)null)
{
((Renderer)weaponClone.OriginalRenderer).enabled = true;
}
if ((Object)(object)weaponClone.Clone != (Object)null)
{
Object.Destroy((Object)(object)weaponClone.Clone);
}
}
_weaponClones.Clear();
}
}
public class DemonSync : MonoBehaviour
{
private Transform? _playerRoot;
private Transform? _demonRoot;
private Animator? _playerAnimator;
private Animator? _demonAnimator;
private bool _ready;
private bool _wasAttacking;
private int _attackCombo;
public void Init(Transform playerRoot, Transform demonRoot)
{
_playerRoot = playerRoot;
_demonRoot = demonRoot;
_playerAnimator = ((Component)playerRoot).GetComponentInChildren<Animator>();
_demonAnimator = ((Component)demonRoot).GetComponentInChildren<Animator>();
if ((Object)(object)_demonAnimator != (Object)null)
{
((Behaviour)_demonAnimator).enabled = true;
_demonAnimator.cullingMode = (AnimatorCullingMode)0;
_demonAnimator.Play("Idle", 0, 0f);
}
_ready = true;
}
private void LateUpdate()
{
//IL_0031: 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)
if (_ready && !((Object)(object)_playerRoot == (Object)null) && !((Object)(object)_demonRoot == (Object)null))
{
_demonRoot.position = _playerRoot.position;
_demonRoot.rotation = _playerRoot.rotation;
if ((Object)(object)_playerAnimator != (Object)null && (Object)(object)_demonAnimator != (Object)null)
{
SyncAnimationState();
}
}
}
private void SyncAnimationState()
{
//IL_0024: 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)
if (!((Object)(object)_playerAnimator == (Object)null) && !((Object)(object)_demonAnimator == (Object)null))
{
AnimatorStateInfo currentAnimatorStateInfo = _playerAnimator.GetCurrentAnimatorStateInfo(0);
bool flag = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsTag("attack") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Attack1") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Attack2") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Attack3") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("swing_axe0") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("swing_axe1") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("swing_axe2") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("swing_pickaxe") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("swing_sledge") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("swing_longsword0") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("swing_longsword1") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("swing_longsword2") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("atgeir_attack0") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("atgeir_attack1") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("atgeir_attack2") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("battleaxe_attack0") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("battleaxe_attack1") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("battleaxe_attack2") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("knife_stab0") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("knife_stab1") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("knife_stab2") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("mace_attack0") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("mace_attack1") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("mace_attack2") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("spear_poke") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("sword_attack0") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("sword_attack1") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("sword_attack2") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("unarmed0") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("unarmed1") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("unarmed2");
float num = 0f;
try
{
num = _playerAnimator.GetFloat("forward_speed");
}
catch
{
}
bool flag2 = num > 0.5f;
bool flag3 = false;
try
{
flag3 = !_playerAnimator.GetBool("inWater") && _playerAnimator.GetBool("jump");
}
catch
{
}
if (flag && !_wasAttacking)
{
_attackCombo = (_attackCombo + 1) % 3;
string text = _attackCombo switch
{
0 => "Attack1",
1 => "Attack2",
_ => "Attack3",
};
TryPlayAnimation(text, "Attack", "attack", "Punch", "Slash", "Hit");
}
else if (flag3)
{
TryPlayAnimation("Jump", "jump", "Jumping");
}
else if (flag2 && !flag)
{
TryPlayAnimation("Run", "run", "Running", "Walk", "walk");
}
else if (!flag && !flag2 && !flag3)
{
TryPlayAnimation("Idle", "idle", "Breathing Idle");
}
_wasAttacking = flag;
}
}
private void TryPlayAnimation(params string[] names)
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_demonAnimator == (Object)null)
{
return;
}
foreach (string text in names)
{
if (HasAnimation(text))
{
AnimatorStateInfo currentAnimatorStateInfo = _demonAnimator.GetCurrentAnimatorStateInfo(0);
if (!((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName(text))
{
_demonAnimator.CrossFade(text, 0.1f, 0);
}
break;
}
}
}
private bool HasAnimation(string name)
{
if ((Object)(object)_demonAnimator == (Object)null || (Object)(object)_demonAnimator.runtimeAnimatorController == (Object)null)
{
return false;
}
AnimationClip[] animationClips = _demonAnimator.runtimeAnimatorController.animationClips;
foreach (AnimationClip val in animationClips)
{
if (((Object)val).name == name || ((Object)val).name.ToLower().Contains(name.ToLower()))
{
return true;
}
}
return false;
}
}
[BepInPlugin("com.aurora.berserkir", "Berserkir", "1.1.1")]
public class BerserkPlugin : BaseUnityPlugin
{
[CompilerGenerated]
private sealed class <LoadAudio>d__21 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public string relative;
public Action<AudioClip> onLoaded;
private UnityWebRequest <req>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <LoadAudio>d__21(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<req>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Invalid comparison between Unknown and I4
bool result;
try
{
switch (<>1__state)
{
default:
result = false;
break;
case 0:
{
<>1__state = -1;
string text = Path.Combine(PluginFolder, relative);
if (!File.Exists(text))
{
Log.LogWarning((object)("[Berserkir] Audio not found: " + text));
result = false;
break;
}
<req>5__2 = UnityWebRequestMultimedia.GetAudioClip("file://" + text, (AudioType)14);
<>1__state = -3;
<>2__current = <req>5__2.SendWebRequest();
<>1__state = 1;
result = true;
break;
}
case 1:
<>1__state = -3;
if ((int)<req>5__2.result != 1)
{
Log.LogError((object)("[Berserkir] Audio load failed: " + <req>5__2.error));
result = false;
}
else
{
AudioClip content = DownloadHandlerAudioClip.GetContent(<req>5__2);
((Object)content).name = relative;
onLoaded(content);
result = false;
}
<>m__Finally1();
break;
}
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
return result;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<req>5__2 != null)
{
((IDisposable)<req>5__2).Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public const string PluginGUID = "com.aurora.berserkir";
public const string PluginName = "Berserkir";
public const string PluginVersion = "1.1.1";
public const string PluginAuthor = "Freyja";
internal static ManualLogSource Log;
internal static BerserkPlugin Instance;
internal static string PluginFolder;
internal static AudioClip? ClipActivate;
internal static AudioClip? ClipSlam;
internal static AudioClip? ClipPulse;
internal static AssetBundle? Bundle;
internal static GameObject? FirePrefab;
internal static AssetBundle? DemonBundle;
internal static GameObject? DemonPrefab;
private Harmony? _harmony;
private bool _enabled = true;
private void Awake()
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
PluginFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
ServerGuard.Init(this);
if (_enabled)
{
_harmony = new Harmony("com.aurora.berserkir");
_harmony.PatchAll();
((MonoBehaviour)this).StartCoroutine(LoadAudio("sounds/zerk_activate.ogg", delegate(AudioClip clip)
{
ClipActivate = clip;
}));
((MonoBehaviour)this).StartCoroutine(LoadAudio("sounds/zerk_slam.ogg", delegate(AudioClip clip)
{
ClipSlam = clip;
}));
((MonoBehaviour)this).StartCoroutine(LoadAudio("sounds/zerk_pulse.ogg", delegate(AudioClip clip)
{
ClipPulse = clip;
}));
LoadBundle();
LoadDemonBundle();
Log.LogInfo((object)"Berserkir v1.1.1 by Freyja — AWAKENED!");
}
}
private void LoadBundle()
{
string text = Path.Combine(PluginFolder, "berserkir");
if (!File.Exists(text))
{
Log.LogWarning((object)("[Berserkir] berserkir bundle not found at: " + text));
return;
}
Bundle = AssetBundle.LoadFromFile(text);
if ((Object)(object)Bundle == (Object)null)
{
Log.LogError((object)"[Berserkir] Bundle load failed.");
return;
}
FirePrefab = Bundle.LoadAsset<GameObject>("BerserkFire");
if ((Object)(object)FirePrefab != (Object)null)
{
Log.LogInfo((object)"[Berserkir] BerserkFire loaded OK");
}
else
{
Log.LogWarning((object)"[Berserkir] BerserkFire not found in bundle.");
}
}
private void LoadDemonBundle()
{
string text = Path.Combine(PluginFolder, "berserkir_demon");
if (!File.Exists(text))
{
Log.LogInfo((object)"[Berserkir] Custom demon bundle not found - will use default skeleton.");
return;
}
DemonBundle = AssetBundle.LoadFromFile(text);
if ((Object)(object)DemonBundle == (Object)null)
{
Log.LogError((object)"[Berserkir] Demon bundle load failed!");
return;
}
DemonPrefab = DemonBundle.LoadAsset<GameObject>("DemonGirl 1 Variant");
if ((Object)(object)DemonPrefab != (Object)null)
{
Log.LogInfo((object)"[Berserkir] Custom DemonGirl loaded OK!");
return;
}
Log.LogWarning((object)"[Berserkir] DemonGirl prefab not found. Assets in bundle:");
string[] allAssetNames = DemonBundle.GetAllAssetNames();
foreach (string text2 in allAssetNames)
{
Log.LogWarning((object)(" - " + text2));
}
}
public void DisablePlugin()
{
_enabled = false;
}
private void OnDestroy()
{
Harmony? harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
[IteratorStateMachine(typeof(<LoadAudio>d__21))]
private static IEnumerator LoadAudio(string relative, Action<AudioClip> onLoaded)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LoadAudio>d__21(0)
{
relative = relative,
onLoaded = onLoaded
};
}
}
[HarmonyPatch]
public static class BerserkPatches
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static ConsoleEvent <>9__21_0;
internal void <Terminal_InitTerminal>b__21_0(ConsoleEventArgs args)
{
BerserkHUD instance = BerserkHUD.Instance;
if ((Object)(object)instance == (Object)null)
{
Terminal.Log((object)"Berserkir HUD not active.");
return;
}
instance.AdminFill();
Terminal.Log((object)"<color=#FF3300>Berserkir: all bars filled — RAGE READY!</color>");
}
}
[CompilerGenerated]
private sealed class <DelayedClawDamage>d__44 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public float delay;
public Player player;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <DelayedClawDamage>d__44(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(delay);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
DealClawDamage(player);
SE_Berserk.PlaySlam();
BerserkHUD.TriggerShake(0.4f);
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <DelayedSlamExplosion>d__48 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public float delay;
public Player player;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <DelayedSlamExplosion>d__48(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: 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_0055: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(delay);
<>1__state = 1;
return true;
case 1:
{
<>1__state = -1;
Vector3 position = ((Component)player).transform.position;
SpawnSpecialSlamVfx(position);
SE_Berserk.DealSlamNova((Character)(object)player, position);
BerserkHUD.TriggerShake(2f);
SE_Berserk.PlaySlam();
return false;
}
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static bool _inAoe;
private static float _slamCooldown;
private static readonly Dictionary<int, Character> LastAttacker = new Dictionary<int, Character>();
private static readonly HashSet<Character> RecentlyHitByLocal = new HashSet<Character>();
private static float _lastSlamTime;
private const float SlamCooldownSeconds = 2f;
private const float SlamHpCost = 0.1f;
private static floa