Decompiled source of PetsCompanions v1.4.2

PetsCompanions.dll

Decompiled 2 days ago
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 EquinoxsModUtils;
using EquinoxsModUtils.Additions;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TechtonicaFramework.TechTree;
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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("PetsCompanions")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PetsCompanions")]
[assembly: AssemblyTitle("PetsCompanions")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 PetsCompanions
{
	[BepInPlugin("com.certifired.PetsCompanions", "PetsCompanions", "1.4.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class PetsCompanionsPlugin : BaseUnityPlugin
	{
		public enum PetType
		{
			Drone,
			Crawler,
			Floater,
			Guardian,
			Scout
		}

		public const string MyGUID = "com.certifired.PetsCompanions";

		public const string PluginName = "PetsCompanions";

		public const string VersionString = "1.4.0";

		private static readonly Harmony Harmony = new Harmony("com.certifired.PetsCompanions");

		public static ManualLogSource Log;

		public static PetsCompanionsPlugin Instance;

		public static string PluginPath;

		public static ConfigEntry<bool> EnablePets;

		public static ConfigEntry<int> MaxActivePets;

		public static ConfigEntry<float> PetFollowDistance;

		public static ConfigEntry<float> PetSpeed;

		public static ConfigEntry<KeyCode> SummonPetKey;

		public static ConfigEntry<KeyCode> DismissPetKey;

		public static ConfigEntry<bool> PetsProvideBuffs;

		public static ConfigEntry<bool> DebugMode;

		public static List<PetController> ActivePets = new List<PetController>();

		public static PetController CurrentPet = null;

		public const string DronePetItem = "Companion Drone";

		public const string CrawlerPetItem = "Companion Crawler";

		public const string FloaterPetItem = "Companion Floater";

		public const string GuardianPetItem = "Guardian Bot";

		public const string ScoutPetItem = "Scout Drone";

		public const string PetUnlock = "Companion Technology";

		private void Awake()
		{
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			PluginPath = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			Log.LogInfo((object)"PetsCompanions v1.4.0 loading...");
			InitializeConfig();
			Harmony.PatchAll();
			RegisterContent();
			Events.GameDefinesLoaded += OnGameDefinesLoaded;
			Events.GameLoaded += OnGameLoaded;
			Events.TechTreeStateLoaded += OnTechTreeStateLoaded;
			Log.LogInfo((object)"PetsCompanions v1.4.0 loaded!");
		}

		private void InitializeConfig()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			EnablePets = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Pets", true, "Enable companion pet system");
			MaxActivePets = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Max Active Pets", 1, new ConfigDescription("Maximum number of active pets at once", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 3), Array.Empty<object>()));
			PetFollowDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Behavior", "Follow Distance", 3f, new ConfigDescription("Distance pets maintain from player", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
			PetSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Behavior", "Pet Speed", 8f, new ConfigDescription("Pet movement speed", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 15f), Array.Empty<object>()));
			SummonPetKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "Summon Pet Key", (KeyCode)44, "Key to summon/cycle pets");
			DismissPetKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "Dismiss Pet Key", (KeyCode)46, "Key to dismiss current pet");
			PetsProvideBuffs = ((BaseUnityPlugin)this).Config.Bind<bool>("Buffs", "Pets Provide Buffs", true, "Whether pets provide passive buffs");
			DebugMode = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Debug Mode", false, "Enable debug logging");
		}

		private void RegisterContent()
		{
			//IL_0017: 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_001d: 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_0027: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_004f: 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_0065: Expected O, but got Unknown
			if (EnablePets.Value)
			{
				EMUAdditions.AddNewUnlock(new NewUnlockDetails
				{
					category = ModdedTabModule.ModdedCategory,
					coreTypeNeeded = (CoreType)0,
					coreCountNeeded = 150,
					description = "Research companion technology to create helpful robotic pets that follow you and provide useful buffs.",
					displayName = "Companion Technology",
					requiredTier = (ResearchTier)64,
					treePosition = 80
				}, false);
				RegisterPetItem("Companion Drone", "A small flying drone that follows you around. Provides a movement speed buff while active.", PetType.Drone, 180);
				RegisterPetItem("Companion Crawler", "A spider-like crawler companion. Increases mining speed while active.", PetType.Crawler, 181);
				RegisterPetItem("Companion Floater", "A hovering companion with storage capabilities. Increases inventory capacity while active.", PetType.Floater, 182);
				RegisterPetItem("Guardian Bot", "A sturdy guardian bot. Reduces damage taken while active.", PetType.Guardian, 183);
				RegisterPetItem("Scout Drone", "A fast scout drone with sensors. Highlights nearby resources and enemies while active.", PetType.Scout, 184);
				Log.LogInfo((object)"Registered 5 companion pet types");
			}
		}

		private void RegisterPetItem(string name, string desc, PetType type, int priority)
		{
			//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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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_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_0034: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_0061: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			EMUAdditions.AddNewResource(new NewResourceDetails
			{
				name = name,
				description = desc,
				craftingMethod = (CraftingMethod)0,
				craftTierRequired = 0,
				headerTitle = "Modded",
				maxStackCount = 1,
				sortPriority = priority,
				unlockName = "Companion Technology",
				parentName = "Processor Unit"
			}, false);
			List<RecipeResourceInfo> petIngredients = GetPetIngredients(type);
			EMUAdditions.AddNewRecipe(new NewRecipeDetails
			{
				GUID = "com.certifired.PetsCompanions_" + name.Replace(" ", "").ToLower(),
				craftingMethod = (CraftingMethod)0,
				craftTierRequired = 0,
				duration = 60f,
				unlockName = "Companion Technology",
				ingredients = petIngredients,
				outputs = new List<RecipeResourceInfo>
				{
					new RecipeResourceInfo(name, 1)
				},
				sortPriority = priority
			}, false);
		}

		private List<RecipeResourceInfo> GetPetIngredients(PetType type)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_00a9: 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)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: 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_01a2: 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)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			return type switch
			{
				PetType.Drone => new List<RecipeResourceInfo>
				{
					new RecipeResourceInfo("Processor Unit", 5),
					new RecipeResourceInfo("Electric Motor", 3),
					new RecipeResourceInfo("Copper Wire", 20),
					new RecipeResourceInfo("Steel Frame", 2)
				}, 
				PetType.Crawler => new List<RecipeResourceInfo>
				{
					new RecipeResourceInfo("Processor Unit", 3),
					new RecipeResourceInfo("Iron Components", 15),
					new RecipeResourceInfo("Electric Motor", 4),
					new RecipeResourceInfo("Steel Frame", 4)
				}, 
				PetType.Floater => new List<RecipeResourceInfo>
				{
					new RecipeResourceInfo("Processor Unit", 4),
					new RecipeResourceInfo("Electric Motor", 2),
					new RecipeResourceInfo("Copper Wire", 30),
					new RecipeResourceInfo("Iron Frame", 3)
				}, 
				PetType.Guardian => new List<RecipeResourceInfo>
				{
					new RecipeResourceInfo("Processor Unit", 6),
					new RecipeResourceInfo("Steel Frame", 8),
					new RecipeResourceInfo("Electric Motor", 4),
					new RecipeResourceInfo("Iron Components", 20)
				}, 
				PetType.Scout => new List<RecipeResourceInfo>
				{
					new RecipeResourceInfo("Processor Unit", 8),
					new RecipeResourceInfo("Electric Motor", 2),
					new RecipeResourceInfo("Copper Wire", 40),
					new RecipeResourceInfo("Shiverthorn Extract", 5)
				}, 
				_ => new List<RecipeResourceInfo>
				{
					new RecipeResourceInfo("Processor Unit", 5),
					new RecipeResourceInfo("Electric Motor", 3)
				}, 
			};
		}

		private void OnGameDefinesLoaded()
		{
			LinkUnlockToResource("Companion Drone", "Companion Technology");
			LinkUnlockToResource("Companion Crawler", "Companion Technology");
			LinkUnlockToResource("Companion Floater", "Companion Technology");
			LinkUnlockToResource("Guardian Bot", "Companion Technology");
			LinkUnlockToResource("Scout Drone", "Companion Technology");
			Log.LogInfo((object)"Linked PetsCompanions unlocks to resources");
		}

		private void LinkUnlockToResource(string resourceName, string unlockName)
		{
			try
			{
				ResourceInfo resourceInfoByName = Resources.GetResourceInfoByName(resourceName, false);
				if ((Object)(object)resourceInfoByName != (Object)null)
				{
					resourceInfoByName.unlock = Unlocks.GetUnlockByName(unlockName, false);
					if (DebugMode.Value)
					{
						Log.LogInfo((object)("Linked " + resourceName + " to unlock " + unlockName));
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Failed to link " + resourceName + " to " + unlockName + ": " + ex.Message));
			}
		}

		private void OnGameLoaded()
		{
			Log.LogInfo((object)"PetsCompanions: Game loaded, pet system ready");
		}

		private void OnTechTreeStateLoaded()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Unlock unlockByName = Unlocks.GetUnlockByName("Companion Technology", false);
				if (!((Object)(object)unlockByName != (Object)null))
				{
					return;
				}
				unlockByName.requiredTier = (ResearchTier)4096;
				unlockByName.treePosition = 50f;
				if ((Object)(object)unlockByName.sprite == (Object)null)
				{
					ResourceInfo resourceInfoByName = Resources.GetResourceInfoByName("Processor Unit", false);
					if ((Object)(object)resourceInfoByName != (Object)null && (Object)(object)resourceInfoByName.sprite != (Object)null)
					{
						unlockByName.sprite = resourceInfoByName.sprite;
					}
				}
				Log.LogInfo((object)"Configured Companion Technology: tier=Tier12 (XRAY), position=50");
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Failed to configure unlock: " + ex.Message));
			}
		}

		private void Update()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (EnablePets.Value && !((Object)(object)Player.instance == (Object)null))
			{
				if (Input.GetKeyDown(SummonPetKey.Value))
				{
					SummonOrCyclePet();
				}
				if (Input.GetKeyDown(DismissPetKey.Value))
				{
					DismissCurrentPet();
				}
				UpdateActivePets();
				if (PetsProvideBuffs.Value)
				{
					ApplyPetBuffs();
				}
			}
		}

		private void SummonOrCyclePet()
		{
			if ((Object)(object)CurrentPet == (Object)null)
			{
				SpawnPet(PetType.Drone);
				return;
			}
			int type = (int)(CurrentPet.Type + 1) % 5;
			DismissCurrentPet();
			SpawnPet((PetType)type);
		}

		private void SpawnPet(PetType type)
		{
			//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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Player.instance == (Object)null))
			{
				Vector3 position = ((Component)Player.instance).transform.position + Vector3.right * 2f + Vector3.up * 1f;
				GameObject val = CreatePetObject(type, position);
				if ((Object)(object)val != (Object)null)
				{
					PetController petController = val.AddComponent<PetController>();
					petController.Initialize(type, ((Component)Player.instance).transform);
					ActivePets.Add(petController);
					CurrentPet = petController;
					Log.LogInfo((object)$"Spawned pet: {type}");
				}
			}
		}

		private GameObject CreatePetObject(PetType type, Vector3 position)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
			((Object)val).name = $"Pet_{type}";
			val.transform.position = position;
			val.transform.localScale = GetPetScale(type);
			Collider component = val.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			Renderer component2 = val.GetComponent<Renderer>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.material.color = GetPetColor(type);
			}
			return val;
		}

		private Vector3 GetPetScale(PetType type)
		{
			//IL_0030: 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_0047: 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)
			//IL_005e: 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)
			//IL_0075: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			return (Vector3)(type switch
			{
				PetType.Drone => new Vector3(0.3f, 0.3f, 0.3f), 
				PetType.Crawler => new Vector3(0.4f, 0.2f, 0.5f), 
				PetType.Floater => new Vector3(0.5f, 0.5f, 0.5f), 
				PetType.Guardian => new Vector3(0.6f, 0.8f, 0.6f), 
				PetType.Scout => new Vector3(0.25f, 0.25f, 0.25f), 
				_ => Vector3.one * 0.3f, 
			});
		}

		private Color GetPetColor(PetType type)
		{
			//IL_0030: 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_0047: 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)
			//IL_005e: 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)
			//IL_0075: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_0094: 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)
			return (Color)(type switch
			{
				PetType.Drone => new Color(0.2f, 0.6f, 1f), 
				PetType.Crawler => new Color(0.8f, 0.5f, 0.2f), 
				PetType.Floater => new Color(0.6f, 0.2f, 0.8f), 
				PetType.Guardian => new Color(0.3f, 0.8f, 0.3f), 
				PetType.Scout => new Color(1f, 1f, 0.3f), 
				_ => Color.white, 
			});
		}

		private void DismissCurrentPet()
		{
			if ((Object)(object)CurrentPet != (Object)null)
			{
				ActivePets.Remove(CurrentPet);
				Object.Destroy((Object)(object)((Component)CurrentPet).gameObject);
				CurrentPet = null;
				Log.LogInfo((object)"Pet dismissed");
			}
		}

		private void UpdateActivePets()
		{
			ActivePets.RemoveAll((PetController p) => (Object)(object)p == (Object)null);
		}

		private void ApplyPetBuffs()
		{
		}

		public static void LogDebug(string message)
		{
			if (DebugMode.Value)
			{
				Log.LogInfo((object)("[DEBUG] " + message));
			}
		}
	}
	public class PetController : MonoBehaviour
	{
		private Transform target;

		private Vector3 targetOffset;

		private float bobPhase;

		private float orbitAngle;

		public PetsCompanionsPlugin.PetType Type { get; private set; }

		public void Initialize(PetsCompanionsPlugin.PetType type, Transform followTarget)
		{
			//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)
			Type = type;
			target = followTarget;
			bobPhase = Random.value * (float)Math.PI * 2f;
			orbitAngle = Random.value * 360f;
			targetOffset = GetRandomOffset();
		}

		private Vector3 GetRandomOffset()
		{
			//IL_0037: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			float num = Random.Range(0f, 360f) * ((float)Math.PI / 180f);
			float value = PetsCompanionsPlugin.PetFollowDistance.Value;
			return new Vector3(Mathf.Cos(num) * value, 1f, Mathf.Sin(num) * value);
		}

		private void Update()
		{
			//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)
			//IL_0071: 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_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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00ba: 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)
			//IL_00e2: 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_00e9: 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)
			if (!((Object)(object)target == (Object)null))
			{
				orbitAngle += Time.deltaTime * 30f;
				float num = orbitAngle * ((float)Math.PI / 180f);
				float value = PetsCompanionsPlugin.PetFollowDistance.Value;
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(Mathf.Cos(num) * value, GetHeightOffset(), Mathf.Sin(num) * value);
				Vector3 val2 = target.position + val;
				float value2 = PetsCompanionsPlugin.PetSpeed.Value;
				((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, val2, Time.deltaTime * value2 * 0.5f);
				Vector3 val3 = val2 - ((Component)this).transform.position;
				if (((Vector3)(ref val3)).sqrMagnitude > 0.01f)
				{
					((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, Quaternion.LookRotation(val3), Time.deltaTime * 5f);
				}
				ApplyTypeBehavior();
			}
		}

		private float GetHeightOffset()
		{
			bobPhase += Time.deltaTime * 2f;
			float num = Mathf.Sin(bobPhase) * 0.2f;
			switch (Type)
			{
			case PetsCompanionsPlugin.PetType.Drone:
			case PetsCompanionsPlugin.PetType.Scout:
				return 2f + num;
			case PetsCompanionsPlugin.PetType.Floater:
				return 1.5f + num;
			case PetsCompanionsPlugin.PetType.Crawler:
				return 0.3f;
			case PetsCompanionsPlugin.PetType.Guardian:
				return 0.5f + num * 0.5f;
			default:
				return 1f;
			}
		}

		private void ApplyTypeBehavior()
		{
			if (PetsCompanionsPlugin.PetsProvideBuffs.Value)
			{
				switch (Type)
				{
				case PetsCompanionsPlugin.PetType.Drone:
					break;
				case PetsCompanionsPlugin.PetType.Crawler:
					break;
				case PetsCompanionsPlugin.PetType.Floater:
					break;
				case PetsCompanionsPlugin.PetType.Guardian:
					break;
				case PetsCompanionsPlugin.PetType.Scout:
					break;
				}
			}
		}
	}
}