Decompiled source of Basic Chat Commands v0.0.1

OutwardBasicChatCommands.dll

Decompiled 5 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using OutwardBasicChatCommands.Events;
using OutwardBasicChatCommands.Managers;
using OutwardBasicChatCommands.Utility.Data;
using OutwardBasicChatCommands.Utility.Enums;
using OutwardBasicChatCommands.Utility.Helpers;
using OutwardModsCommunicator.EventBus;
using SideLoader;
using UnityEngine;
using UnityEngine.AI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("OutwardBasicChatCommands")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OutwardBasicChatCommands")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace OutwardBasicChatCommands
{
	[BepInPlugin("gymmed.basic_chat_commands", "Basic Chat Commands", "0.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class OBCC : BaseUnityPlugin
	{
		public const string GUID = "gymmed.basic_chat_commands";

		public const string NAME = "Basic Chat Commands";

		public const string VERSION = "0.0.1";

		public static string prefix = "[Basic-Chat-Command]";

		public const string EVENTS_LISTENER_GUID = "gymmed.basic_chat_commands_*";

		internal static ManualLogSource Log;

		public static ConfigEntry<int> MaxDistanceToStartFollow;

		internal void Awake()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			LogMessage("Hello world from Basic Chat Commands 0.0.1!");
			new Harmony("gymmed.basic_chat_commands").PatchAll();
			EventBusPublisher.SendAddFollowChatCommand();
		}

		internal void Update()
		{
		}

		public static void LogMessage(string message)
		{
			Log.LogMessage((object)(prefix + " " + message));
		}

		public static void LogStatusMessage(string message, ChatLogStatus status = ChatLogStatus.Info)
		{
			LogMessage($"[{status}] {message}");
		}

		public static void LogSL(string message)
		{
			SL.Log(prefix + " " + message);
		}

		public static string GetProjectLocation()
		{
			return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
		}
	}
}
namespace OutwardBasicChatCommands.Utility.Helpers
{
	public static class CharacterHelpers
	{
		public static Character TryToFindOtherCharacterInLobby(Character mainCharacter, string otherCharName)
		{
			//IL_002b: 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)
			Character val = null;
			foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
			{
				val = item.ControlledCharacter;
				if ((Object)(object)val != (Object)null && val.UID != mainCharacter.UID && string.Equals(otherCharName, val.Name))
				{
					return val;
				}
			}
			return null;
		}

		public static Character TryToFindOtherCharacterInLobby(Character mainCharacter)
		{
			//IL_002b: 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)
			Character val = null;
			foreach (PlayerSystem item in Global.Lobby.PlayersInLobby)
			{
				val = item.ControlledCharacter;
				if ((Object)(object)val != (Object)null && val.UID != mainCharacter.UID)
				{
					return val;
				}
			}
			return val;
		}

		public static bool IsCharacterInDistance(Character firstCharacter, Character secondCharacter, float minimumDistance)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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)
			Vector3 val = ((Component)firstCharacter).transform.position - ((Component)secondCharacter).transform.position;
			float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
			float num = minimumDistance * minimumDistance;
			if (sqrMagnitude > num)
			{
				return false;
			}
			return true;
		}

		public static bool HasManualMovement(Character character)
		{
			CharacterControl characterControl = character.CharacterControl;
			LocalCharacterControl val = (LocalCharacterControl)(object)((characterControl is LocalCharacterControl) ? characterControl : null);
			if (val == null)
			{
				return false;
			}
			if (((Vector2)(ref ((CharacterControl)val).m_moveInput)).sqrMagnitude > 0.01f)
			{
				return true;
			}
			return false;
		}
	}
	public static class ChatHelpers
	{
		public static void SendChatLog(ChatPanel panel, string message, ChatLogStatus status = ChatLogStatus.Info)
		{
			panel.ChatMessageReceived("System", ChatLogStatusHelper.GetChatLogText(message, status));
		}

		public static void SendChatLog(Character character, string message, ChatLogStatus status = ChatLogStatus.Info)
		{
			CharacterUI characterUI = character.CharacterUI;
			if ((Object)(object)((characterUI != null) ? characterUI.ChatPanel : null) == (Object)null)
			{
				OBCC.LogMessage("ChatHelpers@SendChatLog provided character with missing chatPanel!");
			}
			else
			{
				SendChatLog(character.CharacterUI.ChatPanel, message, status);
			}
		}

		public static void SendChatOrLog(Character character, string message, ChatLogStatus status = ChatLogStatus.Info)
		{
			CharacterUI characterUI = character.CharacterUI;
			if ((Object)(object)((characterUI != null) ? characterUI.ChatPanel : null) == (Object)null)
			{
				OBCC.LogStatusMessage(message, status);
			}
			else
			{
				SendChatLog(character.CharacterUI.ChatPanel, message, status);
			}
		}
	}
}
namespace OutwardBasicChatCommands.Utility.Enums
{
	public enum ChatCommandsManagerParams
	{
		CommandName,
		CommandParameters,
		CommandAction,
		IsCheatCommand,
		CommandDescription,
		CommandRequiresDebugMode
	}
	public static class ChatCommandsManagerParamsHelper
	{
		private static readonly Dictionary<ChatCommandsManagerParams, (string key, Type type)> _registry = new Dictionary<ChatCommandsManagerParams, (string, Type)>
		{
			[ChatCommandsManagerParams.CommandName] = ("command", typeof(string)),
			[ChatCommandsManagerParams.CommandParameters] = ("parameters", typeof(Dictionary<string, (string, string)>)),
			[ChatCommandsManagerParams.CommandAction] = ("function", typeof(Action<Character, Dictionary<string, string>>)),
			[ChatCommandsManagerParams.IsCheatCommand] = ("isCheatCommand", typeof(bool)),
			[ChatCommandsManagerParams.CommandDescription] = ("description", typeof(string)),
			[ChatCommandsManagerParams.CommandRequiresDebugMode] = ("debugMode", typeof(bool))
		};

		public static (string key, Type type) Get(ChatCommandsManagerParams param)
		{
			return _registry[param];
		}
	}
	public enum ChatLogStatus
	{
		Info,
		Success,
		Warning,
		Error
	}
	public static class ChatLogStatusHelper
	{
		public static string GetChatLogText(string message, ChatLogStatus status = ChatLogStatus.Info)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			return status switch
			{
				ChatLogStatus.Success => Global.SetTextColor(message, Global.LIGHT_GREEN), 
				ChatLogStatus.Warning => Global.SetTextColor(message, Global.LIGHT_ORANGE), 
				ChatLogStatus.Error => "<color=#" + UnityEngineExtensions.ToHex(Global.LIGHT_RED) + ">" + message + "</color>", 
				_ => message, 
			};
		}
	}
}
namespace OutwardBasicChatCommands.Utility.Data
{
	public class FollowerData
	{
		private int _cornerIndex;

		private float _lastPathTime;

		private LocalCharacterControl _localControl;

		private bool _isFollowing;

		public static float InitialMaxDistance = 20f;

		private const float StopFollowingDistance = 5f;

		private const float PathRecalcInterval = 0.5f;

		private const float CornerReachDistance = 0.6f;

		private const float RotationSpeed = 7f;

		public Character Follower { get; }

		public Character CharacterToFollow { get; set; }

		public NavMeshPath NavMeshPath { get; }

		public bool IsFollowing
		{
			get
			{
				return _isFollowing;
			}
			set
			{
				_isFollowing = value;
			}
		}

		public FollowerData(Character follower, Character characterToFollow)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			Follower = follower;
			CharacterToFollow = characterToFollow;
			NavMeshPath = new NavMeshPath();
			ref LocalCharacterControl localControl = ref _localControl;
			CharacterControl characterControl = follower.CharacterControl;
			localControl = (LocalCharacterControl)(object)((characterControl is LocalCharacterControl) ? characterControl : null);
		}

		public bool StartFollow()
		{
			if ((Object)(object)Follower == (Object)null || (Object)(object)CharacterToFollow == (Object)null)
			{
				OBCC.LogMessage("Follower is null or you are trying to follow null character.");
				return false;
			}
			if (!CharacterHelpers.IsCharacterInDistance(Follower, CharacterToFollow, InitialMaxDistance))
			{
				ChatHelpers.SendChatLog(Follower, "Target is too far away to start following.", ChatLogStatus.Warning);
				return false;
			}
			CharacterControl characterControl = Follower.CharacterControl;
			LocalCharacterControl val = (LocalCharacterControl)(object)((characterControl is LocalCharacterControl) ? characterControl : null);
			if (val == null)
			{
				ChatHelpers.SendChatLog(Follower, "Auto-follow only works on local characters.", ChatLogStatus.Warning);
				return false;
			}
			_localControl = val;
			IsFollowing = true;
			_cornerIndex = 0;
			RecalculatePath();
			ChatHelpers.SendChatLog(Follower, "Now following " + CharacterToFollow.Name + ".");
			return true;
		}

		public void Update()
		{
			if (IsFollowing && !((Object)(object)_localControl == (Object)null) && !((Object)(object)CharacterToFollow == (Object)null))
			{
				if ((Object)(object)Follower == (Object)null || Follower.IsDead || PlayerProvidedMovementInput())
				{
					StopFollow();
				}
				else if (((CharacterControl)_localControl).InputLocked)
				{
					StopFollow();
				}
				else
				{
					ApplyFollowMovement();
				}
			}
		}

		private void RecalculatePath()
		{
			//IL_000b: 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)
			NavMesh.CalculatePath(((Component)Follower).transform.position, ((Component)CharacterToFollow).transform.position, -1, NavMeshPath);
			_cornerIndex = 0;
		}

		private void ApplyFollowMovement()
		{
			//IL_003e: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			if (NavMeshPath.corners == null || NavMeshPath.corners.Length == 0)
			{
				ChatHelpers.SendChatLog(Follower, "Couldn't find navigation path! Recalculating.", ChatLogStatus.Warning);
				RecalculatePath();
				return;
			}
			if (Vector3.Distance(((Component)Follower).transform.position, ((Component)CharacterToFollow).transform.position) <= 5f)
			{
				((CharacterControl)_localControl).m_moveInput = Vector2.zero;
				_localControl.m_modifMoveInput = Vector2.op_Implicit(Vector2.zero);
				if (((CharacterControl)_localControl).m_character.Sprinting)
				{
					((CharacterControl)_localControl).m_character.SprintInput(false);
				}
				return;
			}
			if (Time.time - _lastPathTime > 0.5f)
			{
				RecalculatePath();
				_lastPathTime = Time.time;
			}
			RotateTowardsPath();
			MoveTowardsPath();
		}

		private void RotateTowardsPath()
		{
			//IL_0084: 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)
			//IL_009e: 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_0062: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
			if (NavMeshPath.corners != null && NavMeshPath.corners.Length != 0)
			{
				while (_cornerIndex < NavMeshPath.corners.Length - 1 && Vector3.Distance(((Component)Follower).transform.position, NavMeshPath.corners[_cornerIndex]) < 0.6f)
				{
					_cornerIndex++;
				}
				Vector3 val = NavMeshPath.corners[_cornerIndex] - ((Component)Follower).transform.position;
				val.y = 0f;
				if (!(((Vector3)(ref val)).sqrMagnitude < 0.001f))
				{
					Quaternion val2 = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up);
					((Component)Follower).transform.rotation = Quaternion.Slerp(((Component)Follower).transform.rotation, val2, 7f * Time.deltaTime);
				}
			}
		}

		private void MoveTowardsPath()
		{
			//IL_0034: 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_0053: 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_005c: 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_0083: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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_0159: 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)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			if (NavMeshPath.corners != null && _cornerIndex < NavMeshPath.corners.Length)
			{
				Vector3 val = NavMeshPath.corners[_cornerIndex] - ((Component)((CharacterControl)_localControl).m_character).transform.position;
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				normalized.y = 0f;
				Vector3 forward = ((Component)((CharacterControl)_localControl).m_character.CharacterCamera).transform.forward;
				Vector3 right = ((Component)((CharacterControl)_localControl).m_character.CharacterCamera).transform.right;
				forward.y = (right.y = 0f);
				((Vector3)(ref forward)).Normalize();
				((Vector3)(ref right)).Normalize();
				float num = Vector3.Dot(normalized, forward);
				float num2 = Vector3.Dot(normalized, right);
				Vector2 val2 = default(Vector2);
				((Vector2)(ref val2))..ctor(num2, num);
				if (((Vector2)(ref val2)).magnitude > 1f)
				{
					((Vector2)(ref val2)).Normalize();
				}
				float num3 = ((CharacterControl)_localControl).m_character.Speed * 1.75f;
				if (((CharacterControl)_localControl).m_character.IsSuperSpeedActive)
				{
					num3 *= 4f;
				}
				num3 *= _localControl.MovementMultiplier * ((CharacterControl)_localControl).m_character.Stats.MovementSpeed;
				_localControl.m_modifMoveInput = Vector2.op_Implicit(val2 * num3);
				((CharacterControl)_localControl).m_moveInput = val2;
				if (!((CharacterControl)_localControl).m_character.Sprinting && ((CharacterControl)_localControl).m_character.Stats.CanSprint())
				{
					((CharacterControl)_localControl).m_character.SprintInput(true);
				}
				_localControl.m_autoRun = false;
			}
		}

		private void StopFollow()
		{
			//IL_007b: 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_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_0035: Unknown result type (might be due to invalid IL or missing references)
			IsFollowing = false;
			if ((Object)(object)_localControl != (Object)null)
			{
				((CharacterControl)_localControl).m_moveInput = Vector2.zero;
				_localControl.m_modifMoveInput = Vector2.op_Implicit(Vector2.zero);
				if ((Object)(object)((CharacterControl)_localControl).m_character != (Object)null && ((CharacterControl)_localControl).m_character.Sprinting)
				{
					((CharacterControl)_localControl).m_character.SprintInput(false);
				}
			}
			FollowerDataManager.Instance.RemoveFollower(Follower.UID);
			ChatHelpers.SendChatLog(Follower, "Auto-follow stopped (movement input detected).");
		}

		private bool PlayerProvidedMovementInput()
		{
			int playerID = Follower.OwnerPlayerSys.PlayerID;
			float num = ControlsInput.MoveHorizontal(playerID);
			float num2 = ControlsInput.MoveVertical(playerID);
			if (!(Mathf.Abs(num) > 0.01f))
			{
				return Mathf.Abs(num2) > 0.01f;
			}
			return true;
		}
	}
}
namespace OutwardBasicChatCommands.Patches
{
	[HarmonyPatch(typeof(LocalCharacterControl), "DetectMovementInputs")]
	public static class Patch_LocalCharacterControl_DetectMovementInputs
	{
		private static void Postfix(LocalCharacterControl __instance)
		{
			if (FollowerDataManager.Instance.IsCharacterFollowing(((CharacterControl)__instance).Character, out var data))
			{
				data.Update();
			}
		}
	}
}
namespace OutwardBasicChatCommands.Managers
{
	public class FollowerDataManager
	{
		private static FollowerDataManager _instance;

		private Dictionary<UID, FollowerData> _followerData = new Dictionary<UID, FollowerData>();

		public static FollowerDataManager Instance
		{
			get
			{
				if (_instance == null)
				{
					_instance = new FollowerDataManager();
				}
				return _instance;
			}
		}

		public Dictionary<UID, FollowerData> FollowerData
		{
			get
			{
				return _followerData;
			}
			set
			{
				_followerData = value;
			}
		}

		private FollowerDataManager()
		{
		}

		public bool IsCharacterFollowing(Character follower, out FollowerData data)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			if (!FollowerData.TryGetValue(follower.UID, out data))
			{
				return false;
			}
			if (!data.IsFollowing)
			{
				return false;
			}
			return true;
		}

		public void TryToFollow(Character follower, Character charToFollow)
		{
			//IL_0001: 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_0033: 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_0069: 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)
			if (string.Equals(UID.op_Implicit(follower.UID), UID.op_Implicit(charToFollow.UID)))
			{
				ChatHelpers.SendChatLog(follower, "You cannot follow yourself! Try other target.", ChatLogStatus.Warning);
				return;
			}
			FollowerData value = null;
			if (!FollowerData.TryGetValue(follower.UID, out value))
			{
				value = new FollowerData(follower, charToFollow);
				FollowerData.Add(follower.UID, value);
			}
			else if (value.CharacterToFollow.UID != charToFollow.UID)
			{
				value.CharacterToFollow = charToFollow;
			}
			value.StartFollow();
		}

		public void RemoveFollower(UID uid)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			FollowerData.Remove(uid);
		}
	}
}
namespace OutwardBasicChatCommands.Events
{
	public static class EventBusPublisher
	{
		public const string Event_AddCommand = "ChatCommandsManager@AddChatCommand";

		public const string Event_RemoveCommand = "ChatCommandsManager@RemoveChatCommand";

		public const string ChatCommands_Listener = "gymmed.chat_commands_manager_*";

		public static void SendAddFollowChatCommand()
		{
			//IL_0029: 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_0046: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_008d: Expected O, but got Unknown
			Dictionary<string, (string, string)> value = new Dictionary<string, (string, string)> { 
			{
				"characterName",
				("Optional. Tries to follow character by name. If not provided tries to find first local character or lobby character.", null)
			} };
			Action<Character, Dictionary<string, string>> value2 = FollowCharacter;
			EventPayload val = new EventPayload { };
			string item;
			((Dictionary<string, object>)val)[item] = "follow";
			string item2 = ChatCommandsManagerParamsHelper.Get(ChatCommandsManagerParams.CommandParameters).key;
			((Dictionary<string, object>)val)[item2] = value;
			string item3 = ChatCommandsManagerParamsHelper.Get(ChatCommandsManagerParams.CommandAction).key;
			((Dictionary<string, object>)val)[item3] = value2;
			string item4 = ChatCommandsManagerParamsHelper.Get(ChatCommandsManagerParams.CommandDescription).key;
			((Dictionary<string, object>)val)[item4] = "Tries to find a player to follow. Searching is done starting from local characters and moving to lobby characters.";
			EventPayload val2 = val;
			EventBus.Publish("gymmed.chat_commands_manager_*", "ChatCommandsManager@AddChatCommand", val2);
		}

		public static void FollowCharacter(Character follower, Dictionary<string, string> arguments)
		{
			//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)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			object obj;
			if (follower == null)
			{
				obj = null;
			}
			else
			{
				CharacterUI characterUI = follower.CharacterUI;
				obj = ((characterUI != null) ? characterUI.ChatPanel : null);
			}
			ChatPanel val = (ChatPanel)obj;
			if ((Object)(object)val == (Object)null)
			{
				OBCC.LogMessage("EventBusPublisher@SendAddFollowChatCommand Tried to use missing chatPanel.");
				return;
			}
			arguments.TryGetValue("characterName", out var value);
			if (string.IsNullOrWhiteSpace(value))
			{
				UID uID = ((UIElement)val).LocalCharacter.UID;
				Character firstLocalCharacter = CharacterManager.Instance.GetFirstLocalCharacter();
				if ((Object)(object)firstLocalCharacter != (Object)null && firstLocalCharacter.UID != uID)
				{
					FollowerDataManager.Instance.TryToFollow(((UIElement)val).LocalCharacter, firstLocalCharacter);
					return;
				}
				Character secondLocalCharacter = CharacterManager.Instance.GetSecondLocalCharacter();
				if ((Object)(object)secondLocalCharacter != (Object)null && secondLocalCharacter.UID != uID)
				{
					FollowerDataManager.Instance.TryToFollow(((UIElement)val).LocalCharacter, secondLocalCharacter);
					return;
				}
				Character val2 = CharacterHelpers.TryToFindOtherCharacterInLobby(((UIElement)val).LocalCharacter);
				if ((Object)(object)val2 != (Object)null)
				{
					FollowerDataManager.Instance.TryToFollow(((UIElement)val).LocalCharacter, val2);
				}
				else
				{
					ChatHelpers.SendChatLog(val, "You are playing alone. There is nothing to follow.");
				}
			}
			else
			{
				Character val3 = CharacterHelpers.TryToFindOtherCharacterInLobby(((UIElement)val).LocalCharacter, value);
				if ((Object)(object)val3 != (Object)null)
				{
					FollowerDataManager.Instance.TryToFollow(((UIElement)val).LocalCharacter, val3);
				}
				else
				{
					ChatHelpers.SendChatLog(val, "Could not find other player by name " + value + "!");
				}
			}
		}
	}
	public static class EventBusRegister
	{
		public static void RegisterEvents()
		{
		}
	}
	public static class EventBusSubscriber
	{
		public const string Event_AddedChatCommand = "ChatCommandsManager@AddChatCommand_After";

		public const string Event_RemovedChatCommand = "ChatCommandsManager@RemoveChatCommand_After";

		public static void AddSubscribers()
		{
			EventBus.Subscribe("gymmed.chat_commands_manager_*", "ChatCommandsManager@AddChatCommand_After", (Action<EventPayload>)AddedChatCommand);
			EventBus.Subscribe("gymmed.chat_commands_manager_*", "ChatCommandsManager@RemoveChatCommand_After", (Action<EventPayload>)RemovedChatCommand);
		}

		public static void AddedChatCommand(EventPayload payload)
		{
			if (payload != null)
			{
				(string, Type) tuple = ChatCommandsManagerParamsHelper.Get(ChatCommandsManagerParams.CommandName);
				payload.Get<string>(tuple.Item1, (string)null);
				OBCC.LogMessage("Added command " + tuple.Item1);
			}
		}

		public static void RemovedChatCommand(EventPayload payload)
		{
			if (payload != null)
			{
				(string, Type) tuple = ChatCommandsManagerParamsHelper.Get(ChatCommandsManagerParams.CommandName);
				payload.Get<string>(tuple.Item1, (string)null);
				OBCC.LogMessage("Removed command " + tuple.Item1);
			}
		}
	}
}