#define DEBUG
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 BepInEx.Logging;
using ExampleEnemy.Configuration;
using ExampleEnemy.NetcodePatcher;
using GameNetcodeStuff;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ExampleEnemy")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Lightning McQueen for Lethal Company.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+0864a05544691c96bb0f101813317f1ce77b7629")]
[assembly: AssemblyProduct("ExampleEnemy")]
[assembly: AssemblyTitle("ExampleEnemy")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
static <Module>()
{
}
}
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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace ExampleEnemy
{
internal class ExampleEnemyAI : EnemyAI
{
public float laughTimer;
private Vector3 StalkPos;
private Vector3 positionRandomness;
private Random enemyRandom;
private float MovementSpeed = 100f;
private float RotationSpeed = 2f;
private float timeSinceHittingLocalPlayer;
[Conditional("DEBUG")]
private void LogIfDebugBuild(string text)
{
Plugin.Logger.LogInfo((object)text);
}
public override void Start()
{
//IL_004c: 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)
((EnemyAI)this).Start();
LogIfDebugBuild("Lightning McQueen Spawned");
timeSinceHittingLocalPlayer = 0f;
laughTimer = 0f;
base.agent.speed = MovementSpeed;
positionRandomness = new Vector3(0f, 0f, 0f);
enemyRandom = new Random(StartOfRound.Instance.randomMapSeed + base.thisEnemyIndex);
}
public override void OnCollideWithPlayer(Collider other)
{
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
if (!(timeSinceHittingLocalPlayer < 5f) && !base.isEnemyDead)
{
PlayerControllerB val = ((EnemyAI)this).MeetsStandardPlayerCollisionConditions(other, false, false);
if (!((Object)(object)val == (Object)null))
{
timeSinceHittingLocalPlayer = 0f;
val.DamagePlayer(20, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
base.creatureVoice.Stop();
MovementSpeed = 0f;
base.agent.speed = MovementSpeed;
RotationSpeed = 0f;
base.creatureVoice.PlayOneShot(base.dieSFX);
}
}
}
public override void Update()
{
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: 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_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).Update();
timeSinceHittingLocalPlayer += Time.deltaTime;
laughTimer -= Time.deltaTime;
if ((double)laughTimer <= 0.0)
{
laughTimer = Random.Range(10f, 20f);
MovementSpeed = 100f;
base.agent.speed = MovementSpeed;
RotationSpeed = 2f;
base.creatureVoice.Play();
base.creatureSFX.Play();
if (!base.targetPlayer.isSprinting)
{
base.targetPlayer = null;
}
}
if (!HasValidTarget())
{
base.targetPlayer = GetFastestPlayer();
if (base.debugEnemyAI && (Object)(object)base.targetPlayer != (Object)null)
{
LogIfDebugBuild("Found new target");
}
}
if (!HasValidTarget())
{
if (base.debugEnemyAI)
{
LogIfDebugBuild("Failed to find new target");
}
}
else if (MovementSpeed > 0f)
{
positionRandomness = new Vector3((float)enemyRandom.Next(-1, 1), 0f, (float)enemyRandom.Next(-1, 1));
StalkPos = ((Component)base.targetPlayer).transform.position - Vector3.Scale(new Vector3(-1f, 0f, -1f), ((Component)base.targetPlayer).transform.forward);
((EnemyAI)this).SetDestinationToPosition(StalkPos, false);
}
else
{
positionRandomness = new Vector3((float)enemyRandom.Next(0, 1), 0f, (float)enemyRandom.Next(0, 1));
StalkPos = positionRandomness;
((EnemyAI)this).SetDestinationToPosition(StalkPos, false);
}
}
private bool HasValidTarget()
{
return (Object)(object)base.targetPlayer != (Object)null && base.targetPlayer.isInsideFactory && !base.targetPlayer.isPlayerDead;
}
public PlayerControllerB GetFastestPlayer(bool requireLineOfSight = false, bool cannotBeInShip = false, bool cannotBeNearShip = false)
{
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: 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_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
PlayerControllerB result = null;
base.mostOptimalDistance = 2000f;
for (int i = 0; i < 4; i++)
{
if (!((EnemyAI)this).PlayerIsTargetable(StartOfRound.Instance.allPlayerScripts[i], cannotBeInShip, false))
{
continue;
}
if (cannotBeNearShip)
{
if (StartOfRound.Instance.allPlayerScripts[i].isInElevator)
{
continue;
}
bool flag = false;
for (int j = 0; j < RoundManager.Instance.spawnDenialPoints.Length; j++)
{
if (Vector3.Distance(RoundManager.Instance.spawnDenialPoints[j].transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position) < 10f)
{
flag = true;
break;
}
}
if (flag)
{
continue;
}
}
if (StartOfRound.Instance.allPlayerScripts[i].isSprinting && (!requireLineOfSight || !Physics.Linecast(((Component)this).transform.position + Vector3.up * 0.25f, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position, 256)))
{
base.tempDist = Vector3.Distance(((Component)this).transform.position, ((Component)StartOfRound.Instance.allPlayerScripts[i]).transform.position);
if (base.tempDist < base.mostOptimalDistance)
{
base.mostOptimalDistance = base.tempDist;
result = StartOfRound.Instance.allPlayerScripts[i];
}
}
}
return result;
}
protected override void __initializeVariables()
{
((EnemyAI)this).__initializeVariables();
}
protected internal override string __getTypeName()
{
return "ExampleEnemyAI";
}
}
[BepInPlugin("ExampleEnemy", "ExampleEnemy", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
public static AssetBundle? ModAssets;
internal static PluginConfig BoundConfig { get; private set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
BoundConfig = new PluginConfig(((BaseUnityPlugin)this).Config);
InitializeNetworkBehaviours();
string path = "mcassets";
ModAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), path));
if ((Object)(object)ModAssets == (Object)null)
{
Logger.LogError((object)"Failed to load custom assets.");
return;
}
EnemyType val = ModAssets.LoadAsset<EnemyType>("ExampleEnemy");
TerminalNode val2 = ModAssets.LoadAsset<TerminalNode>("ExampleEnemyTN");
TerminalKeyword val3 = ModAssets.LoadAsset<TerminalKeyword>("ExampleEnemyTK");
NetworkPrefabs.RegisterNetworkPrefab(val.enemyPrefab);
Enemies.RegisterEnemy(val, BoundConfig.SpawnWeight.Value, (LevelTypes)(-1), val2, val3);
Logger.LogInfo((object)"Plugin ExampleEnemy is loaded!");
}
private static void InitializeNetworkBehaviours()
{
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
Type[] array = types;
foreach (Type type in array)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "ExampleEnemy";
public const string PLUGIN_NAME = "ExampleEnemy";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace ExampleEnemy.Configuration
{
public class PluginConfig
{
public ConfigEntry<int> SpawnWeight;
public PluginConfig(ConfigFile cfg)
{
SpawnWeight = cfg.Bind<int>("General", "Spawn weight", 20, "The spawn chance weight for ExampleEnemy, relative to other existing enemies.\nGoes up from 0, lower is more rare, 100 and up is very common.");
ClearUnusedEntries(cfg);
}
private void ClearUnusedEntries(ConfigFile cfg)
{
PropertyInfo property = ((object)cfg).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(cfg, null);
dictionary.Clear();
cfg.Save();
}
}
}
namespace ExampleEnemy.NetcodePatcher
{
[AttributeUsage(AttributeTargets.Module)]
internal class NetcodePatchedAssemblyAttribute : Attribute
{
}
}