using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Munga.Net;
using WeifenLuo.WinFormsUI.Docking;

namespace TeslaConsole.RedPlanet;

public class RPGame : DockContent
{
	private class DragDropData
	{
		public int StartRow;

		public int EndRow;

		public bool RightClick;

		public DragDropData(int startRow, bool rightClick)
		{
			StartRow = startRow;
			RightClick = rightClick;
		}
	}

	private class GameStateData
	{
		public bool EggMessageSent;

		public bool RunMessageSent;

		public bool AbortMessageSent;

		public bool StopMessageSent;

		public bool PodAppearsReset;

		public void Reset()
		{
			EggMessageSent = (RunMessageSent = (AbortMessageSent = (StopMessageSent = (PodAppearsReset = false))));
		}
	}

	private enum RPGameState
	{
		Idle,
		Load,
		AutoTransCount,
		Run,
		Reset
	}

	private static readonly Color sDataLockedColor = Color.LightGray;

	private static readonly ApplicationState[] sStopToIdleStates = new ApplicationState[7]
	{
		ApplicationState.CreatingMission,
		ApplicationState.LaunchingMission,
		ApplicationState.LoadingMission,
		ApplicationState.ResumingMission,
		ApplicationState.RunningMission,
		ApplicationState.SuspendingMission,
		ApplicationState.WaitingForLaunch
	};

	private static readonly Random sRand = new Random();

	private Site mSite;

	private readonly bool mFootballMode;

	private readonly string mGameName;

	private EggFileMessage[] mEggFileMessages;

	private RPGameState mCurrentState;

	private RPGameState mRequestedState;

	private TimeSpan mMissionLength;

	private DateTime mGameStart;

	private bool mNormalMissionEnd;

	private bool mProcessingMissionEndStateChangeReq;

	private int mRemainingUntilTranslocate;

	private Dictionary<MungaGame, GameStateData> mGameStateData = new Dictionary<MungaGame, GameStateData>();

	private RPMissionRecorder mMissionRecorder;

	private Dictionary<int, RPPlayer> mMissionPlayers;

	private LogOutputWindow mLogWindow;

	private RPMissionResults mLastMissionResults;

	private IContainer components;

	private GroupBox mMissionPropertiesGroupBox;

	private Label mIssuesLabel;

	private Label mMissionLengthDisplayLabel;

	private Label mMissionLengthTextLabel;

	private CheckBox mScoreCompression;

	private ComboBox mWeather;

	private ComboBox mMap;

	private ComboBox mTimeOfDay;

	private Label mTimeOfDayLabel;

	private Label mWeatherLabel;

	private Label mMapLabel;

	private GroupBox mPilotsGroupBox;

	private TableLayoutPanel mMissionPropertiesTable;

	private DataGridView mPilotsDataGrid;

	private Button mGoButton;

	private ContextMenuStrip mDragDropContextMenu;

	private ToolStripMenuItem mSwapPilots;

	private ToolStripMenuItem mShiftPilots;

	private Timer mNetworkTimer;

	private DataGridViewCheckBoxColumn mEnabledColumn;

	private DataGridViewImageColumn mStatusIconColumn;

	private DataGridViewTextBoxColumn mStatusTextColumn;

	private DataGridViewTextBoxColumn mPilotColumn;

	private DataGridViewComboBoxColumn mVehicleColumn;

	private DataGridViewComboBoxColumn mColorColumn;

	private DataGridViewComboBoxColumn mBadgeColumn;

	private ContextMenuStrip mResetContextMenu;

	private ToolStripMenuItem resetToolStripMenuItem;

	private Button mPrintLastMission;

	private CheckBox mAutoPrint;

	private CheckBox mAutoTranslocateCheckbox;

	private Button mRandomMap;

	private Button mRandomWeather;

	private Button mRandomTimeOfDay;

	private TextBox mMissionLengthTextBox;

	private Timer tmrAutoTranslocate;

	private string GameStatusText
	{
		set
		{
			if (string.IsNullOrEmpty(value))
			{
				string text3 = (base.TabText = (Text = mGameName));
			}
			else
			{
				string text6 = (base.TabText = (Text = $"{mGameName} [{value}]"));
			}
		}
	}

	private RPGame()
	{
		InitializeComponent();
	}

	internal RPGame(Site site, bool footballMode)
		: this()
	{
		mFootballMode = footballMode;
		mSite = site;
		SuspendLayout();
		mGameName = (mFootballMode ? "Martian Football" : "Death Race");
		GameStatusText = null;
		int selectedIndex;
		int num = (selectedIndex = 0);
		string text = (mFootballMode ? RPDefaults.Football.MapKey : RPDefaults.DeathRace.MapKey);
		mMap.DisplayMember = "Name";
		mMap.ValueMember = "Key";
		foreach (RPMap item in mFootballMode ? RPConfig.Football.Maps.Values : RPConfig.DeathRace.Maps.Values)
		{
			mMap.Items.Add(item);
			if (item.Key == text)
			{
				selectedIndex = num;
			}
			num++;
		}
		mMap.SelectedIndex = selectedIndex;
		num = (selectedIndex = 0);
		text = (mFootballMode ? RPDefaults.Football.WeatherKey : RPDefaults.DeathRace.WeatherKey);
		mWeather.DisplayMember = "Value";
		mWeather.ValueMember = "Key";
		foreach (KeyValuePair<string, string> item2 in mFootballMode ? RPConfig.Football.Weather : RPConfig.DeathRace.Weather)
		{
			mWeather.Items.Add(item2);
			if (item2.Key == text)
			{
				selectedIndex = num;
			}
			num++;
		}
		mWeather.SelectedIndex = selectedIndex;
		num = (selectedIndex = 0);
		text = (mFootballMode ? RPDefaults.Football.TimeOfDayKey : RPDefaults.DeathRace.TimeOfDayKey);
		mTimeOfDay.DisplayMember = "Value";
		mTimeOfDay.ValueMember = "Key";
		foreach (KeyValuePair<string, string> item3 in mFootballMode ? RPConfig.Football.TimesOfDay : RPConfig.DeathRace.TimesOfDay)
		{
			mTimeOfDay.Items.Add(item3);
			if (item3.Key == text)
			{
				selectedIndex = num;
			}
			num++;
		}
		mTimeOfDay.SelectedIndex = selectedIndex;
		mScoreCompression.Checked = (mFootballMode ? RPDefaults.Football.ScoreCompression : RPDefaults.DeathRace.ScoreCompression);
		mMissionLengthTextBox.Text = (mFootballMode ? RPDefaults.Football.MissionLength : RPDefaults.DeathRace.MissionLength).TotalMinutes.ToString();
		num = (selectedIndex = 0);
		text = (mFootballMode ? RPDefaults.Football.VehicleKey : RPDefaults.DeathRace.VehicleKey);
		mVehicleColumn.DisplayMember = "Name";
		mVehicleColumn.ValueMember = "Key";
		foreach (RPVehicle item4 in mFootballMode ? RPConfig.Football.Vehicles.Values : RPConfig.DeathRace.Vehicles.Values)
		{
			mVehicleColumn.Items.Add(item4);
			if (item4.Key == text)
			{
				selectedIndex = num;
			}
			num++;
		}
		mVehicleColumn.Tag = selectedIndex;
		num = (selectedIndex = 0);
		text = (mFootballMode ? RPDefaults.Football.TeamKey : RPDefaults.DeathRace.ColorKey);
		if (mFootballMode)
		{
			mColorColumn.HeaderText = "Team";
		}
		mColorColumn.DisplayMember = (mFootballMode ? "Name" : "Value");
		mColorColumn.ValueMember = "Key";
		if (mFootballMode)
		{
			foreach (RPTeam value in RPConfig.Football.Teams.Values)
			{
				mColorColumn.Items.Add(value);
				if (value.Key == text)
				{
					selectedIndex = num;
				}
				num++;
			}
		}
		else
		{
			foreach (KeyValuePair<string, string> color in RPConfig.DeathRace.Colors)
			{
				mColorColumn.Items.Add(color);
				if (color.Key == text)
				{
					selectedIndex = num;
				}
				num++;
			}
		}
		mColorColumn.Tag = selectedIndex;
		num = (selectedIndex = 0);
		text = (mFootballMode ? RPDefaults.Football.PositionKey : RPDefaults.DeathRace.BadgeKey);
		if (mFootballMode)
		{
			mBadgeColumn.HeaderText = "Position";
		}
		mBadgeColumn.DisplayMember = "Value";
		mBadgeColumn.ValueMember = "Key";
		foreach (KeyValuePair<string, string> item5 in mFootballMode ? RPConfig.Football.Positions : RPConfig.DeathRace.Badges)
		{
			mBadgeColumn.Items.Add(item5);
			if (item5.Key == text)
			{
				selectedIndex = num;
			}
			num++;
		}
		mBadgeColumn.Tag = selectedIndex;
		List<Tuple<Squad, Pod>> list = new List<Tuple<Squad, Pod>>();
		foreach (Squad squad in mSite.Squads)
		{
			foreach (Pod pod in squad.Pods)
			{
				if (pod.HostType == HostType.GameMachineHostType)
				{
					BuildPodRow(squad, pod);
				}
				else if (pod.HostType == HostType.MissionReviewHostType)
				{
					list.Add(new Tuple<Squad, Pod>(squad, pod));
				}
			}
		}
		foreach (Tuple<Squad, Pod> item6 in list)
		{
			BuildPodRow(item6.A, item6.B);
		}
		CheckAllValues();
		ResumeLayout();
	}

	private void BuildPodRow(Squad squad, Pod pod)
	{
		int index = mPilotsDataGrid.Rows.Add();
		DataGridViewRow row = mPilotsDataGrid.Rows[index];
		row.Tag = pod;
		row.HeaderCell.Value = $"{squad.Name} - {pod.Name}";
		row.Cells[mEnabledColumn.Index].Value = false;
		if (pod.HostType == HostType.GameMachineHostType)
		{
			row.Cells[mVehicleColumn.Index].Value = mVehicleColumn.Items[(int)mVehicleColumn.Tag];
			row.Cells[mColorColumn.Index].Value = mColorColumn.Items[(int)mColorColumn.Tag];
			row.Cells[mBadgeColumn.Index].Value = mBadgeColumn.Items[(int)mBadgeColumn.Tag];
		}
		else
		{
			row.Cells[mVehicleColumn.Index].Value = "";
			row.Cells[mColorColumn.Index].Value = "";
			row.Cells[mBadgeColumn.Index].Value = "";
			row.Cells[mPilotColumn.Index].ReadOnly = true;
			row.Cells[mVehicleColumn.Index].ReadOnly = true;
			row.Cells[mColorColumn.Index].ReadOnly = true;
			row.Cells[mBadgeColumn.Index].ReadOnly = true;
		}
		mGameStateData[pod.MungaGame] = new GameStateData();
		SetPodStatus(row, pod.MungaGame);
		pod.MungaGame.OnPodStatusUpdated += delegate(object sender, EventArgs e)
		{
			if (!base.IsDisposed)
			{
				SetPodStatus(row, (MungaGame)sender);
			}
		};
	}

	protected override void OnClosing(CancelEventArgs e)
	{
		if (mCurrentState != 0 && MessageBox.Show("An RP game controlled by this window is currently in progress.  If you choose to continue, the game will end immediately and no score sheets will be printed.  Are you sure you wish to procede?", "Game Running", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
		{
			e.Cancel = true;
		}
		else
		{
			base.OnClosing(e);
		}
	}

	protected override void OnClosed(EventArgs e)
	{
		foreach (Squad squad in mSite.Squads)
		{
			foreach (Pod pod in squad.Pods)
			{
				ForcePodRelease(pod.MungaGame);
				pod.MungaGame.ReleaseRequest(this);
			}
		}
		base.OnClosed(e);
	}

	private bool IsAllPodsAppState(ApplicationState state)
	{
		foreach (DataGridViewRow item in (IEnumerable)mPilotsDataGrid.Rows)
		{
			if ((bool)item.Cells[mEnabledColumn.Index].Value)
			{
				MungaGame mungaGame = (MungaGame)item.HeaderCell.Tag;
				if (!mungaGame.IsPodAppState(ApplicationID.RPL4, state))
				{
					return false;
				}
			}
		}
		return true;
	}

	private static string GetStringOrKey(DataGridViewCell cell)
	{
		if (cell.Value is string)
		{
			return (string)cell.Value;
		}
		return ((KeyValuePair<string, string>)cell.Value).Key;
	}

	private void NetworkScan(object sender, EventArgs e)
	{
		if (mCurrentState == RPGameState.Run && mRequestedState == RPGameState.Run && !mProcessingMissionEndStateChangeReq)
		{
			mProcessingMissionEndStateChangeReq = true;
			TimeSpan timeRemaining = mMissionLength - (DateTime.Now - mGameStart);
			if (timeRemaining.Ticks < 0)
			{
				mNormalMissionEnd = true;
				RequestState(RPGameState.Idle);
				timeRemaining = new TimeSpan(0L);
			}
			string gameStatusText = FormatTimeRemaining(timeRemaining);
			mMissionLengthDisplayLabel.Text = gameStatusText;
			GameStatusText = gameStatusText;
			mProcessingMissionEndStateChangeReq = false;
		}
		bool flag = true;
		foreach (DataGridViewRow item in (IEnumerable)mPilotsDataGrid.Rows)
		{
			Pod pod = (Pod)item.Tag;
			if (mRequestedState == RPGameState.Idle)
			{
				GetPodReleased(pod.MungaGame);
				if (pod.MungaGame.IsOwner(this))
				{
					flag = false;
				}
			}
			else if (!(bool)item.Cells[mEnabledColumn.Index].Value)
			{
				if (pod.MungaGame.IsOwner(this))
				{
					GetPodReleased(pod.MungaGame);
				}
			}
			else
			{
				GameStateData gameStateData = mGameStateData[pod.MungaGame];
				if (!gameStateData.PodAppearsReset)
				{
					if (!pod.MungaGame.IsOwned)
					{
						pod.MungaGame.TakeOwnership(this);
					}
					if (!pod.MungaGame.IsOwner(this))
					{
						flag = false;
					}
					else if (!pod.MungaGame.IsPodOperational(ApplicationID.RPL4))
					{
						flag = false;
					}
					else if (mRequestedState == RPGameState.Load)
					{
						switch (pod.MungaGame.AppState.Value)
						{
						case ApplicationState.RunningMission:
							if (!gameStateData.AbortMessageSent)
							{
								pod.MungaGame.Send(0, 1, new AbortMissionMessage(0));
								gameStateData.AbortMessageSent = true;
							}
							break;
						case ApplicationState.WaitingForEgg:
							if (!pod.MungaGame.EggAcknowledged && pod.MungaGame.EggDelayTimer < DateTime.Now && pod.MungaGame.EggSent.AddSeconds(5.0) < DateTime.Now)
							{
								LogMessage("Egg Sent.");
								EggFileMessage[] array = mEggFileMessages;
								foreach (EggFileMessage message in array)
								{
									pod.MungaGame.Send(0, 1, message);
								}
								pod.MungaGame.EggSent = DateTime.Now;
							}
							break;
						}
						if (!pod.MungaGame.IsPodAppState(ApplicationID.RPL4, ApplicationState.WaitingForLaunch))
						{
							flag = false;
						}
					}
					else if (mRequestedState == RPGameState.Run)
					{
						switch (pod.MungaGame.AppState.Value)
						{
						case ApplicationState.WaitingForEgg:
							gameStateData.PodAppearsReset = true;
							GetPodReleased(pod.MungaGame);
							break;
						case ApplicationState.WaitingForLaunch:
							if (!gameStateData.RunMessageSent)
							{
								pod.MungaGame.Send(0, 1, new RunMissionMessage());
								gameStateData.RunMessageSent = true;
							}
							break;
						}
						if (!pod.MungaGame.IsPodAppState(ApplicationID.RPL4, ApplicationState.RunningMission))
						{
							flag = false;
						}
					}
				}
			}
			if (!pod.MungaGame.IsOwner(this))
			{
				continue;
			}
			for (MetaMessage metaMessage = pod.MungaGame.Receive(); metaMessage != null; metaMessage = pod.MungaGame.Receive())
			{
				LogMessage(pod, metaMessage);
				if (metaMessage.Message is VTVBoosterMessage)
				{
					VTVBoosterMessage vTVBoosterMessage = (VTVBoosterMessage)metaMessage.Message;
					mMissionRecorder.PlayerBoost(mMissionPlayers[vTVBoosterMessage.PlayerHostID], vTVBoosterMessage.BoosterOn);
				}
				else if (metaMessage.Message is VTVDamagedMessage)
				{
					VTVDamagedMessage vTVDamagedMessage = (VTVDamagedMessage)metaMessage.Message;
					mMissionRecorder.PlayerDamaged(mMissionPlayers[vTVDamagedMessage.PlayerHostID], mMissionPlayers[vTVDamagedMessage.DamagerHostID], vTVDamagedMessage.DamageLoss, vTVDamagedMessage.PointsTransfered);
				}
				else if (metaMessage.Message is VTVKilledMessage)
				{
					VTVKilledMessage vTVKilledMessage = (VTVKilledMessage)metaMessage.Message;
					mMissionRecorder.PlayerKilled(mMissionPlayers[vTVKilledMessage.PlayerHostID], mMissionPlayers[vTVKilledMessage.KillerHostID]);
				}
				else if (metaMessage.Message is VTVScoredMessage)
				{
					VTVScoredMessage vTVScoredMessage = (VTVScoredMessage)metaMessage.Message;
					mMissionRecorder.PlayerScored(mMissionPlayers[vTVScoredMessage.PlayerHostID]);
				}
				else if (metaMessage.Message is VTVScoreUpdateMessage)
				{
					VTVScoreUpdateMessage vTVScoreUpdateMessage = (VTVScoreUpdateMessage)metaMessage.Message;
					mMissionRecorder.PlayerScoreUpdate(mMissionPlayers[vTVScoreUpdateMessage.PlayerHostID], vTVScoreUpdateMessage.PlayerScore);
				}
				else if (metaMessage.Message is EndMissionMessage)
				{
					EndMissionMessage endMissionMessage = (EndMissionMessage)metaMessage.Message;
					mMissionRecorder.PlayerFinalScore(mMissionPlayers[endMissionMessage.PlayerHostID], endMissionMessage.FinalScore);
				}
			}
		}
		if (mCurrentState != mRequestedState && flag)
		{
			StateChangeApproved();
		}
	}

	private void LogMessage(string message)
	{
		if (mLogWindow != null && !mLogWindow.IsDisposed)
		{
			mLogWindow.LogMessage(message);
		}
	}

	private void LogMessage(Pod pod, MetaMessage msg)
	{
		if (mLogWindow == null || mLogWindow.IsDisposed)
		{
			return;
		}
		if (msg.Message is AcknowledgeEggFileMessage)
		{
			mLogWindow.LogMessage("{0}: {1}: {2}: Egg ACK", pod.Name, msg.Header.ClientID, msg.Message.GetType().Name);
		}
		else if (msg.Message is EndMissionMessage)
		{
			EndMissionMessage endMissionMessage = (EndMissionMessage)msg.Message;
			mLogWindow.LogMessage("{0}: {1}: {2}: Final Score {3}", pod.Name, msg.Header.ClientID, msg.Message.GetType().Name, endMissionMessage.FinalScore);
		}
		else if (msg.Message is ReadyToRunMessage)
		{
			mLogWindow.LogMessage("{0}: {1}: {2}", pod.Name, msg.Header.ClientID, msg.Message.GetType().Name);
		}
		else if (msg.Message is VTVScoredMessage)
		{
			mLogWindow.LogMessage("{0}: {1}: {2}", pod.Name, msg.Header.ClientID, msg.Message.GetType().Name);
		}
		else if (msg.Message is VTVKilledMessage)
		{
			VTVKilledMessage vTVKilledMessage = (VTVKilledMessage)msg.Message;
			mLogWindow.LogMessage("{0}: {1}: {2}: {3} killed {4}", pod.Name, msg.Header.ClientID, msg.Message.GetType().Name, vTVKilledMessage.KillerHostID, vTVKilledMessage.PlayerHostID);
		}
		else if (msg.Message is VTVBoosterMessage)
		{
			mLogWindow.LogMessage("{0}: {1}: {2}: {3} is {4}boosting", pod.Name, msg.Header.ClientID, msg.Message.GetType().Name, ((VTVBoosterMessage)msg.Message).PlayerHostID, (((VTVBoosterMessage)msg.Message).BoosterOn == 1) ? "" : "not ");
		}
		else if (msg.Message is VTVScoreUpdateMessage)
		{
			mLogWindow.LogMessage("{0}: {1}: {2}: {3} Score = {4}", pod.Name, msg.Header.ClientID, msg.Message.GetType().Name, ((VTVScoreUpdateMessage)msg.Message).PlayerHostID, ((VTVScoreUpdateMessage)msg.Message).PlayerScore);
		}
		else if (msg.Message is VTVDamagedMessage)
		{
			VTVDamagedMessage vTVDamagedMessage = (VTVDamagedMessage)msg.Message;
			if (vTVDamagedMessage.DamageLoss != 0)
			{
				mLogWindow.LogMessage("{0}: {1}: {2}: {3} Damaged {4} For {5} Points.", pod.Name, msg.Header.ClientID, msg.Message.GetType().Name, vTVDamagedMessage.DamagerHostID, vTVDamagedMessage.PlayerHostID, vTVDamagedMessage.PointsTransfered);
			}
		}
		else if (msg.Message is MechKilledMessage || msg.Message is MechScoreUpdateMessage || msg.Message is MechDamagedMessage || msg.Message is BTTeamScoreUpdateMessage || msg.Message is MechDeathWithoutHonorMessage)
		{
			mLogWindow.LogMessage("{0}: {1}: {2}", pod.Name, msg.Header.ClientID, msg.Message.GetType().Name);
		}
		else if (msg.Message is EndMissionMessage)
		{
			mLogWindow.LogMessage("{0}: {1}: {2}: {3}: Final Score = {4}", pod.Name, msg.Header.ClientID, msg.Message.GetType().Name, ((EndMissionMessage)msg.Message).PlayerHostID, ((EndMissionMessage)msg.Message).FinalScore);
		}
	}

	private string FormatTimeRemaining(TimeSpan timeRemaining)
	{
		long num = (long)timeRemaining.TotalMinutes;
		long num2 = (long)(timeRemaining.TotalSeconds - (double)(num * 60));
		return $"{num:00}:{num2:00}";
	}

	private void ForcePodRelease(MungaGame munga)
	{
		GetPodReleased(munga);
		munga.ReleaseOwnership(this);
	}

	private void GetPodReleased(MungaGame munga)
	{
		if (!munga.IsOwner(this))
		{
			return;
		}
		if (!munga.IsPodOperational(ApplicationID.RPL4))
		{
			munga.ReleaseOwnership(this);
			return;
		}
		GameStateData gameStateData = mGameStateData[munga];
		switch (munga.AppState.Value)
		{
		case ApplicationState.WaitingForLaunch:
			if (!gameStateData.AbortMessageSent)
			{
				munga.Send(0, 1, new AbortMissionMessage(0));
				gameStateData.AbortMessageSent = true;
			}
			break;
		case ApplicationState.RunningMission:
			if (!gameStateData.StopMessageSent)
			{
				munga.Send(0, 1, new StopMissionMessage(0));
				gameStateData.StopMessageSent = true;
			}
			break;
		case ApplicationState.WaitingForEgg:
			munga.ReleaseOwnership(this);
			break;
		case ApplicationState.LoadingMission:
		case ApplicationState.LaunchingMission:
			break;
		}
	}

	private void StateChangeApproved()
	{
		switch (mRequestedState)
		{
		case RPGameState.Idle:
			EndMission();
			GameStatusText = null;
			mGoButton.Text = "Load";
			mEggFileMessages = null;
			SwitchControlsMode(editMode: true);
			CheckAllValues();
			mCurrentState = RPGameState.Idle;
			break;
		case RPGameState.Load:
			GameStatusText = "Loaded";
			mGoButton.Text = "Run Mission";
			mGoButton.Enabled = true;
			foreach (GameStateData value in mGameStateData.Values)
			{
				value.Reset();
			}
			mCurrentState = RPGameState.Load;
			if (mAutoTranslocateCheckbox.Checked)
			{
				int num = (mFootballMode ? RPDefaults.Football.LaunchDelay : RPDefaults.DeathRace.LaunchDelay);
				if (num == 0)
				{
					mGoButton.Text = "Launching...";
					GameStatusText = "Launching...";
					mGoButton.Enabled = false;
					RequestState(RPGameState.Run);
				}
				else
				{
					mGoButton.Text = $"Launching in {num}...";
					GameStatusText = mGoButton.Text;
					mRemainingUntilTranslocate = num;
					tmrAutoTranslocate.Start();
				}
			}
			break;
		case RPGameState.Run:
			mGameStart = DateTime.Now;
			mGoButton.Text = "Stop Mission";
			mGoButton.Enabled = true;
			mCurrentState = RPGameState.Run;
			mMissionRecorder.SetMissionStart();
			mMissionLengthDisplayLabel.ForeColor = Color.DarkGreen;
			break;
		case RPGameState.AutoTransCount:
			break;
		}
	}

	private void mGoButton_Click(object sender, EventArgs e)
	{
		switch (mCurrentState)
		{
		case RPGameState.Idle:
			RequestState(RPGameState.Load);
			break;
		case RPGameState.Load:
			tmrAutoTranslocate.Stop();
			RequestState(RPGameState.Run);
			break;
		case RPGameState.Run:
			mNormalMissionEnd = false;
			RequestState(RPGameState.Idle);
			break;
		case RPGameState.AutoTransCount:
			break;
		}
	}

	private void resetToolStripMenuItem_Click(object sender, EventArgs e)
	{
		RequestState(RPGameState.Reset);
	}

	private void RequestState(RPGameState state)
	{
		switch (state)
		{
		case RPGameState.Load:
		{
			mMissionLength = ParseMissionLength();
			string key = ((RPMap)mMap.SelectedItem).Key;
			string key2 = ((KeyValuePair<string, string>)mTimeOfDay.SelectedItem).Key;
			string key3 = ((KeyValuePair<string, string>)mWeather.SelectedItem).Key;
			RPMission rPMission = (mFootballMode ? ((RPMission)new RPFootballMission(key, key2, key3, mScoreCompression.Checked, mMissionLength)) : ((RPMission)new RPRaceMission(key, key2, key3, mScoreCompression.Checked, mMissionLength)));
			mMissionRecorder = new RPMissionRecorder(rPMission);
			mMissionPlayers = new Dictionary<int, RPPlayer>();
			int num = 2;
			Dictionary<string, List<RPFootballPlayer>> dictionary = new Dictionary<string, List<RPFootballPlayer>>();
			foreach (DataGridViewRow item in (IEnumerable)mPilotsDataGrid.Rows)
			{
				if (!(bool)item.Cells[mEnabledColumn.Index].Value)
				{
					continue;
				}
				Pod pod = (Pod)item.Tag;
				if (pod.HostType == HostType.GameMachineHostType)
				{
					string value;
					if (mFootballMode)
					{
						RPTeam rPTeam = ((item.Cells[mColorColumn.Index].Value is RPTeam) ? ((RPTeam)item.Cells[mColorColumn.Index].Value) : RPConfig.Football.Teams[(string)item.Cells[mColorColumn.Index].Value]);
						string stringOrKey = GetStringOrKey(item.Cells[mBadgeColumn.Index]);
						RPFootballPlayer rPFootballPlayer = new RPFootballPlayer(pod.IPAddress.ToString(), value = (string)item.Cells[mPilotColumn.Index].Value, (item.Cells[mVehicleColumn.Index].Value is string) ? ((string)item.Cells[mVehicleColumn.Index].Value) : ((RPVehicle)item.Cells[mVehicleColumn.Index].Value).Key, rPTeam.Key, stringOrKey, (stringOrKey == "runner") ? rPTeam.RunnerColor : rPTeam.TeamColor);
						if (!dictionary.ContainsKey(rPFootballPlayer.TeamKey))
						{
							dictionary[rPFootballPlayer.TeamKey] = new List<RPFootballPlayer>();
						}
						dictionary[rPFootballPlayer.TeamKey].Add(rPFootballPlayer);
					}
					else
					{
						RPRacePlayer rPRacePlayer = new RPRacePlayer(pod.IPAddress.ToString(), value = (string)item.Cells[mPilotColumn.Index].Value, (item.Cells[mVehicleColumn.Index].Value is string) ? ((string)item.Cells[mVehicleColumn.Index].Value) : ((RPVehicle)item.Cells[mVehicleColumn.Index].Value).Key, GetStringOrKey(item.Cells[mColorColumn.Index]), GetStringOrKey(item.Cells[mBadgeColumn.Index]));
						((RPRaceMission)rPMission).RacePlayers.Add(rPRacePlayer);
						mMissionPlayers.Add(num++, rPRacePlayer);
					}
					PilotNameCache.PilotNames.Add(value);
				}
				else
				{
					rPMission.Cameras.Add(new RPCamera(pod.IPAddress.ToString(), pod.HostType));
				}
			}
			if (mFootballMode)
			{
				foreach (List<RPFootballPlayer> value2 in dictionary.Values)
				{
					((RPFootballMission)rPMission).AddFootballTeam(value2);
					foreach (RPFootballPlayer item2 in value2)
					{
						mMissionPlayers.Add(num++, item2);
					}
				}
			}
			mEggFileMessages = rPMission.ToEggFileMessages();
			mRequestedState = RPGameState.Load;
			SwitchControlsMode(editMode: false);
			GameStatusText = "Loading...";
			mGoButton.Text = "Loading...";
			mGoButton.Enabled = false;
			break;
		}
		case RPGameState.Run:
			mRequestedState = RPGameState.Run;
			GameStatusText = "Launching...";
			mGoButton.Text = "Launching...";
			mGoButton.Enabled = false;
			break;
		case RPGameState.Idle:
			mRequestedState = RPGameState.Idle;
			mMissionLengthDisplayLabel.ForeColor = Color.Red;
			GameStatusText = "Stopping Game...";
			mGoButton.Text = "Stopping Game...";
			mGoButton.Enabled = false;
			break;
		case RPGameState.Reset:
			foreach (Squad squad in mSite.Squads)
			{
				foreach (Pod pod2 in squad.Pods)
				{
					ForcePodRelease(pod2.MungaGame);
				}
			}
			mRequestedState = RPGameState.Idle;
			StateChangeApproved();
			break;
		case RPGameState.AutoTransCount:
			break;
		}
	}

	private void EndMission()
	{
		try
		{
			mLastMissionResults = mMissionRecorder.EndMission(mNormalMissionEnd ? mMissionLength : (DateTime.Now - mGameStart));
			try
			{
				mLastMissionResults.Save();
			}
			catch (Exception ex)
			{
				if (Debugger.IsAttached)
				{
					throw;
				}
				Program.LogExceptionAndShowDialog(ex, "Mission results failed to save.", "Error Saving Mission Results");
			}
			if (mAutoPrint.Checked)
			{
				try
				{
					mLastMissionResults.GetPrintDocument().Print();
				}
				catch (Exception ex2)
				{
					if (Debugger.IsAttached)
					{
						throw;
					}
					Program.LogExceptionAndShowDialog(ex2, "Mission results failed to print.", "Error Printing Mission Results");
				}
			}
			mPrintLastMission.Enabled = true;
		}
		catch (Exception ex3)
		{
			if (Debugger.IsAttached)
			{
				throw;
			}
			Program.LogExceptionAndShowDialog(ex3, "Failed to create mission results.", "Error Creating Mission Results");
		}
		mMissionRecorder = null;
		mMissionPlayers = null;
	}

	private void SwitchControlsMode(bool editMode)
	{
		ComboBox comboBox = mMap;
		ComboBox comboBox2 = mWeather;
		ComboBox comboBox3 = mTimeOfDay;
		CheckBox checkBox = mScoreCompression;
		Button button = mRandomMap;
		Button button2 = mRandomWeather;
		bool flag2 = (mRandomTimeOfDay.Enabled = editMode);
		bool flag4 = (button2.Enabled = flag2);
		bool flag6 = (button.Enabled = flag4);
		bool flag8 = (checkBox.Enabled = flag6);
		bool flag10 = (comboBox3.Enabled = flag8);
		bool enabled = (comboBox2.Enabled = flag10);
		comboBox.Enabled = enabled;
		mMissionLengthDisplayLabel.Text = FormatTimeRemaining(mMissionLength);
		mMissionLengthDisplayLabel.ForeColor = Color.Orange;
		mMissionLengthTextBox.Visible = editMode;
		mMissionLengthDisplayLabel.Visible = !editMode;
		int column = mMissionPropertiesTable.GetColumn(mMissionLengthTextBox);
		mMissionPropertiesTable.ColumnStyles[column].Width = 0f;
		mMissionPropertiesTable.ColumnStyles[column].SizeType = ((!editMode) ? SizeType.Absolute : SizeType.AutoSize);
		int column2 = mMissionPropertiesTable.GetColumn(mMissionLengthDisplayLabel);
		mMissionPropertiesTable.ColumnStyles[column2].Width = 0f;
		mMissionPropertiesTable.ColumnStyles[column2].SizeType = (editMode ? SizeType.Absolute : SizeType.AutoSize);
		mPilotsDataGrid.EditMode = (editMode ? DataGridViewEditMode.EditOnKeystrokeOrF2 : DataGridViewEditMode.EditProgrammatically);
		Color backColor = (editMode ? Color.White : sDataLockedColor);
		foreach (DataGridViewRow item in (IEnumerable)mPilotsDataGrid.Rows)
		{
			item.Cells[mEnabledColumn.Index].Style.BackColor = backColor;
			if (((Pod)item.Tag).HostType == HostType.GameMachineHostType)
			{
				item.Cells[mPilotColumn.Index].Style.BackColor = backColor;
				item.Cells[mVehicleColumn.Index].Style.BackColor = backColor;
				item.Cells[mColorColumn.Index].Style.BackColor = backColor;
				item.Cells[mBadgeColumn.Index].Style.BackColor = backColor;
				Color foreColor = (((bool)item.Cells[mEnabledColumn.Index].Value) ? Color.Black : Color.DarkGray);
				item.Cells[mPilotColumn.Index].Style.ForeColor = foreColor;
				item.Cells[mVehicleColumn.Index].Style.ForeColor = foreColor;
				item.Cells[mColorColumn.Index].Style.ForeColor = foreColor;
				item.Cells[mBadgeColumn.Index].Style.ForeColor = foreColor;
			}
		}
		if (editMode)
		{
			CheckAllValues();
		}
	}

	private void SetPodStatus(DataGridViewRow row, MungaGame munga)
	{
		if (munga.IsOwned && !munga.IsOwner(this))
		{
			row.Cells[mStatusIconColumn.Index].Value = ImageCache.PodQuestion16;
			row.Cells[mStatusTextColumn.Index].Value = "In Use";
		}
		else
		{
			row.Cells[mStatusIconColumn.Index].Value = munga.Image;
			row.Cells[mStatusTextColumn.Index].Value = munga.StatusMessage;
		}
		if (mCurrentState == RPGameState.Idle && mRequestedState == RPGameState.Idle)
		{
			CheckAllValues();
		}
	}

	private void CheckAllValues()
	{
		foreach (DataGridViewRow item in (IEnumerable)mPilotsDataGrid.Rows)
		{
			item.Cells[mPilotColumn.Index].ErrorText = "";
			item.Cells[mBadgeColumn.Index].ErrorText = "";
		}
		Dictionary<string, uint> dictionary = new Dictionary<string, uint>();
		uint num = 0u;
		uint num2 = 0u;
		uint num3 = 0u;
		bool flag = false;
		for (int i = 0; i < mPilotsDataGrid.Rows.Count; i++)
		{
			DataGridViewRow dataGridViewRow2 = mPilotsDataGrid.Rows[i];
			Pod pod = (Pod)dataGridViewRow2.Tag;
			if (!(bool)dataGridViewRow2.Cells[mEnabledColumn.Index].Value)
			{
				GreyOutRow(dataGridViewRow2);
				continue;
			}
			if (!pod.MungaGame.IsPodAppState(ApplicationID.RPL4, ApplicationState.WaitingForEgg))
			{
				num++;
			}
			if (pod.HostType == HostType.GameMachineHostType)
			{
				num2++;
				DataGridViewCell dataGridViewCell = dataGridViewRow2.Cells[mPilotColumn.Index];
				dataGridViewCell.Style.ForeColor = mPilotColumn.DefaultCellStyle.ForeColor;
				dataGridViewRow2.Cells[mVehicleColumn.Index].Style.ForeColor = mVehicleColumn.DefaultCellStyle.ForeColor;
				dataGridViewRow2.Cells[mColorColumn.Index].Style.ForeColor = mColorColumn.DefaultCellStyle.ForeColor;
				dataGridViewRow2.Cells[mBadgeColumn.Index].Style.ForeColor = mBadgeColumn.DefaultCellStyle.ForeColor;
				dataGridViewRow2.Cells[mVehicleColumn.Index].Style.BackColor = mVehicleColumn.DefaultCellStyle.BackColor;
				dataGridViewRow2.Cells[mColorColumn.Index].Style.BackColor = mColorColumn.DefaultCellStyle.BackColor;
				dataGridViewRow2.Cells[mBadgeColumn.Index].Style.BackColor = mBadgeColumn.DefaultCellStyle.BackColor;
				if (dataGridViewCell.ErrorText == "")
				{
					if (dataGridViewCell.Value == null || (string)dataGridViewCell.Value == "")
					{
						dataGridViewCell.ErrorText = "Pilot name can not be blank.";
						num3++;
						continue;
					}
					for (int j = i + 1; j < mPilotsDataGrid.Rows.Count; j++)
					{
						DataGridViewRow dataGridViewRow3 = mPilotsDataGrid.Rows[j];
						DataGridViewCell dataGridViewCell2 = dataGridViewRow3.Cells[mPilotColumn.Index];
						if (((Pod)dataGridViewRow3.Tag).HostType == HostType.GameMachineHostType && (bool)dataGridViewRow3.Cells[mEnabledColumn.Index].Value && dataGridViewCell2.ErrorText == "" && dataGridViewCell.Value.Equals(dataGridViewCell2.Value))
						{
							string text3 = (dataGridViewCell.ErrorText = (dataGridViewCell2.ErrorText = "A pilot with this name already exists."));
							flag = true;
						}
					}
				}
				if (!mFootballMode)
				{
					continue;
				}
				DataGridViewCell dataGridViewCell3 = dataGridViewRow2.Cells[mBadgeColumn.Index];
				string text4 = ((dataGridViewRow2.Cells[mColorColumn.Index].Value is string) ? ((string)dataGridViewRow2.Cells[mColorColumn.Index].Value) : ((RPTeam)dataGridViewRow2.Cells[mColorColumn.Index].Value).Key);
				string stringOrKey = GetStringOrKey(dataGridViewCell3);
				if (!dictionary.ContainsKey(text4))
				{
					dictionary.Add(text4, 0u);
				}
				if (!(stringOrKey == "runner"))
				{
					continue;
				}
				dictionary[text4]++;
				for (int k = i + 1; k < mPilotsDataGrid.Rows.Count; k++)
				{
					DataGridViewRow dataGridViewRow4 = mPilotsDataGrid.Rows[k];
					if (dataGridViewRow4.Cells[mEnabledColumn.Index].Value.Equals(true))
					{
						DataGridViewCell dataGridViewCell4 = dataGridViewRow4.Cells[mBadgeColumn.Index];
						string text5 = ((dataGridViewRow4.Cells[mColorColumn.Index].Value is string) ? ((string)dataGridViewRow4.Cells[mColorColumn.Index].Value) : ((RPTeam)dataGridViewRow4.Cells[mColorColumn.Index].Value).Key);
						string stringOrKey2 = GetStringOrKey(dataGridViewCell4);
						if (text4 == text5 && stringOrKey == stringOrKey2)
						{
							string text8 = (dataGridViewCell3.ErrorText = (dataGridViewCell4.ErrorText = "A team can not have more than one runner."));
						}
					}
				}
			}
			else
			{
				GreyOutRow(dataGridViewRow2);
			}
		}
		StringBuilder stringBuilder = new StringBuilder();
		foreach (KeyValuePair<string, uint> item2 in dictionary)
		{
			string name = RPConfig.Football.Teams[item2.Key].Name;
			if (item2.Value == 0)
			{
				stringBuilder.AppendLine($"The {name} team does not have a runner.");
			}
			else if (item2.Value > 1)
			{
				stringBuilder.AppendLine($"The {name} team has more than one runner.");
			}
		}
		if (num2 < 1)
		{
			stringBuilder.AppendLine("You should put at least one player in the game.");
		}
		if (num2 > 8)
		{
			stringBuilder.AppendLine("Red Planet only supports 8 players in a game.");
		}
		if (num3 != 0)
		{
			stringBuilder.AppendLine((num3 > 1) ? "Some pilots have a blank name." : "A pilot has a blank name.");
		}
		if (flag)
		{
			stringBuilder.AppendLine("Some pilots have duplicate names.");
		}
		if (num != 0)
		{
			stringBuilder.AppendLine((num > 1) ? "Some pods are not ready." : "A pod is not ready.");
		}
		if (ParseMissionLength() == TimeSpan.MinValue)
		{
			stringBuilder.AppendLine("The mission length is not valid.");
		}
		else if (ParseMissionLength() < TimeSpan.FromSeconds(10.0))
		{
			stringBuilder.AppendLine("The mission length must be at least 10 seconds.");
		}
		mGoButton.Enabled = stringBuilder.Length <= 0;
		mIssuesLabel.Text = stringBuilder.ToString();
	}

	private void GreyOutRow(DataGridViewRow row)
	{
		row.Cells[mPilotColumn.Index].Style.ForeColor = Color.DarkGray;
		row.Cells[mVehicleColumn.Index].Style.ForeColor = Color.DarkGray;
		row.Cells[mColorColumn.Index].Style.ForeColor = Color.DarkGray;
		row.Cells[mBadgeColumn.Index].Style.ForeColor = Color.DarkGray;
		if (((Pod)row.Tag).HostType != 0)
		{
			row.Cells[mPilotColumn.Index].Style.BackColor = sDataLockedColor;
		}
		row.Cells[mVehicleColumn.Index].Style.BackColor = sDataLockedColor;
		row.Cells[mColorColumn.Index].Style.BackColor = sDataLockedColor;
		row.Cells[mBadgeColumn.Index].Style.BackColor = sDataLockedColor;
	}

	private void mMissionLengthTextBox_TextChanged(object sender, EventArgs e)
	{
		CheckAllValues();
	}

	private TimeSpan ParseMissionLength()
	{
		if (!double.TryParse(mMissionLengthTextBox.Text, out var result))
		{
			return TimeSpan.MinValue;
		}
		try
		{
			return TimeSpan.FromMinutes(result);
		}
		catch (OverflowException)
		{
			return TimeSpan.MinValue;
		}
	}

	private void mPilotsDataGrid_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
	{
		if (e.ColumnIndex == mPilotColumn.Index && !(bool)mPilotsDataGrid.Rows[e.RowIndex].Cells[mEnabledColumn.Index].Value)
		{
			mPilotsDataGrid.Rows[e.RowIndex].Cells[mPilotColumn.Index].Style.ForeColor = mPilotColumn.DefaultCellStyle.ForeColor;
		}
	}

	private void mPilotsDataGrid_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
	{
		if (mPilotsDataGrid.EditingControl is TextBox textBox)
		{
			textBox.AutoCompleteCustomSource = PilotNameCache.PilotNames;
			textBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
			textBox.AutoCompleteSource = AutoCompleteSource.CustomSource;
		}
	}

	private void mPilotsDataGrid_CellEndEdit(object sender, DataGridViewCellEventArgs e)
	{
		bool? flag = null;
		DataGridViewRow dataGridViewRow = mPilotsDataGrid.Rows[e.RowIndex];
		if (e.ColumnIndex == mPilotColumn.Index)
		{
			if (dataGridViewRow.Cells[mPilotColumn.Index].Value != null && (string)dataGridViewRow.Cells[mPilotColumn.Index].Value != "")
			{
				dataGridViewRow.Cells[mEnabledColumn.Index].Value = true;
				flag = true;
			}
			else
			{
				dataGridViewRow.Cells[mEnabledColumn.Index].Value = false;
				flag = false;
			}
		}
		else if (e.ColumnIndex == mEnabledColumn.Index)
		{
			flag = ((!(bool)dataGridViewRow.Cells[mEnabledColumn.Index].Value) ? new bool?(false) : new bool?(true));
		}
		if (flag.HasValue)
		{
			if (flag.Value)
			{
				((Pod)dataGridViewRow.Tag).MungaGame.MakeRequested(this);
			}
			else
			{
				((Pod)dataGridViewRow.Tag).MungaGame.ReleaseRequest(this);
			}
		}
		CheckAllValues();
	}

	private void mPilotsDataGrid_KeyUp(object sender, KeyEventArgs e)
	{
		if ((e.KeyCode == Keys.Delete || e.KeyCode == Keys.Back) && mPilotsDataGrid.SelectedCells.Count == 1 && mPilotsDataGrid.SelectedCells[0].ColumnIndex == mPilotColumn.Index)
		{
			mPilotsDataGrid.SelectedCells[0].Value = "";
			DataGridViewRow dataGridViewRow = mPilotsDataGrid.Rows[mPilotsDataGrid.SelectedCells[0].RowIndex];
			dataGridViewRow.Cells[mEnabledColumn.Index].Value = false;
			((Pod)dataGridViewRow.Tag).MungaGame.ReleaseRequest(this);
			CheckAllValues();
		}
	}

	private void mPilotsDataGrid_MouseDown(object sender, MouseEventArgs e)
	{
		if (mPilotsDataGrid.FirstDisplayedScrollingRowIndex < 0)
		{
			return;
		}
		for (int i = mPilotsDataGrid.FirstDisplayedScrollingRowIndex; i < mPilotsDataGrid.Rows.Count && ((Pod)mPilotsDataGrid.Rows[i].Tag).HostType == HostType.GameMachineHostType; i++)
		{
			if (mPilotsDataGrid.GetCellDisplayRectangle(-1, i, cutOverflow: true).Contains(e.Location))
			{
				mPilotsDataGrid.DoDragDrop(new DragDropData(i, e.Button == MouseButtons.Right), DragDropEffects.Move);
				break;
			}
		}
	}

	private void mPilotsDataGrid_DragOver(object sender, DragEventArgs e)
	{
		if (mPilotsDataGrid.FirstDisplayedScrollingRowIndex >= 0)
		{
			for (int i = mPilotsDataGrid.FirstDisplayedScrollingRowIndex; i < mPilotsDataGrid.Rows.Count && ((Pod)mPilotsDataGrid.Rows[i].Tag).HostType == HostType.GameMachineHostType; i++)
			{
				if (!mPilotsDataGrid.GetCellDisplayRectangle(-1, i, cutOverflow: true).Contains(mPilotsDataGrid.PointToClient(new Point(e.X, e.Y))))
				{
					continue;
				}
				if (e.Data.GetDataPresent(typeof(DragDropData)))
				{
					DragDropData dragDropData = (DragDropData)e.Data.GetData(typeof(DragDropData));
					if (dragDropData.StartRow != i)
					{
						e.Effect = DragDropEffects.Move;
					}
					else
					{
						e.Effect = DragDropEffects.None;
					}
				}
				return;
			}
		}
		e.Effect = DragDropEffects.None;
	}

	private void mPilotsDataGrid_DragDrop(object sender, DragEventArgs e)
	{
		for (int i = mPilotsDataGrid.FirstDisplayedScrollingRowIndex; i < mPilotsDataGrid.Rows.Count; i++)
		{
			if (!mPilotsDataGrid.GetCellDisplayRectangle(-1, i, cutOverflow: true).Contains(mPilotsDataGrid.PointToClient(new Point(e.X, e.Y))))
			{
				continue;
			}
			if (!e.Data.GetDataPresent(typeof(DragDropData)))
			{
				break;
			}
			DragDropData dragDropData = (DragDropData)e.Data.GetData(typeof(DragDropData));
			if (dragDropData.StartRow != i)
			{
				if (dragDropData.RightClick)
				{
					dragDropData.EndRow = i;
					mDragDropContextMenu.Tag = dragDropData;
					mDragDropContextMenu.Show(e.X, e.Y);
				}
				else
				{
					SwapPilots(i, dragDropData.StartRow, update: true);
				}
			}
			break;
		}
	}

	private void swapToolStripMenuItem_Click(object sender, EventArgs e)
	{
		if (mDragDropContextMenu.Tag is DragDropData)
		{
			DragDropData dragDropData = (DragDropData)mDragDropContextMenu.Tag;
			SwapPilots(dragDropData.StartRow, dragDropData.EndRow, update: true);
		}
	}

	private void shiftToolStripMenuItem_Click(object sender, EventArgs e)
	{
		if (!(mDragDropContextMenu.Tag is DragDropData))
		{
			return;
		}
		DragDropData dragDropData = (DragDropData)mDragDropContextMenu.Tag;
		if (dragDropData.StartRow < dragDropData.EndRow)
		{
			for (int i = dragDropData.StartRow; i < dragDropData.EndRow; i++)
			{
				SwapPilots(i, i + 1, i + 1 == dragDropData.EndRow);
			}
			return;
		}
		for (int num = dragDropData.StartRow; num > dragDropData.EndRow; num--)
		{
			SwapPilots(num, num - 1, num - 1 == dragDropData.EndRow);
		}
	}

	private void SwapPilots(int row1, int row2, bool update)
	{
		foreach (DataGridViewColumn column in mPilotsDataGrid.Columns)
		{
			if (column != mStatusIconColumn && column != mStatusTextColumn && column != mEnabledColumn)
			{
				object value = mPilotsDataGrid[column.Index, row1].Value;
				mPilotsDataGrid[column.Index, row1].Value = mPilotsDataGrid[column.Index, row2].Value;
				mPilotsDataGrid[column.Index, row2].Value = value;
			}
		}
		if (update)
		{
			CheckAllValues();
			mPilotsDataGrid.Refresh();
		}
	}

	private void mPrintLastMission_Click(object sender, EventArgs e)
	{
		mLastMissionResults.GetPrintDocument().Print();
	}

	protected override void OnKeyDown(KeyEventArgs e)
	{
		if (e.Modifiers == Keys.Control && e.KeyCode == Keys.L)
		{
			if (mLogWindow == null || mLogWindow.IsDisposed)
			{
				mLogWindow = new LogOutputWindow();
			}
			mLogWindow.Show();
			e.Handled = true;
		}
		base.OnKeyDown(e);
	}

	private void mRandomMap_Click(object sender, EventArgs e)
	{
		mMap.SelectedIndex = sRand.Next(mMap.Items.Count);
	}

	private void mRandomWeather_Click(object sender, EventArgs e)
	{
		mWeather.SelectedIndex = sRand.Next(mWeather.Items.Count);
	}

	private void mRandomTimeOfDay_Click(object sender, EventArgs e)
	{
		mTimeOfDay.SelectedIndex = sRand.Next(mTimeOfDay.Items.Count);
	}

	private void tmrAutoTranslocate_Tick(object sender, EventArgs e)
	{
		mRemainingUntilTranslocate--;
		if (mRemainingUntilTranslocate < 1)
		{
			RequestState(RPGameState.Run);
			tmrAutoTranslocate.Stop();
		}
		else
		{
			string text2 = (GameStatusText = $"Launching in {mRemainingUntilTranslocate}...");
			mGoButton.Text = text2;
		}
	}

	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	private void InitializeComponent()
	{
		this.components = new System.ComponentModel.Container();
		this.mMissionPropertiesGroupBox = new System.Windows.Forms.GroupBox();
		this.mMissionPropertiesTable = new System.Windows.Forms.TableLayoutPanel();
		this.mIssuesLabel = new System.Windows.Forms.Label();
		this.mMissionLengthTextLabel = new System.Windows.Forms.Label();
		this.mMap = new System.Windows.Forms.ComboBox();
		this.mMissionLengthDisplayLabel = new System.Windows.Forms.Label();
		this.mWeather = new System.Windows.Forms.ComboBox();
		this.mTimeOfDay = new System.Windows.Forms.ComboBox();
		this.mMapLabel = new System.Windows.Forms.Label();
		this.mWeatherLabel = new System.Windows.Forms.Label();
		this.mTimeOfDayLabel = new System.Windows.Forms.Label();
		this.mScoreCompression = new System.Windows.Forms.CheckBox();
		this.mGoButton = new System.Windows.Forms.Button();
		this.mResetContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
		this.resetToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
		this.mPrintLastMission = new System.Windows.Forms.Button();
		this.mAutoPrint = new System.Windows.Forms.CheckBox();
		this.mAutoTranslocateCheckbox = new System.Windows.Forms.CheckBox();
		this.mRandomMap = new System.Windows.Forms.Button();
		this.mRandomWeather = new System.Windows.Forms.Button();
		this.mRandomTimeOfDay = new System.Windows.Forms.Button();
		this.mMissionLengthTextBox = new System.Windows.Forms.TextBox();
		this.mPilotsGroupBox = new System.Windows.Forms.GroupBox();
		this.mPilotsDataGrid = new System.Windows.Forms.DataGridView();
		this.mEnabledColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
		this.mStatusIconColumn = new System.Windows.Forms.DataGridViewImageColumn();
		this.mStatusTextColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.mPilotColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.mVehicleColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
		this.mColorColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
		this.mBadgeColumn = new System.Windows.Forms.DataGridViewComboBoxColumn();
		this.mDragDropContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
		this.mSwapPilots = new System.Windows.Forms.ToolStripMenuItem();
		this.mShiftPilots = new System.Windows.Forms.ToolStripMenuItem();
		this.mNetworkTimer = new System.Windows.Forms.Timer(this.components);
		this.tmrAutoTranslocate = new System.Windows.Forms.Timer(this.components);
		this.mMissionPropertiesGroupBox.SuspendLayout();
		this.mMissionPropertiesTable.SuspendLayout();
		this.mResetContextMenu.SuspendLayout();
		this.mPilotsGroupBox.SuspendLayout();
		((System.ComponentModel.ISupportInitialize)this.mPilotsDataGrid).BeginInit();
		this.mDragDropContextMenu.SuspendLayout();
		base.SuspendLayout();
		this.mMissionPropertiesGroupBox.Controls.Add(this.mMissionPropertiesTable);
		this.mMissionPropertiesGroupBox.Dock = System.Windows.Forms.DockStyle.Top;
		this.mMissionPropertiesGroupBox.Location = new System.Drawing.Point(8, 8);
		this.mMissionPropertiesGroupBox.Name = "mMissionPropertiesGroupBox";
		this.mMissionPropertiesGroupBox.Padding = new System.Windows.Forms.Padding(5);
		this.mMissionPropertiesGroupBox.Size = new System.Drawing.Size(1040, 105);
		this.mMissionPropertiesGroupBox.TabIndex = 10;
		this.mMissionPropertiesGroupBox.TabStop = false;
		this.mMissionPropertiesGroupBox.Text = "Mission Properties";
		this.mMissionPropertiesTable.AutoSize = true;
		this.mMissionPropertiesTable.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
		this.mMissionPropertiesTable.ColumnCount = 8;
		this.mMissionPropertiesTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
		this.mMissionPropertiesTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
		this.mMissionPropertiesTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
		this.mMissionPropertiesTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
		this.mMissionPropertiesTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
		this.mMissionPropertiesTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 0f));
		this.mMissionPropertiesTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
		this.mMissionPropertiesTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
		this.mMissionPropertiesTable.Controls.Add(this.mIssuesLabel, 7, 0);
		this.mMissionPropertiesTable.Controls.Add(this.mMissionLengthTextLabel, 3, 1);
		this.mMissionPropertiesTable.Controls.Add(this.mMap, 1, 0);
		this.mMissionPropertiesTable.Controls.Add(this.mMissionLengthDisplayLabel, 5, 1);
		this.mMissionPropertiesTable.Controls.Add(this.mWeather, 1, 1);
		this.mMissionPropertiesTable.Controls.Add(this.mTimeOfDay, 1, 2);
		this.mMissionPropertiesTable.Controls.Add(this.mMapLabel, 0, 0);
		this.mMissionPropertiesTable.Controls.Add(this.mWeatherLabel, 0, 1);
		this.mMissionPropertiesTable.Controls.Add(this.mTimeOfDayLabel, 0, 2);
		this.mMissionPropertiesTable.Controls.Add(this.mScoreCompression, 3, 0);
		this.mMissionPropertiesTable.Controls.Add(this.mGoButton, 3, 2);
		this.mMissionPropertiesTable.Controls.Add(this.mPrintLastMission, 6, 2);
		this.mMissionPropertiesTable.Controls.Add(this.mAutoPrint, 6, 1);
		this.mMissionPropertiesTable.Controls.Add(this.mAutoTranslocateCheckbox, 6, 0);
		this.mMissionPropertiesTable.Controls.Add(this.mRandomMap, 2, 0);
		this.mMissionPropertiesTable.Controls.Add(this.mRandomWeather, 2, 1);
		this.mMissionPropertiesTable.Controls.Add(this.mRandomTimeOfDay, 2, 2);
		this.mMissionPropertiesTable.Controls.Add(this.mMissionLengthTextBox, 4, 1);
		this.mMissionPropertiesTable.Dock = System.Windows.Forms.DockStyle.Fill;
		this.mMissionPropertiesTable.GrowStyle = System.Windows.Forms.TableLayoutPanelGrowStyle.AddColumns;
		this.mMissionPropertiesTable.Location = new System.Drawing.Point(5, 18);
		this.mMissionPropertiesTable.MinimumSize = new System.Drawing.Size(0, 85);
		this.mMissionPropertiesTable.Name = "mMissionPropertiesTable";
		this.mMissionPropertiesTable.RowCount = 4;
		this.mMissionPropertiesTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
		this.mMissionPropertiesTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
		this.mMissionPropertiesTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
		this.mMissionPropertiesTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100f));
		this.mMissionPropertiesTable.Size = new System.Drawing.Size(1030, 85);
		this.mMissionPropertiesTable.TabIndex = 0;
		this.mIssuesLabel.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.mIssuesLabel.AutoSize = true;
		this.mIssuesLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0);
		this.mIssuesLabel.ForeColor = System.Drawing.Color.Red;
		this.mIssuesLabel.Location = new System.Drawing.Point(642, 0);
		this.mIssuesLabel.Name = "mIssuesLabel";
		this.mMissionPropertiesTable.SetRowSpan(this.mIssuesLabel, 4);
		this.mIssuesLabel.Size = new System.Drawing.Size(385, 85);
		this.mIssuesLabel.TabIndex = 0;
		this.mMissionLengthTextLabel.Anchor = System.Windows.Forms.AnchorStyles.Left;
		this.mMissionLengthTextLabel.AutoSize = true;
		this.mMissionLengthTextLabel.Location = new System.Drawing.Point(311, 37);
		this.mMissionLengthTextLabel.Name = "mMissionLengthTextLabel";
		this.mMissionLengthTextLabel.Size = new System.Drawing.Size(106, 13);
		this.mMissionLengthTextLabel.TabIndex = 7;
		this.mMissionLengthTextLabel.Text = "Mission Length (min):";
		this.mMap.Anchor = System.Windows.Forms.AnchorStyles.Left;
		this.mMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
		this.mMap.FormattingEnabled = true;
		this.mMap.Location = new System.Drawing.Point(76, 4);
		this.mMap.Name = "mMap";
		this.mMap.Size = new System.Drawing.Size(198, 21);
		this.mMap.TabIndex = 0;
		this.mMissionLengthDisplayLabel.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.mMissionLengthDisplayLabel.AutoSize = true;
		this.mMissionLengthDisplayLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 12f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0);
		this.mMissionLengthDisplayLabel.ForeColor = System.Drawing.Color.Green;
		this.mMissionLengthDisplayLabel.Location = new System.Drawing.Point(529, 33);
		this.mMissionLengthDisplayLabel.Name = "mMissionLengthDisplayLabel";
		this.mMissionLengthDisplayLabel.Size = new System.Drawing.Size(1, 20);
		this.mMissionLengthDisplayLabel.TabIndex = 9;
		this.mMissionLengthDisplayLabel.Text = "00:00";
		this.mMissionLengthDisplayLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
		this.mMissionLengthDisplayLabel.Visible = false;
		this.mWeather.Anchor = System.Windows.Forms.AnchorStyles.Left;
		this.mWeather.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
		this.mWeather.FormattingEnabled = true;
		this.mWeather.Location = new System.Drawing.Point(76, 33);
		this.mWeather.Name = "mWeather";
		this.mWeather.Size = new System.Drawing.Size(198, 21);
		this.mWeather.TabIndex = 1;
		this.mTimeOfDay.Anchor = System.Windows.Forms.AnchorStyles.Left;
		this.mTimeOfDay.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
		this.mTimeOfDay.FormattingEnabled = true;
		this.mTimeOfDay.Location = new System.Drawing.Point(76, 62);
		this.mTimeOfDay.Name = "mTimeOfDay";
		this.mTimeOfDay.Size = new System.Drawing.Size(198, 21);
		this.mTimeOfDay.TabIndex = 2;
		this.mMapLabel.Anchor = System.Windows.Forms.AnchorStyles.Left;
		this.mMapLabel.AutoSize = true;
		this.mMapLabel.Location = new System.Drawing.Point(3, 8);
		this.mMapLabel.Name = "mMapLabel";
		this.mMapLabel.Size = new System.Drawing.Size(31, 13);
		this.mMapLabel.TabIndex = 0;
		this.mMapLabel.Text = "Map:";
		this.mWeatherLabel.Anchor = System.Windows.Forms.AnchorStyles.Left;
		this.mWeatherLabel.AutoSize = true;
		this.mWeatherLabel.Location = new System.Drawing.Point(3, 37);
		this.mWeatherLabel.Name = "mWeatherLabel";
		this.mWeatherLabel.Size = new System.Drawing.Size(51, 13);
		this.mWeatherLabel.TabIndex = 2;
		this.mWeatherLabel.Text = "Weather:";
		this.mTimeOfDayLabel.Anchor = System.Windows.Forms.AnchorStyles.Left;
		this.mTimeOfDayLabel.AutoSize = true;
		this.mTimeOfDayLabel.Location = new System.Drawing.Point(3, 66);
		this.mTimeOfDayLabel.Name = "mTimeOfDayLabel";
		this.mTimeOfDayLabel.Size = new System.Drawing.Size(67, 13);
		this.mTimeOfDayLabel.TabIndex = 4;
		this.mTimeOfDayLabel.Text = "Time of Day:";
		this.mScoreCompression.Anchor = System.Windows.Forms.AnchorStyles.Left;
		this.mScoreCompression.AutoSize = true;
		this.mMissionPropertiesTable.SetColumnSpan(this.mScoreCompression, 3);
		this.mScoreCompression.Location = new System.Drawing.Point(311, 6);
		this.mScoreCompression.Name = "mScoreCompression";
		this.mScoreCompression.Size = new System.Drawing.Size(117, 17);
		this.mScoreCompression.TabIndex = 6;
		this.mScoreCompression.Text = "Score Compression";
		this.mScoreCompression.UseVisualStyleBackColor = true;
		this.mGoButton.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.mMissionPropertiesTable.SetColumnSpan(this.mGoButton, 3);
		this.mGoButton.ContextMenuStrip = this.mResetContextMenu;
		this.mGoButton.Location = new System.Drawing.Point(311, 61);
		this.mGoButton.Name = "mGoButton";
		this.mGoButton.Size = new System.Drawing.Size(212, 23);
		this.mGoButton.TabIndex = 10;
		this.mGoButton.Text = "Load";
		this.mGoButton.UseVisualStyleBackColor = true;
		this.mGoButton.Click += new System.EventHandler(mGoButton_Click);
		this.mResetContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[1] { this.resetToolStripMenuItem });
		this.mResetContextMenu.Name = "mResetContextMenu";
		this.mResetContextMenu.Size = new System.Drawing.Size(103, 26);
		this.resetToolStripMenuItem.Name = "resetToolStripMenuItem";
		this.resetToolStripMenuItem.Size = new System.Drawing.Size(102, 22);
		this.resetToolStripMenuItem.Text = "&Reset";
		this.resetToolStripMenuItem.Click += new System.EventHandler(resetToolStripMenuItem_Click);
		this.mPrintLastMission.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.mPrintLastMission.AutoSize = true;
		this.mPrintLastMission.Enabled = false;
		this.mPrintLastMission.Location = new System.Drawing.Point(529, 61);
		this.mPrintLastMission.Name = "mPrintLastMission";
		this.mPrintLastMission.Size = new System.Drawing.Size(107, 23);
		this.mPrintLastMission.TabIndex = 11;
		this.mPrintLastMission.Text = "Print Last Mission";
		this.mPrintLastMission.UseVisualStyleBackColor = true;
		this.mPrintLastMission.Click += new System.EventHandler(mPrintLastMission_Click);
		this.mAutoPrint.Anchor = System.Windows.Forms.AnchorStyles.Left;
		this.mAutoPrint.AutoSize = true;
		this.mAutoPrint.Location = new System.Drawing.Point(529, 35);
		this.mAutoPrint.Name = "mAutoPrint";
		this.mAutoPrint.Size = new System.Drawing.Size(72, 17);
		this.mAutoPrint.TabIndex = 9;
		this.mAutoPrint.Text = "Auto Print";
		this.mAutoPrint.UseVisualStyleBackColor = true;
		this.mAutoTranslocateCheckbox.Anchor = System.Windows.Forms.AnchorStyles.Left;
		this.mAutoTranslocateCheckbox.AutoSize = true;
		this.mAutoTranslocateCheckbox.Location = new System.Drawing.Point(529, 6);
		this.mAutoTranslocateCheckbox.Name = "mAutoTranslocateCheckbox";
		this.mAutoTranslocateCheckbox.Size = new System.Drawing.Size(107, 17);
		this.mAutoTranslocateCheckbox.TabIndex = 8;
		this.mAutoTranslocateCheckbox.Text = "Auto Translocate";
		this.mAutoTranslocateCheckbox.UseVisualStyleBackColor = true;
		this.mRandomMap.Location = new System.Drawing.Point(280, 3);
		this.mRandomMap.Name = "mRandomMap";
		this.mRandomMap.Size = new System.Drawing.Size(25, 23);
		this.mRandomMap.TabIndex = 3;
		this.mRandomMap.Text = "R";
		this.mRandomMap.UseVisualStyleBackColor = true;
		this.mRandomMap.Click += new System.EventHandler(mRandomMap_Click);
		this.mRandomWeather.Location = new System.Drawing.Point(280, 32);
		this.mRandomWeather.Name = "mRandomWeather";
		this.mRandomWeather.Size = new System.Drawing.Size(25, 23);
		this.mRandomWeather.TabIndex = 4;
		this.mRandomWeather.Text = "R";
		this.mRandomWeather.UseVisualStyleBackColor = true;
		this.mRandomWeather.Click += new System.EventHandler(mRandomWeather_Click);
		this.mRandomTimeOfDay.Location = new System.Drawing.Point(280, 61);
		this.mRandomTimeOfDay.Name = "mRandomTimeOfDay";
		this.mRandomTimeOfDay.Size = new System.Drawing.Size(25, 23);
		this.mRandomTimeOfDay.TabIndex = 5;
		this.mRandomTimeOfDay.Text = "R";
		this.mRandomTimeOfDay.UseVisualStyleBackColor = true;
		this.mRandomTimeOfDay.Click += new System.EventHandler(mRandomTimeOfDay_Click);
		this.mMissionLengthTextBox.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
		this.mMissionLengthTextBox.Location = new System.Drawing.Point(423, 33);
		this.mMissionLengthTextBox.Name = "mMissionLengthTextBox";
		this.mMissionLengthTextBox.Size = new System.Drawing.Size(100, 20);
		this.mMissionLengthTextBox.TabIndex = 12;
		this.mMissionLengthTextBox.TextChanged += new System.EventHandler(mMissionLengthTextBox_TextChanged);
		this.mPilotsGroupBox.Controls.Add(this.mPilotsDataGrid);
		this.mPilotsGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
		this.mPilotsGroupBox.Location = new System.Drawing.Point(8, 113);
		this.mPilotsGroupBox.Name = "mPilotsGroupBox";
		this.mPilotsGroupBox.Padding = new System.Windows.Forms.Padding(5);
		this.mPilotsGroupBox.Size = new System.Drawing.Size(1040, 425);
		this.mPilotsGroupBox.TabIndex = 11;
		this.mPilotsGroupBox.TabStop = false;
		this.mPilotsGroupBox.Text = "Pilots";
		this.mPilotsDataGrid.AllowDrop = true;
		this.mPilotsDataGrid.AllowUserToAddRows = false;
		this.mPilotsDataGrid.AllowUserToDeleteRows = false;
		this.mPilotsDataGrid.AllowUserToResizeColumns = false;
		this.mPilotsDataGrid.AllowUserToResizeRows = false;
		this.mPilotsDataGrid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
		this.mPilotsDataGrid.Columns.AddRange(this.mEnabledColumn, this.mStatusIconColumn, this.mStatusTextColumn, this.mPilotColumn, this.mVehicleColumn, this.mColorColumn, this.mBadgeColumn);
		this.mPilotsDataGrid.Dock = System.Windows.Forms.DockStyle.Fill;
		this.mPilotsDataGrid.Location = new System.Drawing.Point(5, 18);
		this.mPilotsDataGrid.MultiSelect = false;
		this.mPilotsDataGrid.Name = "mPilotsDataGrid";
		this.mPilotsDataGrid.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
		this.mPilotsDataGrid.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.CellSelect;
		this.mPilotsDataGrid.ShowEditingIcon = false;
		this.mPilotsDataGrid.Size = new System.Drawing.Size(1030, 402);
		this.mPilotsDataGrid.TabIndex = 0;
		this.mPilotsDataGrid.MouseDown += new System.Windows.Forms.MouseEventHandler(mPilotsDataGrid_MouseDown);
		this.mPilotsDataGrid.CellBeginEdit += new System.Windows.Forms.DataGridViewCellCancelEventHandler(mPilotsDataGrid_CellBeginEdit);
		this.mPilotsDataGrid.DragOver += new System.Windows.Forms.DragEventHandler(mPilotsDataGrid_DragOver);
		this.mPilotsDataGrid.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(mPilotsDataGrid_CellEndEdit);
		this.mPilotsDataGrid.EditingControlShowing += new System.Windows.Forms.DataGridViewEditingControlShowingEventHandler(mPilotsDataGrid_EditingControlShowing);
		this.mPilotsDataGrid.KeyUp += new System.Windows.Forms.KeyEventHandler(mPilotsDataGrid_KeyUp);
		this.mPilotsDataGrid.DragDrop += new System.Windows.Forms.DragEventHandler(mPilotsDataGrid_DragDrop);
		this.mEnabledColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
		this.mEnabledColumn.HeaderText = "Enabled";
		this.mEnabledColumn.Name = "mEnabledColumn";
		this.mEnabledColumn.Width = 52;
		this.mStatusIconColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader;
		this.mStatusIconColumn.HeaderText = "Status";
		this.mStatusIconColumn.Name = "mStatusIconColumn";
		this.mStatusIconColumn.ReadOnly = true;
		this.mStatusIconColumn.Resizable = System.Windows.Forms.DataGridViewTriState.False;
		this.mStatusIconColumn.Width = 43;
		this.mStatusTextColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.mStatusTextColumn.HeaderText = "Status Text";
		this.mStatusTextColumn.MinimumWidth = 100;
		this.mStatusTextColumn.Name = "mStatusTextColumn";
		this.mStatusTextColumn.ReadOnly = true;
		this.mPilotColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.mPilotColumn.HeaderText = "Pilot";
		this.mPilotColumn.MinimumWidth = 100;
		this.mPilotColumn.Name = "mPilotColumn";
		this.mPilotColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
		this.mVehicleColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.mVehicleColumn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
		this.mVehicleColumn.HeaderText = "Vehicle";
		this.mVehicleColumn.MinimumWidth = 100;
		this.mVehicleColumn.Name = "mVehicleColumn";
		this.mColorColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.mColorColumn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
		this.mColorColumn.HeaderText = "Color";
		this.mColorColumn.MinimumWidth = 100;
		this.mColorColumn.Name = "mColorColumn";
		this.mBadgeColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.mBadgeColumn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
		this.mBadgeColumn.HeaderText = "Badge";
		this.mBadgeColumn.MinimumWidth = 100;
		this.mBadgeColumn.Name = "mBadgeColumn";
		this.mDragDropContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[2] { this.mSwapPilots, this.mShiftPilots });
		this.mDragDropContextMenu.Name = "contextMenuStrip1";
		this.mDragDropContextMenu.Size = new System.Drawing.Size(103, 48);
		this.mSwapPilots.Name = "mSwapPilots";
		this.mSwapPilots.Size = new System.Drawing.Size(102, 22);
		this.mSwapPilots.Text = "Swap";
		this.mSwapPilots.Click += new System.EventHandler(swapToolStripMenuItem_Click);
		this.mShiftPilots.Name = "mShiftPilots";
		this.mShiftPilots.Size = new System.Drawing.Size(102, 22);
		this.mShiftPilots.Text = "Shift";
		this.mShiftPilots.Click += new System.EventHandler(shiftToolStripMenuItem_Click);
		this.mNetworkTimer.Enabled = true;
		this.mNetworkTimer.Tick += new System.EventHandler(NetworkScan);
		this.tmrAutoTranslocate.Interval = 1000;
		this.tmrAutoTranslocate.Tick += new System.EventHandler(tmrAutoTranslocate_Tick);
		base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(1056, 546);
		base.Controls.Add(this.mPilotsGroupBox);
		base.Controls.Add(this.mMissionPropertiesGroupBox);
		this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0);
		base.KeyPreview = true;
		base.Name = "RPGame";
		base.Padding = new System.Windows.Forms.Padding(8);
		base.TabText = "Red Planet Game";
		this.Text = "Red Planet Game";
		this.mMissionPropertiesGroupBox.ResumeLayout(false);
		this.mMissionPropertiesGroupBox.PerformLayout();
		this.mMissionPropertiesTable.ResumeLayout(false);
		this.mMissionPropertiesTable.PerformLayout();
		this.mResetContextMenu.ResumeLayout(false);
		this.mPilotsGroupBox.ResumeLayout(false);
		((System.ComponentModel.ISupportInitialize)this.mPilotsDataGrid).EndInit();
		this.mDragDropContextMenu.ResumeLayout(false);
		base.ResumeLayout(false);
	}
}
