using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using UnityEngine;
using UnityEngine.InputSystem;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("GruffyAICompanion")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GruffyAICompanion")]
[assembly: AssemblyTitle("GruffyAICompanion")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.yourname.gruffymod", "Gruffy AI Companion", "1.0.0")]
public class GruffyAICompanion : BaseUnityPlugin
{
private GameObject gruffy;
private string[] dialogueLines;
private string currentMessage;
private void Start()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"GruffyAICompanion: Start method called.");
SpawnGruffy();
LoadDialogueLines();
}
private void SpawnGruffy()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: 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_0070: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.FindWithTag("Player");
if ((Object)(object)val == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"GruffyAICompanion: No player found to clone.");
return;
}
gruffy = Object.Instantiate<GameObject>(val);
((Object)gruffy).name = "Gruffy";
gruffy.transform.position = val.transform.position + Vector3.right * 2f;
Object.DestroyImmediate((Object)(object)gruffy.GetComponent<CharacterController>());
Object.DestroyImmediate((Object)(object)gruffy.GetComponent<PlayerInput>());
gruffy.AddComponent<GruffyMind>();
((BaseUnityPlugin)this).Logger.LogInfo((object)"GruffyAICompanion: Gruffy AI spawned successfully.");
}
private void LoadDialogueLines()
{
string path = Path.Combine(Paths.PluginPath, "GruffyAICompanion", "AI_Dialogue.txt");
if (File.Exists(path))
{
dialogueLines = File.ReadAllLines(path);
((BaseUnityPlugin)this).Logger.LogInfo((object)$"GruffyAICompanion: Loaded {dialogueLines.Length} dialogue lines.");
}
else
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"GruffyAICompanion: Dialogue file not found.");
}
}
}
public class GruffyMind : MonoBehaviour
{
public float followDistance = 10f;
public float teleportDistance = 30f;
public float moveSpeed = 4f;
public float itemSearchRadius = 25f;
public float dangerRadius = 10f;
public float reviveRange = 5f;
private Transform player;
private float lastDialogueTime = 0f;
private float dialogueCooldown = 10f;
private string[] scaredQuotes = new string[5] { "AHH! What was that?!", "Nope nope nope! I'm out!", "I did NOT sign up for this!", "Run now, explain later!", "Please be friendly... please be friendly..." };
private string[] helpQuotes = new string[4] { "Don't worry, I got you!", "Hold still, I'm helping.", "You're gonna be okay.", "Wake up sleepyhead!" };
private string[] itemQuotes = new string[4] { "Ooh, shiny!", "Found something useful.", "This could help us.", "Loot secured!" };
private void Start()
{
GameObject val = GameObject.FindWithTag("Player");
if ((Object)(object)val != (Object)null)
{
player = val.transform;
}
}
private void Update()
{
//IL_001e: 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_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: 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_0099: 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_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: 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_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_0267: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_028b: 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_029a: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)player == (Object)null)
{
return;
}
float num = Vector3.Distance(((Component)this).transform.position, player.position);
if (num > teleportDistance)
{
((Component)this).transform.position = player.position + Vector3.right * 2f;
}
else if (num > followDistance)
{
((Component)this).transform.position = Vector3.MoveTowards(((Component)this).transform.position, player.position, moveSpeed * Time.deltaTime);
}
Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, itemSearchRadius);
Collider[] array2 = array;
foreach (Collider val in array2)
{
if (((Component)val).CompareTag("Item"))
{
((Component)val).gameObject.SetActive(false);
if (Time.time - lastDialogueTime > dialogueCooldown)
{
string text = itemQuotes[Random.Range(0, itemQuotes.Length)];
Debug.Log((object)("Gruffy: " + text));
lastDialogueTime = Time.time;
}
}
}
Collider[] array3 = Physics.OverlapSphere(((Component)this).transform.position, reviveRange);
Collider[] array4 = array3;
foreach (Collider val2 in array4)
{
if (((Component)val2).CompareTag("Downed"))
{
Debug.Log((object)"Gruffy: Reviving teammate!");
if (Time.time - lastDialogueTime > dialogueCooldown)
{
string text2 = helpQuotes[Random.Range(0, helpQuotes.Length)];
Debug.Log((object)("Gruffy: " + text2));
lastDialogueTime = Time.time;
}
break;
}
}
Collider[] array5 = Physics.OverlapSphere(((Component)this).transform.position, dangerRadius);
Collider[] array6 = array5;
foreach (Collider val3 in array6)
{
if (((Component)val3).CompareTag("Enemy"))
{
Vector3 val4 = ((Component)this).transform.position - ((Component)val3).transform.position;
Vector3 normalized = ((Vector3)(ref val4)).normalized;
Transform transform = ((Component)this).transform;
transform.position += normalized * moveSpeed * Time.deltaTime;
if (Time.time - lastDialogueTime > dialogueCooldown)
{
string text3 = scaredQuotes[Random.Range(0, scaredQuotes.Length)];
Debug.Log((object)("Gruffy: " + text3));
lastDialogueTime = Time.time;
}
break;
}
}
}
}