using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Mikusch")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Adds a new custom enemy, the floating skull.")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0+3e762e38cdb90fae314f6a02aa21d1f206e17b6b")]
[assembly: AssemblyProduct("SkullEnemy")]
[assembly: AssemblyTitle("SkullEnemy")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace SkullEnemy
{
[BepInPlugin("SkullEnemy", "SkullEnemy", "1.2.0")]
public class SkullEnemyPlugin : BaseUnityPlugin
{
private static readonly Dictionary<LevelTypes, int> DefaultLevelRarities = new Dictionary<LevelTypes, int>
{
[(LevelTypes)128] = 66,
[(LevelTypes)512] = 66,
[(LevelTypes)256] = 66,
[(LevelTypes)1024] = 66
};
public static SkullEnemyPlugin Instance;
public ConfigEntry<float> ConfigMovementSpeed;
public ConfigEntry<float> ConfigRotationSpeed;
public ConfigEntry<bool> ConfigCanOnlyCollideWithTargetPlayer;
private void Awake()
{
//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_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Invalid comparison between Unknown and I4
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Invalid comparison between Unknown and I4
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: 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_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Invalid comparison between Unknown and I4
Instance = this;
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (Utility.IsNullOrWhiteSpace(directoryName))
{
return;
}
AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(directoryName, "skullassets"));
if ((Object)(object)val == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load custom assets");
return;
}
ConfigMovementSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MovementSpeed", 2f, "The speed at which the enemy moves towards its target.");
ConfigRotationSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("General", "RotationSpeed", 2f, "The speed at which the enemy rotates towards its target.");
ConfigCanOnlyCollideWithTargetPlayer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "CanOnlyCollideWithTargetPlayer", true, "If enabled, the enemy will only be able to collide with its target player.");
Dictionary<LevelTypes, int> dictionary = new Dictionary<LevelTypes, int>();
foreach (LevelTypes value in Enum.GetValues(typeof(LevelTypes)))
{
if ((int)value != 1 && (int)value != -1 && (!((Enum)(LevelTypes)1020).HasFlag((Enum)(object)value) || (int)value != 1020))
{
ConfigEntry<int> val3 = ((BaseUnityPlugin)this).Config.Bind<int>("Spawning", $"{(object)value}Rarity", DefaultLevelRarities.GetValueOrDefault(value, 0), $"The spawn rarity on {(object)value}.");
dictionary.Add(value, val3.Value);
}
}
EnemyType val4 = val.LoadAsset<EnemyType>("SkullEnemy");
TerminalNode val5 = val.LoadAsset<TerminalNode>("SkullTerminalNode");
TerminalKeyword val6 = val.LoadAsset<TerminalKeyword>("SkullTerminalKeyword");
NetworkPrefabs.RegisterNetworkPrefab(val4.enemyPrefab);
Enemies.RegisterEnemy(val4, dictionary, (Dictionary<string, int>)null, val5, val6);
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
for (int i = 0; i < types.Length; i++)
{
MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
foreach (MethodInfo methodInfo in methods)
{
if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin SkullEnemy is loaded!");
}
}
public class SkullEnemyAI : EnemyAI
{
public float laughTimer;
private float _movementSpeed;
private float _rotationSpeed;
private bool _canOnlyCollideWithTargetPlayer;
public override void Start()
{
((EnemyAI)this).Start();
_movementSpeed = SkullEnemyPlugin.Instance.ConfigMovementSpeed.Value;
_rotationSpeed = SkullEnemyPlugin.Instance.ConfigRotationSpeed.Value;
_canOnlyCollideWithTargetPlayer = SkullEnemyPlugin.Instance.ConfigCanOnlyCollideWithTargetPlayer.Value;
}
public override void OnCollideWithPlayer(Collider other)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).OnCollideWithPlayer(other);
if (!base.isEnemyDead)
{
PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
if (!((Object)(object)val == (Object)null) && (!_canOnlyCollideWithTargetPlayer || !((Object)(object)val != (Object)(object)base.targetPlayer)))
{
val.KillPlayer(Vector3.zero, true, (CauseOfDeath)0, 1);
}
}
}
public override void Update()
{
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).Update();
laughTimer -= Time.deltaTime;
if ((double)laughTimer <= 0.0)
{
laughTimer = Random.Range(6f, 7f);
if (base.enemyType.audioClips.Length != 0)
{
base.creatureVoice.PlayOneShot(base.enemyType.audioClips[Random.Range(0, base.enemyType.audioClips.Length)]);
}
}
if (!HasValidTarget())
{
base.targetPlayer = ((EnemyAI)this).GetClosestPlayer(false, false, false);
if (base.debugEnemyAI && (Object)(object)base.targetPlayer != (Object)null)
{
Debug.Log((object)("Found new target: " + base.targetPlayer.playerUsername));
}
}
if (!HasValidTarget())
{
if (base.debugEnemyAI)
{
Debug.Log((object)"Failed to find new target");
}
return;
}
Vector3 val = base.targetPlayer.playerGlobalHead.position - ((Component)this).transform.position;
Vector3 normalized = ((Vector3)(ref val)).normalized;
Quaternion val2 = Quaternion.LookRotation(normalized);
((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val2, Time.deltaTime * _rotationSpeed);
Transform transform = ((Component)this).transform;
transform.position += normalized * (Time.deltaTime * _movementSpeed);
}
private bool HasValidTarget()
{
if ((Object)(object)base.targetPlayer != (Object)null && base.targetPlayer.isInsideFactory)
{
return !base.targetPlayer.isPlayerDead;
}
return false;
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "SkullEnemy";
public const string PLUGIN_NAME = "SkullEnemy";
public const string PLUGIN_VERSION = "1.2.0";
}
}