using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LethalCompanyDriveByMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LethalCompanyDriveByMod")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("cc155f0c-6d57-4daa-909f-c96bf7930aae")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
public class DriveByAI : EnemyAI
{
private enum CarState
{
Patrol,
LineUp,
DriveBy
}
[Header("Movement")]
public float cruiseSpeed = 8f;
public float chaseSpeed = 12f;
public float turnRate = 4f;
public float rePathInterval = 0.5f;
[Header("Combat")]
public float detectRange = 22f;
public float fovDegrees = 110f;
public float burstInterval = 0.25f;
public int shotsPerBurst = 3;
public int damagePerHit = 20;
public float bulletRange = 30f;
[Header("Refs")]
public Transform muzzleLeft;
public Transform muzzleRight;
private float _aiTimer;
private float _burstTimer;
private int _burstCount;
private PlayerControllerB _target;
private NavMeshAgent _agent;
private CarState _state = CarState.Patrol;
public override void Start()
{
((EnemyAI)this).Start();
_agent = ((Component)this).GetComponent<NavMeshAgent>();
_agent.speed = cruiseSpeed;
ChooseNewPatrolPoint();
}
private void ChooseNewPatrolPoint()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: 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)
Vector3 val = ((Component)this).transform.position + Random.insideUnitSphere * 15f;
NavMeshHit val2 = default(NavMeshHit);
if (NavMesh.SamplePosition(val, ref val2, 12f, -1))
{
_agent.SetDestination(((NavMeshHit)(ref val2)).position);
}
}
public override void Update()
{
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: 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)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: 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_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
((EnemyAI)this).Update();
if (!((NetworkBehaviour)this).IsServer)
{
return;
}
_aiTimer += Time.deltaTime;
if ((Object)(object)_target == (Object)null || !_target.IsAlive())
{
_target = FindClosestVisiblePlayer();
}
switch (_state)
{
case CarState.Patrol:
_agent.speed = cruiseSpeed;
if (_aiTimer > rePathInterval && _agent.remainingDistance < 2f)
{
_aiTimer = 0f;
ChooseNewPatrolPoint();
}
if ((Object)(object)_target != (Object)null)
{
_state = CarState.LineUp;
}
break;
case CarState.LineUp:
{
if ((Object)(object)_target == (Object)null)
{
_state = CarState.Patrol;
break;
}
Vector3 up = Vector3.up;
Vector3 val = ((Component)_target).transform.position - ((Component)this).transform.position;
Vector3 val2 = Vector3.Cross(up, ((Vector3)(ref val)).normalized);
Vector3 val3 = ((Component)_target).transform.position + val2 * 3f;
_agent.speed = chaseSpeed;
_agent.SetDestination(val3);
RotateTowards(_agent.steeringTarget);
if (Vector3.Distance(((Component)this).transform.position, val3) < 6f)
{
_burstTimer = 0f;
_burstCount = 0;
_state = CarState.DriveBy;
}
break;
}
case CarState.DriveBy:
if ((Object)(object)_target == (Object)null)
{
_state = CarState.Patrol;
break;
}
_burstTimer += Time.deltaTime;
if (_burstTimer >= burstInterval && _burstCount < shotsPerBurst)
{
_burstTimer = 0f;
_burstCount++;
FireSideGunsAt(_target);
}
if (_burstCount >= shotsPerBurst || Vector3.Distance(((Component)this).transform.position, ((Component)_target).transform.position) > 18f)
{
_target = null;
_state = CarState.Patrol;
ChooseNewPatrolPoint();
}
break;
}
}
private PlayerControllerB FindClosestVisiblePlayer()
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: 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_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_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_00d2: Unknown result type (might be due to invalid IL or missing references)
PlayerControllerB result = null;
float num = float.PositiveInfinity;
PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
foreach (PlayerControllerB val in allPlayerScripts)
{
if ((Object)(object)val == (Object)null || !val.IsAlive())
{
continue;
}
float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position);
if (!(num2 > detectRange))
{
Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position;
Vector3 normalized = ((Vector3)(ref val2)).normalized;
float num3 = Vector3.Angle(((Component)this).transform.forward, normalized);
if (!(num3 > fovDegrees * 0.5f) && HasLineOfSight(((Component)val).transform.position) && num2 < num)
{
result = val;
num = num2;
}
}
}
return result;
}
private bool HasLineOfSight(Vector3 worldTarget)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: 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)
//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_002b: 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_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = ((Component)this).transform.position + Vector3.up * 0.8f;
Vector3 val2 = worldTarget - val;
Vector3 normalized = ((Vector3)(ref val2)).normalized;
RaycastHit val3 = default(RaycastHit);
if (Physics.Raycast(val, normalized, ref val3, detectRange, -1, (QueryTriggerInteraction)1))
{
return (Object)(object)((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent<PlayerControllerB>() != (Object)null;
}
return true;
}
private void RotateTowards(Vector3 worldPoint)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: 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_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = worldPoint - ((Component)this).transform.position;
val.y = 0f;
if (!(((Vector3)(ref val)).sqrMagnitude < 0.01f))
{
Quaternion val2 = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up);
((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val2, Time.deltaTime * turnRate);
}
}
private void FireSideGunsAt(PlayerControllerB target)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: 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)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
Transform val = ((Vector3.Distance(muzzleLeft.position, ((Component)target).transform.position) < Vector3.Distance(muzzleRight.position, ((Component)target).transform.position)) ? muzzleLeft : muzzleRight);
Vector3 position = val.position;
Vector3 position2 = target.playerEye.position;
Vector3 val2 = position2 - position;
Vector3 normalized = ((Vector3)(ref val2)).normalized;
RaycastHit val3 = default(RaycastHit);
if (Physics.Raycast(position, normalized, ref val3, bulletRange, -1, (QueryTriggerInteraction)1))
{
PlayerControllerB componentInParent = ((Component)((RaycastHit)(ref val3)).collider).GetComponentInParent<PlayerControllerB>();
if ((Object)(object)componentInParent != (Object)null)
{
int num = damagePerHit;
val2 = default(Vector3);
componentInParent.DamagePlayer(num, true, true, (CauseOfDeath)7, 0, false, val2);
}
}
}
}
public static class PlayerExtensions
{
public static bool IsAlive(this PlayerControllerB pcb)
{
return (Object)(object)pcb != (Object)null && !pcb.isPlayerDead;
}
}
namespace LethalCompanyDriveByMod;
[BepInPlugin("com.noahrix.drivebycar", "DriveByCar", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
public static EnemyType CarEnemyType;
public static GameObject CarPrefab;
private void Awake()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
new Harmony("com.noahrix.drivebycar").PatchAll();
CarPrefab = GameObject.CreatePrimitive((PrimitiveType)0);
((Object)CarPrefab).name = "DriveByOrb";
CarPrefab.AddComponent<DriveByAI>();
Light val = CarPrefab.AddComponent<Light>();
val.color = Color.red;
val.intensity = 5f;
val.range = 6f;
val.type = (LightType)2;
NavMeshAgent val2 = CarPrefab.AddComponent<NavMeshAgent>();
val2.radius = 0.5f;
val2.height = 1f;
val2.speed = 8f;
NetworkPrefabs.RegisterNetworkPrefab(CarPrefab);
CarEnemyType = ScriptableObject.CreateInstance<EnemyType>();
((Object)CarEnemyType).name = "DriveByOrbType";
CarEnemyType.enemyName = "DriveByOrb";
CarEnemyType.canDie = false;
Enemies.RegisterEnemy(CarEnemyType, 1, (LevelTypes)(-1), (SpawnType)0, (TerminalNode)null, (TerminalKeyword)null);
Log.LogInfo((object)"DriveByOrb enemy loaded successfully!");
}
}